babylon.module.d.ts 6.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935
  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. /**
  7852. * Creates a cube texture from an array of image urls
  7853. * @param files defines an array of image urls
  7854. * @param scene defines the hosting scene
  7855. * @param noMipmap specifies if mip maps are not used
  7856. * @returns a cube texture
  7857. */
  7858. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7859. /**
  7860. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7861. * @param url defines the url of the prefiltered texture
  7862. * @param scene defines the scene the texture is attached to
  7863. * @param forcedExtension defines the extension of the file if different from the url
  7864. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7865. * @return the prefiltered texture
  7866. */
  7867. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7868. /**
  7869. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7870. * as prefiltered data.
  7871. * @param rootUrl defines the url of the texture or the root name of the six images
  7872. * @param null defines the scene or engine the texture is attached to
  7873. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7874. * @param noMipmap defines if mipmaps should be created or not
  7875. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7876. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7877. * @param onError defines a callback triggered in case of error during load
  7878. * @param format defines the internal format to use for the texture once loaded
  7879. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7880. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7881. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7884. * @return the cube texture
  7885. */
  7886. 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);
  7887. /**
  7888. * Get the current class name of the texture useful for serialization or dynamic coding.
  7889. * @returns "CubeTexture"
  7890. */
  7891. getClassName(): string;
  7892. /**
  7893. * Update the url (and optional buffer) of this texture if url was null during construction.
  7894. * @param url the url of the texture
  7895. * @param forcedExtension defines the extension to use
  7896. * @param onLoad callback called when the texture is loaded (defaults to null)
  7897. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7898. */
  7899. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7900. /**
  7901. * Delays loading of the cube texture
  7902. * @param forcedExtension defines the extension to use
  7903. */
  7904. delayLoad(forcedExtension?: string): void;
  7905. /**
  7906. * Returns the reflection texture matrix
  7907. * @returns the reflection texture matrix
  7908. */
  7909. getReflectionTextureMatrix(): Matrix;
  7910. /**
  7911. * Sets the reflection texture matrix
  7912. * @param value Reflection texture matrix
  7913. */
  7914. setReflectionTextureMatrix(value: Matrix): void;
  7915. /**
  7916. * Parses text to create a cube texture
  7917. * @param parsedTexture define the serialized text to read from
  7918. * @param scene defines the hosting scene
  7919. * @param rootUrl defines the root url of the cube texture
  7920. * @returns a cube texture
  7921. */
  7922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7923. /**
  7924. * Makes a clone, or deep copy, of the cube texture
  7925. * @returns a new cube texture
  7926. */
  7927. clone(): CubeTexture;
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/materialDefines" {
  7931. /**
  7932. * Manages the defines for the Material
  7933. */
  7934. export class MaterialDefines {
  7935. /** @hidden */
  7936. protected _keys: string[];
  7937. private _isDirty;
  7938. /** @hidden */
  7939. _renderId: number;
  7940. /** @hidden */
  7941. _areLightsDirty: boolean;
  7942. /** @hidden */
  7943. _areLightsDisposed: boolean;
  7944. /** @hidden */
  7945. _areAttributesDirty: boolean;
  7946. /** @hidden */
  7947. _areTexturesDirty: boolean;
  7948. /** @hidden */
  7949. _areFresnelDirty: boolean;
  7950. /** @hidden */
  7951. _areMiscDirty: boolean;
  7952. /** @hidden */
  7953. _areImageProcessingDirty: boolean;
  7954. /** @hidden */
  7955. _normals: boolean;
  7956. /** @hidden */
  7957. _uvs: boolean;
  7958. /** @hidden */
  7959. _needNormals: boolean;
  7960. /** @hidden */
  7961. _needUVs: boolean;
  7962. [id: string]: any;
  7963. /**
  7964. * Specifies if the material needs to be re-calculated
  7965. */
  7966. get isDirty(): boolean;
  7967. /**
  7968. * Marks the material to indicate that it has been re-calculated
  7969. */
  7970. markAsProcessed(): void;
  7971. /**
  7972. * Marks the material to indicate that it needs to be re-calculated
  7973. */
  7974. markAsUnprocessed(): void;
  7975. /**
  7976. * Marks the material to indicate all of its defines need to be re-calculated
  7977. */
  7978. markAllAsDirty(): void;
  7979. /**
  7980. * Marks the material to indicate that image processing needs to be re-calculated
  7981. */
  7982. markAsImageProcessingDirty(): void;
  7983. /**
  7984. * Marks the material to indicate the lights need to be re-calculated
  7985. * @param disposed Defines whether the light is dirty due to dispose or not
  7986. */
  7987. markAsLightDirty(disposed?: boolean): void;
  7988. /**
  7989. * Marks the attribute state as changed
  7990. */
  7991. markAsAttributesDirty(): void;
  7992. /**
  7993. * Marks the texture state as changed
  7994. */
  7995. markAsTexturesDirty(): void;
  7996. /**
  7997. * Marks the fresnel state as changed
  7998. */
  7999. markAsFresnelDirty(): void;
  8000. /**
  8001. * Marks the misc state as changed
  8002. */
  8003. markAsMiscDirty(): void;
  8004. /**
  8005. * Rebuilds the material defines
  8006. */
  8007. rebuild(): void;
  8008. /**
  8009. * Specifies if two material defines are equal
  8010. * @param other - A material define instance to compare to
  8011. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8012. */
  8013. isEqual(other: MaterialDefines): boolean;
  8014. /**
  8015. * Clones this instance's defines to another instance
  8016. * @param other - material defines to clone values to
  8017. */
  8018. cloneTo(other: MaterialDefines): void;
  8019. /**
  8020. * Resets the material define values
  8021. */
  8022. reset(): void;
  8023. /**
  8024. * Converts the material define values to a string
  8025. * @returns - String of material define information
  8026. */
  8027. toString(): string;
  8028. }
  8029. }
  8030. declare module "babylonjs/Materials/colorCurves" {
  8031. import { Effect } from "babylonjs/Materials/effect";
  8032. /**
  8033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8035. * 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;
  8036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8037. */
  8038. export class ColorCurves {
  8039. private _dirty;
  8040. private _tempColor;
  8041. private _globalCurve;
  8042. private _highlightsCurve;
  8043. private _midtonesCurve;
  8044. private _shadowsCurve;
  8045. private _positiveCurve;
  8046. private _negativeCurve;
  8047. private _globalHue;
  8048. private _globalDensity;
  8049. private _globalSaturation;
  8050. private _globalExposure;
  8051. /**
  8052. * Gets the global Hue value.
  8053. * 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).
  8054. */
  8055. get globalHue(): number;
  8056. /**
  8057. * Sets the global Hue value.
  8058. * 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).
  8059. */
  8060. set globalHue(value: number);
  8061. /**
  8062. * Gets the global Density value.
  8063. * 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.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. get globalDensity(): number;
  8067. /**
  8068. * Sets 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. set globalDensity(value: number);
  8073. /**
  8074. * Gets the global Saturation value.
  8075. * 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.
  8076. */
  8077. get globalSaturation(): number;
  8078. /**
  8079. * Sets the global Saturation value.
  8080. * 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.
  8081. */
  8082. set globalSaturation(value: number);
  8083. /**
  8084. * Gets the global Exposure value.
  8085. * 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.
  8086. */
  8087. get globalExposure(): number;
  8088. /**
  8089. * Sets the global Exposure value.
  8090. * 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.
  8091. */
  8092. set globalExposure(value: number);
  8093. private _highlightsHue;
  8094. private _highlightsDensity;
  8095. private _highlightsSaturation;
  8096. private _highlightsExposure;
  8097. /**
  8098. * Gets the highlights Hue value.
  8099. * 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).
  8100. */
  8101. get highlightsHue(): number;
  8102. /**
  8103. * Sets the highlights Hue value.
  8104. * 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).
  8105. */
  8106. set highlightsHue(value: number);
  8107. /**
  8108. * Gets the highlights Density value.
  8109. * 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.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. get highlightsDensity(): number;
  8113. /**
  8114. * Sets 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. set highlightsDensity(value: number);
  8119. /**
  8120. * Gets the highlights Saturation value.
  8121. * 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.
  8122. */
  8123. get highlightsSaturation(): number;
  8124. /**
  8125. * Sets the highlights Saturation value.
  8126. * 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.
  8127. */
  8128. set highlightsSaturation(value: number);
  8129. /**
  8130. * Gets the highlights Exposure value.
  8131. * 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.
  8132. */
  8133. get highlightsExposure(): number;
  8134. /**
  8135. * Sets the highlights Exposure value.
  8136. * 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.
  8137. */
  8138. set highlightsExposure(value: number);
  8139. private _midtonesHue;
  8140. private _midtonesDensity;
  8141. private _midtonesSaturation;
  8142. private _midtonesExposure;
  8143. /**
  8144. * Gets the midtones Hue value.
  8145. * 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).
  8146. */
  8147. get midtonesHue(): number;
  8148. /**
  8149. * Sets the midtones Hue value.
  8150. * 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).
  8151. */
  8152. set midtonesHue(value: number);
  8153. /**
  8154. * Gets the midtones Density value.
  8155. * 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.
  8156. * Values less than zero provide a filter of opposite hue.
  8157. */
  8158. get midtonesDensity(): number;
  8159. /**
  8160. * Sets 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. set midtonesDensity(value: number);
  8165. /**
  8166. * Gets the midtones Saturation value.
  8167. * 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.
  8168. */
  8169. get midtonesSaturation(): number;
  8170. /**
  8171. * Sets the midtones Saturation value.
  8172. * 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.
  8173. */
  8174. set midtonesSaturation(value: number);
  8175. /**
  8176. * Gets the midtones Exposure value.
  8177. * 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.
  8178. */
  8179. get midtonesExposure(): number;
  8180. /**
  8181. * Sets the midtones Exposure value.
  8182. * 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.
  8183. */
  8184. set midtonesExposure(value: number);
  8185. private _shadowsHue;
  8186. private _shadowsDensity;
  8187. private _shadowsSaturation;
  8188. private _shadowsExposure;
  8189. /**
  8190. * Gets the shadows Hue value.
  8191. * 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).
  8192. */
  8193. get shadowsHue(): number;
  8194. /**
  8195. * Sets the shadows Hue value.
  8196. * 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).
  8197. */
  8198. set shadowsHue(value: number);
  8199. /**
  8200. * Gets the shadows Density value.
  8201. * 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.
  8202. * Values less than zero provide a filter of opposite hue.
  8203. */
  8204. get shadowsDensity(): number;
  8205. /**
  8206. * Sets 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. set shadowsDensity(value: number);
  8211. /**
  8212. * Gets the shadows Saturation value.
  8213. * 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.
  8214. */
  8215. get shadowsSaturation(): number;
  8216. /**
  8217. * Sets the shadows Saturation value.
  8218. * 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.
  8219. */
  8220. set shadowsSaturation(value: number);
  8221. /**
  8222. * Gets the shadows Exposure value.
  8223. * 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.
  8224. */
  8225. get shadowsExposure(): number;
  8226. /**
  8227. * Sets the shadows Exposure value.
  8228. * 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.
  8229. */
  8230. set shadowsExposure(value: number);
  8231. /**
  8232. * Returns the class name
  8233. * @returns The class name
  8234. */
  8235. getClassName(): string;
  8236. /**
  8237. * Binds the color curves to the shader.
  8238. * @param colorCurves The color curve to bind
  8239. * @param effect The effect to bind to
  8240. * @param positiveUniform The positive uniform shader parameter
  8241. * @param neutralUniform The neutral uniform shader parameter
  8242. * @param negativeUniform The negative uniform shader parameter
  8243. */
  8244. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8245. /**
  8246. * Prepare the list of uniforms associated with the ColorCurves effects.
  8247. * @param uniformsList The list of uniforms used in the effect
  8248. */
  8249. static PrepareUniforms(uniformsList: string[]): void;
  8250. /**
  8251. * Returns color grading data based on a hue, density, saturation and exposure value.
  8252. * @param filterHue The hue of the color filter.
  8253. * @param filterDensity The density of the color filter.
  8254. * @param saturation The saturation.
  8255. * @param exposure The exposure.
  8256. * @param result The result data container.
  8257. */
  8258. private getColorGradingDataToRef;
  8259. /**
  8260. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8261. * @param value The input slider value in range [-100,100].
  8262. * @returns Adjusted value.
  8263. */
  8264. private static applyColorGradingSliderNonlinear;
  8265. /**
  8266. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8267. * @param hue The hue (H) input.
  8268. * @param saturation The saturation (S) input.
  8269. * @param brightness The brightness (B) input.
  8270. * @result An RGBA color represented as Vector4.
  8271. */
  8272. private static fromHSBToRef;
  8273. /**
  8274. * Returns a value clamped between min and max
  8275. * @param value The value to clamp
  8276. * @param min The minimum of value
  8277. * @param max The maximum of value
  8278. * @returns The clamped value.
  8279. */
  8280. private static clamp;
  8281. /**
  8282. * Clones the current color curve instance.
  8283. * @return The cloned curves
  8284. */
  8285. clone(): ColorCurves;
  8286. /**
  8287. * Serializes the current color curve instance to a json representation.
  8288. * @return a JSON representation
  8289. */
  8290. serialize(): any;
  8291. /**
  8292. * Parses the color curve from a json representation.
  8293. * @param source the JSON source to parse
  8294. * @return The parsed curves
  8295. */
  8296. static Parse(source: any): ColorCurves;
  8297. }
  8298. }
  8299. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8300. import { Observable } from "babylonjs/Misc/observable";
  8301. import { Nullable } from "babylonjs/types";
  8302. import { Color4 } from "babylonjs/Maths/math.color";
  8303. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8304. import { Effect } from "babylonjs/Materials/effect";
  8305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8306. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8307. /**
  8308. * Interface to follow in your material defines to integrate easily the
  8309. * Image proccessing functions.
  8310. * @hidden
  8311. */
  8312. export interface IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. EXPOSURE: boolean;
  8321. COLORCURVES: boolean;
  8322. COLORGRADING: boolean;
  8323. COLORGRADING3D: boolean;
  8324. SAMPLER3DGREENDEPTH: boolean;
  8325. SAMPLER3DBGRMAP: boolean;
  8326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8327. }
  8328. /**
  8329. * @hidden
  8330. */
  8331. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8332. IMAGEPROCESSING: boolean;
  8333. VIGNETTE: boolean;
  8334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8335. VIGNETTEBLENDMODEOPAQUE: boolean;
  8336. TONEMAPPING: boolean;
  8337. TONEMAPPING_ACES: boolean;
  8338. CONTRAST: boolean;
  8339. COLORCURVES: boolean;
  8340. COLORGRADING: boolean;
  8341. COLORGRADING3D: boolean;
  8342. SAMPLER3DGREENDEPTH: boolean;
  8343. SAMPLER3DBGRMAP: boolean;
  8344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8345. EXPOSURE: boolean;
  8346. constructor();
  8347. }
  8348. /**
  8349. * This groups together the common properties used for image processing either in direct forward pass
  8350. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8351. * or not.
  8352. */
  8353. export class ImageProcessingConfiguration {
  8354. /**
  8355. * Default tone mapping applied in BabylonJS.
  8356. */
  8357. static readonly TONEMAPPING_STANDARD: number;
  8358. /**
  8359. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8360. * to other engines rendering to increase portability.
  8361. */
  8362. static readonly TONEMAPPING_ACES: number;
  8363. /**
  8364. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8365. */
  8366. colorCurves: Nullable<ColorCurves>;
  8367. private _colorCurvesEnabled;
  8368. /**
  8369. * Gets wether the color curves effect is enabled.
  8370. */
  8371. get colorCurvesEnabled(): boolean;
  8372. /**
  8373. * Sets wether the color curves effect is enabled.
  8374. */
  8375. set colorCurvesEnabled(value: boolean);
  8376. private _colorGradingTexture;
  8377. /**
  8378. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8379. */
  8380. get colorGradingTexture(): Nullable<BaseTexture>;
  8381. /**
  8382. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8383. */
  8384. set colorGradingTexture(value: Nullable<BaseTexture>);
  8385. private _colorGradingEnabled;
  8386. /**
  8387. * Gets wether the color grading effect is enabled.
  8388. */
  8389. get colorGradingEnabled(): boolean;
  8390. /**
  8391. * Sets wether the color grading effect is enabled.
  8392. */
  8393. set colorGradingEnabled(value: boolean);
  8394. private _colorGradingWithGreenDepth;
  8395. /**
  8396. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8397. */
  8398. get colorGradingWithGreenDepth(): boolean;
  8399. /**
  8400. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8401. */
  8402. set colorGradingWithGreenDepth(value: boolean);
  8403. private _colorGradingBGR;
  8404. /**
  8405. * Gets wether the color grading texture contains BGR values.
  8406. */
  8407. get colorGradingBGR(): boolean;
  8408. /**
  8409. * Sets wether the color grading texture contains BGR values.
  8410. */
  8411. set colorGradingBGR(value: boolean);
  8412. /** @hidden */
  8413. _exposure: number;
  8414. /**
  8415. * Gets the Exposure used in the effect.
  8416. */
  8417. get exposure(): number;
  8418. /**
  8419. * Sets the Exposure used in the effect.
  8420. */
  8421. set exposure(value: number);
  8422. private _toneMappingEnabled;
  8423. /**
  8424. * Gets wether the tone mapping effect is enabled.
  8425. */
  8426. get toneMappingEnabled(): boolean;
  8427. /**
  8428. * Sets wether the tone mapping effect is enabled.
  8429. */
  8430. set toneMappingEnabled(value: boolean);
  8431. private _toneMappingType;
  8432. /**
  8433. * Gets the type of tone mapping effect.
  8434. */
  8435. get toneMappingType(): number;
  8436. /**
  8437. * Sets the type of tone mapping effect used in BabylonJS.
  8438. */
  8439. set toneMappingType(value: number);
  8440. protected _contrast: number;
  8441. /**
  8442. * Gets the contrast used in the effect.
  8443. */
  8444. get contrast(): number;
  8445. /**
  8446. * Sets the contrast used in the effect.
  8447. */
  8448. set contrast(value: number);
  8449. /**
  8450. * Vignette stretch size.
  8451. */
  8452. vignetteStretch: number;
  8453. /**
  8454. * Vignette centre X Offset.
  8455. */
  8456. vignetteCentreX: number;
  8457. /**
  8458. * Vignette centre Y Offset.
  8459. */
  8460. vignetteCentreY: number;
  8461. /**
  8462. * Vignette weight or intensity of the vignette effect.
  8463. */
  8464. vignetteWeight: number;
  8465. /**
  8466. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8467. * if vignetteEnabled is set to true.
  8468. */
  8469. vignetteColor: Color4;
  8470. /**
  8471. * Camera field of view used by the Vignette effect.
  8472. */
  8473. vignetteCameraFov: number;
  8474. private _vignetteBlendMode;
  8475. /**
  8476. * Gets the vignette blend mode allowing different kind of effect.
  8477. */
  8478. get vignetteBlendMode(): number;
  8479. /**
  8480. * Sets the vignette blend mode allowing different kind of effect.
  8481. */
  8482. set vignetteBlendMode(value: number);
  8483. private _vignetteEnabled;
  8484. /**
  8485. * Gets wether the vignette effect is enabled.
  8486. */
  8487. get vignetteEnabled(): boolean;
  8488. /**
  8489. * Sets wether the vignette effect is enabled.
  8490. */
  8491. set vignetteEnabled(value: boolean);
  8492. private _applyByPostProcess;
  8493. /**
  8494. * Gets wether the image processing is applied through a post process or not.
  8495. */
  8496. get applyByPostProcess(): boolean;
  8497. /**
  8498. * Sets wether the image processing is applied through a post process or not.
  8499. */
  8500. set applyByPostProcess(value: boolean);
  8501. private _isEnabled;
  8502. /**
  8503. * Gets wether the image processing is enabled or not.
  8504. */
  8505. get isEnabled(): boolean;
  8506. /**
  8507. * Sets wether the image processing is enabled or not.
  8508. */
  8509. set isEnabled(value: boolean);
  8510. /**
  8511. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8512. */
  8513. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8514. /**
  8515. * Method called each time the image processing information changes requires to recompile the effect.
  8516. */
  8517. protected _updateParameters(): void;
  8518. /**
  8519. * Gets the current class name.
  8520. * @return "ImageProcessingConfiguration"
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Prepare the list of uniforms associated with the Image Processing effects.
  8525. * @param uniforms The list of uniforms used in the effect
  8526. * @param defines the list of defines currently in use
  8527. */
  8528. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8529. /**
  8530. * Prepare the list of samplers associated with the Image Processing effects.
  8531. * @param samplersList The list of uniforms used in the effect
  8532. * @param defines the list of defines currently in use
  8533. */
  8534. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8535. /**
  8536. * Prepare the list of defines associated to the shader.
  8537. * @param defines the list of defines to complete
  8538. * @param forPostProcess Define if we are currently in post process mode or not
  8539. */
  8540. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8541. /**
  8542. * Returns true if all the image processing information are ready.
  8543. * @returns True if ready, otherwise, false
  8544. */
  8545. isReady(): boolean;
  8546. /**
  8547. * Binds the image processing to the shader.
  8548. * @param effect The effect to bind to
  8549. * @param overrideAspectRatio Override the aspect ratio of the effect
  8550. */
  8551. bind(effect: Effect, overrideAspectRatio?: number): void;
  8552. /**
  8553. * Clones the current image processing instance.
  8554. * @return The cloned image processing
  8555. */
  8556. clone(): ImageProcessingConfiguration;
  8557. /**
  8558. * Serializes the current image processing instance to a json representation.
  8559. * @return a JSON representation
  8560. */
  8561. serialize(): any;
  8562. /**
  8563. * Parses the image processing from a json representation.
  8564. * @param source the JSON source to parse
  8565. * @return The parsed image processing
  8566. */
  8567. static Parse(source: any): ImageProcessingConfiguration;
  8568. private static _VIGNETTEMODE_MULTIPLY;
  8569. private static _VIGNETTEMODE_OPAQUE;
  8570. /**
  8571. * Used to apply the vignette as a mix with the pixel color.
  8572. */
  8573. static get VIGNETTEMODE_MULTIPLY(): number;
  8574. /**
  8575. * Used to apply the vignette as a replacement of the pixel color.
  8576. */
  8577. static get VIGNETTEMODE_OPAQUE(): number;
  8578. }
  8579. }
  8580. declare module "babylonjs/Shaders/postprocess.vertex" {
  8581. /** @hidden */
  8582. export var postprocessVertexShader: {
  8583. name: string;
  8584. shader: string;
  8585. };
  8586. }
  8587. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8589. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8590. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8591. module "babylonjs/Engines/thinEngine" {
  8592. interface ThinEngine {
  8593. /**
  8594. * Creates a new render target texture
  8595. * @param size defines the size of the texture
  8596. * @param options defines the options used to create the texture
  8597. * @returns a new render target texture stored in an InternalTexture
  8598. */
  8599. createRenderTargetTexture(size: number | {
  8600. width: number;
  8601. height: number;
  8602. layers?: number;
  8603. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8604. /**
  8605. * Creates a depth stencil texture.
  8606. * This is only available in WebGL 2 or with the depth texture extension available.
  8607. * @param size The size of face edge in the texture.
  8608. * @param options The options defining the texture.
  8609. * @returns The texture
  8610. */
  8611. createDepthStencilTexture(size: number | {
  8612. width: number;
  8613. height: number;
  8614. layers?: number;
  8615. }, options: DepthTextureCreationOptions): InternalTexture;
  8616. /** @hidden */
  8617. _createDepthStencilTexture(size: number | {
  8618. width: number;
  8619. height: number;
  8620. layers?: number;
  8621. }, options: DepthTextureCreationOptions): InternalTexture;
  8622. }
  8623. }
  8624. }
  8625. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8626. /**
  8627. * Defines the kind of connection point for node based material
  8628. */
  8629. export enum NodeMaterialBlockConnectionPointTypes {
  8630. /** Float */
  8631. Float = 1,
  8632. /** Int */
  8633. Int = 2,
  8634. /** Vector2 */
  8635. Vector2 = 4,
  8636. /** Vector3 */
  8637. Vector3 = 8,
  8638. /** Vector4 */
  8639. Vector4 = 16,
  8640. /** Color3 */
  8641. Color3 = 32,
  8642. /** Color4 */
  8643. Color4 = 64,
  8644. /** Matrix */
  8645. Matrix = 128,
  8646. /** Custom object */
  8647. Object = 256,
  8648. /** Detect type based on connection */
  8649. AutoDetect = 1024,
  8650. /** Output type that will be defined by input type */
  8651. BasedOnInput = 2048
  8652. }
  8653. }
  8654. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8655. /**
  8656. * Enum used to define the target of a block
  8657. */
  8658. export enum NodeMaterialBlockTargets {
  8659. /** Vertex shader */
  8660. Vertex = 1,
  8661. /** Fragment shader */
  8662. Fragment = 2,
  8663. /** Neutral */
  8664. Neutral = 4,
  8665. /** Vertex and Fragment */
  8666. VertexAndFragment = 3
  8667. }
  8668. }
  8669. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8670. /**
  8671. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8672. */
  8673. export enum NodeMaterialBlockConnectionPointMode {
  8674. /** Value is an uniform */
  8675. Uniform = 0,
  8676. /** Value is a mesh attribute */
  8677. Attribute = 1,
  8678. /** Value is a varying between vertex and fragment shaders */
  8679. Varying = 2,
  8680. /** Mode is undefined */
  8681. Undefined = 3
  8682. }
  8683. }
  8684. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8685. /**
  8686. * Enum used to define system values e.g. values automatically provided by the system
  8687. */
  8688. export enum NodeMaterialSystemValues {
  8689. /** World */
  8690. World = 1,
  8691. /** View */
  8692. View = 2,
  8693. /** Projection */
  8694. Projection = 3,
  8695. /** ViewProjection */
  8696. ViewProjection = 4,
  8697. /** WorldView */
  8698. WorldView = 5,
  8699. /** WorldViewProjection */
  8700. WorldViewProjection = 6,
  8701. /** CameraPosition */
  8702. CameraPosition = 7,
  8703. /** Fog Color */
  8704. FogColor = 8,
  8705. /** Delta time */
  8706. DeltaTime = 9
  8707. }
  8708. }
  8709. declare module "babylonjs/Maths/math.axis" {
  8710. import { Vector3 } from "babylonjs/Maths/math.vector";
  8711. /** Defines supported spaces */
  8712. export enum Space {
  8713. /** Local (object) space */
  8714. LOCAL = 0,
  8715. /** World space */
  8716. WORLD = 1,
  8717. /** Bone space */
  8718. BONE = 2
  8719. }
  8720. /** Defines the 3 main axes */
  8721. export class Axis {
  8722. /** X axis */
  8723. static X: Vector3;
  8724. /** Y axis */
  8725. static Y: Vector3;
  8726. /** Z axis */
  8727. static Z: Vector3;
  8728. }
  8729. }
  8730. declare module "babylonjs/Maths/math.frustum" {
  8731. import { Matrix } from "babylonjs/Maths/math.vector";
  8732. import { DeepImmutable } from "babylonjs/types";
  8733. import { Plane } from "babylonjs/Maths/math.plane";
  8734. /**
  8735. * Represents a camera frustum
  8736. */
  8737. export class Frustum {
  8738. /**
  8739. * Gets the planes representing the frustum
  8740. * @param transform matrix to be applied to the returned planes
  8741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8742. */
  8743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8744. /**
  8745. * Gets the near frustum plane transformed by the transform matrix
  8746. * @param transform transformation matrix to be applied to the resulting frustum plane
  8747. * @param frustumPlane the resuling frustum plane
  8748. */
  8749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8750. /**
  8751. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8756. /**
  8757. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8762. /**
  8763. * Gets the right 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 GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8768. /**
  8769. * Gets the top 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 GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8774. /**
  8775. * Gets the bottom 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 GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8780. /**
  8781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8782. * @param transform transformation matrix to be applied to the resulting frustum planes
  8783. * @param frustumPlanes the resuling frustum planes
  8784. */
  8785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8786. }
  8787. }
  8788. declare module "babylonjs/Maths/math.size" {
  8789. /**
  8790. * Interface for the size containing width and height
  8791. */
  8792. export interface ISize {
  8793. /**
  8794. * Width
  8795. */
  8796. width: number;
  8797. /**
  8798. * Heighht
  8799. */
  8800. height: number;
  8801. }
  8802. /**
  8803. * Size containing widht and height
  8804. */
  8805. export class Size implements ISize {
  8806. /**
  8807. * Width
  8808. */
  8809. width: number;
  8810. /**
  8811. * Height
  8812. */
  8813. height: number;
  8814. /**
  8815. * Creates a Size object from the given width and height (floats).
  8816. * @param width width of the new size
  8817. * @param height height of the new size
  8818. */
  8819. constructor(width: number, height: number);
  8820. /**
  8821. * Returns a string with the Size width and height
  8822. * @returns a string with the Size width and height
  8823. */
  8824. toString(): string;
  8825. /**
  8826. * "Size"
  8827. * @returns the string "Size"
  8828. */
  8829. getClassName(): string;
  8830. /**
  8831. * Returns the Size hash code.
  8832. * @returns a hash code for a unique width and height
  8833. */
  8834. getHashCode(): number;
  8835. /**
  8836. * Updates the current size from the given one.
  8837. * @param src the given size
  8838. */
  8839. copyFrom(src: Size): void;
  8840. /**
  8841. * Updates in place the current Size from the given floats.
  8842. * @param width width of the new size
  8843. * @param height height of the new size
  8844. * @returns the updated Size.
  8845. */
  8846. copyFromFloats(width: number, height: number): Size;
  8847. /**
  8848. * Updates in place the current Size from the given floats.
  8849. * @param width width to set
  8850. * @param height height to set
  8851. * @returns the updated Size.
  8852. */
  8853. set(width: number, height: number): Size;
  8854. /**
  8855. * Multiplies the width and height by numbers
  8856. * @param w factor to multiple the width by
  8857. * @param h factor to multiple the height by
  8858. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8859. */
  8860. multiplyByFloats(w: number, h: number): Size;
  8861. /**
  8862. * Clones the size
  8863. * @returns a new Size copied from the given one.
  8864. */
  8865. clone(): Size;
  8866. /**
  8867. * True if the current Size and the given one width and height are strictly equal.
  8868. * @param other the other size to compare against
  8869. * @returns True if the current Size and the given one width and height are strictly equal.
  8870. */
  8871. equals(other: Size): boolean;
  8872. /**
  8873. * The surface of the Size : width * height (float).
  8874. */
  8875. get surface(): number;
  8876. /**
  8877. * Create a new size of zero
  8878. * @returns a new Size set to (0.0, 0.0)
  8879. */
  8880. static Zero(): Size;
  8881. /**
  8882. * Sums the width and height of two sizes
  8883. * @param otherSize size to add to this size
  8884. * @returns a new Size set as the addition result of the current Size and the given one.
  8885. */
  8886. add(otherSize: Size): Size;
  8887. /**
  8888. * Subtracts the width and height of two
  8889. * @param otherSize size to subtract to this size
  8890. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8891. */
  8892. subtract(otherSize: Size): Size;
  8893. /**
  8894. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8895. * @param start starting size to lerp between
  8896. * @param end end size to lerp between
  8897. * @param amount amount to lerp between the start and end values
  8898. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8899. */
  8900. static Lerp(start: Size, end: Size, amount: number): Size;
  8901. }
  8902. }
  8903. declare module "babylonjs/Maths/math.vertexFormat" {
  8904. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8905. /**
  8906. * Contains position and normal vectors for a vertex
  8907. */
  8908. export class PositionNormalVertex {
  8909. /** the position of the vertex (defaut: 0,0,0) */
  8910. position: Vector3;
  8911. /** the normal of the vertex (defaut: 0,1,0) */
  8912. normal: Vector3;
  8913. /**
  8914. * Creates a PositionNormalVertex
  8915. * @param position the position of the vertex (defaut: 0,0,0)
  8916. * @param normal the normal of the vertex (defaut: 0,1,0)
  8917. */
  8918. constructor(
  8919. /** the position of the vertex (defaut: 0,0,0) */
  8920. position?: Vector3,
  8921. /** the normal of the vertex (defaut: 0,1,0) */
  8922. normal?: Vector3);
  8923. /**
  8924. * Clones the PositionNormalVertex
  8925. * @returns the cloned PositionNormalVertex
  8926. */
  8927. clone(): PositionNormalVertex;
  8928. }
  8929. /**
  8930. * Contains position, normal and uv vectors for a vertex
  8931. */
  8932. export class PositionNormalTextureVertex {
  8933. /** the position of the vertex (defaut: 0,0,0) */
  8934. position: Vector3;
  8935. /** the normal of the vertex (defaut: 0,1,0) */
  8936. normal: Vector3;
  8937. /** the uv of the vertex (default: 0,0) */
  8938. uv: Vector2;
  8939. /**
  8940. * Creates a PositionNormalTextureVertex
  8941. * @param position the position of the vertex (defaut: 0,0,0)
  8942. * @param normal the normal of the vertex (defaut: 0,1,0)
  8943. * @param uv the uv of the vertex (default: 0,0)
  8944. */
  8945. constructor(
  8946. /** the position of the vertex (defaut: 0,0,0) */
  8947. position?: Vector3,
  8948. /** the normal of the vertex (defaut: 0,1,0) */
  8949. normal?: Vector3,
  8950. /** the uv of the vertex (default: 0,0) */
  8951. uv?: Vector2);
  8952. /**
  8953. * Clones the PositionNormalTextureVertex
  8954. * @returns the cloned PositionNormalTextureVertex
  8955. */
  8956. clone(): PositionNormalTextureVertex;
  8957. }
  8958. }
  8959. declare module "babylonjs/Maths/math" {
  8960. export * from "babylonjs/Maths/math.axis";
  8961. export * from "babylonjs/Maths/math.color";
  8962. export * from "babylonjs/Maths/math.constants";
  8963. export * from "babylonjs/Maths/math.frustum";
  8964. export * from "babylonjs/Maths/math.path";
  8965. export * from "babylonjs/Maths/math.plane";
  8966. export * from "babylonjs/Maths/math.size";
  8967. export * from "babylonjs/Maths/math.vector";
  8968. export * from "babylonjs/Maths/math.vertexFormat";
  8969. export * from "babylonjs/Maths/math.viewport";
  8970. }
  8971. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8972. /**
  8973. * Enum defining the type of animations supported by InputBlock
  8974. */
  8975. export enum AnimatedInputBlockTypes {
  8976. /** No animation */
  8977. None = 0,
  8978. /** Time based animation. Will only work for floats */
  8979. Time = 1
  8980. }
  8981. }
  8982. declare module "babylonjs/Lights/shadowLight" {
  8983. import { Camera } from "babylonjs/Cameras/camera";
  8984. import { Scene } from "babylonjs/scene";
  8985. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8987. import { Light } from "babylonjs/Lights/light";
  8988. /**
  8989. * Interface describing all the common properties and methods a shadow light needs to implement.
  8990. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8991. * as well as binding the different shadow properties to the effects.
  8992. */
  8993. export interface IShadowLight extends Light {
  8994. /**
  8995. * The light id in the scene (used in scene.findLighById for instance)
  8996. */
  8997. id: string;
  8998. /**
  8999. * The position the shdow will be casted from.
  9000. */
  9001. position: Vector3;
  9002. /**
  9003. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9004. */
  9005. direction: Vector3;
  9006. /**
  9007. * The transformed position. Position of the light in world space taking parenting in account.
  9008. */
  9009. transformedPosition: Vector3;
  9010. /**
  9011. * The transformed direction. Direction of the light in world space taking parenting in account.
  9012. */
  9013. transformedDirection: Vector3;
  9014. /**
  9015. * The friendly name of the light in the scene.
  9016. */
  9017. name: string;
  9018. /**
  9019. * Defines the shadow projection clipping minimum z value.
  9020. */
  9021. shadowMinZ: number;
  9022. /**
  9023. * Defines the shadow projection clipping maximum z value.
  9024. */
  9025. shadowMaxZ: number;
  9026. /**
  9027. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9028. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9029. */
  9030. computeTransformedInformation(): boolean;
  9031. /**
  9032. * Gets the scene the light belongs to.
  9033. * @returns The scene
  9034. */
  9035. getScene(): Scene;
  9036. /**
  9037. * Callback defining a custom Projection Matrix Builder.
  9038. * This can be used to override the default projection matrix computation.
  9039. */
  9040. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. /**
  9050. * Gets the current depth scale used in ESM.
  9051. * @returns The scale
  9052. */
  9053. getDepthScale(): number;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /**
  9069. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9070. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9071. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9072. */
  9073. getShadowDirection(faceIndex?: number): Vector3;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. }
  9087. /**
  9088. * Base implementation IShadowLight
  9089. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9090. */
  9091. export abstract class ShadowLight extends Light implements IShadowLight {
  9092. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9093. protected _position: Vector3;
  9094. protected _setPosition(value: Vector3): void;
  9095. /**
  9096. * Sets the position the shadow will be casted from. Also use as the light position for both
  9097. * point and spot lights.
  9098. */
  9099. get position(): Vector3;
  9100. /**
  9101. * Sets the position the shadow will be casted from. Also use as the light position for both
  9102. * point and spot lights.
  9103. */
  9104. set position(value: Vector3);
  9105. protected _direction: Vector3;
  9106. protected _setDirection(value: Vector3): void;
  9107. /**
  9108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9109. * Also use as the light direction on spot and directional lights.
  9110. */
  9111. get direction(): Vector3;
  9112. /**
  9113. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9114. * Also use as the light direction on spot and directional lights.
  9115. */
  9116. set direction(value: Vector3);
  9117. protected _shadowMinZ: number;
  9118. /**
  9119. * Gets the shadow projection clipping minimum z value.
  9120. */
  9121. get shadowMinZ(): number;
  9122. /**
  9123. * Sets the shadow projection clipping minimum z value.
  9124. */
  9125. set shadowMinZ(value: number);
  9126. protected _shadowMaxZ: number;
  9127. /**
  9128. * Sets the shadow projection clipping maximum z value.
  9129. */
  9130. get shadowMaxZ(): number;
  9131. /**
  9132. * Gets the shadow projection clipping maximum z value.
  9133. */
  9134. set shadowMaxZ(value: number);
  9135. /**
  9136. * Callback defining a custom Projection Matrix Builder.
  9137. * This can be used to override the default projection matrix computation.
  9138. */
  9139. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9140. /**
  9141. * The transformed position. Position of the light in world space taking parenting in account.
  9142. */
  9143. transformedPosition: Vector3;
  9144. /**
  9145. * The transformed direction. Direction of the light in world space taking parenting in account.
  9146. */
  9147. transformedDirection: Vector3;
  9148. private _needProjectionMatrixCompute;
  9149. /**
  9150. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9151. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9152. */
  9153. computeTransformedInformation(): boolean;
  9154. /**
  9155. * Return the depth scale used for the shadow map.
  9156. * @returns the depth scale.
  9157. */
  9158. getDepthScale(): number;
  9159. /**
  9160. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9161. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9162. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9163. */
  9164. getShadowDirection(faceIndex?: number): Vector3;
  9165. /**
  9166. * Returns the ShadowLight absolute position in the World.
  9167. * @returns the position vector in world space
  9168. */
  9169. getAbsolutePosition(): Vector3;
  9170. /**
  9171. * Sets the ShadowLight direction toward the passed target.
  9172. * @param target The point to target in local space
  9173. * @returns the updated ShadowLight direction
  9174. */
  9175. setDirectionToTarget(target: Vector3): Vector3;
  9176. /**
  9177. * Returns the light rotation in euler definition.
  9178. * @returns the x y z rotation in local space.
  9179. */
  9180. getRotation(): Vector3;
  9181. /**
  9182. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9183. * @returns true if a cube texture needs to be use
  9184. */
  9185. needCube(): boolean;
  9186. /**
  9187. * Detects if the projection matrix requires to be recomputed this frame.
  9188. * @returns true if it requires to be recomputed otherwise, false.
  9189. */
  9190. needProjectionMatrixCompute(): boolean;
  9191. /**
  9192. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9193. */
  9194. forceProjectionMatrixCompute(): void;
  9195. /** @hidden */
  9196. _initCache(): void;
  9197. /** @hidden */
  9198. _isSynchronized(): boolean;
  9199. /**
  9200. * Computes the world matrix of the node
  9201. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9202. * @returns the world matrix
  9203. */
  9204. computeWorldMatrix(force?: boolean): Matrix;
  9205. /**
  9206. * Gets the minZ used for shadow according to both the scene and the light.
  9207. * @param activeCamera The camera we are returning the min for
  9208. * @returns the depth min z
  9209. */
  9210. getDepthMinZ(activeCamera: Camera): number;
  9211. /**
  9212. * Gets the maxZ used for shadow according to both the scene and the light.
  9213. * @param activeCamera The camera we are returning the max for
  9214. * @returns the depth max z
  9215. */
  9216. getDepthMaxZ(activeCamera: Camera): number;
  9217. /**
  9218. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9219. * @param matrix The materix to updated with the projection information
  9220. * @param viewMatrix The transform matrix of the light
  9221. * @param renderList The list of mesh to render in the map
  9222. * @returns The current light
  9223. */
  9224. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9225. }
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9228. /** @hidden */
  9229. export var packingFunctions: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9235. /** @hidden */
  9236. export var bayerDitherFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9244. /** @hidden */
  9245. export var shadowMapFragmentDeclaration: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9251. /** @hidden */
  9252. export var clipPlaneFragmentDeclaration: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9258. /** @hidden */
  9259. export var clipPlaneFragment: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9265. /** @hidden */
  9266. export var shadowMapFragment: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9272. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9274. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9275. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9276. /** @hidden */
  9277. export var shadowMapPixelShader: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9283. /** @hidden */
  9284. export var bonesDeclaration: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9290. /** @hidden */
  9291. export var morphTargetsVertexGlobalDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9297. /** @hidden */
  9298. export var morphTargetsVertexDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9304. /** @hidden */
  9305. export var instancesDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9311. /** @hidden */
  9312. export var helperFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9318. /** @hidden */
  9319. export var shadowMapVertexDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9325. /** @hidden */
  9326. export var clipPlaneVertexDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9332. /** @hidden */
  9333. export var morphTargetsVertex: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9339. /** @hidden */
  9340. export var instancesVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9346. /** @hidden */
  9347. export var bonesVertex: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9353. /** @hidden */
  9354. export var shadowMapVertexNormalBias: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9360. /** @hidden */
  9361. export var shadowMapVertexMetric: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9367. /** @hidden */
  9368. export var clipPlaneVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9376. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9377. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9378. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9379. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9382. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9383. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9384. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9385. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9387. /** @hidden */
  9388. export var shadowMapVertexShader: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9394. /** @hidden */
  9395. export var depthBoxBlurPixelShader: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9401. /** @hidden */
  9402. export var shadowMapFragmentSoftTransparentShadow: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Materials/effectFallbacks" {
  9408. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9409. import { Effect } from "babylonjs/Materials/effect";
  9410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9411. /**
  9412. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9413. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9414. */
  9415. export class EffectFallbacks implements IEffectFallbacks {
  9416. private _defines;
  9417. private _currentRank;
  9418. private _maxRank;
  9419. private _mesh;
  9420. /**
  9421. * Removes the fallback from the bound mesh.
  9422. */
  9423. unBindMesh(): void;
  9424. /**
  9425. * Adds a fallback on the specified property.
  9426. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9427. * @param define The name of the define in the shader
  9428. */
  9429. addFallback(rank: number, define: string): void;
  9430. /**
  9431. * Sets the mesh to use CPU skinning when needing to fallback.
  9432. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9433. * @param mesh The mesh to use the fallbacks.
  9434. */
  9435. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9436. /**
  9437. * Checks to see if more fallbacks are still availible.
  9438. */
  9439. get hasMoreFallbacks(): boolean;
  9440. /**
  9441. * Removes the defines that should be removed when falling back.
  9442. * @param currentDefines defines the current define statements for the shader.
  9443. * @param effect defines the current effect we try to compile
  9444. * @returns The resulting defines with defines of the current rank removed.
  9445. */
  9446. reduce(currentDefines: string, effect: Effect): string;
  9447. }
  9448. }
  9449. declare module "babylonjs/Actions/action" {
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. import { Condition } from "babylonjs/Actions/condition";
  9452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9453. import { ActionManager } from "babylonjs/Actions/actionManager";
  9454. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9455. /**
  9456. * Interface used to define Action
  9457. */
  9458. export interface IAction {
  9459. /**
  9460. * Trigger for the action
  9461. */
  9462. trigger: number;
  9463. /** Options of the trigger */
  9464. triggerOptions: any;
  9465. /**
  9466. * Gets the trigger parameters
  9467. * @returns the trigger parameters
  9468. */
  9469. getTriggerParameter(): any;
  9470. /**
  9471. * Internal only - executes current action event
  9472. * @hidden
  9473. */
  9474. _executeCurrent(evt?: ActionEvent): void;
  9475. /**
  9476. * Serialize placeholder for child classes
  9477. * @param parent of child
  9478. * @returns the serialized object
  9479. */
  9480. serialize(parent: any): any;
  9481. /**
  9482. * Internal only
  9483. * @hidden
  9484. */
  9485. _prepare(): void;
  9486. /**
  9487. * Internal only - manager for action
  9488. * @hidden
  9489. */
  9490. _actionManager: AbstractActionManager;
  9491. /**
  9492. * Adds action to chain of actions, may be a DoNothingAction
  9493. * @param action defines the next action to execute
  9494. * @returns The action passed in
  9495. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9496. */
  9497. then(action: IAction): IAction;
  9498. }
  9499. /**
  9500. * The action to be carried out following a trigger
  9501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9502. */
  9503. export class Action implements IAction {
  9504. /** the trigger, with or without parameters, for the action */
  9505. triggerOptions: any;
  9506. /**
  9507. * Trigger for the action
  9508. */
  9509. trigger: number;
  9510. /**
  9511. * Internal only - manager for action
  9512. * @hidden
  9513. */
  9514. _actionManager: ActionManager;
  9515. private _nextActiveAction;
  9516. private _child;
  9517. private _condition?;
  9518. private _triggerParameter;
  9519. /**
  9520. * An event triggered prior to action being executed.
  9521. */
  9522. onBeforeExecuteObservable: Observable<Action>;
  9523. /**
  9524. * Creates a new Action
  9525. * @param triggerOptions the trigger, with or without parameters, for the action
  9526. * @param condition an optional determinant of action
  9527. */
  9528. constructor(
  9529. /** the trigger, with or without parameters, for the action */
  9530. triggerOptions: any, condition?: Condition);
  9531. /**
  9532. * Internal only
  9533. * @hidden
  9534. */
  9535. _prepare(): void;
  9536. /**
  9537. * Gets the trigger parameters
  9538. * @returns the trigger parameters
  9539. */
  9540. getTriggerParameter(): any;
  9541. /**
  9542. * Internal only - executes current action event
  9543. * @hidden
  9544. */
  9545. _executeCurrent(evt?: ActionEvent): void;
  9546. /**
  9547. * Execute placeholder for child classes
  9548. * @param evt optional action event
  9549. */
  9550. execute(evt?: ActionEvent): void;
  9551. /**
  9552. * Skips to next active action
  9553. */
  9554. skipToNextActiveAction(): void;
  9555. /**
  9556. * Adds action to chain of actions, may be a DoNothingAction
  9557. * @param action defines the next action to execute
  9558. * @returns The action passed in
  9559. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9560. */
  9561. then(action: Action): Action;
  9562. /**
  9563. * Internal only
  9564. * @hidden
  9565. */
  9566. _getProperty(propertyPath: string): string;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _getEffectiveTarget(target: any, propertyPath: string): any;
  9572. /**
  9573. * Serialize placeholder for child classes
  9574. * @param parent of child
  9575. * @returns the serialized object
  9576. */
  9577. serialize(parent: any): any;
  9578. /**
  9579. * Internal only called by serialize
  9580. * @hidden
  9581. */
  9582. protected _serialize(serializedAction: any, parent?: any): any;
  9583. /**
  9584. * Internal only
  9585. * @hidden
  9586. */
  9587. static _SerializeValueAsString: (value: any) => string;
  9588. /**
  9589. * Internal only
  9590. * @hidden
  9591. */
  9592. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  9593. name: string;
  9594. targetType: string;
  9595. value: string;
  9596. };
  9597. }
  9598. }
  9599. declare module "babylonjs/Actions/condition" {
  9600. import { ActionManager } from "babylonjs/Actions/actionManager";
  9601. /**
  9602. * A Condition applied to an Action
  9603. */
  9604. export class Condition {
  9605. /**
  9606. * Internal only - manager for action
  9607. * @hidden
  9608. */
  9609. _actionManager: ActionManager;
  9610. /**
  9611. * Internal only
  9612. * @hidden
  9613. */
  9614. _evaluationId: number;
  9615. /**
  9616. * Internal only
  9617. * @hidden
  9618. */
  9619. _currentResult: boolean;
  9620. /**
  9621. * Creates a new Condition
  9622. * @param actionManager the manager of the action the condition is applied to
  9623. */
  9624. constructor(actionManager: ActionManager);
  9625. /**
  9626. * Check if the current condition is valid
  9627. * @returns a boolean
  9628. */
  9629. isValid(): boolean;
  9630. /**
  9631. * Internal only
  9632. * @hidden
  9633. */
  9634. _getProperty(propertyPath: string): string;
  9635. /**
  9636. * Internal only
  9637. * @hidden
  9638. */
  9639. _getEffectiveTarget(target: any, propertyPath: string): any;
  9640. /**
  9641. * Serialize placeholder for child classes
  9642. * @returns the serialized object
  9643. */
  9644. serialize(): any;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. protected _serialize(serializedCondition: any): any;
  9650. }
  9651. /**
  9652. * Defines specific conditional operators as extensions of Condition
  9653. */
  9654. export class ValueCondition extends Condition {
  9655. /** path to specify the property of the target the conditional operator uses */
  9656. propertyPath: string;
  9657. /** the value compared by the conditional operator against the current value of the property */
  9658. value: any;
  9659. /** the conditional operator, default ValueCondition.IsEqual */
  9660. operator: number;
  9661. /**
  9662. * Internal only
  9663. * @hidden
  9664. */
  9665. private static _IsEqual;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. private static _IsDifferent;
  9671. /**
  9672. * Internal only
  9673. * @hidden
  9674. */
  9675. private static _IsGreater;
  9676. /**
  9677. * Internal only
  9678. * @hidden
  9679. */
  9680. private static _IsLesser;
  9681. /**
  9682. * returns the number for IsEqual
  9683. */
  9684. static get IsEqual(): number;
  9685. /**
  9686. * Returns the number for IsDifferent
  9687. */
  9688. static get IsDifferent(): number;
  9689. /**
  9690. * Returns the number for IsGreater
  9691. */
  9692. static get IsGreater(): number;
  9693. /**
  9694. * Returns the number for IsLesser
  9695. */
  9696. static get IsLesser(): number;
  9697. /**
  9698. * Internal only The action manager for the condition
  9699. * @hidden
  9700. */
  9701. _actionManager: ActionManager;
  9702. /**
  9703. * Internal only
  9704. * @hidden
  9705. */
  9706. private _target;
  9707. /**
  9708. * Internal only
  9709. * @hidden
  9710. */
  9711. private _effectiveTarget;
  9712. /**
  9713. * Internal only
  9714. * @hidden
  9715. */
  9716. private _property;
  9717. /**
  9718. * Creates a new ValueCondition
  9719. * @param actionManager manager for the action the condition applies to
  9720. * @param target for the action
  9721. * @param propertyPath path to specify the property of the target the conditional operator uses
  9722. * @param value the value compared by the conditional operator against the current value of the property
  9723. * @param operator the conditional operator, default ValueCondition.IsEqual
  9724. */
  9725. constructor(actionManager: ActionManager, target: any,
  9726. /** path to specify the property of the target the conditional operator uses */
  9727. propertyPath: string,
  9728. /** the value compared by the conditional operator against the current value of the property */
  9729. value: any,
  9730. /** the conditional operator, default ValueCondition.IsEqual */
  9731. operator?: number);
  9732. /**
  9733. * Compares the given value with the property value for the specified conditional operator
  9734. * @returns the result of the comparison
  9735. */
  9736. isValid(): boolean;
  9737. /**
  9738. * Serialize the ValueCondition into a JSON compatible object
  9739. * @returns serialization object
  9740. */
  9741. serialize(): any;
  9742. /**
  9743. * Gets the name of the conditional operator for the ValueCondition
  9744. * @param operator the conditional operator
  9745. * @returns the name
  9746. */
  9747. static GetOperatorName(operator: number): string;
  9748. }
  9749. /**
  9750. * Defines a predicate condition as an extension of Condition
  9751. */
  9752. export class PredicateCondition extends Condition {
  9753. /** defines the predicate function used to validate the condition */
  9754. predicate: () => boolean;
  9755. /**
  9756. * Internal only - manager for action
  9757. * @hidden
  9758. */
  9759. _actionManager: ActionManager;
  9760. /**
  9761. * Creates a new PredicateCondition
  9762. * @param actionManager manager for the action the condition applies to
  9763. * @param predicate defines the predicate function used to validate the condition
  9764. */
  9765. constructor(actionManager: ActionManager,
  9766. /** defines the predicate function used to validate the condition */
  9767. predicate: () => boolean);
  9768. /**
  9769. * @returns the validity of the predicate condition
  9770. */
  9771. isValid(): boolean;
  9772. }
  9773. /**
  9774. * Defines a state condition as an extension of Condition
  9775. */
  9776. export class StateCondition extends Condition {
  9777. /** Value to compare with target state */
  9778. value: string;
  9779. /**
  9780. * Internal only - manager for action
  9781. * @hidden
  9782. */
  9783. _actionManager: ActionManager;
  9784. /**
  9785. * Internal only
  9786. * @hidden
  9787. */
  9788. private _target;
  9789. /**
  9790. * Creates a new StateCondition
  9791. * @param actionManager manager for the action the condition applies to
  9792. * @param target of the condition
  9793. * @param value to compare with target state
  9794. */
  9795. constructor(actionManager: ActionManager, target: any,
  9796. /** Value to compare with target state */
  9797. value: string);
  9798. /**
  9799. * Gets a boolean indicating if the current condition is met
  9800. * @returns the validity of the state
  9801. */
  9802. isValid(): boolean;
  9803. /**
  9804. * Serialize the StateCondition into a JSON compatible object
  9805. * @returns serialization object
  9806. */
  9807. serialize(): any;
  9808. }
  9809. }
  9810. declare module "babylonjs/Actions/directActions" {
  9811. import { Action } from "babylonjs/Actions/action";
  9812. import { Condition } from "babylonjs/Actions/condition";
  9813. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9814. /**
  9815. * This defines an action responsible to toggle a boolean once triggered.
  9816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9817. */
  9818. export class SwitchBooleanAction extends Action {
  9819. /**
  9820. * The path to the boolean property in the target object
  9821. */
  9822. propertyPath: string;
  9823. private _target;
  9824. private _effectiveTarget;
  9825. private _property;
  9826. /**
  9827. * Instantiate the action
  9828. * @param triggerOptions defines the trigger options
  9829. * @param target defines the object containing the boolean
  9830. * @param propertyPath defines the path to the boolean property in the target object
  9831. * @param condition defines the trigger related conditions
  9832. */
  9833. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9834. /** @hidden */
  9835. _prepare(): void;
  9836. /**
  9837. * Execute the action toggle the boolean value.
  9838. */
  9839. execute(): void;
  9840. /**
  9841. * Serializes the actions and its related information.
  9842. * @param parent defines the object to serialize in
  9843. * @returns the serialized object
  9844. */
  9845. serialize(parent: any): any;
  9846. }
  9847. /**
  9848. * This defines an action responsible to set a the state field of the target
  9849. * to a desired value once triggered.
  9850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9851. */
  9852. export class SetStateAction extends Action {
  9853. /**
  9854. * The value to store in the state field.
  9855. */
  9856. value: string;
  9857. private _target;
  9858. /**
  9859. * Instantiate the action
  9860. * @param triggerOptions defines the trigger options
  9861. * @param target defines the object containing the state property
  9862. * @param value defines the value to store in the state field
  9863. * @param condition defines the trigger related conditions
  9864. */
  9865. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9866. /**
  9867. * Execute the action and store the value on the target state property.
  9868. */
  9869. execute(): void;
  9870. /**
  9871. * Serializes the actions and its related information.
  9872. * @param parent defines the object to serialize in
  9873. * @returns the serialized object
  9874. */
  9875. serialize(parent: any): any;
  9876. }
  9877. /**
  9878. * This defines an action responsible to set a property of the target
  9879. * to a desired value once triggered.
  9880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class SetValueAction extends Action {
  9883. /**
  9884. * The path of the property to set in the target.
  9885. */
  9886. propertyPath: string;
  9887. /**
  9888. * The value to set in the property
  9889. */
  9890. value: any;
  9891. private _target;
  9892. private _effectiveTarget;
  9893. private _property;
  9894. /**
  9895. * Instantiate the action
  9896. * @param triggerOptions defines the trigger options
  9897. * @param target defines the object containing the property
  9898. * @param propertyPath defines the path of the property to set in the target
  9899. * @param value defines the value to set in the property
  9900. * @param condition defines the trigger related conditions
  9901. */
  9902. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9903. /** @hidden */
  9904. _prepare(): void;
  9905. /**
  9906. * Execute the action and set the targetted property to the desired value.
  9907. */
  9908. execute(): void;
  9909. /**
  9910. * Serializes the actions and its related information.
  9911. * @param parent defines the object to serialize in
  9912. * @returns the serialized object
  9913. */
  9914. serialize(parent: any): any;
  9915. }
  9916. /**
  9917. * This defines an action responsible to increment the target value
  9918. * to a desired value once triggered.
  9919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9920. */
  9921. export class IncrementValueAction extends Action {
  9922. /**
  9923. * The path of the property to increment in the target.
  9924. */
  9925. propertyPath: string;
  9926. /**
  9927. * The value we should increment the property by.
  9928. */
  9929. value: any;
  9930. private _target;
  9931. private _effectiveTarget;
  9932. private _property;
  9933. /**
  9934. * Instantiate the action
  9935. * @param triggerOptions defines the trigger options
  9936. * @param target defines the object containing the property
  9937. * @param propertyPath defines the path of the property to increment in the target
  9938. * @param value defines the value value we should increment the property by
  9939. * @param condition defines the trigger related conditions
  9940. */
  9941. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9942. /** @hidden */
  9943. _prepare(): void;
  9944. /**
  9945. * Execute the action and increment the target of the value amount.
  9946. */
  9947. execute(): void;
  9948. /**
  9949. * Serializes the actions and its related information.
  9950. * @param parent defines the object to serialize in
  9951. * @returns the serialized object
  9952. */
  9953. serialize(parent: any): any;
  9954. }
  9955. /**
  9956. * This defines an action responsible to start an animation once triggered.
  9957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9958. */
  9959. export class PlayAnimationAction extends Action {
  9960. /**
  9961. * Where the animation should start (animation frame)
  9962. */
  9963. from: number;
  9964. /**
  9965. * Where the animation should stop (animation frame)
  9966. */
  9967. to: number;
  9968. /**
  9969. * Define if the animation should loop or stop after the first play.
  9970. */
  9971. loop?: boolean;
  9972. private _target;
  9973. /**
  9974. * Instantiate the action
  9975. * @param triggerOptions defines the trigger options
  9976. * @param target defines the target animation or animation name
  9977. * @param from defines from where the animation should start (animation frame)
  9978. * @param end defines where the animation should stop (animation frame)
  9979. * @param loop defines if the animation should loop or stop after the first play
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and play the animation.
  9987. */
  9988. execute(): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to stop an animation once triggered.
  9998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class StopAnimationAction extends Action {
  10001. private _target;
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param target defines the target animation or animation name
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, target: any, condition?: Condition);
  10009. /** @hidden */
  10010. _prepare(): void;
  10011. /**
  10012. * Execute the action and stop the animation.
  10013. */
  10014. execute(): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible that does nothing once triggered.
  10024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class DoNothingAction extends Action {
  10027. /**
  10028. * Instantiate the action
  10029. * @param triggerOptions defines the trigger options
  10030. * @param condition defines the trigger related conditions
  10031. */
  10032. constructor(triggerOptions?: any, condition?: Condition);
  10033. /**
  10034. * Execute the action and do nothing.
  10035. */
  10036. execute(): void;
  10037. /**
  10038. * Serializes the actions and its related information.
  10039. * @param parent defines the object to serialize in
  10040. * @returns the serialized object
  10041. */
  10042. serialize(parent: any): any;
  10043. }
  10044. /**
  10045. * This defines an action responsible to trigger several actions once triggered.
  10046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10047. */
  10048. export class CombineAction extends Action {
  10049. /**
  10050. * The list of aggregated animations to run.
  10051. */
  10052. children: Action[];
  10053. /**
  10054. * Instantiate the action
  10055. * @param triggerOptions defines the trigger options
  10056. * @param children defines the list of aggregated animations to run
  10057. * @param condition defines the trigger related conditions
  10058. */
  10059. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10060. /** @hidden */
  10061. _prepare(): void;
  10062. /**
  10063. * Execute the action and executes all the aggregated actions.
  10064. */
  10065. execute(evt: ActionEvent): void;
  10066. /**
  10067. * Serializes the actions and its related information.
  10068. * @param parent defines the object to serialize in
  10069. * @returns the serialized object
  10070. */
  10071. serialize(parent: any): any;
  10072. }
  10073. /**
  10074. * This defines an action responsible to run code (external event) once triggered.
  10075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10076. */
  10077. export class ExecuteCodeAction extends Action {
  10078. /**
  10079. * The callback function to run.
  10080. */
  10081. func: (evt: ActionEvent) => void;
  10082. /**
  10083. * Instantiate the action
  10084. * @param triggerOptions defines the trigger options
  10085. * @param func defines the callback function to run
  10086. * @param condition defines the trigger related conditions
  10087. */
  10088. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10089. /**
  10090. * Execute the action and run the attached code.
  10091. */
  10092. execute(evt: ActionEvent): void;
  10093. }
  10094. /**
  10095. * This defines an action responsible to set the parent property of the target once triggered.
  10096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10097. */
  10098. export class SetParentAction extends Action {
  10099. private _parent;
  10100. private _target;
  10101. /**
  10102. * Instantiate the action
  10103. * @param triggerOptions defines the trigger options
  10104. * @param target defines the target containing the parent property
  10105. * @param parent defines from where the animation should start (animation frame)
  10106. * @param condition defines the trigger related conditions
  10107. */
  10108. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10109. /** @hidden */
  10110. _prepare(): void;
  10111. /**
  10112. * Execute the action and set the parent property.
  10113. */
  10114. execute(): void;
  10115. /**
  10116. * Serializes the actions and its related information.
  10117. * @param parent defines the object to serialize in
  10118. * @returns the serialized object
  10119. */
  10120. serialize(parent: any): any;
  10121. }
  10122. }
  10123. declare module "babylonjs/Actions/actionManager" {
  10124. import { Nullable } from "babylonjs/types";
  10125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10126. import { Scene } from "babylonjs/scene";
  10127. import { IAction } from "babylonjs/Actions/action";
  10128. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10129. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10130. /**
  10131. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10132. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10134. */
  10135. export class ActionManager extends AbstractActionManager {
  10136. /**
  10137. * Nothing
  10138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10139. */
  10140. static readonly NothingTrigger: number;
  10141. /**
  10142. * On pick
  10143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10144. */
  10145. static readonly OnPickTrigger: number;
  10146. /**
  10147. * On left pick
  10148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10149. */
  10150. static readonly OnLeftPickTrigger: number;
  10151. /**
  10152. * On right pick
  10153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10154. */
  10155. static readonly OnRightPickTrigger: number;
  10156. /**
  10157. * On center pick
  10158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10159. */
  10160. static readonly OnCenterPickTrigger: number;
  10161. /**
  10162. * On pick down
  10163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10164. */
  10165. static readonly OnPickDownTrigger: number;
  10166. /**
  10167. * On double pick
  10168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10169. */
  10170. static readonly OnDoublePickTrigger: number;
  10171. /**
  10172. * On pick up
  10173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10174. */
  10175. static readonly OnPickUpTrigger: number;
  10176. /**
  10177. * On pick out.
  10178. * This trigger will only be raised if you also declared a OnPickDown
  10179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnPickOutTrigger: number;
  10182. /**
  10183. * On long press
  10184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnLongPressTrigger: number;
  10187. /**
  10188. * On pointer over
  10189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10190. */
  10191. static readonly OnPointerOverTrigger: number;
  10192. /**
  10193. * On pointer out
  10194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10195. */
  10196. static readonly OnPointerOutTrigger: number;
  10197. /**
  10198. * On every frame
  10199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10200. */
  10201. static readonly OnEveryFrameTrigger: number;
  10202. /**
  10203. * On intersection enter
  10204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10205. */
  10206. static readonly OnIntersectionEnterTrigger: number;
  10207. /**
  10208. * On intersection exit
  10209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10210. */
  10211. static readonly OnIntersectionExitTrigger: number;
  10212. /**
  10213. * On key down
  10214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10215. */
  10216. static readonly OnKeyDownTrigger: number;
  10217. /**
  10218. * On key up
  10219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10220. */
  10221. static readonly OnKeyUpTrigger: number;
  10222. private _scene;
  10223. /**
  10224. * Creates a new action manager
  10225. * @param scene defines the hosting scene
  10226. */
  10227. constructor(scene: Scene);
  10228. /**
  10229. * Releases all associated resources
  10230. */
  10231. dispose(): void;
  10232. /**
  10233. * Gets hosting scene
  10234. * @returns the hosting scene
  10235. */
  10236. getScene(): Scene;
  10237. /**
  10238. * Does this action manager handles actions of any of the given triggers
  10239. * @param triggers defines the triggers to be tested
  10240. * @return a boolean indicating whether one (or more) of the triggers is handled
  10241. */
  10242. hasSpecificTriggers(triggers: number[]): boolean;
  10243. /**
  10244. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10245. * speed.
  10246. * @param triggerA defines the trigger to be tested
  10247. * @param triggerB defines the trigger to be tested
  10248. * @return a boolean indicating whether one (or more) of the triggers is handled
  10249. */
  10250. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10251. /**
  10252. * Does this action manager handles actions of a given trigger
  10253. * @param trigger defines the trigger to be tested
  10254. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10255. * @return whether the trigger is handled
  10256. */
  10257. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10258. /**
  10259. * Does this action manager has pointer triggers
  10260. */
  10261. get hasPointerTriggers(): boolean;
  10262. /**
  10263. * Does this action manager has pick triggers
  10264. */
  10265. get hasPickTriggers(): boolean;
  10266. /**
  10267. * Registers an action to this action manager
  10268. * @param action defines the action to be registered
  10269. * @return the action amended (prepared) after registration
  10270. */
  10271. registerAction(action: IAction): Nullable<IAction>;
  10272. /**
  10273. * Unregisters an action to this action manager
  10274. * @param action defines the action to be unregistered
  10275. * @return a boolean indicating whether the action has been unregistered
  10276. */
  10277. unregisterAction(action: IAction): Boolean;
  10278. /**
  10279. * Process a specific trigger
  10280. * @param trigger defines the trigger to process
  10281. * @param evt defines the event details to be processed
  10282. */
  10283. processTrigger(trigger: number, evt?: IActionEvent): void;
  10284. /** @hidden */
  10285. _getEffectiveTarget(target: any, propertyPath: string): any;
  10286. /** @hidden */
  10287. _getProperty(propertyPath: string): string;
  10288. /**
  10289. * Serialize this manager to a JSON object
  10290. * @param name defines the property name to store this manager
  10291. * @returns a JSON representation of this manager
  10292. */
  10293. serialize(name: string): any;
  10294. /**
  10295. * Creates a new ActionManager from a JSON data
  10296. * @param parsedActions defines the JSON data to read from
  10297. * @param object defines the hosting mesh
  10298. * @param scene defines the hosting scene
  10299. */
  10300. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10301. /**
  10302. * Get a trigger name by index
  10303. * @param trigger defines the trigger index
  10304. * @returns a trigger name
  10305. */
  10306. static GetTriggerName(trigger: number): string;
  10307. }
  10308. }
  10309. declare module "babylonjs/Sprites/sprite" {
  10310. import { Vector3 } from "babylonjs/Maths/math.vector";
  10311. import { Nullable } from "babylonjs/types";
  10312. import { ActionManager } from "babylonjs/Actions/actionManager";
  10313. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10314. import { Color4 } from "babylonjs/Maths/math.color";
  10315. import { Observable } from "babylonjs/Misc/observable";
  10316. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10317. import { Animation } from "babylonjs/Animations/animation";
  10318. /**
  10319. * Class used to represent a sprite
  10320. * @see http://doc.babylonjs.com/babylon101/sprites
  10321. */
  10322. export class Sprite implements IAnimatable {
  10323. /** defines the name */
  10324. name: string;
  10325. /** Gets or sets the current world position */
  10326. position: Vector3;
  10327. /** Gets or sets the main color */
  10328. color: Color4;
  10329. /** Gets or sets the width */
  10330. width: number;
  10331. /** Gets or sets the height */
  10332. height: number;
  10333. /** Gets or sets rotation angle */
  10334. angle: number;
  10335. /** Gets or sets the cell index in the sprite sheet */
  10336. cellIndex: number;
  10337. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10338. cellRef: string;
  10339. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10340. invertU: boolean;
  10341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10342. invertV: boolean;
  10343. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10344. disposeWhenFinishedAnimating: boolean;
  10345. /** Gets the list of attached animations */
  10346. animations: Nullable<Array<Animation>>;
  10347. /** Gets or sets a boolean indicating if the sprite can be picked */
  10348. isPickable: boolean;
  10349. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10350. useAlphaForPicking: boolean;
  10351. /** @hidden */
  10352. _xOffset: number;
  10353. /** @hidden */
  10354. _yOffset: number;
  10355. /** @hidden */
  10356. _xSize: number;
  10357. /** @hidden */
  10358. _ySize: number;
  10359. /**
  10360. * Gets or sets the associated action manager
  10361. */
  10362. actionManager: Nullable<ActionManager>;
  10363. /**
  10364. * An event triggered when the control has been disposed
  10365. */
  10366. onDisposeObservable: Observable<Sprite>;
  10367. private _animationStarted;
  10368. private _loopAnimation;
  10369. private _fromIndex;
  10370. private _toIndex;
  10371. private _delay;
  10372. private _direction;
  10373. private _manager;
  10374. private _time;
  10375. private _onAnimationEnd;
  10376. /**
  10377. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10378. */
  10379. isVisible: boolean;
  10380. /**
  10381. * Gets or sets the sprite size
  10382. */
  10383. get size(): number;
  10384. set size(value: number);
  10385. /**
  10386. * Returns a boolean indicating if the animation is started
  10387. */
  10388. get animationStarted(): boolean;
  10389. /**
  10390. * Gets or sets the unique id of the sprite
  10391. */
  10392. uniqueId: number;
  10393. /**
  10394. * Gets the manager of this sprite
  10395. */
  10396. get manager(): ISpriteManager;
  10397. /**
  10398. * Creates a new Sprite
  10399. * @param name defines the name
  10400. * @param manager defines the manager
  10401. */
  10402. constructor(
  10403. /** defines the name */
  10404. name: string, manager: ISpriteManager);
  10405. /**
  10406. * Returns the string "Sprite"
  10407. * @returns "Sprite"
  10408. */
  10409. getClassName(): string;
  10410. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10411. get fromIndex(): number;
  10412. set fromIndex(value: number);
  10413. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10414. get toIndex(): number;
  10415. set toIndex(value: number);
  10416. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10417. get loopAnimation(): boolean;
  10418. set loopAnimation(value: boolean);
  10419. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10420. get delay(): number;
  10421. set delay(value: number);
  10422. /**
  10423. * Starts an animation
  10424. * @param from defines the initial key
  10425. * @param to defines the end key
  10426. * @param loop defines if the animation must loop
  10427. * @param delay defines the start delay (in ms)
  10428. * @param onAnimationEnd defines a callback to call when animation ends
  10429. */
  10430. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10431. /** Stops current animation (if any) */
  10432. stopAnimation(): void;
  10433. /** @hidden */
  10434. _animate(deltaTime: number): void;
  10435. /** Release associated resources */
  10436. dispose(): void;
  10437. /**
  10438. * Serializes the sprite to a JSON object
  10439. * @returns the JSON object
  10440. */
  10441. serialize(): any;
  10442. /**
  10443. * Parses a JSON object to create a new sprite
  10444. * @param parsedSprite The JSON object to parse
  10445. * @param manager defines the hosting manager
  10446. * @returns the new sprite
  10447. */
  10448. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10449. }
  10450. }
  10451. declare module "babylonjs/Collisions/pickingInfo" {
  10452. import { Nullable } from "babylonjs/types";
  10453. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10455. import { Sprite } from "babylonjs/Sprites/sprite";
  10456. import { Ray } from "babylonjs/Culling/ray";
  10457. /**
  10458. * Information about the result of picking within a scene
  10459. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10460. */
  10461. export class PickingInfo {
  10462. /** @hidden */
  10463. _pickingUnavailable: boolean;
  10464. /**
  10465. * If the pick collided with an object
  10466. */
  10467. hit: boolean;
  10468. /**
  10469. * Distance away where the pick collided
  10470. */
  10471. distance: number;
  10472. /**
  10473. * The location of pick collision
  10474. */
  10475. pickedPoint: Nullable<Vector3>;
  10476. /**
  10477. * The mesh corresponding the the pick collision
  10478. */
  10479. pickedMesh: Nullable<AbstractMesh>;
  10480. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10481. bu: number;
  10482. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10483. bv: number;
  10484. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10485. faceId: number;
  10486. /** Id of the the submesh that was picked */
  10487. subMeshId: number;
  10488. /** If a sprite was picked, this will be the sprite the pick collided with */
  10489. pickedSprite: Nullable<Sprite>;
  10490. /**
  10491. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10492. */
  10493. originMesh: Nullable<AbstractMesh>;
  10494. /**
  10495. * The ray that was used to perform the picking.
  10496. */
  10497. ray: Nullable<Ray>;
  10498. /**
  10499. * Gets the normal correspodning to the face the pick collided with
  10500. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10501. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10502. * @returns The normal correspodning to the face the pick collided with
  10503. */
  10504. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10505. /**
  10506. * Gets the texture coordinates of where the pick occured
  10507. * @returns the vector containing the coordnates of the texture
  10508. */
  10509. getTextureCoordinates(): Nullable<Vector2>;
  10510. }
  10511. }
  10512. declare module "babylonjs/Culling/ray" {
  10513. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10514. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10516. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10517. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10518. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10519. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10520. import { Plane } from "babylonjs/Maths/math.plane";
  10521. /**
  10522. * Class representing a ray with position and direction
  10523. */
  10524. export class Ray {
  10525. /** origin point */
  10526. origin: Vector3;
  10527. /** direction */
  10528. direction: Vector3;
  10529. /** length of the ray */
  10530. length: number;
  10531. private static readonly TmpVector3;
  10532. private _tmpRay;
  10533. /**
  10534. * Creates a new ray
  10535. * @param origin origin point
  10536. * @param direction direction
  10537. * @param length length of the ray
  10538. */
  10539. constructor(
  10540. /** origin point */
  10541. origin: Vector3,
  10542. /** direction */
  10543. direction: Vector3,
  10544. /** length of the ray */
  10545. length?: number);
  10546. /**
  10547. * Checks if the ray intersects a box
  10548. * This does not account for the ray lenght by design to improve perfs.
  10549. * @param minimum bound of the box
  10550. * @param maximum bound of the box
  10551. * @param intersectionTreshold extra extend to be added to the box in all direction
  10552. * @returns if the box was hit
  10553. */
  10554. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10555. /**
  10556. * Checks if the ray intersects a box
  10557. * This does not account for the ray lenght by design to improve perfs.
  10558. * @param box the bounding box to check
  10559. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10560. * @returns if the box was hit
  10561. */
  10562. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10563. /**
  10564. * If the ray hits a sphere
  10565. * @param sphere the bounding sphere to check
  10566. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10567. * @returns true if it hits the sphere
  10568. */
  10569. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10570. /**
  10571. * If the ray hits a triange
  10572. * @param vertex0 triangle vertex
  10573. * @param vertex1 triangle vertex
  10574. * @param vertex2 triangle vertex
  10575. * @returns intersection information if hit
  10576. */
  10577. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10578. /**
  10579. * Checks if ray intersects a plane
  10580. * @param plane the plane to check
  10581. * @returns the distance away it was hit
  10582. */
  10583. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10584. /**
  10585. * Calculate the intercept of a ray on a given axis
  10586. * @param axis to check 'x' | 'y' | 'z'
  10587. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10588. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10589. */
  10590. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10591. /**
  10592. * Checks if ray intersects a mesh
  10593. * @param mesh the mesh to check
  10594. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10595. * @returns picking info of the intersecton
  10596. */
  10597. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10598. /**
  10599. * Checks if ray intersects a mesh
  10600. * @param meshes the meshes to check
  10601. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10602. * @param results array to store result in
  10603. * @returns Array of picking infos
  10604. */
  10605. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10606. private _comparePickingInfo;
  10607. private static smallnum;
  10608. private static rayl;
  10609. /**
  10610. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10611. * @param sega the first point of the segment to test the intersection against
  10612. * @param segb the second point of the segment to test the intersection against
  10613. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10614. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10615. */
  10616. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10617. /**
  10618. * Update the ray from viewport position
  10619. * @param x position
  10620. * @param y y position
  10621. * @param viewportWidth viewport width
  10622. * @param viewportHeight viewport height
  10623. * @param world world matrix
  10624. * @param view view matrix
  10625. * @param projection projection matrix
  10626. * @returns this ray updated
  10627. */
  10628. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10629. /**
  10630. * Creates a ray with origin and direction of 0,0,0
  10631. * @returns the new ray
  10632. */
  10633. static Zero(): Ray;
  10634. /**
  10635. * Creates a new ray from screen space and viewport
  10636. * @param x position
  10637. * @param y y position
  10638. * @param viewportWidth viewport width
  10639. * @param viewportHeight viewport height
  10640. * @param world world matrix
  10641. * @param view view matrix
  10642. * @param projection projection matrix
  10643. * @returns new ray
  10644. */
  10645. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10646. /**
  10647. * 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
  10648. * transformed to the given world matrix.
  10649. * @param origin The origin point
  10650. * @param end The end point
  10651. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10652. * @returns the new ray
  10653. */
  10654. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10655. /**
  10656. * Transforms a ray by a matrix
  10657. * @param ray ray to transform
  10658. * @param matrix matrix to apply
  10659. * @returns the resulting new ray
  10660. */
  10661. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10662. /**
  10663. * Transforms a ray by a matrix
  10664. * @param ray ray to transform
  10665. * @param matrix matrix to apply
  10666. * @param result ray to store result in
  10667. */
  10668. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10669. /**
  10670. * Unproject a ray from screen space to object space
  10671. * @param sourceX defines the screen space x coordinate to use
  10672. * @param sourceY defines the screen space y coordinate to use
  10673. * @param viewportWidth defines the current width of the viewport
  10674. * @param viewportHeight defines the current height of the viewport
  10675. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10676. * @param view defines the view matrix to use
  10677. * @param projection defines the projection matrix to use
  10678. */
  10679. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10680. }
  10681. /**
  10682. * Type used to define predicate used to select faces when a mesh intersection is detected
  10683. */
  10684. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10685. module "babylonjs/scene" {
  10686. interface Scene {
  10687. /** @hidden */
  10688. _tempPickingRay: Nullable<Ray>;
  10689. /** @hidden */
  10690. _cachedRayForTransform: Ray;
  10691. /** @hidden */
  10692. _pickWithRayInverseMatrix: Matrix;
  10693. /** @hidden */
  10694. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10695. /** @hidden */
  10696. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10697. }
  10698. }
  10699. }
  10700. declare module "babylonjs/sceneComponent" {
  10701. import { Scene } from "babylonjs/scene";
  10702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10704. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10705. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10706. import { Nullable } from "babylonjs/types";
  10707. import { Camera } from "babylonjs/Cameras/camera";
  10708. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10709. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10710. import { AbstractScene } from "babylonjs/abstractScene";
  10711. import { Mesh } from "babylonjs/Meshes/mesh";
  10712. /**
  10713. * Groups all the scene component constants in one place to ease maintenance.
  10714. * @hidden
  10715. */
  10716. export class SceneComponentConstants {
  10717. static readonly NAME_EFFECTLAYER: string;
  10718. static readonly NAME_LAYER: string;
  10719. static readonly NAME_LENSFLARESYSTEM: string;
  10720. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10721. static readonly NAME_PARTICLESYSTEM: string;
  10722. static readonly NAME_GAMEPAD: string;
  10723. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10724. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10725. static readonly NAME_DEPTHRENDERER: string;
  10726. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10727. static readonly NAME_SPRITE: string;
  10728. static readonly NAME_OUTLINERENDERER: string;
  10729. static readonly NAME_PROCEDURALTEXTURE: string;
  10730. static readonly NAME_SHADOWGENERATOR: string;
  10731. static readonly NAME_OCTREE: string;
  10732. static readonly NAME_PHYSICSENGINE: string;
  10733. static readonly NAME_AUDIO: string;
  10734. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10735. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10736. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10737. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10739. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10740. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10741. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10742. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10743. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10744. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10745. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10746. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10747. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10748. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10749. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10750. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10751. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10752. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10753. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10754. static readonly STEP_AFTERRENDER_AUDIO: number;
  10755. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10756. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10759. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10760. static readonly STEP_POINTERMOVE_SPRITE: number;
  10761. static readonly STEP_POINTERDOWN_SPRITE: number;
  10762. static readonly STEP_POINTERUP_SPRITE: number;
  10763. }
  10764. /**
  10765. * This represents a scene component.
  10766. *
  10767. * This is used to decouple the dependency the scene is having on the different workloads like
  10768. * layers, post processes...
  10769. */
  10770. export interface ISceneComponent {
  10771. /**
  10772. * The name of the component. Each component must have a unique name.
  10773. */
  10774. name: string;
  10775. /**
  10776. * The scene the component belongs to.
  10777. */
  10778. scene: Scene;
  10779. /**
  10780. * Register the component to one instance of a scene.
  10781. */
  10782. register(): void;
  10783. /**
  10784. * Rebuilds the elements related to this component in case of
  10785. * context lost for instance.
  10786. */
  10787. rebuild(): void;
  10788. /**
  10789. * Disposes the component and the associated ressources.
  10790. */
  10791. dispose(): void;
  10792. }
  10793. /**
  10794. * This represents a SERIALIZABLE scene component.
  10795. *
  10796. * This extends Scene Component to add Serialization methods on top.
  10797. */
  10798. export interface ISceneSerializableComponent extends ISceneComponent {
  10799. /**
  10800. * Adds all the elements from the container to the scene
  10801. * @param container the container holding the elements
  10802. */
  10803. addFromContainer(container: AbstractScene): void;
  10804. /**
  10805. * Removes all the elements in the container from the scene
  10806. * @param container contains the elements to remove
  10807. * @param dispose if the removed element should be disposed (default: false)
  10808. */
  10809. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10810. /**
  10811. * Serializes the component data to the specified json object
  10812. * @param serializationObject The object to serialize to
  10813. */
  10814. serialize(serializationObject: any): void;
  10815. }
  10816. /**
  10817. * Strong typing of a Mesh related stage step action
  10818. */
  10819. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10820. /**
  10821. * Strong typing of a Evaluate Sub Mesh related stage step action
  10822. */
  10823. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10824. /**
  10825. * Strong typing of a Active Mesh related stage step action
  10826. */
  10827. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10828. /**
  10829. * Strong typing of a Camera related stage step action
  10830. */
  10831. export type CameraStageAction = (camera: Camera) => void;
  10832. /**
  10833. * Strong typing of a Camera Frame buffer related stage step action
  10834. */
  10835. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10836. /**
  10837. * Strong typing of a Render Target related stage step action
  10838. */
  10839. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10840. /**
  10841. * Strong typing of a RenderingGroup related stage step action
  10842. */
  10843. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10844. /**
  10845. * Strong typing of a Mesh Render related stage step action
  10846. */
  10847. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10848. /**
  10849. * Strong typing of a simple stage step action
  10850. */
  10851. export type SimpleStageAction = () => void;
  10852. /**
  10853. * Strong typing of a render target action.
  10854. */
  10855. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10856. /**
  10857. * Strong typing of a pointer move action.
  10858. */
  10859. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10860. /**
  10861. * Strong typing of a pointer up/down action.
  10862. */
  10863. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10864. /**
  10865. * Representation of a stage in the scene (Basically a list of ordered steps)
  10866. * @hidden
  10867. */
  10868. export class Stage<T extends Function> extends Array<{
  10869. index: number;
  10870. component: ISceneComponent;
  10871. action: T;
  10872. }> {
  10873. /**
  10874. * Hide ctor from the rest of the world.
  10875. * @param items The items to add.
  10876. */
  10877. private constructor();
  10878. /**
  10879. * Creates a new Stage.
  10880. * @returns A new instance of a Stage
  10881. */
  10882. static Create<T extends Function>(): Stage<T>;
  10883. /**
  10884. * Registers a step in an ordered way in the targeted stage.
  10885. * @param index Defines the position to register the step in
  10886. * @param component Defines the component attached to the step
  10887. * @param action Defines the action to launch during the step
  10888. */
  10889. registerStep(index: number, component: ISceneComponent, action: T): void;
  10890. /**
  10891. * Clears all the steps from the stage.
  10892. */
  10893. clear(): void;
  10894. }
  10895. }
  10896. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10897. import { Nullable } from "babylonjs/types";
  10898. import { Observable } from "babylonjs/Misc/observable";
  10899. import { Scene } from "babylonjs/scene";
  10900. import { Sprite } from "babylonjs/Sprites/sprite";
  10901. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10902. import { Ray } from "babylonjs/Culling/ray";
  10903. import { Camera } from "babylonjs/Cameras/camera";
  10904. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10905. import { ISceneComponent } from "babylonjs/sceneComponent";
  10906. module "babylonjs/scene" {
  10907. interface Scene {
  10908. /** @hidden */
  10909. _pointerOverSprite: Nullable<Sprite>;
  10910. /** @hidden */
  10911. _pickedDownSprite: Nullable<Sprite>;
  10912. /** @hidden */
  10913. _tempSpritePickingRay: Nullable<Ray>;
  10914. /**
  10915. * All of the sprite managers added to this scene
  10916. * @see http://doc.babylonjs.com/babylon101/sprites
  10917. */
  10918. spriteManagers: Array<ISpriteManager>;
  10919. /**
  10920. * An event triggered when sprites rendering is about to start
  10921. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10922. */
  10923. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10924. /**
  10925. * An event triggered when sprites rendering is done
  10926. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10927. */
  10928. onAfterSpritesRenderingObservable: Observable<Scene>;
  10929. /** @hidden */
  10930. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10931. /** Launch a ray to try to pick a sprite in the scene
  10932. * @param x position on screen
  10933. * @param y position on screen
  10934. * @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
  10935. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10936. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10937. * @returns a PickingInfo
  10938. */
  10939. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10940. /** Use the given ray to pick a sprite in the scene
  10941. * @param ray The ray (in world space) to use to pick meshes
  10942. * @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
  10943. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10944. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10945. * @returns a PickingInfo
  10946. */
  10947. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10948. /** @hidden */
  10949. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10950. /** Launch a ray to try to pick sprites in the scene
  10951. * @param x position on screen
  10952. * @param y position on screen
  10953. * @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
  10954. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10955. * @returns a PickingInfo array
  10956. */
  10957. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /** Use the given ray to pick sprites in the scene
  10959. * @param ray The ray (in world space) to use to pick meshes
  10960. * @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
  10961. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10962. * @returns a PickingInfo array
  10963. */
  10964. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10965. /**
  10966. * Force the sprite under the pointer
  10967. * @param sprite defines the sprite to use
  10968. */
  10969. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10970. /**
  10971. * Gets the sprite under the pointer
  10972. * @returns a Sprite or null if no sprite is under the pointer
  10973. */
  10974. getPointerOverSprite(): Nullable<Sprite>;
  10975. }
  10976. }
  10977. /**
  10978. * Defines the sprite scene component responsible to manage sprites
  10979. * in a given scene.
  10980. */
  10981. export class SpriteSceneComponent implements ISceneComponent {
  10982. /**
  10983. * The component name helpfull to identify the component in the list of scene components.
  10984. */
  10985. readonly name: string;
  10986. /**
  10987. * The scene the component belongs to.
  10988. */
  10989. scene: Scene;
  10990. /** @hidden */
  10991. private _spritePredicate;
  10992. /**
  10993. * Creates a new instance of the component for the given scene
  10994. * @param scene Defines the scene to register the component in
  10995. */
  10996. constructor(scene: Scene);
  10997. /**
  10998. * Registers the component in a given scene
  10999. */
  11000. register(): void;
  11001. /**
  11002. * Rebuilds the elements related to this component in case of
  11003. * context lost for instance.
  11004. */
  11005. rebuild(): void;
  11006. /**
  11007. * Disposes the component and the associated ressources.
  11008. */
  11009. dispose(): void;
  11010. private _pickSpriteButKeepRay;
  11011. private _pointerMove;
  11012. private _pointerDown;
  11013. private _pointerUp;
  11014. }
  11015. }
  11016. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11017. /** @hidden */
  11018. export var fogFragmentDeclaration: {
  11019. name: string;
  11020. shader: string;
  11021. };
  11022. }
  11023. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11024. /** @hidden */
  11025. export var fogFragment: {
  11026. name: string;
  11027. shader: string;
  11028. };
  11029. }
  11030. declare module "babylonjs/Shaders/sprites.fragment" {
  11031. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11032. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11033. /** @hidden */
  11034. export var spritesPixelShader: {
  11035. name: string;
  11036. shader: string;
  11037. };
  11038. }
  11039. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11040. /** @hidden */
  11041. export var fogVertexDeclaration: {
  11042. name: string;
  11043. shader: string;
  11044. };
  11045. }
  11046. declare module "babylonjs/Shaders/sprites.vertex" {
  11047. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11048. /** @hidden */
  11049. export var spritesVertexShader: {
  11050. name: string;
  11051. shader: string;
  11052. };
  11053. }
  11054. declare module "babylonjs/Sprites/spriteManager" {
  11055. import { IDisposable, Scene } from "babylonjs/scene";
  11056. import { Nullable } from "babylonjs/types";
  11057. import { Observable } from "babylonjs/Misc/observable";
  11058. import { Sprite } from "babylonjs/Sprites/sprite";
  11059. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11060. import { Camera } from "babylonjs/Cameras/camera";
  11061. import { Texture } from "babylonjs/Materials/Textures/texture";
  11062. import "babylonjs/Shaders/sprites.fragment";
  11063. import "babylonjs/Shaders/sprites.vertex";
  11064. import { Ray } from "babylonjs/Culling/ray";
  11065. /**
  11066. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11067. */
  11068. export interface ISpriteManager extends IDisposable {
  11069. /**
  11070. * Gets manager's name
  11071. */
  11072. name: string;
  11073. /**
  11074. * Restricts the camera to viewing objects with the same layerMask.
  11075. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11076. */
  11077. layerMask: number;
  11078. /**
  11079. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11080. */
  11081. isPickable: boolean;
  11082. /**
  11083. * Gets the hosting scene
  11084. */
  11085. scene: Scene;
  11086. /**
  11087. * Specifies the rendering group id for this mesh (0 by default)
  11088. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11089. */
  11090. renderingGroupId: number;
  11091. /**
  11092. * Defines the list of sprites managed by the manager.
  11093. */
  11094. sprites: Array<Sprite>;
  11095. /**
  11096. * Gets or sets the spritesheet texture
  11097. */
  11098. texture: Texture;
  11099. /** Defines the default width of a cell in the spritesheet */
  11100. cellWidth: number;
  11101. /** Defines the default height of a cell in the spritesheet */
  11102. cellHeight: number;
  11103. /**
  11104. * Tests the intersection of a sprite with a specific ray.
  11105. * @param ray The ray we are sending to test the collision
  11106. * @param camera The camera space we are sending rays in
  11107. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11108. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11109. * @returns picking info or null.
  11110. */
  11111. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11112. /**
  11113. * Intersects the sprites with a ray
  11114. * @param ray defines the ray to intersect with
  11115. * @param camera defines the current active camera
  11116. * @param predicate defines a predicate used to select candidate sprites
  11117. * @returns null if no hit or a PickingInfo array
  11118. */
  11119. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11120. /**
  11121. * Renders the list of sprites on screen.
  11122. */
  11123. render(): void;
  11124. }
  11125. /**
  11126. * Class used to manage multiple sprites on the same spritesheet
  11127. * @see http://doc.babylonjs.com/babylon101/sprites
  11128. */
  11129. export class SpriteManager implements ISpriteManager {
  11130. /** defines the manager's name */
  11131. name: string;
  11132. /** Define the Url to load snippets */
  11133. static SnippetUrl: string;
  11134. /** Snippet ID if the manager was created from the snippet server */
  11135. snippetId: string;
  11136. /** Gets the list of sprites */
  11137. sprites: Sprite[];
  11138. /** Gets or sets the rendering group id (0 by default) */
  11139. renderingGroupId: number;
  11140. /** Gets or sets camera layer mask */
  11141. layerMask: number;
  11142. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11143. fogEnabled: boolean;
  11144. /** Gets or sets a boolean indicating if the sprites are pickable */
  11145. isPickable: boolean;
  11146. /** Defines the default width of a cell in the spritesheet */
  11147. cellWidth: number;
  11148. /** Defines the default height of a cell in the spritesheet */
  11149. cellHeight: number;
  11150. /** Associative array from JSON sprite data file */
  11151. private _cellData;
  11152. /** Array of sprite names from JSON sprite data file */
  11153. private _spriteMap;
  11154. /** True when packed cell data from JSON file is ready*/
  11155. private _packedAndReady;
  11156. private _textureContent;
  11157. /**
  11158. * An event triggered when the manager is disposed.
  11159. */
  11160. onDisposeObservable: Observable<SpriteManager>;
  11161. private _onDisposeObserver;
  11162. /**
  11163. * Callback called when the manager is disposed
  11164. */
  11165. set onDispose(callback: () => void);
  11166. private _capacity;
  11167. private _fromPacked;
  11168. private _spriteTexture;
  11169. private _epsilon;
  11170. private _scene;
  11171. private _vertexData;
  11172. private _buffer;
  11173. private _vertexBuffers;
  11174. private _indexBuffer;
  11175. private _effectBase;
  11176. private _effectFog;
  11177. /**
  11178. * Gets or sets the unique id of the sprite
  11179. */
  11180. uniqueId: number;
  11181. /**
  11182. * Gets the array of sprites
  11183. */
  11184. get children(): Sprite[];
  11185. /**
  11186. * Gets the hosting scene
  11187. */
  11188. get scene(): Scene;
  11189. /**
  11190. * Gets the capacity of the manager
  11191. */
  11192. get capacity(): number;
  11193. /**
  11194. * Gets or sets the spritesheet texture
  11195. */
  11196. get texture(): Texture;
  11197. set texture(value: Texture);
  11198. private _blendMode;
  11199. /**
  11200. * Blend mode use to render the particle, it can be any of
  11201. * the static Constants.ALPHA_x properties provided in this class.
  11202. * Default value is Constants.ALPHA_COMBINE
  11203. */
  11204. get blendMode(): number;
  11205. set blendMode(blendMode: number);
  11206. /** Disables writing to the depth buffer when rendering the sprites.
  11207. * It can be handy to disable depth writing when using textures without alpha channel
  11208. * and setting some specific blend modes.
  11209. */
  11210. disableDepthWrite: boolean;
  11211. /**
  11212. * Creates a new sprite manager
  11213. * @param name defines the manager's name
  11214. * @param imgUrl defines the sprite sheet url
  11215. * @param capacity defines the maximum allowed number of sprites
  11216. * @param cellSize defines the size of a sprite cell
  11217. * @param scene defines the hosting scene
  11218. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11219. * @param samplingMode defines the smapling mode to use with spritesheet
  11220. * @param fromPacked set to false; do not alter
  11221. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11222. */
  11223. constructor(
  11224. /** defines the manager's name */
  11225. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11226. /**
  11227. * Returns the string "SpriteManager"
  11228. * @returns "SpriteManager"
  11229. */
  11230. getClassName(): string;
  11231. private _makePacked;
  11232. private _appendSpriteVertex;
  11233. private _checkTextureAlpha;
  11234. /**
  11235. * Intersects the sprites with a ray
  11236. * @param ray defines the ray to intersect with
  11237. * @param camera defines the current active camera
  11238. * @param predicate defines a predicate used to select candidate sprites
  11239. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11240. * @returns null if no hit or a PickingInfo
  11241. */
  11242. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11243. /**
  11244. * Intersects the sprites with a ray
  11245. * @param ray defines the ray to intersect with
  11246. * @param camera defines the current active camera
  11247. * @param predicate defines a predicate used to select candidate sprites
  11248. * @returns null if no hit or a PickingInfo array
  11249. */
  11250. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11251. /**
  11252. * Render all child sprites
  11253. */
  11254. render(): void;
  11255. /**
  11256. * Release associated resources
  11257. */
  11258. dispose(): void;
  11259. /**
  11260. * Serializes the sprite manager to a JSON object
  11261. * @param serializeTexture defines if the texture must be serialized as well
  11262. * @returns the JSON object
  11263. */
  11264. serialize(serializeTexture?: boolean): any;
  11265. /**
  11266. * Parses a JSON object to create a new sprite manager.
  11267. * @param parsedManager The JSON object to parse
  11268. * @param scene The scene to create the sprite managerin
  11269. * @param rootUrl The root url to use to load external dependencies like texture
  11270. * @returns the new sprite manager
  11271. */
  11272. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11273. /**
  11274. * Creates a sprite manager from a snippet saved in a remote file
  11275. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11276. * @param url defines the url to load from
  11277. * @param scene defines the hosting scene
  11278. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11279. * @returns a promise that will resolve to the new sprite manager
  11280. */
  11281. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11282. /**
  11283. * Creates a sprite manager from a snippet saved by the sprite editor
  11284. * @param snippetId defines the snippet to load
  11285. * @param scene defines the hosting scene
  11286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11287. * @returns a promise that will resolve to the new sprite manager
  11288. */
  11289. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11290. }
  11291. }
  11292. declare module "babylonjs/Misc/gradients" {
  11293. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11294. /** Interface used by value gradients (color, factor, ...) */
  11295. export interface IValueGradient {
  11296. /**
  11297. * Gets or sets the gradient value (between 0 and 1)
  11298. */
  11299. gradient: number;
  11300. }
  11301. /** Class used to store color4 gradient */
  11302. export class ColorGradient implements IValueGradient {
  11303. /**
  11304. * Gets or sets the gradient value (between 0 and 1)
  11305. */
  11306. gradient: number;
  11307. /**
  11308. * Gets or sets first associated color
  11309. */
  11310. color1: Color4;
  11311. /**
  11312. * Gets or sets second associated color
  11313. */
  11314. color2?: Color4 | undefined;
  11315. /**
  11316. * Creates a new color4 gradient
  11317. * @param gradient gets or sets the gradient value (between 0 and 1)
  11318. * @param color1 gets or sets first associated color
  11319. * @param color2 gets or sets first second color
  11320. */
  11321. constructor(
  11322. /**
  11323. * Gets or sets the gradient value (between 0 and 1)
  11324. */
  11325. gradient: number,
  11326. /**
  11327. * Gets or sets first associated color
  11328. */
  11329. color1: Color4,
  11330. /**
  11331. * Gets or sets second associated color
  11332. */
  11333. color2?: Color4 | undefined);
  11334. /**
  11335. * Will get a color picked randomly between color1 and color2.
  11336. * If color2 is undefined then color1 will be used
  11337. * @param result defines the target Color4 to store the result in
  11338. */
  11339. getColorToRef(result: Color4): void;
  11340. }
  11341. /** Class used to store color 3 gradient */
  11342. export class Color3Gradient implements IValueGradient {
  11343. /**
  11344. * Gets or sets the gradient value (between 0 and 1)
  11345. */
  11346. gradient: number;
  11347. /**
  11348. * Gets or sets the associated color
  11349. */
  11350. color: Color3;
  11351. /**
  11352. * Creates a new color3 gradient
  11353. * @param gradient gets or sets the gradient value (between 0 and 1)
  11354. * @param color gets or sets associated color
  11355. */
  11356. constructor(
  11357. /**
  11358. * Gets or sets the gradient value (between 0 and 1)
  11359. */
  11360. gradient: number,
  11361. /**
  11362. * Gets or sets the associated color
  11363. */
  11364. color: Color3);
  11365. }
  11366. /** Class used to store factor gradient */
  11367. export class FactorGradient implements IValueGradient {
  11368. /**
  11369. * Gets or sets the gradient value (between 0 and 1)
  11370. */
  11371. gradient: number;
  11372. /**
  11373. * Gets or sets first associated factor
  11374. */
  11375. factor1: number;
  11376. /**
  11377. * Gets or sets second associated factor
  11378. */
  11379. factor2?: number | undefined;
  11380. /**
  11381. * Creates a new factor gradient
  11382. * @param gradient gets or sets the gradient value (between 0 and 1)
  11383. * @param factor1 gets or sets first associated factor
  11384. * @param factor2 gets or sets second associated factor
  11385. */
  11386. constructor(
  11387. /**
  11388. * Gets or sets the gradient value (between 0 and 1)
  11389. */
  11390. gradient: number,
  11391. /**
  11392. * Gets or sets first associated factor
  11393. */
  11394. factor1: number,
  11395. /**
  11396. * Gets or sets second associated factor
  11397. */
  11398. factor2?: number | undefined);
  11399. /**
  11400. * Will get a number picked randomly between factor1 and factor2.
  11401. * If factor2 is undefined then factor1 will be used
  11402. * @returns the picked number
  11403. */
  11404. getFactor(): number;
  11405. }
  11406. /**
  11407. * Helper used to simplify some generic gradient tasks
  11408. */
  11409. export class GradientHelper {
  11410. /**
  11411. * Gets the current gradient from an array of IValueGradient
  11412. * @param ratio defines the current ratio to get
  11413. * @param gradients defines the array of IValueGradient
  11414. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11415. */
  11416. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11417. }
  11418. }
  11419. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  11420. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11421. import { Nullable } from "babylonjs/types";
  11422. module "babylonjs/Engines/thinEngine" {
  11423. interface ThinEngine {
  11424. /**
  11425. * Creates a dynamic texture
  11426. * @param width defines the width of the texture
  11427. * @param height defines the height of the texture
  11428. * @param generateMipMaps defines if the engine should generate the mip levels
  11429. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11430. * @returns the dynamic texture inside an InternalTexture
  11431. */
  11432. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11433. /**
  11434. * Update the content of a dynamic texture
  11435. * @param texture defines the texture to update
  11436. * @param canvas defines the canvas containing the source
  11437. * @param invertY defines if data must be stored with Y axis inverted
  11438. * @param premulAlpha defines if alpha is stored as premultiplied
  11439. * @param format defines the format of the data
  11440. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11441. */
  11442. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11443. }
  11444. }
  11445. }
  11446. declare module "babylonjs/Misc/canvasGenerator" {
  11447. /**
  11448. * Helper class used to generate a canvas to manipulate images
  11449. */
  11450. export class CanvasGenerator {
  11451. /**
  11452. * Create a new canvas (or offscreen canvas depending on the context)
  11453. * @param width defines the expected width
  11454. * @param height defines the expected height
  11455. * @return a new canvas or offscreen canvas
  11456. */
  11457. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11458. }
  11459. }
  11460. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  11461. import { Scene } from "babylonjs/scene";
  11462. import { Texture } from "babylonjs/Materials/Textures/texture";
  11463. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  11464. /**
  11465. * A class extending Texture allowing drawing on a texture
  11466. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11467. */
  11468. export class DynamicTexture extends Texture {
  11469. private _generateMipMaps;
  11470. private _canvas;
  11471. private _context;
  11472. /**
  11473. * Creates a DynamicTexture
  11474. * @param name defines the name of the texture
  11475. * @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
  11476. * @param scene defines the scene where you want the texture
  11477. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11478. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11479. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11480. */
  11481. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11482. /**
  11483. * Get the current class name of the texture useful for serialization or dynamic coding.
  11484. * @returns "DynamicTexture"
  11485. */
  11486. getClassName(): string;
  11487. /**
  11488. * Gets the current state of canRescale
  11489. */
  11490. get canRescale(): boolean;
  11491. private _recreate;
  11492. /**
  11493. * Scales the texture
  11494. * @param ratio the scale factor to apply to both width and height
  11495. */
  11496. scale(ratio: number): void;
  11497. /**
  11498. * Resizes the texture
  11499. * @param width the new width
  11500. * @param height the new height
  11501. */
  11502. scaleTo(width: number, height: number): void;
  11503. /**
  11504. * Gets the context of the canvas used by the texture
  11505. * @returns the canvas context of the dynamic texture
  11506. */
  11507. getContext(): CanvasRenderingContext2D;
  11508. /**
  11509. * Clears the texture
  11510. */
  11511. clear(): void;
  11512. /**
  11513. * Updates the texture
  11514. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11515. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11516. */
  11517. update(invertY?: boolean, premulAlpha?: boolean): void;
  11518. /**
  11519. * Draws text onto the texture
  11520. * @param text defines the text to be drawn
  11521. * @param x defines the placement of the text from the left
  11522. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11523. * @param font defines the font to be used with font-style, font-size, font-name
  11524. * @param color defines the color used for the text
  11525. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11526. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11527. * @param update defines whether texture is immediately update (default is true)
  11528. */
  11529. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11530. /**
  11531. * Clones the texture
  11532. * @returns the clone of the texture.
  11533. */
  11534. clone(): DynamicTexture;
  11535. /**
  11536. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11537. * @returns a serialized dynamic texture object
  11538. */
  11539. serialize(): any;
  11540. /** @hidden */
  11541. _rebuild(): void;
  11542. }
  11543. }
  11544. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11545. import { Nullable } from "babylonjs/types";
  11546. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11547. import { Scene } from "babylonjs/scene";
  11548. module "babylonjs/Engines/thinEngine" {
  11549. interface ThinEngine {
  11550. /**
  11551. * Creates a raw texture
  11552. * @param data defines the data to store in the texture
  11553. * @param width defines the width of the texture
  11554. * @param height defines the height of the texture
  11555. * @param format defines the format of the data
  11556. * @param generateMipMaps defines if the engine should generate the mip levels
  11557. * @param invertY defines if data must be stored with Y axis inverted
  11558. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11559. * @param compression defines the compression used (null by default)
  11560. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11561. * @returns the raw texture inside an InternalTexture
  11562. */
  11563. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11564. /**
  11565. * Update a raw texture
  11566. * @param texture defines the texture to update
  11567. * @param data defines the data to store in the texture
  11568. * @param format defines the format of the data
  11569. * @param invertY defines if data must be stored with Y axis inverted
  11570. */
  11571. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11572. /**
  11573. * Update a raw texture
  11574. * @param texture defines the texture to update
  11575. * @param data defines the data to store in the texture
  11576. * @param format defines the format of the data
  11577. * @param invertY defines if data must be stored with Y axis inverted
  11578. * @param compression defines the compression used (null by default)
  11579. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11580. */
  11581. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11582. /**
  11583. * Creates a new raw cube texture
  11584. * @param data defines the array of data to use to create each face
  11585. * @param size defines the size of the textures
  11586. * @param format defines the format of the data
  11587. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11588. * @param generateMipMaps defines if the engine should generate the mip levels
  11589. * @param invertY defines if data must be stored with Y axis inverted
  11590. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11591. * @param compression defines the compression used (null by default)
  11592. * @returns the cube texture as an InternalTexture
  11593. */
  11594. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11595. /**
  11596. * Update a raw cube texture
  11597. * @param texture defines the texture to udpdate
  11598. * @param data defines the data to store
  11599. * @param format defines the data format
  11600. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. */
  11603. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11604. /**
  11605. * Update a raw cube texture
  11606. * @param texture defines the texture to udpdate
  11607. * @param data defines the data to store
  11608. * @param format defines the data format
  11609. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11610. * @param invertY defines if data must be stored with Y axis inverted
  11611. * @param compression defines the compression used (null by default)
  11612. */
  11613. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11614. /**
  11615. * Update a raw cube texture
  11616. * @param texture defines the texture to udpdate
  11617. * @param data defines the data to store
  11618. * @param format defines the data format
  11619. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11620. * @param invertY defines if data must be stored with Y axis inverted
  11621. * @param compression defines the compression used (null by default)
  11622. * @param level defines which level of the texture to update
  11623. */
  11624. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11625. /**
  11626. * Creates a new raw cube texture from a specified url
  11627. * @param url defines the url where the data is located
  11628. * @param scene defines the current scene
  11629. * @param size defines the size of the textures
  11630. * @param format defines the format of the data
  11631. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11632. * @param noMipmap defines if the engine should avoid generating the mip levels
  11633. * @param callback defines a callback used to extract texture data from loaded data
  11634. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11635. * @param onLoad defines a callback called when texture is loaded
  11636. * @param onError defines a callback called if there is an error
  11637. * @returns the cube texture as an InternalTexture
  11638. */
  11639. 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;
  11640. /**
  11641. * Creates a new raw cube texture from a specified url
  11642. * @param url defines the url where the data is located
  11643. * @param scene defines the current scene
  11644. * @param size defines the size of the textures
  11645. * @param format defines the format of the data
  11646. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11647. * @param noMipmap defines if the engine should avoid generating the mip levels
  11648. * @param callback defines a callback used to extract texture data from loaded data
  11649. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11650. * @param onLoad defines a callback called when texture is loaded
  11651. * @param onError defines a callback called if there is an error
  11652. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11653. * @param invertY defines if data must be stored with Y axis inverted
  11654. * @returns the cube texture as an InternalTexture
  11655. */
  11656. 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;
  11657. /**
  11658. * Creates a new raw 3D texture
  11659. * @param data defines the data used to create the texture
  11660. * @param width defines the width of the texture
  11661. * @param height defines the height of the texture
  11662. * @param depth defines the depth of the texture
  11663. * @param format defines the format of the texture
  11664. * @param generateMipMaps defines if the engine must generate mip levels
  11665. * @param invertY defines if data must be stored with Y axis inverted
  11666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11667. * @param compression defines the compressed used (can be null)
  11668. * @param textureType defines the compressed used (can be null)
  11669. * @returns a new raw 3D texture (stored in an InternalTexture)
  11670. */
  11671. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11672. /**
  11673. * Update a raw 3D 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. */
  11679. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11680. /**
  11681. * Update a raw 3D texture
  11682. * @param texture defines the texture to update
  11683. * @param data defines the data to store
  11684. * @param format defines the data format
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. * @param compression defines the used compression (can be null)
  11687. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11688. */
  11689. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11690. /**
  11691. * Creates a new raw 2D array texture
  11692. * @param data defines the data used to create the texture
  11693. * @param width defines the width of the texture
  11694. * @param height defines the height of the texture
  11695. * @param depth defines the number of layers of the texture
  11696. * @param format defines the format of the texture
  11697. * @param generateMipMaps defines if the engine must generate mip levels
  11698. * @param invertY defines if data must be stored with Y axis inverted
  11699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11700. * @param compression defines the compressed used (can be null)
  11701. * @param textureType defines the compressed used (can be null)
  11702. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11703. */
  11704. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11705. /**
  11706. * Update a raw 2D array texture
  11707. * @param texture defines the texture to update
  11708. * @param data defines the data to store
  11709. * @param format defines the data format
  11710. * @param invertY defines if data must be stored with Y axis inverted
  11711. */
  11712. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11713. /**
  11714. * Update a raw 2D array texture
  11715. * @param texture defines the texture to update
  11716. * @param data defines the data to store
  11717. * @param format defines the data format
  11718. * @param invertY defines if data must be stored with Y axis inverted
  11719. * @param compression defines the used compression (can be null)
  11720. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11721. */
  11722. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11723. }
  11724. }
  11725. }
  11726. declare module "babylonjs/Materials/Textures/rawTexture" {
  11727. import { Scene } from "babylonjs/scene";
  11728. import { Texture } from "babylonjs/Materials/Textures/texture";
  11729. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11730. /**
  11731. * Raw texture can help creating a texture directly from an array of data.
  11732. * This can be super useful if you either get the data from an uncompressed source or
  11733. * if you wish to create your texture pixel by pixel.
  11734. */
  11735. export class RawTexture extends Texture {
  11736. /**
  11737. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11738. */
  11739. format: number;
  11740. /**
  11741. * Instantiates a new RawTexture.
  11742. * Raw texture can help creating a texture directly from an array of data.
  11743. * This can be super useful if you either get the data from an uncompressed source or
  11744. * if you wish to create your texture pixel by pixel.
  11745. * @param data define the array of data to use to create the texture
  11746. * @param width define the width of the texture
  11747. * @param height define the height of the texture
  11748. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11749. * @param scene define the scene the texture belongs to
  11750. * @param generateMipMaps define whether mip maps should be generated or not
  11751. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11752. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11753. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11754. */
  11755. constructor(data: ArrayBufferView, width: number, height: number,
  11756. /**
  11757. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11758. */
  11759. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11760. /**
  11761. * Updates the texture underlying data.
  11762. * @param data Define the new data of the texture
  11763. */
  11764. update(data: ArrayBufferView): void;
  11765. /**
  11766. * Creates a luminance texture from some data.
  11767. * @param data Define the texture data
  11768. * @param width Define the width of the texture
  11769. * @param height Define the height of the texture
  11770. * @param scene Define the scene the texture belongs to
  11771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11774. * @returns the luminance texture
  11775. */
  11776. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11777. /**
  11778. * Creates a luminance alpha texture from some data.
  11779. * @param data Define the texture data
  11780. * @param width Define the width of the texture
  11781. * @param height Define the height of the texture
  11782. * @param scene Define the scene the texture belongs to
  11783. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11784. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11785. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11786. * @returns the luminance alpha texture
  11787. */
  11788. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11789. /**
  11790. * Creates an alpha texture from some data.
  11791. * @param data Define the texture data
  11792. * @param width Define the width of the texture
  11793. * @param height Define the height of the texture
  11794. * @param scene Define the scene the texture belongs to
  11795. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11796. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11797. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11798. * @returns the alpha texture
  11799. */
  11800. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11801. /**
  11802. * Creates a RGB texture from some data.
  11803. * @param data Define the texture data
  11804. * @param width Define the width of the texture
  11805. * @param height Define the height of the texture
  11806. * @param scene Define the scene the texture belongs to
  11807. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11808. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11809. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11810. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11811. * @returns the RGB alpha texture
  11812. */
  11813. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11814. /**
  11815. * Creates a RGBA texture from some data.
  11816. * @param data Define the texture data
  11817. * @param width Define the width of the texture
  11818. * @param height Define the height of the texture
  11819. * @param scene Define the scene the texture belongs to
  11820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11823. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11824. * @returns the RGBA texture
  11825. */
  11826. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11827. /**
  11828. * Creates a R texture from some data.
  11829. * @param data Define the texture data
  11830. * @param width Define the width of the texture
  11831. * @param height Define the height of the texture
  11832. * @param scene Define the scene the texture belongs to
  11833. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11834. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11835. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11836. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11837. * @returns the R texture
  11838. */
  11839. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11840. }
  11841. }
  11842. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11843. import { Scene } from "babylonjs/scene";
  11844. import { ISceneComponent } from "babylonjs/sceneComponent";
  11845. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11846. module "babylonjs/abstractScene" {
  11847. interface AbstractScene {
  11848. /**
  11849. * The list of procedural textures added to the scene
  11850. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11851. */
  11852. proceduralTextures: Array<ProceduralTexture>;
  11853. }
  11854. }
  11855. /**
  11856. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11857. * in a given scene.
  11858. */
  11859. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11860. /**
  11861. * The component name helpfull to identify the component in the list of scene components.
  11862. */
  11863. readonly name: string;
  11864. /**
  11865. * The scene the component belongs to.
  11866. */
  11867. scene: Scene;
  11868. /**
  11869. * Creates a new instance of the component for the given scene
  11870. * @param scene Defines the scene to register the component in
  11871. */
  11872. constructor(scene: Scene);
  11873. /**
  11874. * Registers the component in a given scene
  11875. */
  11876. register(): void;
  11877. /**
  11878. * Rebuilds the elements related to this component in case of
  11879. * context lost for instance.
  11880. */
  11881. rebuild(): void;
  11882. /**
  11883. * Disposes the component and the associated ressources.
  11884. */
  11885. dispose(): void;
  11886. private _beforeClear;
  11887. }
  11888. }
  11889. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11890. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11891. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11892. module "babylonjs/Engines/thinEngine" {
  11893. interface ThinEngine {
  11894. /**
  11895. * Creates a new render target cube texture
  11896. * @param size defines the size of the texture
  11897. * @param options defines the options used to create the texture
  11898. * @returns a new render target cube texture stored in an InternalTexture
  11899. */
  11900. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11901. }
  11902. }
  11903. }
  11904. declare module "babylonjs/Shaders/procedural.vertex" {
  11905. /** @hidden */
  11906. export var proceduralVertexShader: {
  11907. name: string;
  11908. shader: string;
  11909. };
  11910. }
  11911. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11912. import { Observable } from "babylonjs/Misc/observable";
  11913. import { Nullable } from "babylonjs/types";
  11914. import { Scene } from "babylonjs/scene";
  11915. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11916. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11917. import { Effect } from "babylonjs/Materials/effect";
  11918. import { Texture } from "babylonjs/Materials/Textures/texture";
  11919. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11920. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11921. import "babylonjs/Shaders/procedural.vertex";
  11922. /**
  11923. * 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.
  11924. * This is the base class of any Procedural texture and contains most of the shareable code.
  11925. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11926. */
  11927. export class ProceduralTexture extends Texture {
  11928. isCube: boolean;
  11929. /**
  11930. * Define if the texture is enabled or not (disabled texture will not render)
  11931. */
  11932. isEnabled: boolean;
  11933. /**
  11934. * Define if the texture must be cleared before rendering (default is true)
  11935. */
  11936. autoClear: boolean;
  11937. /**
  11938. * Callback called when the texture is generated
  11939. */
  11940. onGenerated: () => void;
  11941. /**
  11942. * Event raised when the texture is generated
  11943. */
  11944. onGeneratedObservable: Observable<ProceduralTexture>;
  11945. /** @hidden */
  11946. _generateMipMaps: boolean;
  11947. /** @hidden **/
  11948. _effect: Effect;
  11949. /** @hidden */
  11950. _textures: {
  11951. [key: string]: Texture;
  11952. };
  11953. /** @hidden */
  11954. protected _fallbackTexture: Nullable<Texture>;
  11955. private _size;
  11956. private _currentRefreshId;
  11957. private _frameId;
  11958. private _refreshRate;
  11959. private _vertexBuffers;
  11960. private _indexBuffer;
  11961. private _uniforms;
  11962. private _samplers;
  11963. private _fragment;
  11964. private _floats;
  11965. private _ints;
  11966. private _floatsArrays;
  11967. private _colors3;
  11968. private _colors4;
  11969. private _vectors2;
  11970. private _vectors3;
  11971. private _matrices;
  11972. private _fallbackTextureUsed;
  11973. private _fullEngine;
  11974. private _cachedDefines;
  11975. private _contentUpdateId;
  11976. private _contentData;
  11977. /**
  11978. * Instantiates a new procedural texture.
  11979. * 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.
  11980. * This is the base class of any Procedural texture and contains most of the shareable code.
  11981. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11982. * @param name Define the name of the texture
  11983. * @param size Define the size of the texture to create
  11984. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11985. * @param scene Define the scene the texture belongs to
  11986. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11987. * @param generateMipMaps Define if the texture should creates mip maps or not
  11988. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11989. */
  11990. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11991. /**
  11992. * The effect that is created when initializing the post process.
  11993. * @returns The created effect corresponding the the postprocess.
  11994. */
  11995. getEffect(): Effect;
  11996. /**
  11997. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11998. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11999. */
  12000. getContent(): Nullable<ArrayBufferView>;
  12001. private _createIndexBuffer;
  12002. /** @hidden */
  12003. _rebuild(): void;
  12004. /**
  12005. * Resets the texture in order to recreate its associated resources.
  12006. * This can be called in case of context loss
  12007. */
  12008. reset(): void;
  12009. protected _getDefines(): string;
  12010. /**
  12011. * Is the texture ready to be used ? (rendered at least once)
  12012. * @returns true if ready, otherwise, false.
  12013. */
  12014. isReady(): boolean;
  12015. /**
  12016. * Resets the refresh counter of the texture and start bak from scratch.
  12017. * Could be useful to regenerate the texture if it is setup to render only once.
  12018. */
  12019. resetRefreshCounter(): void;
  12020. /**
  12021. * Set the fragment shader to use in order to render the texture.
  12022. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12023. */
  12024. setFragment(fragment: any): void;
  12025. /**
  12026. * Define the refresh rate of the texture or the rendering frequency.
  12027. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12028. */
  12029. get refreshRate(): number;
  12030. set refreshRate(value: number);
  12031. /** @hidden */
  12032. _shouldRender(): boolean;
  12033. /**
  12034. * Get the size the texture is rendering at.
  12035. * @returns the size (texture is always squared)
  12036. */
  12037. getRenderSize(): number;
  12038. /**
  12039. * Resize the texture to new value.
  12040. * @param size Define the new size the texture should have
  12041. * @param generateMipMaps Define whether the new texture should create mip maps
  12042. */
  12043. resize(size: number, generateMipMaps: boolean): void;
  12044. private _checkUniform;
  12045. /**
  12046. * Set a texture in the shader program used to render.
  12047. * @param name Define the name of the uniform samplers as defined in the shader
  12048. * @param texture Define the texture to bind to this sampler
  12049. * @return the texture itself allowing "fluent" like uniform updates
  12050. */
  12051. setTexture(name: string, texture: Texture): ProceduralTexture;
  12052. /**
  12053. * Set a float in the shader.
  12054. * @param name Define the name of the uniform as defined in the shader
  12055. * @param value Define the value to give to the uniform
  12056. * @return the texture itself allowing "fluent" like uniform updates
  12057. */
  12058. setFloat(name: string, value: number): ProceduralTexture;
  12059. /**
  12060. * Set a int in the shader.
  12061. * @param name Define the name of the uniform as defined in the shader
  12062. * @param value Define the value to give to the uniform
  12063. * @return the texture itself allowing "fluent" like uniform updates
  12064. */
  12065. setInt(name: string, value: number): ProceduralTexture;
  12066. /**
  12067. * Set an array of floats in the shader.
  12068. * @param name Define the name of the uniform as defined in the shader
  12069. * @param value Define the value to give to the uniform
  12070. * @return the texture itself allowing "fluent" like uniform updates
  12071. */
  12072. setFloats(name: string, value: number[]): ProceduralTexture;
  12073. /**
  12074. * Set a vec3 in the shader from a Color3.
  12075. * @param name Define the name of the uniform as defined in the shader
  12076. * @param value Define the value to give to the uniform
  12077. * @return the texture itself allowing "fluent" like uniform updates
  12078. */
  12079. setColor3(name: string, value: Color3): ProceduralTexture;
  12080. /**
  12081. * Set a vec4 in the shader from a Color4.
  12082. * @param name Define the name of the uniform as defined in the shader
  12083. * @param value Define the value to give to the uniform
  12084. * @return the texture itself allowing "fluent" like uniform updates
  12085. */
  12086. setColor4(name: string, value: Color4): ProceduralTexture;
  12087. /**
  12088. * Set a vec2 in the shader from a Vector2.
  12089. * @param name Define the name of the uniform as defined in the shader
  12090. * @param value Define the value to give to the uniform
  12091. * @return the texture itself allowing "fluent" like uniform updates
  12092. */
  12093. setVector2(name: string, value: Vector2): ProceduralTexture;
  12094. /**
  12095. * Set a vec3 in the shader from a Vector3.
  12096. * @param name Define the name of the uniform as defined in the shader
  12097. * @param value Define the value to give to the uniform
  12098. * @return the texture itself allowing "fluent" like uniform updates
  12099. */
  12100. setVector3(name: string, value: Vector3): ProceduralTexture;
  12101. /**
  12102. * Set a mat4 in the shader from a MAtrix.
  12103. * @param name Define the name of the uniform as defined in the shader
  12104. * @param value Define the value to give to the uniform
  12105. * @return the texture itself allowing "fluent" like uniform updates
  12106. */
  12107. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12108. /**
  12109. * Render the texture to its associated render target.
  12110. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12111. */
  12112. render(useCameraPostProcess?: boolean): void;
  12113. /**
  12114. * Clone the texture.
  12115. * @returns the cloned texture
  12116. */
  12117. clone(): ProceduralTexture;
  12118. /**
  12119. * Dispose the texture and release its asoociated resources.
  12120. */
  12121. dispose(): void;
  12122. }
  12123. }
  12124. declare module "babylonjs/Particles/baseParticleSystem" {
  12125. import { Nullable } from "babylonjs/types";
  12126. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12128. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12129. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12130. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12131. import { Scene } from "babylonjs/scene";
  12132. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12133. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12134. import { Texture } from "babylonjs/Materials/Textures/texture";
  12135. import { Color4 } from "babylonjs/Maths/math.color";
  12136. import { Animation } from "babylonjs/Animations/animation";
  12137. /**
  12138. * This represents the base class for particle system in Babylon.
  12139. * 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.
  12140. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12141. * @example https://doc.babylonjs.com/babylon101/particles
  12142. */
  12143. export class BaseParticleSystem {
  12144. /**
  12145. * Source color is added to the destination color without alpha affecting the result
  12146. */
  12147. static BLENDMODE_ONEONE: number;
  12148. /**
  12149. * Blend current color and particle color using particle’s alpha
  12150. */
  12151. static BLENDMODE_STANDARD: number;
  12152. /**
  12153. * Add current color and particle color multiplied by particle’s alpha
  12154. */
  12155. static BLENDMODE_ADD: number;
  12156. /**
  12157. * Multiply current color with particle color
  12158. */
  12159. static BLENDMODE_MULTIPLY: number;
  12160. /**
  12161. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12162. */
  12163. static BLENDMODE_MULTIPLYADD: number;
  12164. /**
  12165. * List of animations used by the particle system.
  12166. */
  12167. animations: Animation[];
  12168. /**
  12169. * Gets or sets the unique id of the particle system
  12170. */
  12171. uniqueId: number;
  12172. /**
  12173. * The id of the Particle system.
  12174. */
  12175. id: string;
  12176. /**
  12177. * The friendly name of the Particle system.
  12178. */
  12179. name: string;
  12180. /**
  12181. * Snippet ID if the particle system was created from the snippet server
  12182. */
  12183. snippetId: string;
  12184. /**
  12185. * The rendering group used by the Particle system to chose when to render.
  12186. */
  12187. renderingGroupId: number;
  12188. /**
  12189. * The emitter represents the Mesh or position we are attaching the particle system to.
  12190. */
  12191. emitter: Nullable<AbstractMesh | Vector3>;
  12192. /**
  12193. * The maximum number of particles to emit per frame
  12194. */
  12195. emitRate: number;
  12196. /**
  12197. * If you want to launch only a few particles at once, that can be done, as well.
  12198. */
  12199. manualEmitCount: number;
  12200. /**
  12201. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12202. */
  12203. updateSpeed: number;
  12204. /**
  12205. * The amount of time the particle system is running (depends of the overall update speed).
  12206. */
  12207. targetStopDuration: number;
  12208. /**
  12209. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12210. */
  12211. disposeOnStop: boolean;
  12212. /**
  12213. * Minimum power of emitting particles.
  12214. */
  12215. minEmitPower: number;
  12216. /**
  12217. * Maximum power of emitting particles.
  12218. */
  12219. maxEmitPower: number;
  12220. /**
  12221. * Minimum life time of emitting particles.
  12222. */
  12223. minLifeTime: number;
  12224. /**
  12225. * Maximum life time of emitting particles.
  12226. */
  12227. maxLifeTime: number;
  12228. /**
  12229. * Minimum Size of emitting particles.
  12230. */
  12231. minSize: number;
  12232. /**
  12233. * Maximum Size of emitting particles.
  12234. */
  12235. maxSize: number;
  12236. /**
  12237. * Minimum scale of emitting particles on X axis.
  12238. */
  12239. minScaleX: number;
  12240. /**
  12241. * Maximum scale of emitting particles on X axis.
  12242. */
  12243. maxScaleX: number;
  12244. /**
  12245. * Minimum scale of emitting particles on Y axis.
  12246. */
  12247. minScaleY: number;
  12248. /**
  12249. * Maximum scale of emitting particles on Y axis.
  12250. */
  12251. maxScaleY: number;
  12252. /**
  12253. * Gets or sets the minimal initial rotation in radians.
  12254. */
  12255. minInitialRotation: number;
  12256. /**
  12257. * Gets or sets the maximal initial rotation in radians.
  12258. */
  12259. maxInitialRotation: number;
  12260. /**
  12261. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12262. */
  12263. minAngularSpeed: number;
  12264. /**
  12265. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12266. */
  12267. maxAngularSpeed: number;
  12268. /**
  12269. * The texture used to render each particle. (this can be a spritesheet)
  12270. */
  12271. particleTexture: Nullable<Texture>;
  12272. /**
  12273. * The layer mask we are rendering the particles through.
  12274. */
  12275. layerMask: number;
  12276. /**
  12277. * This can help using your own shader to render the particle system.
  12278. * The according effect will be created
  12279. */
  12280. customShader: any;
  12281. /**
  12282. * By default particle system starts as soon as they are created. This prevents the
  12283. * automatic start to happen and let you decide when to start emitting particles.
  12284. */
  12285. preventAutoStart: boolean;
  12286. private _noiseTexture;
  12287. /**
  12288. * Gets or sets a texture used to add random noise to particle positions
  12289. */
  12290. get noiseTexture(): Nullable<ProceduralTexture>;
  12291. set noiseTexture(value: Nullable<ProceduralTexture>);
  12292. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12293. noiseStrength: Vector3;
  12294. /**
  12295. * Callback triggered when the particle animation is ending.
  12296. */
  12297. onAnimationEnd: Nullable<() => void>;
  12298. /**
  12299. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12300. */
  12301. blendMode: number;
  12302. /**
  12303. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12304. * to override the particles.
  12305. */
  12306. forceDepthWrite: boolean;
  12307. /** 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 */
  12308. preWarmCycles: number;
  12309. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12310. preWarmStepOffset: number;
  12311. /**
  12312. * 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)
  12313. */
  12314. spriteCellChangeSpeed: number;
  12315. /**
  12316. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12317. */
  12318. startSpriteCellID: number;
  12319. /**
  12320. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12321. */
  12322. endSpriteCellID: number;
  12323. /**
  12324. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12325. */
  12326. spriteCellWidth: number;
  12327. /**
  12328. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12329. */
  12330. spriteCellHeight: number;
  12331. /**
  12332. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12333. */
  12334. spriteRandomStartCell: boolean;
  12335. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12336. translationPivot: Vector2;
  12337. /** @hidden */
  12338. protected _isAnimationSheetEnabled: boolean;
  12339. /**
  12340. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12341. */
  12342. beginAnimationOnStart: boolean;
  12343. /**
  12344. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12345. */
  12346. beginAnimationFrom: number;
  12347. /**
  12348. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12349. */
  12350. beginAnimationTo: number;
  12351. /**
  12352. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12353. */
  12354. beginAnimationLoop: boolean;
  12355. /**
  12356. * Gets or sets a world offset applied to all particles
  12357. */
  12358. worldOffset: Vector3;
  12359. /**
  12360. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12361. */
  12362. get isAnimationSheetEnabled(): boolean;
  12363. set isAnimationSheetEnabled(value: boolean);
  12364. /**
  12365. * Get hosting scene
  12366. * @returns the scene
  12367. */
  12368. getScene(): Scene;
  12369. /**
  12370. * You can use gravity if you want to give an orientation to your particles.
  12371. */
  12372. gravity: Vector3;
  12373. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12374. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12375. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12376. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12377. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12378. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12379. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12380. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12381. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12382. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12383. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12384. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12385. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12386. /**
  12387. * Defines the delay in milliseconds before starting the system (0 by default)
  12388. */
  12389. startDelay: number;
  12390. /**
  12391. * Gets the current list of drag gradients.
  12392. * You must use addDragGradient and removeDragGradient to udpate this list
  12393. * @returns the list of drag gradients
  12394. */
  12395. getDragGradients(): Nullable<Array<FactorGradient>>;
  12396. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12397. limitVelocityDamping: number;
  12398. /**
  12399. * Gets the current list of limit velocity gradients.
  12400. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12401. * @returns the list of limit velocity gradients
  12402. */
  12403. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12404. /**
  12405. * Gets the current list of color gradients.
  12406. * You must use addColorGradient and removeColorGradient to udpate this list
  12407. * @returns the list of color gradients
  12408. */
  12409. getColorGradients(): Nullable<Array<ColorGradient>>;
  12410. /**
  12411. * Gets the current list of size gradients.
  12412. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12413. * @returns the list of size gradients
  12414. */
  12415. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12416. /**
  12417. * Gets the current list of color remap gradients.
  12418. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12419. * @returns the list of color remap gradients
  12420. */
  12421. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12422. /**
  12423. * Gets the current list of alpha remap gradients.
  12424. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12425. * @returns the list of alpha remap gradients
  12426. */
  12427. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12428. /**
  12429. * Gets the current list of life time gradients.
  12430. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12431. * @returns the list of life time gradients
  12432. */
  12433. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12434. /**
  12435. * Gets the current list of angular speed gradients.
  12436. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12437. * @returns the list of angular speed gradients
  12438. */
  12439. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12440. /**
  12441. * Gets the current list of velocity gradients.
  12442. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12443. * @returns the list of velocity gradients
  12444. */
  12445. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12446. /**
  12447. * Gets the current list of start size gradients.
  12448. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12449. * @returns the list of start size gradients
  12450. */
  12451. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12452. /**
  12453. * Gets the current list of emit rate gradients.
  12454. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12455. * @returns the list of emit rate gradients
  12456. */
  12457. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12458. /**
  12459. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12460. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12461. */
  12462. get direction1(): Vector3;
  12463. set direction1(value: Vector3);
  12464. /**
  12465. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12466. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12467. */
  12468. get direction2(): Vector3;
  12469. set direction2(value: Vector3);
  12470. /**
  12471. * 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.
  12472. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12473. */
  12474. get minEmitBox(): Vector3;
  12475. set minEmitBox(value: Vector3);
  12476. /**
  12477. * 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.
  12478. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12479. */
  12480. get maxEmitBox(): Vector3;
  12481. set maxEmitBox(value: Vector3);
  12482. /**
  12483. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12484. */
  12485. color1: Color4;
  12486. /**
  12487. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12488. */
  12489. color2: Color4;
  12490. /**
  12491. * Color the particle will have at the end of its lifetime
  12492. */
  12493. colorDead: Color4;
  12494. /**
  12495. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12496. */
  12497. textureMask: Color4;
  12498. /**
  12499. * The particle emitter type defines the emitter used by the particle system.
  12500. * It can be for example box, sphere, or cone...
  12501. */
  12502. particleEmitterType: IParticleEmitterType;
  12503. /** @hidden */
  12504. _isSubEmitter: boolean;
  12505. /**
  12506. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12507. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12508. */
  12509. billboardMode: number;
  12510. protected _isBillboardBased: boolean;
  12511. /**
  12512. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12513. */
  12514. get isBillboardBased(): boolean;
  12515. set isBillboardBased(value: boolean);
  12516. /**
  12517. * The scene the particle system belongs to.
  12518. */
  12519. protected _scene: Scene;
  12520. /**
  12521. * Local cache of defines for image processing.
  12522. */
  12523. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12524. /**
  12525. * Default configuration related to image processing available in the standard Material.
  12526. */
  12527. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12528. /**
  12529. * Gets the image processing configuration used either in this material.
  12530. */
  12531. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12532. /**
  12533. * Sets the Default image processing configuration used either in the this material.
  12534. *
  12535. * If sets to null, the scene one is in use.
  12536. */
  12537. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12538. /**
  12539. * Attaches a new image processing configuration to the Standard Material.
  12540. * @param configuration
  12541. */
  12542. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12543. /** @hidden */
  12544. protected _reset(): void;
  12545. /** @hidden */
  12546. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12547. /**
  12548. * Instantiates a particle system.
  12549. * 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.
  12550. * @param name The name of the particle system
  12551. */
  12552. constructor(name: string);
  12553. /**
  12554. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12557. * @returns the emitter
  12558. */
  12559. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12560. /**
  12561. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12562. * @param radius The radius of the hemisphere to emit from
  12563. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12564. * @returns the emitter
  12565. */
  12566. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12567. /**
  12568. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12569. * @param radius The radius of the sphere to emit from
  12570. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12571. * @returns the emitter
  12572. */
  12573. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12574. /**
  12575. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12576. * @param radius The radius of the sphere to emit from
  12577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12579. * @returns the emitter
  12580. */
  12581. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12582. /**
  12583. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12584. * @param radius The radius of the emission cylinder
  12585. * @param height The height of the emission cylinder
  12586. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12587. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12588. * @returns the emitter
  12589. */
  12590. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12591. /**
  12592. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12593. * @param radius The radius of the cylinder to emit from
  12594. * @param height The height of the emission cylinder
  12595. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12596. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12597. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12598. * @returns the emitter
  12599. */
  12600. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12601. /**
  12602. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12603. * @param radius The radius of the cone to emit from
  12604. * @param angle The base angle of the cone
  12605. * @returns the emitter
  12606. */
  12607. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12608. /**
  12609. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12610. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12611. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12612. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12613. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12614. * @returns the emitter
  12615. */
  12616. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12617. }
  12618. }
  12619. declare module "babylonjs/Particles/subEmitter" {
  12620. import { Scene } from "babylonjs/scene";
  12621. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12622. /**
  12623. * Type of sub emitter
  12624. */
  12625. export enum SubEmitterType {
  12626. /**
  12627. * Attached to the particle over it's lifetime
  12628. */
  12629. ATTACHED = 0,
  12630. /**
  12631. * Created when the particle dies
  12632. */
  12633. END = 1
  12634. }
  12635. /**
  12636. * Sub emitter class used to emit particles from an existing particle
  12637. */
  12638. export class SubEmitter {
  12639. /**
  12640. * the particle system to be used by the sub emitter
  12641. */
  12642. particleSystem: ParticleSystem;
  12643. /**
  12644. * Type of the submitter (Default: END)
  12645. */
  12646. type: SubEmitterType;
  12647. /**
  12648. * 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)
  12649. * Note: This only is supported when using an emitter of type Mesh
  12650. */
  12651. inheritDirection: boolean;
  12652. /**
  12653. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12654. */
  12655. inheritedVelocityAmount: number;
  12656. /**
  12657. * Creates a sub emitter
  12658. * @param particleSystem the particle system to be used by the sub emitter
  12659. */
  12660. constructor(
  12661. /**
  12662. * the particle system to be used by the sub emitter
  12663. */
  12664. particleSystem: ParticleSystem);
  12665. /**
  12666. * Clones the sub emitter
  12667. * @returns the cloned sub emitter
  12668. */
  12669. clone(): SubEmitter;
  12670. /**
  12671. * Serialize current object to a JSON object
  12672. * @returns the serialized object
  12673. */
  12674. serialize(): any;
  12675. /** @hidden */
  12676. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12677. /**
  12678. * Creates a new SubEmitter from a serialized JSON version
  12679. * @param serializationObject defines the JSON object to read from
  12680. * @param scene defines the hosting scene
  12681. * @param rootUrl defines the rootUrl for data loading
  12682. * @returns a new SubEmitter
  12683. */
  12684. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12685. /** Release associated resources */
  12686. dispose(): void;
  12687. }
  12688. }
  12689. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12690. /** @hidden */
  12691. export var imageProcessingDeclaration: {
  12692. name: string;
  12693. shader: string;
  12694. };
  12695. }
  12696. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12697. /** @hidden */
  12698. export var imageProcessingFunctions: {
  12699. name: string;
  12700. shader: string;
  12701. };
  12702. }
  12703. declare module "babylonjs/Shaders/particles.fragment" {
  12704. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12705. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12706. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12707. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12708. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12709. /** @hidden */
  12710. export var particlesPixelShader: {
  12711. name: string;
  12712. shader: string;
  12713. };
  12714. }
  12715. declare module "babylonjs/Shaders/particles.vertex" {
  12716. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12717. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12718. /** @hidden */
  12719. export var particlesVertexShader: {
  12720. name: string;
  12721. shader: string;
  12722. };
  12723. }
  12724. declare module "babylonjs/Particles/particleSystem" {
  12725. import { Nullable } from "babylonjs/types";
  12726. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12727. import { Observable } from "babylonjs/Misc/observable";
  12728. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12729. import { Effect } from "babylonjs/Materials/effect";
  12730. import { Scene, IDisposable } from "babylonjs/scene";
  12731. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12732. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12733. import { Particle } from "babylonjs/Particles/particle";
  12734. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12735. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12736. import "babylonjs/Shaders/particles.fragment";
  12737. import "babylonjs/Shaders/particles.vertex";
  12738. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12739. /**
  12740. * This represents a particle system in Babylon.
  12741. * 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.
  12742. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12743. * @example https://doc.babylonjs.com/babylon101/particles
  12744. */
  12745. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12746. /**
  12747. * Billboard mode will only apply to Y axis
  12748. */
  12749. static readonly BILLBOARDMODE_Y: number;
  12750. /**
  12751. * Billboard mode will apply to all axes
  12752. */
  12753. static readonly BILLBOARDMODE_ALL: number;
  12754. /**
  12755. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12756. */
  12757. static readonly BILLBOARDMODE_STRETCHED: number;
  12758. /**
  12759. * This function can be defined to provide custom update for active particles.
  12760. * This function will be called instead of regular update (age, position, color, etc.).
  12761. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12762. */
  12763. updateFunction: (particles: Particle[]) => void;
  12764. private _emitterWorldMatrix;
  12765. /**
  12766. * This function can be defined to specify initial direction for every new particle.
  12767. * It by default use the emitterType defined function
  12768. */
  12769. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12770. /**
  12771. * This function can be defined to specify initial position for every new particle.
  12772. * It by default use the emitterType defined function
  12773. */
  12774. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12775. /**
  12776. * @hidden
  12777. */
  12778. _inheritedVelocityOffset: Vector3;
  12779. /**
  12780. * An event triggered when the system is disposed
  12781. */
  12782. onDisposeObservable: Observable<IParticleSystem>;
  12783. private _onDisposeObserver;
  12784. /**
  12785. * Sets a callback that will be triggered when the system is disposed
  12786. */
  12787. set onDispose(callback: () => void);
  12788. private _particles;
  12789. private _epsilon;
  12790. private _capacity;
  12791. private _stockParticles;
  12792. private _newPartsExcess;
  12793. private _vertexData;
  12794. private _vertexBuffer;
  12795. private _vertexBuffers;
  12796. private _spriteBuffer;
  12797. private _indexBuffer;
  12798. private _effect;
  12799. private _customEffect;
  12800. private _cachedDefines;
  12801. private _scaledColorStep;
  12802. private _colorDiff;
  12803. private _scaledDirection;
  12804. private _scaledGravity;
  12805. private _currentRenderId;
  12806. private _alive;
  12807. private _useInstancing;
  12808. private _started;
  12809. private _stopped;
  12810. private _actualFrame;
  12811. private _scaledUpdateSpeed;
  12812. private _vertexBufferSize;
  12813. /** @hidden */
  12814. _currentEmitRateGradient: Nullable<FactorGradient>;
  12815. /** @hidden */
  12816. _currentEmitRate1: number;
  12817. /** @hidden */
  12818. _currentEmitRate2: number;
  12819. /** @hidden */
  12820. _currentStartSizeGradient: Nullable<FactorGradient>;
  12821. /** @hidden */
  12822. _currentStartSize1: number;
  12823. /** @hidden */
  12824. _currentStartSize2: number;
  12825. private readonly _rawTextureWidth;
  12826. private _rampGradientsTexture;
  12827. private _useRampGradients;
  12828. /** Gets or sets a boolean indicating that ramp gradients must be used
  12829. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12830. */
  12831. get useRampGradients(): boolean;
  12832. set useRampGradients(value: boolean);
  12833. /**
  12834. * 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.
  12835. * 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: [])
  12836. */
  12837. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12838. private _subEmitters;
  12839. /**
  12840. * @hidden
  12841. * If the particle systems emitter should be disposed when the particle system is disposed
  12842. */
  12843. _disposeEmitterOnDispose: boolean;
  12844. /**
  12845. * The current active Sub-systems, this property is used by the root particle system only.
  12846. */
  12847. activeSubSystems: Array<ParticleSystem>;
  12848. /**
  12849. * Specifies if the particles are updated in emitter local space or world space
  12850. */
  12851. isLocal: boolean;
  12852. private _rootParticleSystem;
  12853. /**
  12854. * Gets the current list of active particles
  12855. */
  12856. get particles(): Particle[];
  12857. /**
  12858. * Gets the number of particles active at the same time.
  12859. * @returns The number of active particles.
  12860. */
  12861. getActiveCount(): number;
  12862. /**
  12863. * Returns the string "ParticleSystem"
  12864. * @returns a string containing the class name
  12865. */
  12866. getClassName(): string;
  12867. /**
  12868. * Gets a boolean indicating that the system is stopping
  12869. * @returns true if the system is currently stopping
  12870. */
  12871. isStopping(): boolean;
  12872. /**
  12873. * Gets the custom effect used to render the particles
  12874. * @param blendMode Blend mode for which the effect should be retrieved
  12875. * @returns The effect
  12876. */
  12877. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12878. /**
  12879. * Sets the custom effect used to render the particles
  12880. * @param effect The effect to set
  12881. * @param blendMode Blend mode for which the effect should be set
  12882. */
  12883. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12884. /** @hidden */
  12885. private _onBeforeDrawParticlesObservable;
  12886. /**
  12887. * Observable that will be called just before the particles are drawn
  12888. */
  12889. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12890. /**
  12891. * Gets the name of the particle vertex shader
  12892. */
  12893. get vertexShaderName(): string;
  12894. /**
  12895. * Instantiates a particle system.
  12896. * 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.
  12897. * @param name The name of the particle system
  12898. * @param capacity The max number of particles alive at the same time
  12899. * @param scene The scene the particle system belongs to
  12900. * @param customEffect a custom effect used to change the way particles are rendered by default
  12901. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12902. * @param epsilon Offset used to render the particles
  12903. */
  12904. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12905. private _addFactorGradient;
  12906. private _removeFactorGradient;
  12907. /**
  12908. * Adds a new life time gradient
  12909. * @param gradient defines the gradient to use (between 0 and 1)
  12910. * @param factor defines the life time factor to affect to the specified gradient
  12911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12912. * @returns the current particle system
  12913. */
  12914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12915. /**
  12916. * Remove a specific life time gradient
  12917. * @param gradient defines the gradient to remove
  12918. * @returns the current particle system
  12919. */
  12920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12921. /**
  12922. * Adds a new size gradient
  12923. * @param gradient defines the gradient to use (between 0 and 1)
  12924. * @param factor defines the size factor to affect to the specified gradient
  12925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12926. * @returns the current particle system
  12927. */
  12928. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12929. /**
  12930. * Remove a specific size gradient
  12931. * @param gradient defines the gradient to remove
  12932. * @returns the current particle system
  12933. */
  12934. removeSizeGradient(gradient: number): IParticleSystem;
  12935. /**
  12936. * Adds a new color remap gradient
  12937. * @param gradient defines the gradient to use (between 0 and 1)
  12938. * @param min defines the color remap minimal range
  12939. * @param max defines the color remap maximal range
  12940. * @returns the current particle system
  12941. */
  12942. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12943. /**
  12944. * Remove a specific color remap gradient
  12945. * @param gradient defines the gradient to remove
  12946. * @returns the current particle system
  12947. */
  12948. removeColorRemapGradient(gradient: number): IParticleSystem;
  12949. /**
  12950. * Adds a new alpha remap gradient
  12951. * @param gradient defines the gradient to use (between 0 and 1)
  12952. * @param min defines the alpha remap minimal range
  12953. * @param max defines the alpha remap maximal range
  12954. * @returns the current particle system
  12955. */
  12956. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12957. /**
  12958. * Remove a specific alpha remap gradient
  12959. * @param gradient defines the gradient to remove
  12960. * @returns the current particle system
  12961. */
  12962. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12963. /**
  12964. * Adds a new angular speed gradient
  12965. * @param gradient defines the gradient to use (between 0 and 1)
  12966. * @param factor defines the angular speed to affect to the specified gradient
  12967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12968. * @returns the current particle system
  12969. */
  12970. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12971. /**
  12972. * Remove a specific angular speed gradient
  12973. * @param gradient defines the gradient to remove
  12974. * @returns the current particle system
  12975. */
  12976. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12977. /**
  12978. * Adds a new velocity gradient
  12979. * @param gradient defines the gradient to use (between 0 and 1)
  12980. * @param factor defines the velocity to affect to the specified gradient
  12981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12982. * @returns the current particle system
  12983. */
  12984. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12985. /**
  12986. * Remove a specific velocity gradient
  12987. * @param gradient defines the gradient to remove
  12988. * @returns the current particle system
  12989. */
  12990. removeVelocityGradient(gradient: number): IParticleSystem;
  12991. /**
  12992. * Adds a new limit velocity gradient
  12993. * @param gradient defines the gradient to use (between 0 and 1)
  12994. * @param factor defines the limit velocity value to affect to the specified gradient
  12995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12996. * @returns the current particle system
  12997. */
  12998. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12999. /**
  13000. * Remove a specific limit velocity gradient
  13001. * @param gradient defines the gradient to remove
  13002. * @returns the current particle system
  13003. */
  13004. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13005. /**
  13006. * Adds a new drag gradient
  13007. * @param gradient defines the gradient to use (between 0 and 1)
  13008. * @param factor defines the drag value to affect to the specified gradient
  13009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13010. * @returns the current particle system
  13011. */
  13012. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13013. /**
  13014. * Remove a specific drag gradient
  13015. * @param gradient defines the gradient to remove
  13016. * @returns the current particle system
  13017. */
  13018. removeDragGradient(gradient: number): IParticleSystem;
  13019. /**
  13020. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13021. * @param gradient defines the gradient to use (between 0 and 1)
  13022. * @param factor defines the emit rate value to affect to the specified gradient
  13023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13024. * @returns the current particle system
  13025. */
  13026. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13027. /**
  13028. * Remove a specific emit rate gradient
  13029. * @param gradient defines the gradient to remove
  13030. * @returns the current particle system
  13031. */
  13032. removeEmitRateGradient(gradient: number): IParticleSystem;
  13033. /**
  13034. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13035. * @param gradient defines the gradient to use (between 0 and 1)
  13036. * @param factor defines the start size value to affect to the specified gradient
  13037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13038. * @returns the current particle system
  13039. */
  13040. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13041. /**
  13042. * Remove a specific start size gradient
  13043. * @param gradient defines the gradient to remove
  13044. * @returns the current particle system
  13045. */
  13046. removeStartSizeGradient(gradient: number): IParticleSystem;
  13047. private _createRampGradientTexture;
  13048. /**
  13049. * Gets the current list of ramp gradients.
  13050. * You must use addRampGradient and removeRampGradient to udpate this list
  13051. * @returns the list of ramp gradients
  13052. */
  13053. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13054. /** Force the system to rebuild all gradients that need to be resync */
  13055. forceRefreshGradients(): void;
  13056. private _syncRampGradientTexture;
  13057. /**
  13058. * Adds a new ramp gradient used to remap particle colors
  13059. * @param gradient defines the gradient to use (between 0 and 1)
  13060. * @param color defines the color to affect to the specified gradient
  13061. * @returns the current particle system
  13062. */
  13063. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13064. /**
  13065. * Remove a specific ramp gradient
  13066. * @param gradient defines the gradient to remove
  13067. * @returns the current particle system
  13068. */
  13069. removeRampGradient(gradient: number): ParticleSystem;
  13070. /**
  13071. * Adds a new color gradient
  13072. * @param gradient defines the gradient to use (between 0 and 1)
  13073. * @param color1 defines the color to affect to the specified gradient
  13074. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13075. * @returns this particle system
  13076. */
  13077. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13078. /**
  13079. * Remove a specific color gradient
  13080. * @param gradient defines the gradient to remove
  13081. * @returns this particle system
  13082. */
  13083. removeColorGradient(gradient: number): IParticleSystem;
  13084. private _fetchR;
  13085. protected _reset(): void;
  13086. private _resetEffect;
  13087. private _createVertexBuffers;
  13088. private _createIndexBuffer;
  13089. /**
  13090. * Gets the maximum number of particles active at the same time.
  13091. * @returns The max number of active particles.
  13092. */
  13093. getCapacity(): number;
  13094. /**
  13095. * Gets whether there are still active particles in the system.
  13096. * @returns True if it is alive, otherwise false.
  13097. */
  13098. isAlive(): boolean;
  13099. /**
  13100. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13101. * @returns True if it has been started, otherwise false.
  13102. */
  13103. isStarted(): boolean;
  13104. private _prepareSubEmitterInternalArray;
  13105. /**
  13106. * Starts the particle system and begins to emit
  13107. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13108. */
  13109. start(delay?: number): void;
  13110. /**
  13111. * Stops the particle system.
  13112. * @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.
  13113. */
  13114. stop(stopSubEmitters?: boolean): void;
  13115. /**
  13116. * Remove all active particles
  13117. */
  13118. reset(): void;
  13119. /**
  13120. * @hidden (for internal use only)
  13121. */
  13122. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13123. /**
  13124. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13125. * Its lifetime will start back at 0.
  13126. */
  13127. recycleParticle: (particle: Particle) => void;
  13128. private _stopSubEmitters;
  13129. private _createParticle;
  13130. private _removeFromRoot;
  13131. private _emitFromParticle;
  13132. private _update;
  13133. /** @hidden */
  13134. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13135. /** @hidden */
  13136. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13137. /**
  13138. * Fill the defines array according to the current settings of the particle system
  13139. * @param defines Array to be updated
  13140. * @param blendMode blend mode to take into account when updating the array
  13141. */
  13142. fillDefines(defines: Array<string>, blendMode: number): void;
  13143. /**
  13144. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13145. * @param uniforms Uniforms array to fill
  13146. * @param attributes Attributes array to fill
  13147. * @param samplers Samplers array to fill
  13148. */
  13149. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13150. /** @hidden */
  13151. private _getEffect;
  13152. /**
  13153. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13154. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13155. */
  13156. animate(preWarmOnly?: boolean): void;
  13157. private _appendParticleVertices;
  13158. /**
  13159. * Rebuilds the particle system.
  13160. */
  13161. rebuild(): void;
  13162. /**
  13163. * Is this system ready to be used/rendered
  13164. * @return true if the system is ready
  13165. */
  13166. isReady(): boolean;
  13167. private _render;
  13168. /**
  13169. * Renders the particle system in its current state.
  13170. * @returns the current number of particles
  13171. */
  13172. render(): number;
  13173. /**
  13174. * Disposes the particle system and free the associated resources
  13175. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13176. */
  13177. dispose(disposeTexture?: boolean): void;
  13178. /**
  13179. * Clones the particle system.
  13180. * @param name The name of the cloned object
  13181. * @param newEmitter The new emitter to use
  13182. * @returns the cloned particle system
  13183. */
  13184. clone(name: string, newEmitter: any): ParticleSystem;
  13185. /**
  13186. * Serializes the particle system to a JSON object
  13187. * @param serializeTexture defines if the texture must be serialized as well
  13188. * @returns the JSON object
  13189. */
  13190. serialize(serializeTexture?: boolean): any;
  13191. /** @hidden */
  13192. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13193. /** @hidden */
  13194. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13195. /**
  13196. * Parses a JSON object to create a particle system.
  13197. * @param parsedParticleSystem The JSON object to parse
  13198. * @param scene The scene to create the particle system in
  13199. * @param rootUrl The root url to use to load external dependencies like texture
  13200. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13201. * @returns the Parsed particle system
  13202. */
  13203. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13204. }
  13205. }
  13206. declare module "babylonjs/Particles/particle" {
  13207. import { Nullable } from "babylonjs/types";
  13208. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13209. import { Color4 } from "babylonjs/Maths/math.color";
  13210. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13211. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13212. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13213. /**
  13214. * A particle represents one of the element emitted by a particle system.
  13215. * This is mainly define by its coordinates, direction, velocity and age.
  13216. */
  13217. export class Particle {
  13218. /**
  13219. * The particle system the particle belongs to.
  13220. */
  13221. particleSystem: ParticleSystem;
  13222. private static _Count;
  13223. /**
  13224. * Unique ID of the particle
  13225. */
  13226. id: number;
  13227. /**
  13228. * The world position of the particle in the scene.
  13229. */
  13230. position: Vector3;
  13231. /**
  13232. * The world direction of the particle in the scene.
  13233. */
  13234. direction: Vector3;
  13235. /**
  13236. * The color of the particle.
  13237. */
  13238. color: Color4;
  13239. /**
  13240. * The color change of the particle per step.
  13241. */
  13242. colorStep: Color4;
  13243. /**
  13244. * Defines how long will the life of the particle be.
  13245. */
  13246. lifeTime: number;
  13247. /**
  13248. * The current age of the particle.
  13249. */
  13250. age: number;
  13251. /**
  13252. * The current size of the particle.
  13253. */
  13254. size: number;
  13255. /**
  13256. * The current scale of the particle.
  13257. */
  13258. scale: Vector2;
  13259. /**
  13260. * The current angle of the particle.
  13261. */
  13262. angle: number;
  13263. /**
  13264. * Defines how fast is the angle changing.
  13265. */
  13266. angularSpeed: number;
  13267. /**
  13268. * Defines the cell index used by the particle to be rendered from a sprite.
  13269. */
  13270. cellIndex: number;
  13271. /**
  13272. * The information required to support color remapping
  13273. */
  13274. remapData: Vector4;
  13275. /** @hidden */
  13276. _randomCellOffset?: number;
  13277. /** @hidden */
  13278. _initialDirection: Nullable<Vector3>;
  13279. /** @hidden */
  13280. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13281. /** @hidden */
  13282. _initialStartSpriteCellID: number;
  13283. /** @hidden */
  13284. _initialEndSpriteCellID: number;
  13285. /** @hidden */
  13286. _currentColorGradient: Nullable<ColorGradient>;
  13287. /** @hidden */
  13288. _currentColor1: Color4;
  13289. /** @hidden */
  13290. _currentColor2: Color4;
  13291. /** @hidden */
  13292. _currentSizeGradient: Nullable<FactorGradient>;
  13293. /** @hidden */
  13294. _currentSize1: number;
  13295. /** @hidden */
  13296. _currentSize2: number;
  13297. /** @hidden */
  13298. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13299. /** @hidden */
  13300. _currentAngularSpeed1: number;
  13301. /** @hidden */
  13302. _currentAngularSpeed2: number;
  13303. /** @hidden */
  13304. _currentVelocityGradient: Nullable<FactorGradient>;
  13305. /** @hidden */
  13306. _currentVelocity1: number;
  13307. /** @hidden */
  13308. _currentVelocity2: number;
  13309. /** @hidden */
  13310. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13311. /** @hidden */
  13312. _currentLimitVelocity1: number;
  13313. /** @hidden */
  13314. _currentLimitVelocity2: number;
  13315. /** @hidden */
  13316. _currentDragGradient: Nullable<FactorGradient>;
  13317. /** @hidden */
  13318. _currentDrag1: number;
  13319. /** @hidden */
  13320. _currentDrag2: number;
  13321. /** @hidden */
  13322. _randomNoiseCoordinates1: Vector3;
  13323. /** @hidden */
  13324. _randomNoiseCoordinates2: Vector3;
  13325. /** @hidden */
  13326. _localPosition?: Vector3;
  13327. /**
  13328. * Creates a new instance Particle
  13329. * @param particleSystem the particle system the particle belongs to
  13330. */
  13331. constructor(
  13332. /**
  13333. * The particle system the particle belongs to.
  13334. */
  13335. particleSystem: ParticleSystem);
  13336. private updateCellInfoFromSystem;
  13337. /**
  13338. * Defines how the sprite cell index is updated for the particle
  13339. */
  13340. updateCellIndex(): void;
  13341. /** @hidden */
  13342. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13343. /** @hidden */
  13344. _inheritParticleInfoToSubEmitters(): void;
  13345. /** @hidden */
  13346. _reset(): void;
  13347. /**
  13348. * Copy the properties of particle to another one.
  13349. * @param other the particle to copy the information to.
  13350. */
  13351. copyTo(other: Particle): void;
  13352. }
  13353. }
  13354. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13355. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13356. import { Effect } from "babylonjs/Materials/effect";
  13357. import { Particle } from "babylonjs/Particles/particle";
  13358. import { Scene } from "babylonjs/scene";
  13359. /**
  13360. * Particle emitter represents a volume emitting particles.
  13361. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13362. */
  13363. export interface IParticleEmitterType {
  13364. /**
  13365. * Called by the particle System when the direction is computed for the created particle.
  13366. * @param worldMatrix is the world matrix of the particle system
  13367. * @param directionToUpdate is the direction vector to update with the result
  13368. * @param particle is the particle we are computed the direction for
  13369. * @param isLocal defines if the direction should be set in local space
  13370. */
  13371. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13372. /**
  13373. * Called by the particle System when the position is computed for the created particle.
  13374. * @param worldMatrix is the world matrix of the particle system
  13375. * @param positionToUpdate is the position vector to update with the result
  13376. * @param particle is the particle we are computed the position for
  13377. * @param isLocal defines if the position should be set in local space
  13378. */
  13379. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13380. /**
  13381. * Clones the current emitter and returns a copy of it
  13382. * @returns the new emitter
  13383. */
  13384. clone(): IParticleEmitterType;
  13385. /**
  13386. * Called by the GPUParticleSystem to setup the update shader
  13387. * @param effect defines the update shader
  13388. */
  13389. applyToShader(effect: Effect): void;
  13390. /**
  13391. * Returns a string to use to update the GPU particles update shader
  13392. * @returns the effect defines string
  13393. */
  13394. getEffectDefines(): string;
  13395. /**
  13396. * Returns a string representing the class name
  13397. * @returns a string containing the class name
  13398. */
  13399. getClassName(): string;
  13400. /**
  13401. * Serializes the particle system to a JSON object.
  13402. * @returns the JSON object
  13403. */
  13404. serialize(): any;
  13405. /**
  13406. * Parse properties from a JSON object
  13407. * @param serializationObject defines the JSON object
  13408. * @param scene defines the hosting scene
  13409. */
  13410. parse(serializationObject: any, scene: Scene): void;
  13411. }
  13412. }
  13413. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13414. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13415. import { Effect } from "babylonjs/Materials/effect";
  13416. import { Particle } from "babylonjs/Particles/particle";
  13417. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13418. /**
  13419. * Particle emitter emitting particles from the inside of a box.
  13420. * It emits the particles randomly between 2 given directions.
  13421. */
  13422. export class BoxParticleEmitter implements IParticleEmitterType {
  13423. /**
  13424. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13425. */
  13426. direction1: Vector3;
  13427. /**
  13428. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13429. */
  13430. direction2: Vector3;
  13431. /**
  13432. * 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.
  13433. */
  13434. minEmitBox: Vector3;
  13435. /**
  13436. * 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.
  13437. */
  13438. maxEmitBox: Vector3;
  13439. /**
  13440. * Creates a new instance BoxParticleEmitter
  13441. */
  13442. constructor();
  13443. /**
  13444. * Called by the particle System when the direction is computed for the created particle.
  13445. * @param worldMatrix is the world matrix of the particle system
  13446. * @param directionToUpdate is the direction vector to update with the result
  13447. * @param particle is the particle we are computed the direction for
  13448. * @param isLocal defines if the direction should be set in local space
  13449. */
  13450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13451. /**
  13452. * Called by the particle System when the position is computed for the created particle.
  13453. * @param worldMatrix is the world matrix of the particle system
  13454. * @param positionToUpdate is the position vector to update with the result
  13455. * @param particle is the particle we are computed the position for
  13456. * @param isLocal defines if the position should be set in local space
  13457. */
  13458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13459. /**
  13460. * Clones the current emitter and returns a copy of it
  13461. * @returns the new emitter
  13462. */
  13463. clone(): BoxParticleEmitter;
  13464. /**
  13465. * Called by the GPUParticleSystem to setup the update shader
  13466. * @param effect defines the update shader
  13467. */
  13468. applyToShader(effect: Effect): void;
  13469. /**
  13470. * Returns a string to use to update the GPU particles update shader
  13471. * @returns a string containng the defines string
  13472. */
  13473. getEffectDefines(): string;
  13474. /**
  13475. * Returns the string "BoxParticleEmitter"
  13476. * @returns a string containing the class name
  13477. */
  13478. getClassName(): string;
  13479. /**
  13480. * Serializes the particle system to a JSON object.
  13481. * @returns the JSON object
  13482. */
  13483. serialize(): any;
  13484. /**
  13485. * Parse properties from a JSON object
  13486. * @param serializationObject defines the JSON object
  13487. */
  13488. parse(serializationObject: any): void;
  13489. }
  13490. }
  13491. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13492. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13493. import { Effect } from "babylonjs/Materials/effect";
  13494. import { Particle } from "babylonjs/Particles/particle";
  13495. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13496. /**
  13497. * Particle emitter emitting particles from the inside of a cone.
  13498. * It emits the particles alongside the cone volume from the base to the particle.
  13499. * The emission direction might be randomized.
  13500. */
  13501. export class ConeParticleEmitter implements IParticleEmitterType {
  13502. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13503. directionRandomizer: number;
  13504. private _radius;
  13505. private _angle;
  13506. private _height;
  13507. /**
  13508. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13509. */
  13510. radiusRange: number;
  13511. /**
  13512. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13513. */
  13514. heightRange: number;
  13515. /**
  13516. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13517. */
  13518. emitFromSpawnPointOnly: boolean;
  13519. /**
  13520. * Gets or sets the radius of the emission cone
  13521. */
  13522. get radius(): number;
  13523. set radius(value: number);
  13524. /**
  13525. * Gets or sets the angle of the emission cone
  13526. */
  13527. get angle(): number;
  13528. set angle(value: number);
  13529. private _buildHeight;
  13530. /**
  13531. * Creates a new instance ConeParticleEmitter
  13532. * @param radius the radius of the emission cone (1 by default)
  13533. * @param angle the cone base angle (PI by default)
  13534. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13535. */
  13536. constructor(radius?: number, angle?: number,
  13537. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13538. directionRandomizer?: number);
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): ConeParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "ConeParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. }
  13587. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13588. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13589. import { Effect } from "babylonjs/Materials/effect";
  13590. import { Particle } from "babylonjs/Particles/particle";
  13591. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13592. /**
  13593. * Particle emitter emitting particles from the inside of a cylinder.
  13594. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13595. */
  13596. export class CylinderParticleEmitter implements IParticleEmitterType {
  13597. /**
  13598. * The radius of the emission cylinder.
  13599. */
  13600. radius: number;
  13601. /**
  13602. * The height of the emission cylinder.
  13603. */
  13604. height: number;
  13605. /**
  13606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13607. */
  13608. radiusRange: number;
  13609. /**
  13610. * How much to randomize the particle direction [0-1].
  13611. */
  13612. directionRandomizer: number;
  13613. /**
  13614. * Creates a new instance CylinderParticleEmitter
  13615. * @param radius the radius of the emission cylinder (1 by default)
  13616. * @param height the height of the emission cylinder (1 by default)
  13617. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13618. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13619. */
  13620. constructor(
  13621. /**
  13622. * The radius of the emission cylinder.
  13623. */
  13624. radius?: number,
  13625. /**
  13626. * The height of the emission cylinder.
  13627. */
  13628. height?: number,
  13629. /**
  13630. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13631. */
  13632. radiusRange?: number,
  13633. /**
  13634. * How much to randomize the particle direction [0-1].
  13635. */
  13636. directionRandomizer?: number);
  13637. /**
  13638. * Called by the particle System when the direction is computed for the created particle.
  13639. * @param worldMatrix is the world matrix of the particle system
  13640. * @param directionToUpdate is the direction vector to update with the result
  13641. * @param particle is the particle we are computed the direction for
  13642. * @param isLocal defines if the direction should be set in local space
  13643. */
  13644. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13645. /**
  13646. * Called by the particle System when the position is computed for the created particle.
  13647. * @param worldMatrix is the world matrix of the particle system
  13648. * @param positionToUpdate is the position vector to update with the result
  13649. * @param particle is the particle we are computed the position for
  13650. * @param isLocal defines if the position should be set in local space
  13651. */
  13652. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13653. /**
  13654. * Clones the current emitter and returns a copy of it
  13655. * @returns the new emitter
  13656. */
  13657. clone(): CylinderParticleEmitter;
  13658. /**
  13659. * Called by the GPUParticleSystem to setup the update shader
  13660. * @param effect defines the update shader
  13661. */
  13662. applyToShader(effect: Effect): void;
  13663. /**
  13664. * Returns a string to use to update the GPU particles update shader
  13665. * @returns a string containng the defines string
  13666. */
  13667. getEffectDefines(): string;
  13668. /**
  13669. * Returns the string "CylinderParticleEmitter"
  13670. * @returns a string containing the class name
  13671. */
  13672. getClassName(): string;
  13673. /**
  13674. * Serializes the particle system to a JSON object.
  13675. * @returns the JSON object
  13676. */
  13677. serialize(): any;
  13678. /**
  13679. * Parse properties from a JSON object
  13680. * @param serializationObject defines the JSON object
  13681. */
  13682. parse(serializationObject: any): void;
  13683. }
  13684. /**
  13685. * Particle emitter emitting particles from the inside of a cylinder.
  13686. * It emits the particles randomly between two vectors.
  13687. */
  13688. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13689. /**
  13690. * The min limit of the emission direction.
  13691. */
  13692. direction1: Vector3;
  13693. /**
  13694. * The max limit of the emission direction.
  13695. */
  13696. direction2: Vector3;
  13697. /**
  13698. * Creates a new instance CylinderDirectedParticleEmitter
  13699. * @param radius the radius of the emission cylinder (1 by default)
  13700. * @param height the height of the emission cylinder (1 by default)
  13701. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13702. * @param direction1 the min limit of the emission direction (up vector by default)
  13703. * @param direction2 the max limit of the emission direction (up vector by default)
  13704. */
  13705. constructor(radius?: number, height?: number, radiusRange?: number,
  13706. /**
  13707. * The min limit of the emission direction.
  13708. */
  13709. direction1?: Vector3,
  13710. /**
  13711. * The max limit of the emission direction.
  13712. */
  13713. direction2?: Vector3);
  13714. /**
  13715. * Called by the particle System when the direction is computed for the created particle.
  13716. * @param worldMatrix is the world matrix of the particle system
  13717. * @param directionToUpdate is the direction vector to update with the result
  13718. * @param particle is the particle we are computed the direction for
  13719. */
  13720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13721. /**
  13722. * Clones the current emitter and returns a copy of it
  13723. * @returns the new emitter
  13724. */
  13725. clone(): CylinderDirectedParticleEmitter;
  13726. /**
  13727. * Called by the GPUParticleSystem to setup the update shader
  13728. * @param effect defines the update shader
  13729. */
  13730. applyToShader(effect: Effect): void;
  13731. /**
  13732. * Returns a string to use to update the GPU particles update shader
  13733. * @returns a string containng the defines string
  13734. */
  13735. getEffectDefines(): string;
  13736. /**
  13737. * Returns the string "CylinderDirectedParticleEmitter"
  13738. * @returns a string containing the class name
  13739. */
  13740. getClassName(): string;
  13741. /**
  13742. * Serializes the particle system to a JSON object.
  13743. * @returns the JSON object
  13744. */
  13745. serialize(): any;
  13746. /**
  13747. * Parse properties from a JSON object
  13748. * @param serializationObject defines the JSON object
  13749. */
  13750. parse(serializationObject: any): void;
  13751. }
  13752. }
  13753. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13754. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13755. import { Effect } from "babylonjs/Materials/effect";
  13756. import { Particle } from "babylonjs/Particles/particle";
  13757. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13758. /**
  13759. * Particle emitter emitting particles from the inside of a hemisphere.
  13760. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13761. */
  13762. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13763. /**
  13764. * The radius of the emission hemisphere.
  13765. */
  13766. radius: number;
  13767. /**
  13768. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13769. */
  13770. radiusRange: number;
  13771. /**
  13772. * How much to randomize the particle direction [0-1].
  13773. */
  13774. directionRandomizer: number;
  13775. /**
  13776. * Creates a new instance HemisphericParticleEmitter
  13777. * @param radius the radius of the emission hemisphere (1 by default)
  13778. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13779. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13780. */
  13781. constructor(
  13782. /**
  13783. * The radius of the emission hemisphere.
  13784. */
  13785. radius?: number,
  13786. /**
  13787. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13788. */
  13789. radiusRange?: number,
  13790. /**
  13791. * How much to randomize the particle direction [0-1].
  13792. */
  13793. directionRandomizer?: number);
  13794. /**
  13795. * Called by the particle System when the direction is computed for the created particle.
  13796. * @param worldMatrix is the world matrix of the particle system
  13797. * @param directionToUpdate is the direction vector to update with the result
  13798. * @param particle is the particle we are computed the direction for
  13799. * @param isLocal defines if the direction should be set in local space
  13800. */
  13801. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13802. /**
  13803. * Called by the particle System when the position is computed for the created particle.
  13804. * @param worldMatrix is the world matrix of the particle system
  13805. * @param positionToUpdate is the position vector to update with the result
  13806. * @param particle is the particle we are computed the position for
  13807. * @param isLocal defines if the position should be set in local space
  13808. */
  13809. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13810. /**
  13811. * Clones the current emitter and returns a copy of it
  13812. * @returns the new emitter
  13813. */
  13814. clone(): HemisphericParticleEmitter;
  13815. /**
  13816. * Called by the GPUParticleSystem to setup the update shader
  13817. * @param effect defines the update shader
  13818. */
  13819. applyToShader(effect: Effect): void;
  13820. /**
  13821. * Returns a string to use to update the GPU particles update shader
  13822. * @returns a string containng the defines string
  13823. */
  13824. getEffectDefines(): string;
  13825. /**
  13826. * Returns the string "HemisphericParticleEmitter"
  13827. * @returns a string containing the class name
  13828. */
  13829. getClassName(): string;
  13830. /**
  13831. * Serializes the particle system to a JSON object.
  13832. * @returns the JSON object
  13833. */
  13834. serialize(): any;
  13835. /**
  13836. * Parse properties from a JSON object
  13837. * @param serializationObject defines the JSON object
  13838. */
  13839. parse(serializationObject: any): void;
  13840. }
  13841. }
  13842. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13843. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13844. import { Effect } from "babylonjs/Materials/effect";
  13845. import { Particle } from "babylonjs/Particles/particle";
  13846. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13847. /**
  13848. * Particle emitter emitting particles from a point.
  13849. * It emits the particles randomly between 2 given directions.
  13850. */
  13851. export class PointParticleEmitter implements IParticleEmitterType {
  13852. /**
  13853. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13854. */
  13855. direction1: Vector3;
  13856. /**
  13857. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13858. */
  13859. direction2: Vector3;
  13860. /**
  13861. * Creates a new instance PointParticleEmitter
  13862. */
  13863. constructor();
  13864. /**
  13865. * Called by the particle System when the direction is computed for the created particle.
  13866. * @param worldMatrix is the world matrix of the particle system
  13867. * @param directionToUpdate is the direction vector to update with the result
  13868. * @param particle is the particle we are computed the direction for
  13869. * @param isLocal defines if the direction should be set in local space
  13870. */
  13871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13872. /**
  13873. * Called by the particle System when the position is computed for the created particle.
  13874. * @param worldMatrix is the world matrix of the particle system
  13875. * @param positionToUpdate is the position vector to update with the result
  13876. * @param particle is the particle we are computed the position for
  13877. * @param isLocal defines if the position should be set in local space
  13878. */
  13879. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13880. /**
  13881. * Clones the current emitter and returns a copy of it
  13882. * @returns the new emitter
  13883. */
  13884. clone(): PointParticleEmitter;
  13885. /**
  13886. * Called by the GPUParticleSystem to setup the update shader
  13887. * @param effect defines the update shader
  13888. */
  13889. applyToShader(effect: Effect): void;
  13890. /**
  13891. * Returns a string to use to update the GPU particles update shader
  13892. * @returns a string containng the defines string
  13893. */
  13894. getEffectDefines(): string;
  13895. /**
  13896. * Returns the string "PointParticleEmitter"
  13897. * @returns a string containing the class name
  13898. */
  13899. getClassName(): string;
  13900. /**
  13901. * Serializes the particle system to a JSON object.
  13902. * @returns the JSON object
  13903. */
  13904. serialize(): any;
  13905. /**
  13906. * Parse properties from a JSON object
  13907. * @param serializationObject defines the JSON object
  13908. */
  13909. parse(serializationObject: any): void;
  13910. }
  13911. }
  13912. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13913. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13914. import { Effect } from "babylonjs/Materials/effect";
  13915. import { Particle } from "babylonjs/Particles/particle";
  13916. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13917. /**
  13918. * Particle emitter emitting particles from the inside of a sphere.
  13919. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13920. */
  13921. export class SphereParticleEmitter implements IParticleEmitterType {
  13922. /**
  13923. * The radius of the emission sphere.
  13924. */
  13925. radius: number;
  13926. /**
  13927. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13928. */
  13929. radiusRange: number;
  13930. /**
  13931. * How much to randomize the particle direction [0-1].
  13932. */
  13933. directionRandomizer: number;
  13934. /**
  13935. * Creates a new instance SphereParticleEmitter
  13936. * @param radius the radius of the emission sphere (1 by default)
  13937. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13938. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13939. */
  13940. constructor(
  13941. /**
  13942. * The radius of the emission sphere.
  13943. */
  13944. radius?: number,
  13945. /**
  13946. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13947. */
  13948. radiusRange?: number,
  13949. /**
  13950. * How much to randomize the particle direction [0-1].
  13951. */
  13952. directionRandomizer?: number);
  13953. /**
  13954. * Called by the particle System when the direction is computed for the created particle.
  13955. * @param worldMatrix is the world matrix of the particle system
  13956. * @param directionToUpdate is the direction vector to update with the result
  13957. * @param particle is the particle we are computed the direction for
  13958. * @param isLocal defines if the direction should be set in local space
  13959. */
  13960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13961. /**
  13962. * Called by the particle System when the position is computed for the created particle.
  13963. * @param worldMatrix is the world matrix of the particle system
  13964. * @param positionToUpdate is the position vector to update with the result
  13965. * @param particle is the particle we are computed the position for
  13966. * @param isLocal defines if the position should be set in local space
  13967. */
  13968. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13969. /**
  13970. * Clones the current emitter and returns a copy of it
  13971. * @returns the new emitter
  13972. */
  13973. clone(): SphereParticleEmitter;
  13974. /**
  13975. * Called by the GPUParticleSystem to setup the update shader
  13976. * @param effect defines the update shader
  13977. */
  13978. applyToShader(effect: Effect): void;
  13979. /**
  13980. * Returns a string to use to update the GPU particles update shader
  13981. * @returns a string containng the defines string
  13982. */
  13983. getEffectDefines(): string;
  13984. /**
  13985. * Returns the string "SphereParticleEmitter"
  13986. * @returns a string containing the class name
  13987. */
  13988. getClassName(): string;
  13989. /**
  13990. * Serializes the particle system to a JSON object.
  13991. * @returns the JSON object
  13992. */
  13993. serialize(): any;
  13994. /**
  13995. * Parse properties from a JSON object
  13996. * @param serializationObject defines the JSON object
  13997. */
  13998. parse(serializationObject: any): void;
  13999. }
  14000. /**
  14001. * Particle emitter emitting particles from the inside of a sphere.
  14002. * It emits the particles randomly between two vectors.
  14003. */
  14004. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14005. /**
  14006. * The min limit of the emission direction.
  14007. */
  14008. direction1: Vector3;
  14009. /**
  14010. * The max limit of the emission direction.
  14011. */
  14012. direction2: Vector3;
  14013. /**
  14014. * Creates a new instance SphereDirectedParticleEmitter
  14015. * @param radius the radius of the emission sphere (1 by default)
  14016. * @param direction1 the min limit of the emission direction (up vector by default)
  14017. * @param direction2 the max limit of the emission direction (up vector by default)
  14018. */
  14019. constructor(radius?: number,
  14020. /**
  14021. * The min limit of the emission direction.
  14022. */
  14023. direction1?: Vector3,
  14024. /**
  14025. * The max limit of the emission direction.
  14026. */
  14027. direction2?: Vector3);
  14028. /**
  14029. * Called by the particle System when the direction is computed for the created particle.
  14030. * @param worldMatrix is the world matrix of the particle system
  14031. * @param directionToUpdate is the direction vector to update with the result
  14032. * @param particle is the particle we are computed the direction for
  14033. */
  14034. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14035. /**
  14036. * Clones the current emitter and returns a copy of it
  14037. * @returns the new emitter
  14038. */
  14039. clone(): SphereDirectedParticleEmitter;
  14040. /**
  14041. * Called by the GPUParticleSystem to setup the update shader
  14042. * @param effect defines the update shader
  14043. */
  14044. applyToShader(effect: Effect): void;
  14045. /**
  14046. * Returns a string to use to update the GPU particles update shader
  14047. * @returns a string containng the defines string
  14048. */
  14049. getEffectDefines(): string;
  14050. /**
  14051. * Returns the string "SphereDirectedParticleEmitter"
  14052. * @returns a string containing the class name
  14053. */
  14054. getClassName(): string;
  14055. /**
  14056. * Serializes the particle system to a JSON object.
  14057. * @returns the JSON object
  14058. */
  14059. serialize(): any;
  14060. /**
  14061. * Parse properties from a JSON object
  14062. * @param serializationObject defines the JSON object
  14063. */
  14064. parse(serializationObject: any): void;
  14065. }
  14066. }
  14067. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14068. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14069. import { Effect } from "babylonjs/Materials/effect";
  14070. import { Particle } from "babylonjs/Particles/particle";
  14071. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14072. import { Nullable } from "babylonjs/types";
  14073. /**
  14074. * Particle emitter emitting particles from a custom list of positions.
  14075. */
  14076. export class CustomParticleEmitter implements IParticleEmitterType {
  14077. /**
  14078. * Gets or sets the position generator that will create the inital position of each particle.
  14079. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14080. */
  14081. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14082. /**
  14083. * Gets or sets the destination generator that will create the final destination of each particle.
  14084. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14085. */
  14086. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14087. /**
  14088. * Creates a new instance CustomParticleEmitter
  14089. */
  14090. constructor();
  14091. /**
  14092. * Called by the particle System when the direction is computed for the created particle.
  14093. * @param worldMatrix is the world matrix of the particle system
  14094. * @param directionToUpdate is the direction vector to update with the result
  14095. * @param particle is the particle we are computed the direction for
  14096. * @param isLocal defines if the direction should be set in local space
  14097. */
  14098. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14099. /**
  14100. * Called by the particle System when the position is computed for the created particle.
  14101. * @param worldMatrix is the world matrix of the particle system
  14102. * @param positionToUpdate is the position vector to update with the result
  14103. * @param particle is the particle we are computed the position for
  14104. * @param isLocal defines if the position should be set in local space
  14105. */
  14106. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14107. /**
  14108. * Clones the current emitter and returns a copy of it
  14109. * @returns the new emitter
  14110. */
  14111. clone(): CustomParticleEmitter;
  14112. /**
  14113. * Called by the GPUParticleSystem to setup the update shader
  14114. * @param effect defines the update shader
  14115. */
  14116. applyToShader(effect: Effect): void;
  14117. /**
  14118. * Returns a string to use to update the GPU particles update shader
  14119. * @returns a string containng the defines string
  14120. */
  14121. getEffectDefines(): string;
  14122. /**
  14123. * Returns the string "PointParticleEmitter"
  14124. * @returns a string containing the class name
  14125. */
  14126. getClassName(): string;
  14127. /**
  14128. * Serializes the particle system to a JSON object.
  14129. * @returns the JSON object
  14130. */
  14131. serialize(): any;
  14132. /**
  14133. * Parse properties from a JSON object
  14134. * @param serializationObject defines the JSON object
  14135. */
  14136. parse(serializationObject: any): void;
  14137. }
  14138. }
  14139. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14140. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14141. import { Effect } from "babylonjs/Materials/effect";
  14142. import { Particle } from "babylonjs/Particles/particle";
  14143. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14144. import { Nullable } from "babylonjs/types";
  14145. import { Scene } from "babylonjs/scene";
  14146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14147. /**
  14148. * Particle emitter emitting particles from the inside of a box.
  14149. * It emits the particles randomly between 2 given directions.
  14150. */
  14151. export class MeshParticleEmitter implements IParticleEmitterType {
  14152. private _indices;
  14153. private _positions;
  14154. private _normals;
  14155. private _storedNormal;
  14156. private _mesh;
  14157. /**
  14158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14159. */
  14160. direction1: Vector3;
  14161. /**
  14162. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14163. */
  14164. direction2: Vector3;
  14165. /**
  14166. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14167. */
  14168. useMeshNormalsForDirection: boolean;
  14169. /** Defines the mesh to use as source */
  14170. get mesh(): Nullable<AbstractMesh>;
  14171. set mesh(value: Nullable<AbstractMesh>);
  14172. /**
  14173. * Creates a new instance MeshParticleEmitter
  14174. * @param mesh defines the mesh to use as source
  14175. */
  14176. constructor(mesh?: Nullable<AbstractMesh>);
  14177. /**
  14178. * Called by the particle System when the direction is computed for the created particle.
  14179. * @param worldMatrix is the world matrix of the particle system
  14180. * @param directionToUpdate is the direction vector to update with the result
  14181. * @param particle is the particle we are computed the direction for
  14182. * @param isLocal defines if the direction should be set in local space
  14183. */
  14184. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14185. /**
  14186. * Called by the particle System when the position is computed for the created particle.
  14187. * @param worldMatrix is the world matrix of the particle system
  14188. * @param positionToUpdate is the position vector to update with the result
  14189. * @param particle is the particle we are computed the position for
  14190. * @param isLocal defines if the position should be set in local space
  14191. */
  14192. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14193. /**
  14194. * Clones the current emitter and returns a copy of it
  14195. * @returns the new emitter
  14196. */
  14197. clone(): MeshParticleEmitter;
  14198. /**
  14199. * Called by the GPUParticleSystem to setup the update shader
  14200. * @param effect defines the update shader
  14201. */
  14202. applyToShader(effect: Effect): void;
  14203. /**
  14204. * Returns a string to use to update the GPU particles update shader
  14205. * @returns a string containng the defines string
  14206. */
  14207. getEffectDefines(): string;
  14208. /**
  14209. * Returns the string "BoxParticleEmitter"
  14210. * @returns a string containing the class name
  14211. */
  14212. getClassName(): string;
  14213. /**
  14214. * Serializes the particle system to a JSON object.
  14215. * @returns the JSON object
  14216. */
  14217. serialize(): any;
  14218. /**
  14219. * Parse properties from a JSON object
  14220. * @param serializationObject defines the JSON object
  14221. * @param scene defines the hosting scene
  14222. */
  14223. parse(serializationObject: any, scene: Scene): void;
  14224. }
  14225. }
  14226. declare module "babylonjs/Particles/EmitterTypes/index" {
  14227. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14228. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14229. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14230. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14231. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14232. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14233. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14234. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14235. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14236. }
  14237. declare module "babylonjs/Particles/IParticleSystem" {
  14238. import { Nullable } from "babylonjs/types";
  14239. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14240. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14243. import { Texture } from "babylonjs/Materials/Textures/texture";
  14244. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14245. import { Scene } from "babylonjs/scene";
  14246. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14247. import { Effect } from "babylonjs/Materials/effect";
  14248. import { Observable } from "babylonjs/Misc/observable";
  14249. import { Animation } from "babylonjs/Animations/animation";
  14250. /**
  14251. * Interface representing a particle system in Babylon.js.
  14252. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14253. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14254. */
  14255. export interface IParticleSystem {
  14256. /**
  14257. * List of animations used by the particle system.
  14258. */
  14259. animations: Animation[];
  14260. /**
  14261. * The id of the Particle system.
  14262. */
  14263. id: string;
  14264. /**
  14265. * The name of the Particle system.
  14266. */
  14267. name: string;
  14268. /**
  14269. * The emitter represents the Mesh or position we are attaching the particle system to.
  14270. */
  14271. emitter: Nullable<AbstractMesh | Vector3>;
  14272. /**
  14273. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14274. */
  14275. isBillboardBased: boolean;
  14276. /**
  14277. * The rendering group used by the Particle system to chose when to render.
  14278. */
  14279. renderingGroupId: number;
  14280. /**
  14281. * The layer mask we are rendering the particles through.
  14282. */
  14283. layerMask: number;
  14284. /**
  14285. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14286. */
  14287. updateSpeed: number;
  14288. /**
  14289. * The amount of time the particle system is running (depends of the overall update speed).
  14290. */
  14291. targetStopDuration: number;
  14292. /**
  14293. * The texture used to render each particle. (this can be a spritesheet)
  14294. */
  14295. particleTexture: Nullable<Texture>;
  14296. /**
  14297. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14298. */
  14299. blendMode: number;
  14300. /**
  14301. * Minimum life time of emitting particles.
  14302. */
  14303. minLifeTime: number;
  14304. /**
  14305. * Maximum life time of emitting particles.
  14306. */
  14307. maxLifeTime: number;
  14308. /**
  14309. * Minimum Size of emitting particles.
  14310. */
  14311. minSize: number;
  14312. /**
  14313. * Maximum Size of emitting particles.
  14314. */
  14315. maxSize: number;
  14316. /**
  14317. * Minimum scale of emitting particles on X axis.
  14318. */
  14319. minScaleX: number;
  14320. /**
  14321. * Maximum scale of emitting particles on X axis.
  14322. */
  14323. maxScaleX: number;
  14324. /**
  14325. * Minimum scale of emitting particles on Y axis.
  14326. */
  14327. minScaleY: number;
  14328. /**
  14329. * Maximum scale of emitting particles on Y axis.
  14330. */
  14331. maxScaleY: number;
  14332. /**
  14333. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14334. */
  14335. color1: Color4;
  14336. /**
  14337. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14338. */
  14339. color2: Color4;
  14340. /**
  14341. * Color the particle will have at the end of its lifetime.
  14342. */
  14343. colorDead: Color4;
  14344. /**
  14345. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14346. */
  14347. emitRate: number;
  14348. /**
  14349. * You can use gravity if you want to give an orientation to your particles.
  14350. */
  14351. gravity: Vector3;
  14352. /**
  14353. * Minimum power of emitting particles.
  14354. */
  14355. minEmitPower: number;
  14356. /**
  14357. * Maximum power of emitting particles.
  14358. */
  14359. maxEmitPower: number;
  14360. /**
  14361. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14362. */
  14363. minAngularSpeed: number;
  14364. /**
  14365. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14366. */
  14367. maxAngularSpeed: number;
  14368. /**
  14369. * Gets or sets the minimal initial rotation in radians.
  14370. */
  14371. minInitialRotation: number;
  14372. /**
  14373. * Gets or sets the maximal initial rotation in radians.
  14374. */
  14375. maxInitialRotation: number;
  14376. /**
  14377. * The particle emitter type defines the emitter used by the particle system.
  14378. * It can be for example box, sphere, or cone...
  14379. */
  14380. particleEmitterType: Nullable<IParticleEmitterType>;
  14381. /**
  14382. * Defines the delay in milliseconds before starting the system (0 by default)
  14383. */
  14384. startDelay: number;
  14385. /**
  14386. * 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
  14387. */
  14388. preWarmCycles: number;
  14389. /**
  14390. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14391. */
  14392. preWarmStepOffset: number;
  14393. /**
  14394. * 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)
  14395. */
  14396. spriteCellChangeSpeed: number;
  14397. /**
  14398. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14399. */
  14400. startSpriteCellID: number;
  14401. /**
  14402. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14403. */
  14404. endSpriteCellID: number;
  14405. /**
  14406. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14407. */
  14408. spriteCellWidth: number;
  14409. /**
  14410. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14411. */
  14412. spriteCellHeight: number;
  14413. /**
  14414. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14415. */
  14416. spriteRandomStartCell: boolean;
  14417. /**
  14418. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14419. */
  14420. isAnimationSheetEnabled: boolean;
  14421. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14422. translationPivot: Vector2;
  14423. /**
  14424. * Gets or sets a texture used to add random noise to particle positions
  14425. */
  14426. noiseTexture: Nullable<BaseTexture>;
  14427. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14428. noiseStrength: Vector3;
  14429. /**
  14430. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14431. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14432. */
  14433. billboardMode: number;
  14434. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14435. limitVelocityDamping: number;
  14436. /**
  14437. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14438. */
  14439. beginAnimationOnStart: boolean;
  14440. /**
  14441. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14442. */
  14443. beginAnimationFrom: number;
  14444. /**
  14445. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14446. */
  14447. beginAnimationTo: number;
  14448. /**
  14449. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14450. */
  14451. beginAnimationLoop: boolean;
  14452. /**
  14453. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14454. */
  14455. disposeOnStop: boolean;
  14456. /**
  14457. * Specifies if the particles are updated in emitter local space or world space
  14458. */
  14459. isLocal: boolean;
  14460. /** Snippet ID if the particle system was created from the snippet server */
  14461. snippetId: string;
  14462. /**
  14463. * Gets the maximum number of particles active at the same time.
  14464. * @returns The max number of active particles.
  14465. */
  14466. getCapacity(): number;
  14467. /**
  14468. * Gets the number of particles active at the same time.
  14469. * @returns The number of active particles.
  14470. */
  14471. getActiveCount(): number;
  14472. /**
  14473. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14474. * @returns True if it has been started, otherwise false.
  14475. */
  14476. isStarted(): boolean;
  14477. /**
  14478. * Animates the particle system for this frame.
  14479. */
  14480. animate(): void;
  14481. /**
  14482. * Renders the particle system in its current state.
  14483. * @returns the current number of particles
  14484. */
  14485. render(): number;
  14486. /**
  14487. * Dispose the particle system and frees its associated resources.
  14488. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14489. */
  14490. dispose(disposeTexture?: boolean): void;
  14491. /**
  14492. * An event triggered when the system is disposed
  14493. */
  14494. onDisposeObservable: Observable<IParticleSystem>;
  14495. /**
  14496. * Clones the particle system.
  14497. * @param name The name of the cloned object
  14498. * @param newEmitter The new emitter to use
  14499. * @returns the cloned particle system
  14500. */
  14501. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14502. /**
  14503. * Serializes the particle system to a JSON object
  14504. * @param serializeTexture defines if the texture must be serialized as well
  14505. * @returns the JSON object
  14506. */
  14507. serialize(serializeTexture: boolean): any;
  14508. /**
  14509. * Rebuild the particle system
  14510. */
  14511. rebuild(): void;
  14512. /** Force the system to rebuild all gradients that need to be resync */
  14513. forceRefreshGradients(): void;
  14514. /**
  14515. * Starts the particle system and begins to emit
  14516. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14517. */
  14518. start(delay?: number): void;
  14519. /**
  14520. * Stops the particle system.
  14521. */
  14522. stop(): void;
  14523. /**
  14524. * Remove all active particles
  14525. */
  14526. reset(): void;
  14527. /**
  14528. * Gets a boolean indicating that the system is stopping
  14529. * @returns true if the system is currently stopping
  14530. */
  14531. isStopping(): boolean;
  14532. /**
  14533. * Is this system ready to be used/rendered
  14534. * @return true if the system is ready
  14535. */
  14536. isReady(): boolean;
  14537. /**
  14538. * Returns the string "ParticleSystem"
  14539. * @returns a string containing the class name
  14540. */
  14541. getClassName(): string;
  14542. /**
  14543. * Gets the custom effect used to render the particles
  14544. * @param blendMode Blend mode for which the effect should be retrieved
  14545. * @returns The effect
  14546. */
  14547. getCustomEffect(blendMode: number): Nullable<Effect>;
  14548. /**
  14549. * Sets the custom effect used to render the particles
  14550. * @param effect The effect to set
  14551. * @param blendMode Blend mode for which the effect should be set
  14552. */
  14553. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14554. /**
  14555. * Fill the defines array according to the current settings of the particle system
  14556. * @param defines Array to be updated
  14557. * @param blendMode blend mode to take into account when updating the array
  14558. */
  14559. fillDefines(defines: Array<string>, blendMode: number): void;
  14560. /**
  14561. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14562. * @param uniforms Uniforms array to fill
  14563. * @param attributes Attributes array to fill
  14564. * @param samplers Samplers array to fill
  14565. */
  14566. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14567. /**
  14568. * Observable that will be called just before the particles are drawn
  14569. */
  14570. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14571. /**
  14572. * Gets the name of the particle vertex shader
  14573. */
  14574. vertexShaderName: string;
  14575. /**
  14576. * Adds a new color gradient
  14577. * @param gradient defines the gradient to use (between 0 and 1)
  14578. * @param color1 defines the color to affect to the specified gradient
  14579. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14580. * @returns the current particle system
  14581. */
  14582. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14583. /**
  14584. * Remove a specific color gradient
  14585. * @param gradient defines the gradient to remove
  14586. * @returns the current particle system
  14587. */
  14588. removeColorGradient(gradient: number): IParticleSystem;
  14589. /**
  14590. * Adds a new size gradient
  14591. * @param gradient defines the gradient to use (between 0 and 1)
  14592. * @param factor defines the size factor to affect to the specified gradient
  14593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14594. * @returns the current particle system
  14595. */
  14596. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14597. /**
  14598. * Remove a specific size gradient
  14599. * @param gradient defines the gradient to remove
  14600. * @returns the current particle system
  14601. */
  14602. removeSizeGradient(gradient: number): IParticleSystem;
  14603. /**
  14604. * Gets the current list of color gradients.
  14605. * You must use addColorGradient and removeColorGradient to udpate this list
  14606. * @returns the list of color gradients
  14607. */
  14608. getColorGradients(): Nullable<Array<ColorGradient>>;
  14609. /**
  14610. * Gets the current list of size gradients.
  14611. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14612. * @returns the list of size gradients
  14613. */
  14614. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14615. /**
  14616. * Gets the current list of angular speed gradients.
  14617. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14618. * @returns the list of angular speed gradients
  14619. */
  14620. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14621. /**
  14622. * Adds a new angular speed gradient
  14623. * @param gradient defines the gradient to use (between 0 and 1)
  14624. * @param factor defines the angular speed to affect to the specified gradient
  14625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14626. * @returns the current particle system
  14627. */
  14628. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14629. /**
  14630. * Remove a specific angular speed gradient
  14631. * @param gradient defines the gradient to remove
  14632. * @returns the current particle system
  14633. */
  14634. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14635. /**
  14636. * Gets the current list of velocity gradients.
  14637. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14638. * @returns the list of velocity gradients
  14639. */
  14640. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14641. /**
  14642. * Adds a new velocity gradient
  14643. * @param gradient defines the gradient to use (between 0 and 1)
  14644. * @param factor defines the velocity to affect to the specified gradient
  14645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14646. * @returns the current particle system
  14647. */
  14648. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14649. /**
  14650. * Remove a specific velocity gradient
  14651. * @param gradient defines the gradient to remove
  14652. * @returns the current particle system
  14653. */
  14654. removeVelocityGradient(gradient: number): IParticleSystem;
  14655. /**
  14656. * Gets the current list of limit velocity gradients.
  14657. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14658. * @returns the list of limit velocity gradients
  14659. */
  14660. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14661. /**
  14662. * Adds a new limit velocity gradient
  14663. * @param gradient defines the gradient to use (between 0 and 1)
  14664. * @param factor defines the limit velocity to affect to the specified gradient
  14665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14666. * @returns the current particle system
  14667. */
  14668. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14669. /**
  14670. * Remove a specific limit velocity gradient
  14671. * @param gradient defines the gradient to remove
  14672. * @returns the current particle system
  14673. */
  14674. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14675. /**
  14676. * Adds a new drag gradient
  14677. * @param gradient defines the gradient to use (between 0 and 1)
  14678. * @param factor defines the drag to affect to the specified gradient
  14679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14680. * @returns the current particle system
  14681. */
  14682. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14683. /**
  14684. * Remove a specific drag gradient
  14685. * @param gradient defines the gradient to remove
  14686. * @returns the current particle system
  14687. */
  14688. removeDragGradient(gradient: number): IParticleSystem;
  14689. /**
  14690. * Gets the current list of drag gradients.
  14691. * You must use addDragGradient and removeDragGradient to udpate this list
  14692. * @returns the list of drag gradients
  14693. */
  14694. getDragGradients(): Nullable<Array<FactorGradient>>;
  14695. /**
  14696. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14697. * @param gradient defines the gradient to use (between 0 and 1)
  14698. * @param factor defines the emit rate to affect to the specified gradient
  14699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14700. * @returns the current particle system
  14701. */
  14702. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14703. /**
  14704. * Remove a specific emit rate gradient
  14705. * @param gradient defines the gradient to remove
  14706. * @returns the current particle system
  14707. */
  14708. removeEmitRateGradient(gradient: number): IParticleSystem;
  14709. /**
  14710. * Gets the current list of emit rate gradients.
  14711. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14712. * @returns the list of emit rate gradients
  14713. */
  14714. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14715. /**
  14716. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14717. * @param gradient defines the gradient to use (between 0 and 1)
  14718. * @param factor defines the start size to affect to the specified gradient
  14719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14720. * @returns the current particle system
  14721. */
  14722. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14723. /**
  14724. * Remove a specific start size gradient
  14725. * @param gradient defines the gradient to remove
  14726. * @returns the current particle system
  14727. */
  14728. removeStartSizeGradient(gradient: number): IParticleSystem;
  14729. /**
  14730. * Gets the current list of start size gradients.
  14731. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14732. * @returns the list of start size gradients
  14733. */
  14734. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14735. /**
  14736. * Adds a new life time gradient
  14737. * @param gradient defines the gradient to use (between 0 and 1)
  14738. * @param factor defines the life time factor to affect to the specified gradient
  14739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14740. * @returns the current particle system
  14741. */
  14742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14743. /**
  14744. * Remove a specific life time gradient
  14745. * @param gradient defines the gradient to remove
  14746. * @returns the current particle system
  14747. */
  14748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14749. /**
  14750. * Gets the current list of life time gradients.
  14751. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14752. * @returns the list of life time gradients
  14753. */
  14754. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14755. /**
  14756. * Gets the current list of color gradients.
  14757. * You must use addColorGradient and removeColorGradient to udpate this list
  14758. * @returns the list of color gradients
  14759. */
  14760. getColorGradients(): Nullable<Array<ColorGradient>>;
  14761. /**
  14762. * Adds a new ramp gradient used to remap particle colors
  14763. * @param gradient defines the gradient to use (between 0 and 1)
  14764. * @param color defines the color to affect to the specified gradient
  14765. * @returns the current particle system
  14766. */
  14767. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14768. /**
  14769. * Gets the current list of ramp gradients.
  14770. * You must use addRampGradient and removeRampGradient to udpate this list
  14771. * @returns the list of ramp gradients
  14772. */
  14773. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14774. /** Gets or sets a boolean indicating that ramp gradients must be used
  14775. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14776. */
  14777. useRampGradients: boolean;
  14778. /**
  14779. * Adds a new color remap gradient
  14780. * @param gradient defines the gradient to use (between 0 and 1)
  14781. * @param min defines the color remap minimal range
  14782. * @param max defines the color remap maximal range
  14783. * @returns the current particle system
  14784. */
  14785. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14786. /**
  14787. * Gets the current list of color remap gradients.
  14788. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14789. * @returns the list of color remap gradients
  14790. */
  14791. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14792. /**
  14793. * Adds a new alpha remap gradient
  14794. * @param gradient defines the gradient to use (between 0 and 1)
  14795. * @param min defines the alpha remap minimal range
  14796. * @param max defines the alpha remap maximal range
  14797. * @returns the current particle system
  14798. */
  14799. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14800. /**
  14801. * Gets the current list of alpha remap gradients.
  14802. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14803. * @returns the list of alpha remap gradients
  14804. */
  14805. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14806. /**
  14807. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14810. * @returns the emitter
  14811. */
  14812. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14813. /**
  14814. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14815. * @param radius The radius of the hemisphere to emit from
  14816. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14817. * @returns the emitter
  14818. */
  14819. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14820. /**
  14821. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14822. * @param radius The radius of the sphere to emit from
  14823. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14824. * @returns the emitter
  14825. */
  14826. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14827. /**
  14828. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14829. * @param radius The radius of the sphere to emit from
  14830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14832. * @returns the emitter
  14833. */
  14834. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14835. /**
  14836. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14837. * @param radius The radius of the emission cylinder
  14838. * @param height The height of the emission cylinder
  14839. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14840. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14841. * @returns the emitter
  14842. */
  14843. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14844. /**
  14845. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14846. * @param radius The radius of the cylinder to emit from
  14847. * @param height The height of the emission cylinder
  14848. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14849. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14850. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14851. * @returns the emitter
  14852. */
  14853. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14854. /**
  14855. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14856. * @param radius The radius of the cone to emit from
  14857. * @param angle The base angle of the cone
  14858. * @returns the emitter
  14859. */
  14860. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14861. /**
  14862. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14863. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14864. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14865. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14866. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14867. * @returns the emitter
  14868. */
  14869. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14870. /**
  14871. * Get hosting scene
  14872. * @returns the scene
  14873. */
  14874. getScene(): Scene;
  14875. }
  14876. }
  14877. declare module "babylonjs/Meshes/transformNode" {
  14878. import { DeepImmutable } from "babylonjs/types";
  14879. import { Observable } from "babylonjs/Misc/observable";
  14880. import { Nullable } from "babylonjs/types";
  14881. import { Camera } from "babylonjs/Cameras/camera";
  14882. import { Scene } from "babylonjs/scene";
  14883. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14884. import { Node } from "babylonjs/node";
  14885. import { Bone } from "babylonjs/Bones/bone";
  14886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14887. import { Space } from "babylonjs/Maths/math.axis";
  14888. /**
  14889. * 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.
  14890. * @see https://doc.babylonjs.com/how_to/transformnode
  14891. */
  14892. export class TransformNode extends Node {
  14893. /**
  14894. * Object will not rotate to face the camera
  14895. */
  14896. static BILLBOARDMODE_NONE: number;
  14897. /**
  14898. * Object will rotate to face the camera but only on the x axis
  14899. */
  14900. static BILLBOARDMODE_X: number;
  14901. /**
  14902. * Object will rotate to face the camera but only on the y axis
  14903. */
  14904. static BILLBOARDMODE_Y: number;
  14905. /**
  14906. * Object will rotate to face the camera but only on the z axis
  14907. */
  14908. static BILLBOARDMODE_Z: number;
  14909. /**
  14910. * Object will rotate to face the camera
  14911. */
  14912. static BILLBOARDMODE_ALL: number;
  14913. /**
  14914. * Object will rotate to face the camera's position instead of orientation
  14915. */
  14916. static BILLBOARDMODE_USE_POSITION: number;
  14917. private _forward;
  14918. private _forwardInverted;
  14919. private _up;
  14920. private _right;
  14921. private _rightInverted;
  14922. private _position;
  14923. private _rotation;
  14924. private _rotationQuaternion;
  14925. protected _scaling: Vector3;
  14926. protected _isDirty: boolean;
  14927. private _transformToBoneReferal;
  14928. private _isAbsoluteSynced;
  14929. private _billboardMode;
  14930. /**
  14931. * Gets or sets the billboard mode. Default is 0.
  14932. *
  14933. * | Value | Type | Description |
  14934. * | --- | --- | --- |
  14935. * | 0 | BILLBOARDMODE_NONE | |
  14936. * | 1 | BILLBOARDMODE_X | |
  14937. * | 2 | BILLBOARDMODE_Y | |
  14938. * | 4 | BILLBOARDMODE_Z | |
  14939. * | 7 | BILLBOARDMODE_ALL | |
  14940. *
  14941. */
  14942. get billboardMode(): number;
  14943. set billboardMode(value: number);
  14944. private _preserveParentRotationForBillboard;
  14945. /**
  14946. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14947. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14948. */
  14949. get preserveParentRotationForBillboard(): boolean;
  14950. set preserveParentRotationForBillboard(value: boolean);
  14951. /**
  14952. * 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
  14953. */
  14954. scalingDeterminant: number;
  14955. private _infiniteDistance;
  14956. /**
  14957. * Gets or sets the distance of the object to max, often used by skybox
  14958. */
  14959. get infiniteDistance(): boolean;
  14960. set infiniteDistance(value: boolean);
  14961. /**
  14962. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14963. * By default the system will update normals to compensate
  14964. */
  14965. ignoreNonUniformScaling: boolean;
  14966. /**
  14967. * 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
  14968. */
  14969. reIntegrateRotationIntoRotationQuaternion: boolean;
  14970. /** @hidden */
  14971. _poseMatrix: Nullable<Matrix>;
  14972. /** @hidden */
  14973. _localMatrix: Matrix;
  14974. private _usePivotMatrix;
  14975. private _absolutePosition;
  14976. private _absoluteScaling;
  14977. private _absoluteRotationQuaternion;
  14978. private _pivotMatrix;
  14979. private _pivotMatrixInverse;
  14980. protected _postMultiplyPivotMatrix: boolean;
  14981. protected _isWorldMatrixFrozen: boolean;
  14982. /** @hidden */
  14983. _indexInSceneTransformNodesArray: number;
  14984. /**
  14985. * An event triggered after the world matrix is updated
  14986. */
  14987. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14988. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14989. /**
  14990. * Gets a string identifying the name of the class
  14991. * @returns "TransformNode" string
  14992. */
  14993. getClassName(): string;
  14994. /**
  14995. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14996. */
  14997. get position(): Vector3;
  14998. set position(newPosition: Vector3);
  14999. /**
  15000. * 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)).
  15001. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15002. */
  15003. get rotation(): Vector3;
  15004. set rotation(newRotation: Vector3);
  15005. /**
  15006. * 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)).
  15007. */
  15008. get scaling(): Vector3;
  15009. set scaling(newScaling: Vector3);
  15010. /**
  15011. * 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).
  15012. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15013. */
  15014. get rotationQuaternion(): Nullable<Quaternion>;
  15015. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15016. /**
  15017. * The forward direction of that transform in world space.
  15018. */
  15019. get forward(): Vector3;
  15020. /**
  15021. * The up direction of that transform in world space.
  15022. */
  15023. get up(): Vector3;
  15024. /**
  15025. * The right direction of that transform in world space.
  15026. */
  15027. get right(): Vector3;
  15028. /**
  15029. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15030. * @param matrix the matrix to copy the pose from
  15031. * @returns this TransformNode.
  15032. */
  15033. updatePoseMatrix(matrix: Matrix): TransformNode;
  15034. /**
  15035. * Returns the mesh Pose matrix.
  15036. * @returns the pose matrix
  15037. */
  15038. getPoseMatrix(): Matrix;
  15039. /** @hidden */
  15040. _isSynchronized(): boolean;
  15041. /** @hidden */
  15042. _initCache(): void;
  15043. /**
  15044. * Flag the transform node as dirty (Forcing it to update everything)
  15045. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15046. * @returns this transform node
  15047. */
  15048. markAsDirty(property: string): TransformNode;
  15049. /**
  15050. * Returns the current mesh absolute position.
  15051. * Returns a Vector3.
  15052. */
  15053. get absolutePosition(): Vector3;
  15054. /**
  15055. * Returns the current mesh absolute scaling.
  15056. * Returns a Vector3.
  15057. */
  15058. get absoluteScaling(): Vector3;
  15059. /**
  15060. * Returns the current mesh absolute rotation.
  15061. * Returns a Quaternion.
  15062. */
  15063. get absoluteRotationQuaternion(): Quaternion;
  15064. /**
  15065. * Sets a new matrix to apply before all other transformation
  15066. * @param matrix defines the transform matrix
  15067. * @returns the current TransformNode
  15068. */
  15069. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15070. /**
  15071. * Sets a new pivot matrix to the current node
  15072. * @param matrix defines the new pivot matrix to use
  15073. * @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
  15074. * @returns the current TransformNode
  15075. */
  15076. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15077. /**
  15078. * Returns the mesh pivot matrix.
  15079. * Default : Identity.
  15080. * @returns the matrix
  15081. */
  15082. getPivotMatrix(): Matrix;
  15083. /**
  15084. * Instantiate (when possible) or clone that node with its hierarchy
  15085. * @param newParent defines the new parent to use for the instance (or clone)
  15086. * @param options defines options to configure how copy is done
  15087. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15088. * @returns an instance (or a clone) of the current node with its hiearchy
  15089. */
  15090. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15091. doNotInstantiate: boolean;
  15092. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15093. /**
  15094. * Prevents the World matrix to be computed any longer
  15095. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15096. * @returns the TransformNode.
  15097. */
  15098. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15099. /**
  15100. * Allows back the World matrix computation.
  15101. * @returns the TransformNode.
  15102. */
  15103. unfreezeWorldMatrix(): this;
  15104. /**
  15105. * True if the World matrix has been frozen.
  15106. */
  15107. get isWorldMatrixFrozen(): boolean;
  15108. /**
  15109. * Retuns the mesh absolute position in the World.
  15110. * @returns a Vector3.
  15111. */
  15112. getAbsolutePosition(): Vector3;
  15113. /**
  15114. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15115. * @param absolutePosition the absolute position to set
  15116. * @returns the TransformNode.
  15117. */
  15118. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15119. /**
  15120. * Sets the mesh position in its local space.
  15121. * @param vector3 the position to set in localspace
  15122. * @returns the TransformNode.
  15123. */
  15124. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15125. /**
  15126. * Returns the mesh position in the local space from the current World matrix values.
  15127. * @returns a new Vector3.
  15128. */
  15129. getPositionExpressedInLocalSpace(): Vector3;
  15130. /**
  15131. * Translates the mesh along the passed Vector3 in its local space.
  15132. * @param vector3 the distance to translate in localspace
  15133. * @returns the TransformNode.
  15134. */
  15135. locallyTranslate(vector3: Vector3): TransformNode;
  15136. private static _lookAtVectorCache;
  15137. /**
  15138. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15139. * @param targetPoint the position (must be in same space as current mesh) to look at
  15140. * @param yawCor optional yaw (y-axis) correction in radians
  15141. * @param pitchCor optional pitch (x-axis) correction in radians
  15142. * @param rollCor optional roll (z-axis) correction in radians
  15143. * @param space the choosen space of the target
  15144. * @returns the TransformNode.
  15145. */
  15146. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15147. /**
  15148. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15149. * This Vector3 is expressed in the World space.
  15150. * @param localAxis axis to rotate
  15151. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15152. */
  15153. getDirection(localAxis: Vector3): Vector3;
  15154. /**
  15155. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15156. * localAxis is expressed in the mesh local space.
  15157. * result is computed in the Wordl space from the mesh World matrix.
  15158. * @param localAxis axis to rotate
  15159. * @param result the resulting transformnode
  15160. * @returns this TransformNode.
  15161. */
  15162. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15163. /**
  15164. * Sets this transform node rotation to the given local axis.
  15165. * @param localAxis the axis in local space
  15166. * @param yawCor optional yaw (y-axis) correction in radians
  15167. * @param pitchCor optional pitch (x-axis) correction in radians
  15168. * @param rollCor optional roll (z-axis) correction in radians
  15169. * @returns this TransformNode
  15170. */
  15171. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15172. /**
  15173. * Sets a new pivot point to the current node
  15174. * @param point defines the new pivot point to use
  15175. * @param space defines if the point is in world or local space (local by default)
  15176. * @returns the current TransformNode
  15177. */
  15178. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15179. /**
  15180. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15181. * @returns the pivot point
  15182. */
  15183. getPivotPoint(): Vector3;
  15184. /**
  15185. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15186. * @param result the vector3 to store the result
  15187. * @returns this TransformNode.
  15188. */
  15189. getPivotPointToRef(result: Vector3): TransformNode;
  15190. /**
  15191. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15192. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15193. */
  15194. getAbsolutePivotPoint(): Vector3;
  15195. /**
  15196. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15197. * @param result vector3 to store the result
  15198. * @returns this TransformNode.
  15199. */
  15200. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15201. /**
  15202. * Defines the passed node as the parent of the current node.
  15203. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15204. * @see https://doc.babylonjs.com/how_to/parenting
  15205. * @param node the node ot set as the parent
  15206. * @returns this TransformNode.
  15207. */
  15208. setParent(node: Nullable<Node>): TransformNode;
  15209. private _nonUniformScaling;
  15210. /**
  15211. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15212. */
  15213. get nonUniformScaling(): boolean;
  15214. /** @hidden */
  15215. _updateNonUniformScalingState(value: boolean): boolean;
  15216. /**
  15217. * Attach the current TransformNode to another TransformNode associated with a bone
  15218. * @param bone Bone affecting the TransformNode
  15219. * @param affectedTransformNode TransformNode associated with the bone
  15220. * @returns this object
  15221. */
  15222. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15223. /**
  15224. * Detach the transform node if its associated with a bone
  15225. * @returns this object
  15226. */
  15227. detachFromBone(): TransformNode;
  15228. private static _rotationAxisCache;
  15229. /**
  15230. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15231. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15232. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15233. * The passed axis is also normalized.
  15234. * @param axis the axis to rotate around
  15235. * @param amount the amount to rotate in radians
  15236. * @param space Space to rotate in (Default: local)
  15237. * @returns the TransformNode.
  15238. */
  15239. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15240. /**
  15241. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15242. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15243. * The passed axis is also normalized. .
  15244. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15245. * @param point the point to rotate around
  15246. * @param axis the axis to rotate around
  15247. * @param amount the amount to rotate in radians
  15248. * @returns the TransformNode
  15249. */
  15250. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15251. /**
  15252. * Translates the mesh along the axis vector for the passed distance in the given space.
  15253. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15254. * @param axis the axis to translate in
  15255. * @param distance the distance to translate
  15256. * @param space Space to rotate in (Default: local)
  15257. * @returns the TransformNode.
  15258. */
  15259. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15260. /**
  15261. * Adds a rotation step to the mesh current rotation.
  15262. * x, y, z are Euler angles expressed in radians.
  15263. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15264. * This means this rotation is made in the mesh local space only.
  15265. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15266. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15267. * ```javascript
  15268. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15269. * ```
  15270. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15271. * 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.
  15272. * @param x Rotation to add
  15273. * @param y Rotation to add
  15274. * @param z Rotation to add
  15275. * @returns the TransformNode.
  15276. */
  15277. addRotation(x: number, y: number, z: number): TransformNode;
  15278. /**
  15279. * @hidden
  15280. */
  15281. protected _getEffectiveParent(): Nullable<Node>;
  15282. /**
  15283. * Computes the world matrix of the node
  15284. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15285. * @returns the world matrix
  15286. */
  15287. computeWorldMatrix(force?: boolean): Matrix;
  15288. /**
  15289. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15290. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15291. */
  15292. resetLocalMatrix(independentOfChildren?: boolean): void;
  15293. protected _afterComputeWorldMatrix(): void;
  15294. /**
  15295. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15296. * @param func callback function to add
  15297. *
  15298. * @returns the TransformNode.
  15299. */
  15300. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15301. /**
  15302. * Removes a registered callback function.
  15303. * @param func callback function to remove
  15304. * @returns the TransformNode.
  15305. */
  15306. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15307. /**
  15308. * Gets the position of the current mesh in camera space
  15309. * @param camera defines the camera to use
  15310. * @returns a position
  15311. */
  15312. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15313. /**
  15314. * Returns the distance from the mesh to the active camera
  15315. * @param camera defines the camera to use
  15316. * @returns the distance
  15317. */
  15318. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15319. /**
  15320. * Clone the current transform node
  15321. * @param name Name of the new clone
  15322. * @param newParent New parent for the clone
  15323. * @param doNotCloneChildren Do not clone children hierarchy
  15324. * @returns the new transform node
  15325. */
  15326. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15327. /**
  15328. * Serializes the objects information.
  15329. * @param currentSerializationObject defines the object to serialize in
  15330. * @returns the serialized object
  15331. */
  15332. serialize(currentSerializationObject?: any): any;
  15333. /**
  15334. * Returns a new TransformNode object parsed from the source provided.
  15335. * @param parsedTransformNode is the source.
  15336. * @param scene the scne the object belongs to
  15337. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15338. * @returns a new TransformNode object parsed from the source provided.
  15339. */
  15340. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15341. /**
  15342. * Get all child-transformNodes of this node
  15343. * @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
  15344. * @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
  15345. * @returns an array of TransformNode
  15346. */
  15347. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15348. /**
  15349. * Releases resources associated with this transform node.
  15350. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15351. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15352. */
  15353. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15354. /**
  15355. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15356. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15357. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15358. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15359. * @returns the current mesh
  15360. */
  15361. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15362. private _syncAbsoluteScalingAndRotation;
  15363. }
  15364. }
  15365. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15366. /**
  15367. * Class used to override all child animations of a given target
  15368. */
  15369. export class AnimationPropertiesOverride {
  15370. /**
  15371. * Gets or sets a value indicating if animation blending must be used
  15372. */
  15373. enableBlending: boolean;
  15374. /**
  15375. * Gets or sets the blending speed to use when enableBlending is true
  15376. */
  15377. blendingSpeed: number;
  15378. /**
  15379. * Gets or sets the default loop mode to use
  15380. */
  15381. loopMode: number;
  15382. }
  15383. }
  15384. declare module "babylonjs/Bones/bone" {
  15385. import { Skeleton } from "babylonjs/Bones/skeleton";
  15386. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15387. import { Nullable } from "babylonjs/types";
  15388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15389. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15390. import { Node } from "babylonjs/node";
  15391. import { Space } from "babylonjs/Maths/math.axis";
  15392. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15393. /**
  15394. * Class used to store bone information
  15395. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15396. */
  15397. export class Bone extends Node {
  15398. /**
  15399. * defines the bone name
  15400. */
  15401. name: string;
  15402. private static _tmpVecs;
  15403. private static _tmpQuat;
  15404. private static _tmpMats;
  15405. /**
  15406. * Gets the list of child bones
  15407. */
  15408. children: Bone[];
  15409. /** Gets the animations associated with this bone */
  15410. animations: import("babylonjs/Animations/animation").Animation[];
  15411. /**
  15412. * Gets or sets bone length
  15413. */
  15414. length: number;
  15415. /**
  15416. * @hidden Internal only
  15417. * Set this value to map this bone to a different index in the transform matrices
  15418. * Set this value to -1 to exclude the bone from the transform matrices
  15419. */
  15420. _index: Nullable<number>;
  15421. private _skeleton;
  15422. private _localMatrix;
  15423. private _restPose;
  15424. private _baseMatrix;
  15425. private _absoluteTransform;
  15426. private _invertedAbsoluteTransform;
  15427. private _parent;
  15428. private _scalingDeterminant;
  15429. private _worldTransform;
  15430. private _localScaling;
  15431. private _localRotation;
  15432. private _localPosition;
  15433. private _needToDecompose;
  15434. private _needToCompose;
  15435. /** @hidden */
  15436. _linkedTransformNode: Nullable<TransformNode>;
  15437. /** @hidden */
  15438. _waitingTransformNodeId: Nullable<string>;
  15439. /** @hidden */
  15440. get _matrix(): Matrix;
  15441. /** @hidden */
  15442. set _matrix(value: Matrix);
  15443. /**
  15444. * Create a new bone
  15445. * @param name defines the bone name
  15446. * @param skeleton defines the parent skeleton
  15447. * @param parentBone defines the parent (can be null if the bone is the root)
  15448. * @param localMatrix defines the local matrix
  15449. * @param restPose defines the rest pose matrix
  15450. * @param baseMatrix defines the base matrix
  15451. * @param index defines index of the bone in the hiearchy
  15452. */
  15453. constructor(
  15454. /**
  15455. * defines the bone name
  15456. */
  15457. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15458. /**
  15459. * Gets the current object class name.
  15460. * @return the class name
  15461. */
  15462. getClassName(): string;
  15463. /**
  15464. * Gets the parent skeleton
  15465. * @returns a skeleton
  15466. */
  15467. getSkeleton(): Skeleton;
  15468. /**
  15469. * Gets parent bone
  15470. * @returns a bone or null if the bone is the root of the bone hierarchy
  15471. */
  15472. getParent(): Nullable<Bone>;
  15473. /**
  15474. * Returns an array containing the root bones
  15475. * @returns an array containing the root bones
  15476. */
  15477. getChildren(): Array<Bone>;
  15478. /**
  15479. * Gets the node index in matrix array generated for rendering
  15480. * @returns the node index
  15481. */
  15482. getIndex(): number;
  15483. /**
  15484. * Sets the parent bone
  15485. * @param parent defines the parent (can be null if the bone is the root)
  15486. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15487. */
  15488. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15489. /**
  15490. * Gets the local matrix
  15491. * @returns a matrix
  15492. */
  15493. getLocalMatrix(): Matrix;
  15494. /**
  15495. * Gets the base matrix (initial matrix which remains unchanged)
  15496. * @returns a matrix
  15497. */
  15498. getBaseMatrix(): Matrix;
  15499. /**
  15500. * Gets the rest pose matrix
  15501. * @returns a matrix
  15502. */
  15503. getRestPose(): Matrix;
  15504. /**
  15505. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15506. */
  15507. getWorldMatrix(): Matrix;
  15508. /**
  15509. * Sets the local matrix to rest pose matrix
  15510. */
  15511. returnToRest(): void;
  15512. /**
  15513. * Gets the inverse of the absolute transform matrix.
  15514. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15515. * @returns a matrix
  15516. */
  15517. getInvertedAbsoluteTransform(): Matrix;
  15518. /**
  15519. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15520. * @returns a matrix
  15521. */
  15522. getAbsoluteTransform(): Matrix;
  15523. /**
  15524. * Links with the given transform node.
  15525. * The local matrix of this bone is copied from the transform node every frame.
  15526. * @param transformNode defines the transform node to link to
  15527. */
  15528. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15529. /**
  15530. * Gets the node used to drive the bone's transformation
  15531. * @returns a transform node or null
  15532. */
  15533. getTransformNode(): Nullable<TransformNode>;
  15534. /** Gets or sets current position (in local space) */
  15535. get position(): Vector3;
  15536. set position(newPosition: Vector3);
  15537. /** Gets or sets current rotation (in local space) */
  15538. get rotation(): Vector3;
  15539. set rotation(newRotation: Vector3);
  15540. /** Gets or sets current rotation quaternion (in local space) */
  15541. get rotationQuaternion(): Quaternion;
  15542. set rotationQuaternion(newRotation: Quaternion);
  15543. /** Gets or sets current scaling (in local space) */
  15544. get scaling(): Vector3;
  15545. set scaling(newScaling: Vector3);
  15546. /**
  15547. * Gets the animation properties override
  15548. */
  15549. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15550. private _decompose;
  15551. private _compose;
  15552. /**
  15553. * Update the base and local matrices
  15554. * @param matrix defines the new base or local matrix
  15555. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15556. * @param updateLocalMatrix defines if the local matrix should be updated
  15557. */
  15558. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15559. /** @hidden */
  15560. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15561. /**
  15562. * Flag the bone as dirty (Forcing it to update everything)
  15563. */
  15564. markAsDirty(): void;
  15565. /** @hidden */
  15566. _markAsDirtyAndCompose(): void;
  15567. private _markAsDirtyAndDecompose;
  15568. /**
  15569. * Translate the bone in local or world space
  15570. * @param vec The amount to translate the bone
  15571. * @param space The space that the translation is in
  15572. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15573. */
  15574. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15575. /**
  15576. * Set the postion of the bone in local or world space
  15577. * @param position The position to set the bone
  15578. * @param space The space that the position is in
  15579. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15580. */
  15581. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15582. /**
  15583. * Set the absolute position of the bone (world space)
  15584. * @param position The position to set the bone
  15585. * @param mesh The mesh that this bone is attached to
  15586. */
  15587. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15588. /**
  15589. * Scale the bone on the x, y and z axes (in local space)
  15590. * @param x The amount to scale the bone on the x axis
  15591. * @param y The amount to scale the bone on the y axis
  15592. * @param z The amount to scale the bone on the z axis
  15593. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15594. */
  15595. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15596. /**
  15597. * Set the bone scaling in local space
  15598. * @param scale defines the scaling vector
  15599. */
  15600. setScale(scale: Vector3): void;
  15601. /**
  15602. * Gets the current scaling in local space
  15603. * @returns the current scaling vector
  15604. */
  15605. getScale(): Vector3;
  15606. /**
  15607. * Gets the current scaling in local space and stores it in a target vector
  15608. * @param result defines the target vector
  15609. */
  15610. getScaleToRef(result: Vector3): void;
  15611. /**
  15612. * Set the yaw, pitch, and roll of the bone in local or world space
  15613. * @param yaw The rotation of the bone on the y axis
  15614. * @param pitch The rotation of the bone on the x axis
  15615. * @param roll The rotation of the bone on the z axis
  15616. * @param space The space that the axes of rotation are in
  15617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15618. */
  15619. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15620. /**
  15621. * Add a rotation to the bone on an axis in local or world space
  15622. * @param axis The axis to rotate the bone on
  15623. * @param amount The amount to rotate the bone
  15624. * @param space The space that the axis is in
  15625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15626. */
  15627. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15628. /**
  15629. * Set the rotation of the bone to a particular axis angle in local or world space
  15630. * @param axis The axis to rotate the bone on
  15631. * @param angle The angle that the bone should be rotated to
  15632. * @param space The space that the axis is in
  15633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15634. */
  15635. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15636. /**
  15637. * Set the euler rotation of the bone in local of world space
  15638. * @param rotation The euler rotation that the bone should be set to
  15639. * @param space The space that the rotation is in
  15640. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15641. */
  15642. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15643. /**
  15644. * Set the quaternion rotation of the bone in local of world space
  15645. * @param quat The quaternion rotation that the bone should be set to
  15646. * @param space The space that the rotation is in
  15647. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15648. */
  15649. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15650. /**
  15651. * Set the rotation matrix of the bone in local of world space
  15652. * @param rotMat The rotation matrix that the bone should be set to
  15653. * @param space The space that the rotation is in
  15654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15655. */
  15656. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15657. private _rotateWithMatrix;
  15658. private _getNegativeRotationToRef;
  15659. /**
  15660. * Get the position of the bone in local or world space
  15661. * @param space The space that the returned position is in
  15662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15663. * @returns The position of the bone
  15664. */
  15665. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15666. /**
  15667. * Copy the position of the bone to a vector3 in local or world space
  15668. * @param space The space that the returned position is in
  15669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15670. * @param result The vector3 to copy the position to
  15671. */
  15672. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15673. /**
  15674. * Get the absolute position of the bone (world space)
  15675. * @param mesh The mesh that this bone is attached to
  15676. * @returns The absolute position of the bone
  15677. */
  15678. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15679. /**
  15680. * Copy the absolute position of the bone (world space) to the result param
  15681. * @param mesh The mesh that this bone is attached to
  15682. * @param result The vector3 to copy the absolute position to
  15683. */
  15684. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15685. /**
  15686. * Compute the absolute transforms of this bone and its children
  15687. */
  15688. computeAbsoluteTransforms(): void;
  15689. /**
  15690. * Get the world direction from an axis that is in the local space of the bone
  15691. * @param localAxis The local direction that is used to compute the world direction
  15692. * @param mesh The mesh that this bone is attached to
  15693. * @returns The world direction
  15694. */
  15695. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15696. /**
  15697. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15698. * @param localAxis The local direction that is used to compute the world direction
  15699. * @param mesh The mesh that this bone is attached to
  15700. * @param result The vector3 that the world direction will be copied to
  15701. */
  15702. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15703. /**
  15704. * Get the euler rotation of the bone in local or world space
  15705. * @param space The space that the rotation should be in
  15706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15707. * @returns The euler rotation
  15708. */
  15709. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15710. /**
  15711. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15712. * @param space The space that the rotation should be in
  15713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15714. * @param result The vector3 that the rotation should be copied to
  15715. */
  15716. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15717. /**
  15718. * Get the quaternion rotation of the bone in either local or world space
  15719. * @param space The space that the rotation should be in
  15720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15721. * @returns The quaternion rotation
  15722. */
  15723. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15724. /**
  15725. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15726. * @param space The space that the rotation should be in
  15727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15728. * @param result The quaternion that the rotation should be copied to
  15729. */
  15730. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15731. /**
  15732. * Get the rotation matrix of the bone in local or world space
  15733. * @param space The space that the rotation should be in
  15734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15735. * @returns The rotation matrix
  15736. */
  15737. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15738. /**
  15739. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15740. * @param space The space that the rotation should be in
  15741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15742. * @param result The quaternion that the rotation should be copied to
  15743. */
  15744. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15745. /**
  15746. * Get the world position of a point that is in the local space of the bone
  15747. * @param position The local position
  15748. * @param mesh The mesh that this bone is attached to
  15749. * @returns The world position
  15750. */
  15751. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15752. /**
  15753. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15754. * @param position The local position
  15755. * @param mesh The mesh that this bone is attached to
  15756. * @param result The vector3 that the world position should be copied to
  15757. */
  15758. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15759. /**
  15760. * Get the local position of a point that is in world space
  15761. * @param position The world position
  15762. * @param mesh The mesh that this bone is attached to
  15763. * @returns The local position
  15764. */
  15765. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15766. /**
  15767. * Get the local position of a point that is in world space and copy it to the result param
  15768. * @param position The world position
  15769. * @param mesh The mesh that this bone is attached to
  15770. * @param result The vector3 that the local position should be copied to
  15771. */
  15772. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15773. }
  15774. }
  15775. declare module "babylonjs/Animations/runtimeAnimation" {
  15776. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15777. import { Animatable } from "babylonjs/Animations/animatable";
  15778. import { Scene } from "babylonjs/scene";
  15779. /**
  15780. * Defines a runtime animation
  15781. */
  15782. export class RuntimeAnimation {
  15783. private _events;
  15784. /**
  15785. * The current frame of the runtime animation
  15786. */
  15787. private _currentFrame;
  15788. /**
  15789. * The animation used by the runtime animation
  15790. */
  15791. private _animation;
  15792. /**
  15793. * The target of the runtime animation
  15794. */
  15795. private _target;
  15796. /**
  15797. * The initiating animatable
  15798. */
  15799. private _host;
  15800. /**
  15801. * The original value of the runtime animation
  15802. */
  15803. private _originalValue;
  15804. /**
  15805. * The original blend value of the runtime animation
  15806. */
  15807. private _originalBlendValue;
  15808. /**
  15809. * The offsets cache of the runtime animation
  15810. */
  15811. private _offsetsCache;
  15812. /**
  15813. * The high limits cache of the runtime animation
  15814. */
  15815. private _highLimitsCache;
  15816. /**
  15817. * Specifies if the runtime animation has been stopped
  15818. */
  15819. private _stopped;
  15820. /**
  15821. * The blending factor of the runtime animation
  15822. */
  15823. private _blendingFactor;
  15824. /**
  15825. * The BabylonJS scene
  15826. */
  15827. private _scene;
  15828. /**
  15829. * The current value of the runtime animation
  15830. */
  15831. private _currentValue;
  15832. /** @hidden */
  15833. _animationState: _IAnimationState;
  15834. /**
  15835. * The active target of the runtime animation
  15836. */
  15837. private _activeTargets;
  15838. private _currentActiveTarget;
  15839. private _directTarget;
  15840. /**
  15841. * The target path of the runtime animation
  15842. */
  15843. private _targetPath;
  15844. /**
  15845. * The weight of the runtime animation
  15846. */
  15847. private _weight;
  15848. /**
  15849. * The ratio offset of the runtime animation
  15850. */
  15851. private _ratioOffset;
  15852. /**
  15853. * The previous delay of the runtime animation
  15854. */
  15855. private _previousDelay;
  15856. /**
  15857. * The previous ratio of the runtime animation
  15858. */
  15859. private _previousRatio;
  15860. private _enableBlending;
  15861. private _keys;
  15862. private _minFrame;
  15863. private _maxFrame;
  15864. private _minValue;
  15865. private _maxValue;
  15866. private _targetIsArray;
  15867. /**
  15868. * Gets the current frame of the runtime animation
  15869. */
  15870. get currentFrame(): number;
  15871. /**
  15872. * Gets the weight of the runtime animation
  15873. */
  15874. get weight(): number;
  15875. /**
  15876. * Gets the current value of the runtime animation
  15877. */
  15878. get currentValue(): any;
  15879. /**
  15880. * Gets the target path of the runtime animation
  15881. */
  15882. get targetPath(): string;
  15883. /**
  15884. * Gets the actual target of the runtime animation
  15885. */
  15886. get target(): any;
  15887. /**
  15888. * Gets the additive state of the runtime animation
  15889. */
  15890. get isAdditive(): boolean;
  15891. /** @hidden */
  15892. _onLoop: () => void;
  15893. /**
  15894. * Create a new RuntimeAnimation object
  15895. * @param target defines the target of the animation
  15896. * @param animation defines the source animation object
  15897. * @param scene defines the hosting scene
  15898. * @param host defines the initiating Animatable
  15899. */
  15900. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15901. private _preparePath;
  15902. /**
  15903. * Gets the animation from the runtime animation
  15904. */
  15905. get animation(): Animation;
  15906. /**
  15907. * Resets the runtime animation to the beginning
  15908. * @param restoreOriginal defines whether to restore the target property to the original value
  15909. */
  15910. reset(restoreOriginal?: boolean): void;
  15911. /**
  15912. * Specifies if the runtime animation is stopped
  15913. * @returns Boolean specifying if the runtime animation is stopped
  15914. */
  15915. isStopped(): boolean;
  15916. /**
  15917. * Disposes of the runtime animation
  15918. */
  15919. dispose(): void;
  15920. /**
  15921. * Apply the interpolated value to the target
  15922. * @param currentValue defines the value computed by the animation
  15923. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15924. */
  15925. setValue(currentValue: any, weight: number): void;
  15926. private _getOriginalValues;
  15927. private _setValue;
  15928. /**
  15929. * Gets the loop pmode of the runtime animation
  15930. * @returns Loop Mode
  15931. */
  15932. private _getCorrectLoopMode;
  15933. /**
  15934. * Move the current animation to a given frame
  15935. * @param frame defines the frame to move to
  15936. */
  15937. goToFrame(frame: number): void;
  15938. /**
  15939. * @hidden Internal use only
  15940. */
  15941. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15942. /**
  15943. * Execute the current animation
  15944. * @param delay defines the delay to add to the current frame
  15945. * @param from defines the lower bound of the animation range
  15946. * @param to defines the upper bound of the animation range
  15947. * @param loop defines if the current animation must loop
  15948. * @param speedRatio defines the current speed ratio
  15949. * @param weight defines the weight of the animation (default is -1 so no weight)
  15950. * @param onLoop optional callback called when animation loops
  15951. * @returns a boolean indicating if the animation is running
  15952. */
  15953. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15954. }
  15955. }
  15956. declare module "babylonjs/Animations/animatable" {
  15957. import { Animation } from "babylonjs/Animations/animation";
  15958. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15959. import { Nullable } from "babylonjs/types";
  15960. import { Observable } from "babylonjs/Misc/observable";
  15961. import { Scene } from "babylonjs/scene";
  15962. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15963. import { Node } from "babylonjs/node";
  15964. /**
  15965. * Class used to store an actual running animation
  15966. */
  15967. export class Animatable {
  15968. /** defines the target object */
  15969. target: any;
  15970. /** defines the starting frame number (default is 0) */
  15971. fromFrame: number;
  15972. /** defines the ending frame number (default is 100) */
  15973. toFrame: number;
  15974. /** defines if the animation must loop (default is false) */
  15975. loopAnimation: boolean;
  15976. /** defines a callback to call when animation ends if it is not looping */
  15977. onAnimationEnd?: (() => void) | null | undefined;
  15978. /** defines a callback to call when animation loops */
  15979. onAnimationLoop?: (() => void) | null | undefined;
  15980. /** defines whether the animation should be evaluated additively */
  15981. isAdditive: boolean;
  15982. private _localDelayOffset;
  15983. private _pausedDelay;
  15984. private _runtimeAnimations;
  15985. private _paused;
  15986. private _scene;
  15987. private _speedRatio;
  15988. private _weight;
  15989. private _syncRoot;
  15990. /**
  15991. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15992. * This will only apply for non looping animation (default is true)
  15993. */
  15994. disposeOnEnd: boolean;
  15995. /**
  15996. * Gets a boolean indicating if the animation has started
  15997. */
  15998. animationStarted: boolean;
  15999. /**
  16000. * Observer raised when the animation ends
  16001. */
  16002. onAnimationEndObservable: Observable<Animatable>;
  16003. /**
  16004. * Observer raised when the animation loops
  16005. */
  16006. onAnimationLoopObservable: Observable<Animatable>;
  16007. /**
  16008. * Gets the root Animatable used to synchronize and normalize animations
  16009. */
  16010. get syncRoot(): Nullable<Animatable>;
  16011. /**
  16012. * Gets the current frame of the first RuntimeAnimation
  16013. * Used to synchronize Animatables
  16014. */
  16015. get masterFrame(): number;
  16016. /**
  16017. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16018. */
  16019. get weight(): number;
  16020. set weight(value: number);
  16021. /**
  16022. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16023. */
  16024. get speedRatio(): number;
  16025. set speedRatio(value: number);
  16026. /**
  16027. * Creates a new Animatable
  16028. * @param scene defines the hosting scene
  16029. * @param target defines the target object
  16030. * @param fromFrame defines the starting frame number (default is 0)
  16031. * @param toFrame defines the ending frame number (default is 100)
  16032. * @param loopAnimation defines if the animation must loop (default is false)
  16033. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16034. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16035. * @param animations defines a group of animation to add to the new Animatable
  16036. * @param onAnimationLoop defines a callback to call when animation loops
  16037. * @param isAdditive defines whether the animation should be evaluated additively
  16038. */
  16039. constructor(scene: Scene,
  16040. /** defines the target object */
  16041. target: any,
  16042. /** defines the starting frame number (default is 0) */
  16043. fromFrame?: number,
  16044. /** defines the ending frame number (default is 100) */
  16045. toFrame?: number,
  16046. /** defines if the animation must loop (default is false) */
  16047. loopAnimation?: boolean, speedRatio?: number,
  16048. /** defines a callback to call when animation ends if it is not looping */
  16049. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16050. /** defines a callback to call when animation loops */
  16051. onAnimationLoop?: (() => void) | null | undefined,
  16052. /** defines whether the animation should be evaluated additively */
  16053. isAdditive?: boolean);
  16054. /**
  16055. * Synchronize and normalize current Animatable with a source Animatable
  16056. * This is useful when using animation weights and when animations are not of the same length
  16057. * @param root defines the root Animatable to synchronize with
  16058. * @returns the current Animatable
  16059. */
  16060. syncWith(root: Animatable): Animatable;
  16061. /**
  16062. * Gets the list of runtime animations
  16063. * @returns an array of RuntimeAnimation
  16064. */
  16065. getAnimations(): RuntimeAnimation[];
  16066. /**
  16067. * Adds more animations to the current animatable
  16068. * @param target defines the target of the animations
  16069. * @param animations defines the new animations to add
  16070. */
  16071. appendAnimations(target: any, animations: Animation[]): void;
  16072. /**
  16073. * Gets the source animation for a specific property
  16074. * @param property defines the propertyu to look for
  16075. * @returns null or the source animation for the given property
  16076. */
  16077. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16078. /**
  16079. * Gets the runtime animation for a specific property
  16080. * @param property defines the propertyu to look for
  16081. * @returns null or the runtime animation for the given property
  16082. */
  16083. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16084. /**
  16085. * Resets the animatable to its original state
  16086. */
  16087. reset(): void;
  16088. /**
  16089. * Allows the animatable to blend with current running animations
  16090. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16091. * @param blendingSpeed defines the blending speed to use
  16092. */
  16093. enableBlending(blendingSpeed: number): void;
  16094. /**
  16095. * Disable animation blending
  16096. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16097. */
  16098. disableBlending(): void;
  16099. /**
  16100. * Jump directly to a given frame
  16101. * @param frame defines the frame to jump to
  16102. */
  16103. goToFrame(frame: number): void;
  16104. /**
  16105. * Pause the animation
  16106. */
  16107. pause(): void;
  16108. /**
  16109. * Restart the animation
  16110. */
  16111. restart(): void;
  16112. private _raiseOnAnimationEnd;
  16113. /**
  16114. * Stop and delete the current animation
  16115. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16116. * @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)
  16117. */
  16118. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16119. /**
  16120. * Wait asynchronously for the animation to end
  16121. * @returns a promise which will be fullfilled when the animation ends
  16122. */
  16123. waitAsync(): Promise<Animatable>;
  16124. /** @hidden */
  16125. _animate(delay: number): boolean;
  16126. }
  16127. module "babylonjs/scene" {
  16128. interface Scene {
  16129. /** @hidden */
  16130. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16131. /** @hidden */
  16132. _processLateAnimationBindingsForMatrices(holder: {
  16133. totalWeight: number;
  16134. totalAdditiveWeight: number;
  16135. animations: RuntimeAnimation[];
  16136. additiveAnimations: RuntimeAnimation[];
  16137. originalValue: Matrix;
  16138. }): any;
  16139. /** @hidden */
  16140. _processLateAnimationBindingsForQuaternions(holder: {
  16141. totalWeight: number;
  16142. totalAdditiveWeight: number;
  16143. animations: RuntimeAnimation[];
  16144. additiveAnimations: RuntimeAnimation[];
  16145. originalValue: Quaternion;
  16146. }, refQuaternion: Quaternion): Quaternion;
  16147. /** @hidden */
  16148. _processLateAnimationBindings(): void;
  16149. /**
  16150. * Will start the animation sequence of a given target
  16151. * @param target defines the target
  16152. * @param from defines from which frame should animation start
  16153. * @param to defines until which frame should animation run.
  16154. * @param weight defines the weight to apply to the animation (1.0 by default)
  16155. * @param loop defines if the animation loops
  16156. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16157. * @param onAnimationEnd defines the function to be executed when the animation ends
  16158. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16159. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16160. * @param onAnimationLoop defines the callback to call when an animation loops
  16161. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16162. * @returns the animatable object created for this animation
  16163. */
  16164. 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;
  16165. /**
  16166. * Will start the animation sequence of a given target
  16167. * @param target defines the target
  16168. * @param from defines from which frame should animation start
  16169. * @param to defines until which frame should animation run.
  16170. * @param loop defines if the animation loops
  16171. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16172. * @param onAnimationEnd defines the function to be executed when the animation ends
  16173. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16174. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16175. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16176. * @param onAnimationLoop defines the callback to call when an animation loops
  16177. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16178. * @returns the animatable object created for this animation
  16179. */
  16180. 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;
  16181. /**
  16182. * Will start the animation sequence of a given target and its hierarchy
  16183. * @param target defines the target
  16184. * @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.
  16185. * @param from defines from which frame should animation start
  16186. * @param to defines until which frame should animation run.
  16187. * @param loop defines if the animation loops
  16188. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16189. * @param onAnimationEnd defines the function to be executed when the animation ends
  16190. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16191. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16192. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16193. * @param onAnimationLoop defines the callback to call when an animation loops
  16194. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16195. * @returns the list of created animatables
  16196. */
  16197. 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[];
  16198. /**
  16199. * Begin a new animation on a given node
  16200. * @param target defines the target where the animation will take place
  16201. * @param animations defines the list of animations to start
  16202. * @param from defines the initial value
  16203. * @param to defines the final value
  16204. * @param loop defines if you want animation to loop (off by default)
  16205. * @param speedRatio defines the speed ratio to apply to all animations
  16206. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16207. * @param onAnimationLoop defines the callback to call when an animation loops
  16208. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16209. * @returns the list of created animatables
  16210. */
  16211. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16212. /**
  16213. * Begin a new animation on a given node and its hierarchy
  16214. * @param target defines the root node where the animation will take place
  16215. * @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.
  16216. * @param animations defines the list of animations to start
  16217. * @param from defines the initial value
  16218. * @param to defines the final value
  16219. * @param loop defines if you want animation to loop (off by default)
  16220. * @param speedRatio defines the speed ratio to apply to all animations
  16221. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16222. * @param onAnimationLoop defines the callback to call when an animation loops
  16223. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16224. * @returns the list of animatables created for all nodes
  16225. */
  16226. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16227. /**
  16228. * Gets the animatable associated with a specific target
  16229. * @param target defines the target of the animatable
  16230. * @returns the required animatable if found
  16231. */
  16232. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16233. /**
  16234. * Gets all animatables associated with a given target
  16235. * @param target defines the target to look animatables for
  16236. * @returns an array of Animatables
  16237. */
  16238. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16239. /**
  16240. * Stops and removes all animations that have been applied to the scene
  16241. */
  16242. stopAllAnimations(): void;
  16243. /**
  16244. * Gets the current delta time used by animation engine
  16245. */
  16246. deltaTime: number;
  16247. }
  16248. }
  16249. module "babylonjs/Bones/bone" {
  16250. interface Bone {
  16251. /**
  16252. * Copy an animation range from another bone
  16253. * @param source defines the source bone
  16254. * @param rangeName defines the range name to copy
  16255. * @param frameOffset defines the frame offset
  16256. * @param rescaleAsRequired defines if rescaling must be applied if required
  16257. * @param skelDimensionsRatio defines the scaling ratio
  16258. * @returns true if operation was successful
  16259. */
  16260. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16261. }
  16262. }
  16263. }
  16264. declare module "babylonjs/Bones/skeleton" {
  16265. import { Bone } from "babylonjs/Bones/bone";
  16266. import { Observable } from "babylonjs/Misc/observable";
  16267. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16268. import { Scene } from "babylonjs/scene";
  16269. import { Nullable } from "babylonjs/types";
  16270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16271. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16272. import { Animatable } from "babylonjs/Animations/animatable";
  16273. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16274. import { Animation } from "babylonjs/Animations/animation";
  16275. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16276. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16277. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16278. /**
  16279. * Class used to handle skinning animations
  16280. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16281. */
  16282. export class Skeleton implements IAnimatable {
  16283. /** defines the skeleton name */
  16284. name: string;
  16285. /** defines the skeleton Id */
  16286. id: string;
  16287. /**
  16288. * Defines the list of child bones
  16289. */
  16290. bones: Bone[];
  16291. /**
  16292. * Defines an estimate of the dimension of the skeleton at rest
  16293. */
  16294. dimensionsAtRest: Vector3;
  16295. /**
  16296. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16297. */
  16298. needInitialSkinMatrix: boolean;
  16299. /**
  16300. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16301. */
  16302. overrideMesh: Nullable<AbstractMesh>;
  16303. /**
  16304. * Gets the list of animations attached to this skeleton
  16305. */
  16306. animations: Array<Animation>;
  16307. private _scene;
  16308. private _isDirty;
  16309. private _transformMatrices;
  16310. private _transformMatrixTexture;
  16311. private _meshesWithPoseMatrix;
  16312. private _animatables;
  16313. private _identity;
  16314. private _synchronizedWithMesh;
  16315. private _ranges;
  16316. private _lastAbsoluteTransformsUpdateId;
  16317. private _canUseTextureForBones;
  16318. private _uniqueId;
  16319. /** @hidden */
  16320. _numBonesWithLinkedTransformNode: number;
  16321. /** @hidden */
  16322. _hasWaitingData: Nullable<boolean>;
  16323. /**
  16324. * Specifies if the skeleton should be serialized
  16325. */
  16326. doNotSerialize: boolean;
  16327. private _useTextureToStoreBoneMatrices;
  16328. /**
  16329. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16330. * Please note that this option is not available if the hardware does not support it
  16331. */
  16332. get useTextureToStoreBoneMatrices(): boolean;
  16333. set useTextureToStoreBoneMatrices(value: boolean);
  16334. private _animationPropertiesOverride;
  16335. /**
  16336. * Gets or sets the animation properties override
  16337. */
  16338. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16339. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16340. /**
  16341. * List of inspectable custom properties (used by the Inspector)
  16342. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16343. */
  16344. inspectableCustomProperties: IInspectable[];
  16345. /**
  16346. * An observable triggered before computing the skeleton's matrices
  16347. */
  16348. onBeforeComputeObservable: Observable<Skeleton>;
  16349. /**
  16350. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16351. */
  16352. get isUsingTextureForMatrices(): boolean;
  16353. /**
  16354. * Gets the unique ID of this skeleton
  16355. */
  16356. get uniqueId(): number;
  16357. /**
  16358. * Creates a new skeleton
  16359. * @param name defines the skeleton name
  16360. * @param id defines the skeleton Id
  16361. * @param scene defines the hosting scene
  16362. */
  16363. constructor(
  16364. /** defines the skeleton name */
  16365. name: string,
  16366. /** defines the skeleton Id */
  16367. id: string, scene: Scene);
  16368. /**
  16369. * Gets the current object class name.
  16370. * @return the class name
  16371. */
  16372. getClassName(): string;
  16373. /**
  16374. * Returns an array containing the root bones
  16375. * @returns an array containing the root bones
  16376. */
  16377. getChildren(): Array<Bone>;
  16378. /**
  16379. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16380. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16381. * @returns a Float32Array containing matrices data
  16382. */
  16383. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16384. /**
  16385. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16386. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16387. * @returns a raw texture containing the data
  16388. */
  16389. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16390. /**
  16391. * Gets the current hosting scene
  16392. * @returns a scene object
  16393. */
  16394. getScene(): Scene;
  16395. /**
  16396. * Gets a string representing the current skeleton data
  16397. * @param fullDetails defines a boolean indicating if we want a verbose version
  16398. * @returns a string representing the current skeleton data
  16399. */
  16400. toString(fullDetails?: boolean): string;
  16401. /**
  16402. * Get bone's index searching by name
  16403. * @param name defines bone's name to search for
  16404. * @return the indice of the bone. Returns -1 if not found
  16405. */
  16406. getBoneIndexByName(name: string): number;
  16407. /**
  16408. * Creater a new animation range
  16409. * @param name defines the name of the range
  16410. * @param from defines the start key
  16411. * @param to defines the end key
  16412. */
  16413. createAnimationRange(name: string, from: number, to: number): void;
  16414. /**
  16415. * Delete a specific animation range
  16416. * @param name defines the name of the range
  16417. * @param deleteFrames defines if frames must be removed as well
  16418. */
  16419. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16420. /**
  16421. * Gets a specific animation range
  16422. * @param name defines the name of the range to look for
  16423. * @returns the requested animation range or null if not found
  16424. */
  16425. getAnimationRange(name: string): Nullable<AnimationRange>;
  16426. /**
  16427. * Gets the list of all animation ranges defined on this skeleton
  16428. * @returns an array
  16429. */
  16430. getAnimationRanges(): Nullable<AnimationRange>[];
  16431. /**
  16432. * Copy animation range from a source skeleton.
  16433. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16434. * @param source defines the source skeleton
  16435. * @param name defines the name of the range to copy
  16436. * @param rescaleAsRequired defines if rescaling must be applied if required
  16437. * @returns true if operation was successful
  16438. */
  16439. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16440. /**
  16441. * Forces the skeleton to go to rest pose
  16442. */
  16443. returnToRest(): void;
  16444. private _getHighestAnimationFrame;
  16445. /**
  16446. * Begin a specific animation range
  16447. * @param name defines the name of the range to start
  16448. * @param loop defines if looping must be turned on (false by default)
  16449. * @param speedRatio defines the speed ratio to apply (1 by default)
  16450. * @param onAnimationEnd defines a callback which will be called when animation will end
  16451. * @returns a new animatable
  16452. */
  16453. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16454. /**
  16455. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16456. * @param skeleton defines the Skeleton containing the animation range to convert
  16457. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16458. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16459. * @returns the original skeleton
  16460. */
  16461. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16462. /** @hidden */
  16463. _markAsDirty(): void;
  16464. /** @hidden */
  16465. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16466. /** @hidden */
  16467. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16468. private _computeTransformMatrices;
  16469. /**
  16470. * Build all resources required to render a skeleton
  16471. */
  16472. prepare(): void;
  16473. /**
  16474. * Gets the list of animatables currently running for this skeleton
  16475. * @returns an array of animatables
  16476. */
  16477. getAnimatables(): IAnimatable[];
  16478. /**
  16479. * Clone the current skeleton
  16480. * @param name defines the name of the new skeleton
  16481. * @param id defines the id of the new skeleton
  16482. * @returns the new skeleton
  16483. */
  16484. clone(name: string, id?: string): Skeleton;
  16485. /**
  16486. * Enable animation blending for this skeleton
  16487. * @param blendingSpeed defines the blending speed to apply
  16488. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16489. */
  16490. enableBlending(blendingSpeed?: number): void;
  16491. /**
  16492. * Releases all resources associated with the current skeleton
  16493. */
  16494. dispose(): void;
  16495. /**
  16496. * Serialize the skeleton in a JSON object
  16497. * @returns a JSON object
  16498. */
  16499. serialize(): any;
  16500. /**
  16501. * Creates a new skeleton from serialized data
  16502. * @param parsedSkeleton defines the serialized data
  16503. * @param scene defines the hosting scene
  16504. * @returns a new skeleton
  16505. */
  16506. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16507. /**
  16508. * Compute all node absolute transforms
  16509. * @param forceUpdate defines if computation must be done even if cache is up to date
  16510. */
  16511. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16512. /**
  16513. * Gets the root pose matrix
  16514. * @returns a matrix
  16515. */
  16516. getPoseMatrix(): Nullable<Matrix>;
  16517. /**
  16518. * Sorts bones per internal index
  16519. */
  16520. sortBones(): void;
  16521. private _sortBones;
  16522. }
  16523. }
  16524. declare module "babylonjs/Meshes/instancedMesh" {
  16525. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16526. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16527. import { Camera } from "babylonjs/Cameras/camera";
  16528. import { Node } from "babylonjs/node";
  16529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16530. import { Mesh } from "babylonjs/Meshes/mesh";
  16531. import { Material } from "babylonjs/Materials/material";
  16532. import { Skeleton } from "babylonjs/Bones/skeleton";
  16533. import { Light } from "babylonjs/Lights/light";
  16534. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16535. /**
  16536. * Creates an instance based on a source mesh.
  16537. */
  16538. export class InstancedMesh extends AbstractMesh {
  16539. private _sourceMesh;
  16540. private _currentLOD;
  16541. /** @hidden */
  16542. _indexInSourceMeshInstanceArray: number;
  16543. constructor(name: string, source: Mesh);
  16544. /**
  16545. * Returns the string "InstancedMesh".
  16546. */
  16547. getClassName(): string;
  16548. /** Gets the list of lights affecting that mesh */
  16549. get lightSources(): Light[];
  16550. _resyncLightSources(): void;
  16551. _resyncLightSource(light: Light): void;
  16552. _removeLightSource(light: Light, dispose: boolean): void;
  16553. /**
  16554. * If the source mesh receives shadows
  16555. */
  16556. get receiveShadows(): boolean;
  16557. /**
  16558. * The material of the source mesh
  16559. */
  16560. get material(): Nullable<Material>;
  16561. /**
  16562. * Visibility of the source mesh
  16563. */
  16564. get visibility(): number;
  16565. /**
  16566. * Skeleton of the source mesh
  16567. */
  16568. get skeleton(): Nullable<Skeleton>;
  16569. /**
  16570. * Rendering ground id of the source mesh
  16571. */
  16572. get renderingGroupId(): number;
  16573. set renderingGroupId(value: number);
  16574. /**
  16575. * Returns the total number of vertices (integer).
  16576. */
  16577. getTotalVertices(): number;
  16578. /**
  16579. * Returns a positive integer : the total number of indices in this mesh geometry.
  16580. * @returns the numner of indices or zero if the mesh has no geometry.
  16581. */
  16582. getTotalIndices(): number;
  16583. /**
  16584. * The source mesh of the instance
  16585. */
  16586. get sourceMesh(): Mesh;
  16587. /**
  16588. * Creates a new InstancedMesh object from the mesh model.
  16589. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16590. * @param name defines the name of the new instance
  16591. * @returns a new InstancedMesh
  16592. */
  16593. createInstance(name: string): InstancedMesh;
  16594. /**
  16595. * Is this node ready to be used/rendered
  16596. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16597. * @return {boolean} is it ready
  16598. */
  16599. isReady(completeCheck?: boolean): boolean;
  16600. /**
  16601. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16602. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16603. * @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.
  16604. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16605. */
  16606. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16607. /**
  16608. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16609. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16610. * The `data` are either a numeric array either a Float32Array.
  16611. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16612. * 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).
  16613. * Note that a new underlying VertexBuffer object is created each call.
  16614. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16615. *
  16616. * Possible `kind` values :
  16617. * - VertexBuffer.PositionKind
  16618. * - VertexBuffer.UVKind
  16619. * - VertexBuffer.UV2Kind
  16620. * - VertexBuffer.UV3Kind
  16621. * - VertexBuffer.UV4Kind
  16622. * - VertexBuffer.UV5Kind
  16623. * - VertexBuffer.UV6Kind
  16624. * - VertexBuffer.ColorKind
  16625. * - VertexBuffer.MatricesIndicesKind
  16626. * - VertexBuffer.MatricesIndicesExtraKind
  16627. * - VertexBuffer.MatricesWeightsKind
  16628. * - VertexBuffer.MatricesWeightsExtraKind
  16629. *
  16630. * Returns the Mesh.
  16631. */
  16632. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16633. /**
  16634. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16635. * If the mesh has no geometry, it is simply returned as it is.
  16636. * The `data` are either a numeric array either a Float32Array.
  16637. * No new underlying VertexBuffer object is created.
  16638. * 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.
  16639. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16640. *
  16641. * Possible `kind` values :
  16642. * - VertexBuffer.PositionKind
  16643. * - VertexBuffer.UVKind
  16644. * - VertexBuffer.UV2Kind
  16645. * - VertexBuffer.UV3Kind
  16646. * - VertexBuffer.UV4Kind
  16647. * - VertexBuffer.UV5Kind
  16648. * - VertexBuffer.UV6Kind
  16649. * - VertexBuffer.ColorKind
  16650. * - VertexBuffer.MatricesIndicesKind
  16651. * - VertexBuffer.MatricesIndicesExtraKind
  16652. * - VertexBuffer.MatricesWeightsKind
  16653. * - VertexBuffer.MatricesWeightsExtraKind
  16654. *
  16655. * Returns the Mesh.
  16656. */
  16657. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16658. /**
  16659. * Sets the mesh indices.
  16660. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16661. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16662. * This method creates a new index buffer each call.
  16663. * Returns the Mesh.
  16664. */
  16665. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16666. /**
  16667. * Boolean : True if the mesh owns the requested kind of data.
  16668. */
  16669. isVerticesDataPresent(kind: string): boolean;
  16670. /**
  16671. * Returns an array of indices (IndicesArray).
  16672. */
  16673. getIndices(): Nullable<IndicesArray>;
  16674. get _positions(): Nullable<Vector3[]>;
  16675. /**
  16676. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16677. * This means the mesh underlying bounding box and sphere are recomputed.
  16678. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16679. * @returns the current mesh
  16680. */
  16681. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16682. /** @hidden */
  16683. _preActivate(): InstancedMesh;
  16684. /** @hidden */
  16685. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16686. /** @hidden */
  16687. _postActivate(): void;
  16688. getWorldMatrix(): Matrix;
  16689. get isAnInstance(): boolean;
  16690. /**
  16691. * Returns the current associated LOD AbstractMesh.
  16692. */
  16693. getLOD(camera: Camera): AbstractMesh;
  16694. /** @hidden */
  16695. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16696. /** @hidden */
  16697. _syncSubMeshes(): InstancedMesh;
  16698. /** @hidden */
  16699. _generatePointsArray(): boolean;
  16700. /**
  16701. * Creates a new InstancedMesh from the current mesh.
  16702. * - name (string) : the cloned mesh name
  16703. * - newParent (optional Node) : the optional Node to parent the clone to.
  16704. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16705. *
  16706. * Returns the clone.
  16707. */
  16708. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16709. /**
  16710. * Disposes the InstancedMesh.
  16711. * Returns nothing.
  16712. */
  16713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16714. }
  16715. module "babylonjs/Meshes/mesh" {
  16716. interface Mesh {
  16717. /**
  16718. * Register a custom buffer that will be instanced
  16719. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16720. * @param kind defines the buffer kind
  16721. * @param stride defines the stride in floats
  16722. */
  16723. registerInstancedBuffer(kind: string, stride: number): void;
  16724. /** @hidden */
  16725. _userInstancedBuffersStorage: {
  16726. data: {
  16727. [key: string]: Float32Array;
  16728. };
  16729. sizes: {
  16730. [key: string]: number;
  16731. };
  16732. vertexBuffers: {
  16733. [key: string]: Nullable<VertexBuffer>;
  16734. };
  16735. strides: {
  16736. [key: string]: number;
  16737. };
  16738. };
  16739. }
  16740. }
  16741. module "babylonjs/Meshes/abstractMesh" {
  16742. interface AbstractMesh {
  16743. /**
  16744. * Object used to store instanced buffers defined by user
  16745. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16746. */
  16747. instancedBuffers: {
  16748. [key: string]: any;
  16749. };
  16750. }
  16751. }
  16752. }
  16753. declare module "babylonjs/Materials/shaderMaterial" {
  16754. import { Nullable } from "babylonjs/types";
  16755. import { Scene } from "babylonjs/scene";
  16756. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16758. import { Mesh } from "babylonjs/Meshes/mesh";
  16759. import { SubMesh, BaseSubMesh } from "babylonjs/Meshes/subMesh";
  16760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16761. import { Effect } from "babylonjs/Materials/effect";
  16762. import { Material } from "babylonjs/Materials/material";
  16763. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16764. /**
  16765. * Defines the options associated with the creation of a shader material.
  16766. */
  16767. export interface IShaderMaterialOptions {
  16768. /**
  16769. * Does the material work in alpha blend mode
  16770. */
  16771. needAlphaBlending: boolean;
  16772. /**
  16773. * Does the material work in alpha test mode
  16774. */
  16775. needAlphaTesting: boolean;
  16776. /**
  16777. * The list of attribute names used in the shader
  16778. */
  16779. attributes: string[];
  16780. /**
  16781. * The list of unifrom names used in the shader
  16782. */
  16783. uniforms: string[];
  16784. /**
  16785. * The list of UBO names used in the shader
  16786. */
  16787. uniformBuffers: string[];
  16788. /**
  16789. * The list of sampler names used in the shader
  16790. */
  16791. samplers: string[];
  16792. /**
  16793. * The list of defines used in the shader
  16794. */
  16795. defines: string[];
  16796. }
  16797. /**
  16798. * 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.
  16799. *
  16800. * This returned material effects how the mesh will look based on the code in the shaders.
  16801. *
  16802. * @see http://doc.babylonjs.com/how_to/shader_material
  16803. */
  16804. export class ShaderMaterial extends Material {
  16805. private _shaderPath;
  16806. private _options;
  16807. private _textures;
  16808. private _textureArrays;
  16809. private _floats;
  16810. private _ints;
  16811. private _floatsArrays;
  16812. private _colors3;
  16813. private _colors3Arrays;
  16814. private _colors4;
  16815. private _colors4Arrays;
  16816. private _vectors2;
  16817. private _vectors3;
  16818. private _vectors4;
  16819. private _matrices;
  16820. private _matrixArrays;
  16821. private _matrices3x3;
  16822. private _matrices2x2;
  16823. private _vectors2Arrays;
  16824. private _vectors3Arrays;
  16825. private _vectors4Arrays;
  16826. private _cachedWorldViewMatrix;
  16827. private _cachedWorldViewProjectionMatrix;
  16828. private _renderId;
  16829. private _multiview;
  16830. private _cachedDefines;
  16831. /**
  16832. * Instantiate a new shader material.
  16833. * 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.
  16834. * This returned material effects how the mesh will look based on the code in the shaders.
  16835. * @see http://doc.babylonjs.com/how_to/shader_material
  16836. * @param name Define the name of the material in the scene
  16837. * @param scene Define the scene the material belongs to
  16838. * @param shaderPath Defines the route to the shader code in one of three ways:
  16839. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16840. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16841. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16842. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16843. * @param options Define the options used to create the shader
  16844. */
  16845. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16846. /**
  16847. * Gets the shader path used to define the shader code
  16848. * It can be modified to trigger a new compilation
  16849. */
  16850. get shaderPath(): any;
  16851. /**
  16852. * Sets the shader path used to define the shader code
  16853. * It can be modified to trigger a new compilation
  16854. */
  16855. set shaderPath(shaderPath: any);
  16856. /**
  16857. * Gets the options used to compile the shader.
  16858. * They can be modified to trigger a new compilation
  16859. */
  16860. get options(): IShaderMaterialOptions;
  16861. /**
  16862. * Gets the current class name of the material e.g. "ShaderMaterial"
  16863. * Mainly use in serialization.
  16864. * @returns the class name
  16865. */
  16866. getClassName(): string;
  16867. /**
  16868. * Specifies if the material will require alpha blending
  16869. * @returns a boolean specifying if alpha blending is needed
  16870. */
  16871. needAlphaBlending(): boolean;
  16872. /**
  16873. * Specifies if this material should be rendered in alpha test mode
  16874. * @returns a boolean specifying if an alpha test is needed.
  16875. */
  16876. needAlphaTesting(): boolean;
  16877. private _checkUniform;
  16878. /**
  16879. * Set a texture in the shader.
  16880. * @param name Define the name of the uniform samplers as defined in the shader
  16881. * @param texture Define the texture to bind to this sampler
  16882. * @return the material itself allowing "fluent" like uniform updates
  16883. */
  16884. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16885. /**
  16886. * Set a texture array in the shader.
  16887. * @param name Define the name of the uniform sampler array as defined in the shader
  16888. * @param textures Define the list of textures to bind to this sampler
  16889. * @return the material itself allowing "fluent" like uniform updates
  16890. */
  16891. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16892. /**
  16893. * Set a float in the shader.
  16894. * @param name Define the name of the uniform as defined in the shader
  16895. * @param value Define the value to give to the uniform
  16896. * @return the material itself allowing "fluent" like uniform updates
  16897. */
  16898. setFloat(name: string, value: number): ShaderMaterial;
  16899. /**
  16900. * Set a int in the shader.
  16901. * @param name Define the name of the uniform as defined in the shader
  16902. * @param value Define the value to give to the uniform
  16903. * @return the material itself allowing "fluent" like uniform updates
  16904. */
  16905. setInt(name: string, value: number): ShaderMaterial;
  16906. /**
  16907. * Set an array of floats in the shader.
  16908. * @param name Define the name of the uniform as defined in the shader
  16909. * @param value Define the value to give to the uniform
  16910. * @return the material itself allowing "fluent" like uniform updates
  16911. */
  16912. setFloats(name: string, value: number[]): ShaderMaterial;
  16913. /**
  16914. * Set a vec3 in the shader from a Color3.
  16915. * @param name Define the name of the uniform as defined in the shader
  16916. * @param value Define the value to give to the uniform
  16917. * @return the material itself allowing "fluent" like uniform updates
  16918. */
  16919. setColor3(name: string, value: Color3): ShaderMaterial;
  16920. /**
  16921. * Set a vec3 array in the shader from a Color3 array.
  16922. * @param name Define the name of the uniform as defined in the shader
  16923. * @param value Define the value to give to the uniform
  16924. * @return the material itself allowing "fluent" like uniform updates
  16925. */
  16926. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16927. /**
  16928. * Set a vec4 in the shader from a Color4.
  16929. * @param name Define the name of the uniform as defined in the shader
  16930. * @param value Define the value to give to the uniform
  16931. * @return the material itself allowing "fluent" like uniform updates
  16932. */
  16933. setColor4(name: string, value: Color4): ShaderMaterial;
  16934. /**
  16935. * Set a vec4 array in the shader from a Color4 array.
  16936. * @param name Define the name of the uniform as defined in the shader
  16937. * @param value Define the value to give to the uniform
  16938. * @return the material itself allowing "fluent" like uniform updates
  16939. */
  16940. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16941. /**
  16942. * Set a vec2 in the shader from a Vector2.
  16943. * @param name Define the name of the uniform as defined in the shader
  16944. * @param value Define the value to give to the uniform
  16945. * @return the material itself allowing "fluent" like uniform updates
  16946. */
  16947. setVector2(name: string, value: Vector2): ShaderMaterial;
  16948. /**
  16949. * Set a vec3 in the shader from a Vector3.
  16950. * @param name Define the name of the uniform as defined in the shader
  16951. * @param value Define the value to give to the uniform
  16952. * @return the material itself allowing "fluent" like uniform updates
  16953. */
  16954. setVector3(name: string, value: Vector3): ShaderMaterial;
  16955. /**
  16956. * Set a vec4 in the shader from a Vector4.
  16957. * @param name Define the name of the uniform as defined in the shader
  16958. * @param value Define the value to give to the uniform
  16959. * @return the material itself allowing "fluent" like uniform updates
  16960. */
  16961. setVector4(name: string, value: Vector4): ShaderMaterial;
  16962. /**
  16963. * Set a mat4 in the shader from a Matrix.
  16964. * @param name Define the name of the uniform as defined in the shader
  16965. * @param value Define the value to give to the uniform
  16966. * @return the material itself allowing "fluent" like uniform updates
  16967. */
  16968. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16969. /**
  16970. * Set a float32Array in the shader from a matrix array.
  16971. * @param name Define the name of the uniform as defined in the shader
  16972. * @param value Define the value to give to the uniform
  16973. * @return the material itself allowing "fluent" like uniform updates
  16974. */
  16975. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16976. /**
  16977. * Set a mat3 in the shader from a Float32Array.
  16978. * @param name Define the name of the uniform as defined in the shader
  16979. * @param value Define the value to give to the uniform
  16980. * @return the material itself allowing "fluent" like uniform updates
  16981. */
  16982. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16983. /**
  16984. * Set a mat2 in the shader from a Float32Array.
  16985. * @param name Define the name of the uniform as defined in the shader
  16986. * @param value Define the value to give to the uniform
  16987. * @return the material itself allowing "fluent" like uniform updates
  16988. */
  16989. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16990. /**
  16991. * Set a vec2 array in the shader from a number array.
  16992. * @param name Define the name of the uniform as defined in the shader
  16993. * @param value Define the value to give to the uniform
  16994. * @return the material itself allowing "fluent" like uniform updates
  16995. */
  16996. setArray2(name: string, value: number[]): ShaderMaterial;
  16997. /**
  16998. * Set a vec3 array in the shader from a number array.
  16999. * @param name Define the name of the uniform as defined in the shader
  17000. * @param value Define the value to give to the uniform
  17001. * @return the material itself allowing "fluent" like uniform updates
  17002. */
  17003. setArray3(name: string, value: number[]): ShaderMaterial;
  17004. /**
  17005. * Set a vec4 array in the shader from a number array.
  17006. * @param name Define the name of the uniform as defined in the shader
  17007. * @param value Define the value to give to the uniform
  17008. * @return the material itself allowing "fluent" like uniform updates
  17009. */
  17010. setArray4(name: string, value: number[]): ShaderMaterial;
  17011. private _checkCache;
  17012. /**
  17013. * Specifies that the submesh is ready to be used
  17014. * @param mesh defines the mesh to check
  17015. * @param subMesh defines which submesh to check
  17016. * @param useInstances specifies that instances should be used
  17017. * @returns a boolean indicating that the submesh is ready or not
  17018. */
  17019. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17020. /**
  17021. * Checks if the material is ready to render the requested mesh
  17022. * @param mesh Define the mesh to render
  17023. * @param useInstances Define whether or not the material is used with instances
  17024. * @returns true if ready, otherwise false
  17025. */
  17026. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17027. /**
  17028. * Binds the world matrix to the material
  17029. * @param world defines the world transformation matrix
  17030. * @param effectOverride - If provided, use this effect instead of internal effect
  17031. */
  17032. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17033. /**
  17034. * Binds the submesh to this material by preparing the effect and shader to draw
  17035. * @param world defines the world transformation matrix
  17036. * @param mesh defines the mesh containing the submesh
  17037. * @param subMesh defines the submesh to bind the material to
  17038. */
  17039. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17040. /**
  17041. * Binds the material to the mesh
  17042. * @param world defines the world transformation matrix
  17043. * @param mesh defines the mesh to bind the material to
  17044. * @param effectOverride - If provided, use this effect instead of internal effect
  17045. */
  17046. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17047. protected _afterBind(mesh?: Mesh): void;
  17048. /**
  17049. * Gets the active textures from the material
  17050. * @returns an array of textures
  17051. */
  17052. getActiveTextures(): BaseTexture[];
  17053. /**
  17054. * Specifies if the material uses a texture
  17055. * @param texture defines the texture to check against the material
  17056. * @returns a boolean specifying if the material uses the texture
  17057. */
  17058. hasTexture(texture: BaseTexture): boolean;
  17059. /**
  17060. * Makes a duplicate of the material, and gives it a new name
  17061. * @param name defines the new name for the duplicated material
  17062. * @returns the cloned material
  17063. */
  17064. clone(name: string): ShaderMaterial;
  17065. /**
  17066. * Disposes the material
  17067. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17068. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17069. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17070. */
  17071. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17072. /**
  17073. * Serializes this material in a JSON representation
  17074. * @returns the serialized material object
  17075. */
  17076. serialize(): any;
  17077. /**
  17078. * Creates a shader material from parsed shader material data
  17079. * @param source defines the JSON represnetation of the material
  17080. * @param scene defines the hosting scene
  17081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17082. * @returns a new material
  17083. */
  17084. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17085. }
  17086. }
  17087. declare module "babylonjs/Shaders/color.fragment" {
  17088. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17089. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17090. /** @hidden */
  17091. export var colorPixelShader: {
  17092. name: string;
  17093. shader: string;
  17094. };
  17095. }
  17096. declare module "babylonjs/Shaders/color.vertex" {
  17097. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17098. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17099. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17100. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17102. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17103. /** @hidden */
  17104. export var colorVertexShader: {
  17105. name: string;
  17106. shader: string;
  17107. };
  17108. }
  17109. declare module "babylonjs/Meshes/linesMesh" {
  17110. import { Nullable } from "babylonjs/types";
  17111. import { Scene } from "babylonjs/scene";
  17112. import { Color3 } from "babylonjs/Maths/math.color";
  17113. import { Node } from "babylonjs/node";
  17114. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17115. import { Mesh } from "babylonjs/Meshes/mesh";
  17116. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17117. import { Effect } from "babylonjs/Materials/effect";
  17118. import { Material } from "babylonjs/Materials/material";
  17119. import "babylonjs/Shaders/color.fragment";
  17120. import "babylonjs/Shaders/color.vertex";
  17121. /**
  17122. * Line mesh
  17123. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17124. */
  17125. export class LinesMesh extends Mesh {
  17126. /**
  17127. * If vertex color should be applied to the mesh
  17128. */
  17129. readonly useVertexColor?: boolean | undefined;
  17130. /**
  17131. * If vertex alpha should be applied to the mesh
  17132. */
  17133. readonly useVertexAlpha?: boolean | undefined;
  17134. /**
  17135. * Color of the line (Default: White)
  17136. */
  17137. color: Color3;
  17138. /**
  17139. * Alpha of the line (Default: 1)
  17140. */
  17141. alpha: number;
  17142. /**
  17143. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17144. * This margin is expressed in world space coordinates, so its value may vary.
  17145. * Default value is 0.1
  17146. */
  17147. intersectionThreshold: number;
  17148. private _colorShader;
  17149. private color4;
  17150. /**
  17151. * Creates a new LinesMesh
  17152. * @param name defines the name
  17153. * @param scene defines the hosting scene
  17154. * @param parent defines the parent mesh if any
  17155. * @param source defines the optional source LinesMesh used to clone data from
  17156. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17157. * When false, achieved by calling a clone(), also passing False.
  17158. * This will make creation of children, recursive.
  17159. * @param useVertexColor defines if this LinesMesh supports vertex color
  17160. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17161. */
  17162. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17163. /**
  17164. * If vertex color should be applied to the mesh
  17165. */
  17166. useVertexColor?: boolean | undefined,
  17167. /**
  17168. * If vertex alpha should be applied to the mesh
  17169. */
  17170. useVertexAlpha?: boolean | undefined);
  17171. private _addClipPlaneDefine;
  17172. private _removeClipPlaneDefine;
  17173. isReady(): boolean;
  17174. /**
  17175. * Returns the string "LineMesh"
  17176. */
  17177. getClassName(): string;
  17178. /**
  17179. * @hidden
  17180. */
  17181. get material(): Material;
  17182. /**
  17183. * @hidden
  17184. */
  17185. set material(value: Material);
  17186. /**
  17187. * @hidden
  17188. */
  17189. get checkCollisions(): boolean;
  17190. /** @hidden */
  17191. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17192. /** @hidden */
  17193. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17194. /**
  17195. * Disposes of the line mesh
  17196. * @param doNotRecurse If children should be disposed
  17197. */
  17198. dispose(doNotRecurse?: boolean): void;
  17199. /**
  17200. * Returns a new LineMesh object cloned from the current one.
  17201. */
  17202. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17203. /**
  17204. * Creates a new InstancedLinesMesh object from the mesh model.
  17205. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17206. * @param name defines the name of the new instance
  17207. * @returns a new InstancedLinesMesh
  17208. */
  17209. createInstance(name: string): InstancedLinesMesh;
  17210. }
  17211. /**
  17212. * Creates an instance based on a source LinesMesh
  17213. */
  17214. export class InstancedLinesMesh extends InstancedMesh {
  17215. /**
  17216. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17217. * This margin is expressed in world space coordinates, so its value may vary.
  17218. * Initilized with the intersectionThreshold value of the source LinesMesh
  17219. */
  17220. intersectionThreshold: number;
  17221. constructor(name: string, source: LinesMesh);
  17222. /**
  17223. * Returns the string "InstancedLinesMesh".
  17224. */
  17225. getClassName(): string;
  17226. }
  17227. }
  17228. declare module "babylonjs/Shaders/line.fragment" {
  17229. /** @hidden */
  17230. export var linePixelShader: {
  17231. name: string;
  17232. shader: string;
  17233. };
  17234. }
  17235. declare module "babylonjs/Shaders/line.vertex" {
  17236. /** @hidden */
  17237. export var lineVertexShader: {
  17238. name: string;
  17239. shader: string;
  17240. };
  17241. }
  17242. declare module "babylonjs/Rendering/edgesRenderer" {
  17243. import { Nullable } from "babylonjs/types";
  17244. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17246. import { Vector3 } from "babylonjs/Maths/math.vector";
  17247. import { IDisposable } from "babylonjs/scene";
  17248. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17249. import "babylonjs/Shaders/line.fragment";
  17250. import "babylonjs/Shaders/line.vertex";
  17251. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17252. module "babylonjs/Meshes/abstractMesh" {
  17253. interface AbstractMesh {
  17254. /**
  17255. * Gets the edgesRenderer associated with the mesh
  17256. */
  17257. edgesRenderer: Nullable<EdgesRenderer>;
  17258. }
  17259. }
  17260. module "babylonjs/Meshes/linesMesh" {
  17261. interface LinesMesh {
  17262. /**
  17263. * Enables the edge rendering mode on the mesh.
  17264. * This mode makes the mesh edges visible
  17265. * @param epsilon defines the maximal distance between two angles to detect a face
  17266. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17267. * @returns the currentAbstractMesh
  17268. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17269. */
  17270. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17271. }
  17272. }
  17273. module "babylonjs/Meshes/linesMesh" {
  17274. interface InstancedLinesMesh {
  17275. /**
  17276. * Enables the edge rendering mode on the mesh.
  17277. * This mode makes the mesh edges visible
  17278. * @param epsilon defines the maximal distance between two angles to detect a face
  17279. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17280. * @returns the current InstancedLinesMesh
  17281. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17282. */
  17283. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17284. }
  17285. }
  17286. /**
  17287. * Defines the minimum contract an Edges renderer should follow.
  17288. */
  17289. export interface IEdgesRenderer extends IDisposable {
  17290. /**
  17291. * Gets or sets a boolean indicating if the edgesRenderer is active
  17292. */
  17293. isEnabled: boolean;
  17294. /**
  17295. * Renders the edges of the attached mesh,
  17296. */
  17297. render(): void;
  17298. /**
  17299. * Checks wether or not the edges renderer is ready to render.
  17300. * @return true if ready, otherwise false.
  17301. */
  17302. isReady(): boolean;
  17303. }
  17304. /**
  17305. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17306. */
  17307. export class EdgesRenderer implements IEdgesRenderer {
  17308. /**
  17309. * Define the size of the edges with an orthographic camera
  17310. */
  17311. edgesWidthScalerForOrthographic: number;
  17312. /**
  17313. * Define the size of the edges with a perspective camera
  17314. */
  17315. edgesWidthScalerForPerspective: number;
  17316. protected _source: AbstractMesh;
  17317. protected _linesPositions: number[];
  17318. protected _linesNormals: number[];
  17319. protected _linesIndices: number[];
  17320. protected _epsilon: number;
  17321. protected _indicesCount: number;
  17322. protected _lineShader: ShaderMaterial;
  17323. protected _ib: DataBuffer;
  17324. protected _buffers: {
  17325. [key: string]: Nullable<VertexBuffer>;
  17326. };
  17327. protected _checkVerticesInsteadOfIndices: boolean;
  17328. private _meshRebuildObserver;
  17329. private _meshDisposeObserver;
  17330. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17331. isEnabled: boolean;
  17332. /**
  17333. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17334. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17335. * @param source Mesh used to create edges
  17336. * @param epsilon sum of angles in adjacency to check for edge
  17337. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17338. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17339. */
  17340. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17341. protected _prepareRessources(): void;
  17342. /** @hidden */
  17343. _rebuild(): void;
  17344. /**
  17345. * Releases the required resources for the edges renderer
  17346. */
  17347. dispose(): void;
  17348. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17349. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17350. /**
  17351. * Checks if the pair of p0 and p1 is en edge
  17352. * @param faceIndex
  17353. * @param edge
  17354. * @param faceNormals
  17355. * @param p0
  17356. * @param p1
  17357. * @private
  17358. */
  17359. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17360. /**
  17361. * push line into the position, normal and index buffer
  17362. * @protected
  17363. */
  17364. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17365. /**
  17366. * Generates lines edges from adjacencjes
  17367. * @private
  17368. */
  17369. _generateEdgesLines(): void;
  17370. /**
  17371. * Checks wether or not the edges renderer is ready to render.
  17372. * @return true if ready, otherwise false.
  17373. */
  17374. isReady(): boolean;
  17375. /**
  17376. * Renders the edges of the attached mesh,
  17377. */
  17378. render(): void;
  17379. }
  17380. /**
  17381. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17382. */
  17383. export class LineEdgesRenderer extends EdgesRenderer {
  17384. /**
  17385. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17386. * @param source LineMesh used to generate edges
  17387. * @param epsilon not important (specified angle for edge detection)
  17388. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17389. */
  17390. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17391. /**
  17392. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17393. */
  17394. _generateEdgesLines(): void;
  17395. }
  17396. }
  17397. declare module "babylonjs/Rendering/renderingGroup" {
  17398. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17401. import { Nullable } from "babylonjs/types";
  17402. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17403. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17404. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17405. import { Material } from "babylonjs/Materials/material";
  17406. import { Scene } from "babylonjs/scene";
  17407. /**
  17408. * This represents the object necessary to create a rendering group.
  17409. * This is exclusively used and created by the rendering manager.
  17410. * To modify the behavior, you use the available helpers in your scene or meshes.
  17411. * @hidden
  17412. */
  17413. export class RenderingGroup {
  17414. index: number;
  17415. private static _zeroVector;
  17416. private _scene;
  17417. private _opaqueSubMeshes;
  17418. private _transparentSubMeshes;
  17419. private _alphaTestSubMeshes;
  17420. private _depthOnlySubMeshes;
  17421. private _particleSystems;
  17422. private _spriteManagers;
  17423. private _opaqueSortCompareFn;
  17424. private _alphaTestSortCompareFn;
  17425. private _transparentSortCompareFn;
  17426. private _renderOpaque;
  17427. private _renderAlphaTest;
  17428. private _renderTransparent;
  17429. /** @hidden */
  17430. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17431. onBeforeTransparentRendering: () => void;
  17432. /**
  17433. * Set the opaque sort comparison function.
  17434. * If null the sub meshes will be render in the order they were created
  17435. */
  17436. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17437. /**
  17438. * Set the alpha test sort comparison function.
  17439. * If null the sub meshes will be render in the order they were created
  17440. */
  17441. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17442. /**
  17443. * Set the transparent sort comparison function.
  17444. * If null the sub meshes will be render in the order they were created
  17445. */
  17446. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17447. /**
  17448. * Creates a new rendering group.
  17449. * @param index The rendering group index
  17450. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17451. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17452. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17453. */
  17454. 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>);
  17455. /**
  17456. * Render all the sub meshes contained in the group.
  17457. * @param customRenderFunction Used to override the default render behaviour of the group.
  17458. * @returns true if rendered some submeshes.
  17459. */
  17460. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17461. /**
  17462. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17463. * @param subMeshes The submeshes to render
  17464. */
  17465. private renderOpaqueSorted;
  17466. /**
  17467. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17468. * @param subMeshes The submeshes to render
  17469. */
  17470. private renderAlphaTestSorted;
  17471. /**
  17472. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17473. * @param subMeshes The submeshes to render
  17474. */
  17475. private renderTransparentSorted;
  17476. /**
  17477. * Renders the submeshes in a specified order.
  17478. * @param subMeshes The submeshes to sort before render
  17479. * @param sortCompareFn The comparison function use to sort
  17480. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17481. * @param transparent Specifies to activate blending if true
  17482. */
  17483. private static renderSorted;
  17484. /**
  17485. * Renders the submeshes in the order they were dispatched (no sort applied).
  17486. * @param subMeshes The submeshes to render
  17487. */
  17488. private static renderUnsorted;
  17489. /**
  17490. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17491. * are rendered back to front if in the same alpha index.
  17492. *
  17493. * @param a The first submesh
  17494. * @param b The second submesh
  17495. * @returns The result of the comparison
  17496. */
  17497. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17498. /**
  17499. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17500. * are rendered back to front.
  17501. *
  17502. * @param a The first submesh
  17503. * @param b The second submesh
  17504. * @returns The result of the comparison
  17505. */
  17506. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17507. /**
  17508. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17509. * are rendered front to back (prevent overdraw).
  17510. *
  17511. * @param a The first submesh
  17512. * @param b The second submesh
  17513. * @returns The result of the comparison
  17514. */
  17515. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17516. /**
  17517. * Resets the different lists of submeshes to prepare a new frame.
  17518. */
  17519. prepare(): void;
  17520. dispose(): void;
  17521. /**
  17522. * Inserts the submesh in its correct queue depending on its material.
  17523. * @param subMesh The submesh to dispatch
  17524. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17525. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17526. */
  17527. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17528. dispatchSprites(spriteManager: ISpriteManager): void;
  17529. dispatchParticles(particleSystem: IParticleSystem): void;
  17530. private _renderParticles;
  17531. private _renderSprites;
  17532. }
  17533. }
  17534. declare module "babylonjs/Rendering/renderingManager" {
  17535. import { Nullable } from "babylonjs/types";
  17536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17537. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17538. import { SmartArray } from "babylonjs/Misc/smartArray";
  17539. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17540. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17541. import { Material } from "babylonjs/Materials/material";
  17542. import { Scene } from "babylonjs/scene";
  17543. import { Camera } from "babylonjs/Cameras/camera";
  17544. /**
  17545. * Interface describing the different options available in the rendering manager
  17546. * regarding Auto Clear between groups.
  17547. */
  17548. export interface IRenderingManagerAutoClearSetup {
  17549. /**
  17550. * Defines whether or not autoclear is enable.
  17551. */
  17552. autoClear: boolean;
  17553. /**
  17554. * Defines whether or not to autoclear the depth buffer.
  17555. */
  17556. depth: boolean;
  17557. /**
  17558. * Defines whether or not to autoclear the stencil buffer.
  17559. */
  17560. stencil: boolean;
  17561. }
  17562. /**
  17563. * This class is used by the onRenderingGroupObservable
  17564. */
  17565. export class RenderingGroupInfo {
  17566. /**
  17567. * The Scene that being rendered
  17568. */
  17569. scene: Scene;
  17570. /**
  17571. * The camera currently used for the rendering pass
  17572. */
  17573. camera: Nullable<Camera>;
  17574. /**
  17575. * The ID of the renderingGroup being processed
  17576. */
  17577. renderingGroupId: number;
  17578. }
  17579. /**
  17580. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17581. * It is enable to manage the different groups as well as the different necessary sort functions.
  17582. * This should not be used directly aside of the few static configurations
  17583. */
  17584. export class RenderingManager {
  17585. /**
  17586. * The max id used for rendering groups (not included)
  17587. */
  17588. static MAX_RENDERINGGROUPS: number;
  17589. /**
  17590. * The min id used for rendering groups (included)
  17591. */
  17592. static MIN_RENDERINGGROUPS: number;
  17593. /**
  17594. * Used to globally prevent autoclearing scenes.
  17595. */
  17596. static AUTOCLEAR: boolean;
  17597. /**
  17598. * @hidden
  17599. */
  17600. _useSceneAutoClearSetup: boolean;
  17601. private _scene;
  17602. private _renderingGroups;
  17603. private _depthStencilBufferAlreadyCleaned;
  17604. private _autoClearDepthStencil;
  17605. private _customOpaqueSortCompareFn;
  17606. private _customAlphaTestSortCompareFn;
  17607. private _customTransparentSortCompareFn;
  17608. private _renderingGroupInfo;
  17609. /**
  17610. * Instantiates a new rendering group for a particular scene
  17611. * @param scene Defines the scene the groups belongs to
  17612. */
  17613. constructor(scene: Scene);
  17614. private _clearDepthStencilBuffer;
  17615. /**
  17616. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17617. * @hidden
  17618. */
  17619. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17620. /**
  17621. * Resets the different information of the group to prepare a new frame
  17622. * @hidden
  17623. */
  17624. reset(): void;
  17625. /**
  17626. * Dispose and release the group and its associated resources.
  17627. * @hidden
  17628. */
  17629. dispose(): void;
  17630. /**
  17631. * Clear the info related to rendering groups preventing retention points during dispose.
  17632. */
  17633. freeRenderingGroups(): void;
  17634. private _prepareRenderingGroup;
  17635. /**
  17636. * Add a sprite manager to the rendering manager in order to render it this frame.
  17637. * @param spriteManager Define the sprite manager to render
  17638. */
  17639. dispatchSprites(spriteManager: ISpriteManager): void;
  17640. /**
  17641. * Add a particle system to the rendering manager in order to render it this frame.
  17642. * @param particleSystem Define the particle system to render
  17643. */
  17644. dispatchParticles(particleSystem: IParticleSystem): void;
  17645. /**
  17646. * Add a submesh to the manager in order to render it this frame
  17647. * @param subMesh The submesh to dispatch
  17648. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17649. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17650. */
  17651. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17652. /**
  17653. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17654. * This allowed control for front to back rendering or reversly depending of the special needs.
  17655. *
  17656. * @param renderingGroupId The rendering group id corresponding to its index
  17657. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17658. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17659. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17660. */
  17661. 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;
  17662. /**
  17663. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17664. *
  17665. * @param renderingGroupId The rendering group id corresponding to its index
  17666. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17667. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17668. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17669. */
  17670. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17671. /**
  17672. * Gets the current auto clear configuration for one rendering group of the rendering
  17673. * manager.
  17674. * @param index the rendering group index to get the information for
  17675. * @returns The auto clear setup for the requested rendering group
  17676. */
  17677. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17678. }
  17679. }
  17680. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17681. import { SmartArray } from "babylonjs/Misc/smartArray";
  17682. import { Nullable } from "babylonjs/types";
  17683. import { Scene } from "babylonjs/scene";
  17684. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17685. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17687. import { Mesh } from "babylonjs/Meshes/mesh";
  17688. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17689. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17690. import { Effect } from "babylonjs/Materials/effect";
  17691. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17692. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17693. import "babylonjs/Shaders/shadowMap.fragment";
  17694. import "babylonjs/Shaders/shadowMap.vertex";
  17695. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17696. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17697. import { Observable } from "babylonjs/Misc/observable";
  17698. /**
  17699. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17700. */
  17701. export interface ICustomShaderOptions {
  17702. /**
  17703. * Gets or sets the custom shader name to use
  17704. */
  17705. shaderName: string;
  17706. /**
  17707. * The list of attribute names used in the shader
  17708. */
  17709. attributes?: string[];
  17710. /**
  17711. * The list of unifrom names used in the shader
  17712. */
  17713. uniforms?: string[];
  17714. /**
  17715. * The list of sampler names used in the shader
  17716. */
  17717. samplers?: string[];
  17718. /**
  17719. * The list of defines used in the shader
  17720. */
  17721. defines?: string[];
  17722. }
  17723. /**
  17724. * Interface to implement to create a shadow generator compatible with BJS.
  17725. */
  17726. export interface IShadowGenerator {
  17727. /**
  17728. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17729. * @returns The render target texture if present otherwise, null
  17730. */
  17731. getShadowMap(): Nullable<RenderTargetTexture>;
  17732. /**
  17733. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17734. * @param subMesh The submesh we want to render in the shadow map
  17735. * @param useInstances Defines wether will draw in the map using instances
  17736. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17737. * @returns true if ready otherwise, false
  17738. */
  17739. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17740. /**
  17741. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17742. * @param defines Defines of the material we want to update
  17743. * @param lightIndex Index of the light in the enabled light list of the material
  17744. */
  17745. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17746. /**
  17747. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17748. * defined in the generator but impacting the effect).
  17749. * It implies the unifroms available on the materials are the standard BJS ones.
  17750. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17751. * @param effect The effect we are binfing the information for
  17752. */
  17753. bindShadowLight(lightIndex: string, effect: Effect): void;
  17754. /**
  17755. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17756. * (eq to shadow prjection matrix * light transform matrix)
  17757. * @returns The transform matrix used to create the shadow map
  17758. */
  17759. getTransformMatrix(): Matrix;
  17760. /**
  17761. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17762. * Cube and 2D textures for instance.
  17763. */
  17764. recreateShadowMap(): void;
  17765. /**
  17766. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17767. * @param onCompiled Callback triggered at the and of the effects compilation
  17768. * @param options Sets of optional options forcing the compilation with different modes
  17769. */
  17770. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17771. useInstances: boolean;
  17772. }>): void;
  17773. /**
  17774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17775. * @param options Sets of optional options forcing the compilation with different modes
  17776. * @returns A promise that resolves when the compilation completes
  17777. */
  17778. forceCompilationAsync(options?: Partial<{
  17779. useInstances: boolean;
  17780. }>): Promise<void>;
  17781. /**
  17782. * Serializes the shadow generator setup to a json object.
  17783. * @returns The serialized JSON object
  17784. */
  17785. serialize(): any;
  17786. /**
  17787. * Disposes the Shadow map and related Textures and effects.
  17788. */
  17789. dispose(): void;
  17790. }
  17791. /**
  17792. * Default implementation IShadowGenerator.
  17793. * This is the main object responsible of generating shadows in the framework.
  17794. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17795. */
  17796. export class ShadowGenerator implements IShadowGenerator {
  17797. /**
  17798. * Name of the shadow generator class
  17799. */
  17800. static CLASSNAME: string;
  17801. /**
  17802. * Shadow generator mode None: no filtering applied.
  17803. */
  17804. static readonly FILTER_NONE: number;
  17805. /**
  17806. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17807. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17808. */
  17809. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17810. /**
  17811. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17812. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17813. */
  17814. static readonly FILTER_POISSONSAMPLING: number;
  17815. /**
  17816. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17817. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17818. */
  17819. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17820. /**
  17821. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17822. * edge artifacts on steep falloff.
  17823. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17824. */
  17825. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17826. /**
  17827. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17828. * edge artifacts on steep falloff.
  17829. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17830. */
  17831. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17832. /**
  17833. * Shadow generator mode PCF: Percentage Closer Filtering
  17834. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17835. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17836. */
  17837. static readonly FILTER_PCF: number;
  17838. /**
  17839. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17840. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17841. * Contact Hardening
  17842. */
  17843. static readonly FILTER_PCSS: number;
  17844. /**
  17845. * Reserved for PCF and PCSS
  17846. * Highest Quality.
  17847. *
  17848. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17849. *
  17850. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17851. */
  17852. static readonly QUALITY_HIGH: number;
  17853. /**
  17854. * Reserved for PCF and PCSS
  17855. * Good tradeoff for quality/perf cross devices
  17856. *
  17857. * Execute PCF on a 3*3 kernel.
  17858. *
  17859. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17860. */
  17861. static readonly QUALITY_MEDIUM: number;
  17862. /**
  17863. * Reserved for PCF and PCSS
  17864. * The lowest quality but the fastest.
  17865. *
  17866. * Execute PCF on a 1*1 kernel.
  17867. *
  17868. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17869. */
  17870. static readonly QUALITY_LOW: number;
  17871. /** Gets or sets the custom shader name to use */
  17872. customShaderOptions: ICustomShaderOptions;
  17873. /**
  17874. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17875. */
  17876. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17877. /**
  17878. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17879. */
  17880. onAfterShadowMapRenderObservable: Observable<Effect>;
  17881. /**
  17882. * Observable triggered before a mesh is rendered in the shadow map.
  17883. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17884. */
  17885. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17886. /**
  17887. * Observable triggered after a mesh is rendered in the shadow map.
  17888. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17889. */
  17890. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17891. protected _bias: number;
  17892. /**
  17893. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17894. */
  17895. get bias(): number;
  17896. /**
  17897. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17898. */
  17899. set bias(bias: number);
  17900. protected _normalBias: number;
  17901. /**
  17902. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17903. */
  17904. get normalBias(): number;
  17905. /**
  17906. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17907. */
  17908. set normalBias(normalBias: number);
  17909. protected _blurBoxOffset: number;
  17910. /**
  17911. * Gets the blur box offset: offset applied during the blur pass.
  17912. * Only useful if useKernelBlur = false
  17913. */
  17914. get blurBoxOffset(): number;
  17915. /**
  17916. * Sets the blur box offset: offset applied during the blur pass.
  17917. * Only useful if useKernelBlur = false
  17918. */
  17919. set blurBoxOffset(value: number);
  17920. protected _blurScale: number;
  17921. /**
  17922. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17923. * 2 means half of the size.
  17924. */
  17925. get blurScale(): number;
  17926. /**
  17927. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17928. * 2 means half of the size.
  17929. */
  17930. set blurScale(value: number);
  17931. protected _blurKernel: number;
  17932. /**
  17933. * Gets the blur kernel: kernel size of the blur pass.
  17934. * Only useful if useKernelBlur = true
  17935. */
  17936. get blurKernel(): number;
  17937. /**
  17938. * Sets the blur kernel: kernel size of the blur pass.
  17939. * Only useful if useKernelBlur = true
  17940. */
  17941. set blurKernel(value: number);
  17942. protected _useKernelBlur: boolean;
  17943. /**
  17944. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17945. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17946. */
  17947. get useKernelBlur(): boolean;
  17948. /**
  17949. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17950. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17951. */
  17952. set useKernelBlur(value: boolean);
  17953. protected _depthScale: number;
  17954. /**
  17955. * Gets the depth scale used in ESM mode.
  17956. */
  17957. get depthScale(): number;
  17958. /**
  17959. * Sets the depth scale used in ESM mode.
  17960. * This can override the scale stored on the light.
  17961. */
  17962. set depthScale(value: number);
  17963. protected _validateFilter(filter: number): number;
  17964. protected _filter: number;
  17965. /**
  17966. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17967. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17968. */
  17969. get filter(): number;
  17970. /**
  17971. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17972. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17973. */
  17974. set filter(value: number);
  17975. /**
  17976. * Gets if the current filter is set to Poisson Sampling.
  17977. */
  17978. get usePoissonSampling(): boolean;
  17979. /**
  17980. * Sets the current filter to Poisson Sampling.
  17981. */
  17982. set usePoissonSampling(value: boolean);
  17983. /**
  17984. * Gets if the current filter is set to ESM.
  17985. */
  17986. get useExponentialShadowMap(): boolean;
  17987. /**
  17988. * Sets the current filter is to ESM.
  17989. */
  17990. set useExponentialShadowMap(value: boolean);
  17991. /**
  17992. * Gets if the current filter is set to filtered ESM.
  17993. */
  17994. get useBlurExponentialShadowMap(): boolean;
  17995. /**
  17996. * Gets if the current filter is set to filtered ESM.
  17997. */
  17998. set useBlurExponentialShadowMap(value: boolean);
  17999. /**
  18000. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18001. * exponential to prevent steep falloff artifacts).
  18002. */
  18003. get useCloseExponentialShadowMap(): boolean;
  18004. /**
  18005. * Sets the current filter to "close ESM" (using the inverse of the
  18006. * exponential to prevent steep falloff artifacts).
  18007. */
  18008. set useCloseExponentialShadowMap(value: boolean);
  18009. /**
  18010. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18011. * exponential to prevent steep falloff artifacts).
  18012. */
  18013. get useBlurCloseExponentialShadowMap(): boolean;
  18014. /**
  18015. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18016. * exponential to prevent steep falloff artifacts).
  18017. */
  18018. set useBlurCloseExponentialShadowMap(value: boolean);
  18019. /**
  18020. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18021. */
  18022. get usePercentageCloserFiltering(): boolean;
  18023. /**
  18024. * Sets the current filter to "PCF" (percentage closer filtering).
  18025. */
  18026. set usePercentageCloserFiltering(value: boolean);
  18027. protected _filteringQuality: number;
  18028. /**
  18029. * Gets the PCF or PCSS Quality.
  18030. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18031. */
  18032. get filteringQuality(): number;
  18033. /**
  18034. * Sets the PCF or PCSS Quality.
  18035. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18036. */
  18037. set filteringQuality(filteringQuality: number);
  18038. /**
  18039. * Gets if the current filter is set to "PCSS" (contact hardening).
  18040. */
  18041. get useContactHardeningShadow(): boolean;
  18042. /**
  18043. * Sets the current filter to "PCSS" (contact hardening).
  18044. */
  18045. set useContactHardeningShadow(value: boolean);
  18046. protected _contactHardeningLightSizeUVRatio: number;
  18047. /**
  18048. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18049. * Using a ratio helps keeping shape stability independently of the map size.
  18050. *
  18051. * It does not account for the light projection as it was having too much
  18052. * instability during the light setup or during light position changes.
  18053. *
  18054. * Only valid if useContactHardeningShadow is true.
  18055. */
  18056. get contactHardeningLightSizeUVRatio(): number;
  18057. /**
  18058. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18059. * Using a ratio helps keeping shape stability independently of the map size.
  18060. *
  18061. * It does not account for the light projection as it was having too much
  18062. * instability during the light setup or during light position changes.
  18063. *
  18064. * Only valid if useContactHardeningShadow is true.
  18065. */
  18066. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18067. protected _darkness: number;
  18068. /** Gets or sets the actual darkness of a shadow */
  18069. get darkness(): number;
  18070. set darkness(value: number);
  18071. /**
  18072. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18073. * 0 means strongest and 1 would means no shadow.
  18074. * @returns the darkness.
  18075. */
  18076. getDarkness(): number;
  18077. /**
  18078. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18079. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18080. * @returns the shadow generator allowing fluent coding.
  18081. */
  18082. setDarkness(darkness: number): ShadowGenerator;
  18083. protected _transparencyShadow: boolean;
  18084. /** Gets or sets the ability to have transparent shadow */
  18085. get transparencyShadow(): boolean;
  18086. set transparencyShadow(value: boolean);
  18087. /**
  18088. * Sets the ability to have transparent shadow (boolean).
  18089. * @param transparent True if transparent else False
  18090. * @returns the shadow generator allowing fluent coding
  18091. */
  18092. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18093. /**
  18094. * Enables or disables shadows with varying strength based on the transparency
  18095. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18096. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18097. * mesh.visibility * alphaTexture.a
  18098. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18099. */
  18100. enableSoftTransparentShadow: boolean;
  18101. protected _shadowMap: Nullable<RenderTargetTexture>;
  18102. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18103. /**
  18104. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18105. * @returns The render target texture if present otherwise, null
  18106. */
  18107. getShadowMap(): Nullable<RenderTargetTexture>;
  18108. /**
  18109. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18110. * @returns The render target texture if the shadow map is present otherwise, null
  18111. */
  18112. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18113. /**
  18114. * Gets the class name of that object
  18115. * @returns "ShadowGenerator"
  18116. */
  18117. getClassName(): string;
  18118. /**
  18119. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18120. * @param mesh Mesh to add
  18121. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18122. * @returns the Shadow Generator itself
  18123. */
  18124. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18125. /**
  18126. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18127. * @param mesh Mesh to remove
  18128. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18129. * @returns the Shadow Generator itself
  18130. */
  18131. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18132. /**
  18133. * Controls the extent to which the shadows fade out at the edge of the frustum
  18134. */
  18135. frustumEdgeFalloff: number;
  18136. protected _light: IShadowLight;
  18137. /**
  18138. * Returns the associated light object.
  18139. * @returns the light generating the shadow
  18140. */
  18141. getLight(): IShadowLight;
  18142. /**
  18143. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18144. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18145. * It might on the other hand introduce peter panning.
  18146. */
  18147. forceBackFacesOnly: boolean;
  18148. protected _scene: Scene;
  18149. protected _lightDirection: Vector3;
  18150. protected _effect: Effect;
  18151. protected _viewMatrix: Matrix;
  18152. protected _projectionMatrix: Matrix;
  18153. protected _transformMatrix: Matrix;
  18154. protected _cachedPosition: Vector3;
  18155. protected _cachedDirection: Vector3;
  18156. protected _cachedDefines: string;
  18157. protected _currentRenderID: number;
  18158. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18159. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18160. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18161. protected _blurPostProcesses: PostProcess[];
  18162. protected _mapSize: number;
  18163. protected _currentFaceIndex: number;
  18164. protected _currentFaceIndexCache: number;
  18165. protected _textureType: number;
  18166. protected _defaultTextureMatrix: Matrix;
  18167. protected _storedUniqueId: Nullable<number>;
  18168. /** @hidden */
  18169. static _SceneComponentInitialization: (scene: Scene) => void;
  18170. /**
  18171. * Creates a ShadowGenerator object.
  18172. * A ShadowGenerator is the required tool to use the shadows.
  18173. * Each light casting shadows needs to use its own ShadowGenerator.
  18174. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18175. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18176. * @param light The light object generating the shadows.
  18177. * @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.
  18178. */
  18179. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18180. protected _initializeGenerator(): void;
  18181. protected _createTargetRenderTexture(): void;
  18182. protected _initializeShadowMap(): void;
  18183. protected _initializeBlurRTTAndPostProcesses(): void;
  18184. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18185. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18186. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18187. protected _applyFilterValues(): void;
  18188. /**
  18189. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18190. * @param onCompiled Callback triggered at the and of the effects compilation
  18191. * @param options Sets of optional options forcing the compilation with different modes
  18192. */
  18193. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18194. useInstances: boolean;
  18195. }>): void;
  18196. /**
  18197. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18198. * @param options Sets of optional options forcing the compilation with different modes
  18199. * @returns A promise that resolves when the compilation completes
  18200. */
  18201. forceCompilationAsync(options?: Partial<{
  18202. useInstances: boolean;
  18203. }>): Promise<void>;
  18204. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18205. private _prepareShadowDefines;
  18206. /**
  18207. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18208. * @param subMesh The submesh we want to render in the shadow map
  18209. * @param useInstances Defines wether will draw in the map using instances
  18210. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18211. * @returns true if ready otherwise, false
  18212. */
  18213. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18214. /**
  18215. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18216. * @param defines Defines of the material we want to update
  18217. * @param lightIndex Index of the light in the enabled light list of the material
  18218. */
  18219. prepareDefines(defines: any, lightIndex: number): void;
  18220. /**
  18221. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18222. * defined in the generator but impacting the effect).
  18223. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18224. * @param effect The effect we are binfing the information for
  18225. */
  18226. bindShadowLight(lightIndex: string, effect: Effect): void;
  18227. /**
  18228. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18229. * (eq to shadow prjection matrix * light transform matrix)
  18230. * @returns The transform matrix used to create the shadow map
  18231. */
  18232. getTransformMatrix(): Matrix;
  18233. /**
  18234. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18235. * Cube and 2D textures for instance.
  18236. */
  18237. recreateShadowMap(): void;
  18238. protected _disposeBlurPostProcesses(): void;
  18239. protected _disposeRTTandPostProcesses(): void;
  18240. /**
  18241. * Disposes the ShadowGenerator.
  18242. * Returns nothing.
  18243. */
  18244. dispose(): void;
  18245. /**
  18246. * Serializes the shadow generator setup to a json object.
  18247. * @returns The serialized JSON object
  18248. */
  18249. serialize(): any;
  18250. /**
  18251. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18252. * @param parsedShadowGenerator The JSON object to parse
  18253. * @param scene The scene to create the shadow map for
  18254. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18255. * @returns The parsed shadow generator
  18256. */
  18257. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18258. }
  18259. }
  18260. declare module "babylonjs/Lights/light" {
  18261. import { Nullable } from "babylonjs/types";
  18262. import { Scene } from "babylonjs/scene";
  18263. import { Vector3 } from "babylonjs/Maths/math.vector";
  18264. import { Color3 } from "babylonjs/Maths/math.color";
  18265. import { Node } from "babylonjs/node";
  18266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18267. import { Effect } from "babylonjs/Materials/effect";
  18268. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18269. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18270. /**
  18271. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18272. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18273. * 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.
  18274. */
  18275. export abstract class Light extends Node {
  18276. /**
  18277. * Falloff Default: light is falling off following the material specification:
  18278. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18279. */
  18280. static readonly FALLOFF_DEFAULT: number;
  18281. /**
  18282. * Falloff Physical: light is falling off following the inverse squared distance law.
  18283. */
  18284. static readonly FALLOFF_PHYSICAL: number;
  18285. /**
  18286. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18287. * to enhance interoperability with other engines.
  18288. */
  18289. static readonly FALLOFF_GLTF: number;
  18290. /**
  18291. * Falloff Standard: light is falling off like in the standard material
  18292. * to enhance interoperability with other materials.
  18293. */
  18294. static readonly FALLOFF_STANDARD: number;
  18295. /**
  18296. * If every light affecting the material is in this lightmapMode,
  18297. * material.lightmapTexture adds or multiplies
  18298. * (depends on material.useLightmapAsShadowmap)
  18299. * after every other light calculations.
  18300. */
  18301. static readonly LIGHTMAP_DEFAULT: number;
  18302. /**
  18303. * material.lightmapTexture as only diffuse lighting from this light
  18304. * adds only specular lighting from this light
  18305. * adds dynamic shadows
  18306. */
  18307. static readonly LIGHTMAP_SPECULAR: number;
  18308. /**
  18309. * material.lightmapTexture as only lighting
  18310. * no light calculation from this light
  18311. * only adds dynamic shadows from this light
  18312. */
  18313. static readonly LIGHTMAP_SHADOWSONLY: number;
  18314. /**
  18315. * Each light type uses the default quantity according to its type:
  18316. * point/spot lights use luminous intensity
  18317. * directional lights use illuminance
  18318. */
  18319. static readonly INTENSITYMODE_AUTOMATIC: number;
  18320. /**
  18321. * lumen (lm)
  18322. */
  18323. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18324. /**
  18325. * candela (lm/sr)
  18326. */
  18327. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18328. /**
  18329. * lux (lm/m^2)
  18330. */
  18331. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18332. /**
  18333. * nit (cd/m^2)
  18334. */
  18335. static readonly INTENSITYMODE_LUMINANCE: number;
  18336. /**
  18337. * Light type const id of the point light.
  18338. */
  18339. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18340. /**
  18341. * Light type const id of the directional light.
  18342. */
  18343. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18344. /**
  18345. * Light type const id of the spot light.
  18346. */
  18347. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18348. /**
  18349. * Light type const id of the hemispheric light.
  18350. */
  18351. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18352. /**
  18353. * Diffuse gives the basic color to an object.
  18354. */
  18355. diffuse: Color3;
  18356. /**
  18357. * Specular produces a highlight color on an object.
  18358. * Note: This is note affecting PBR materials.
  18359. */
  18360. specular: Color3;
  18361. /**
  18362. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18363. * falling off base on range or angle.
  18364. * This can be set to any values in Light.FALLOFF_x.
  18365. *
  18366. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18367. * other types of materials.
  18368. */
  18369. falloffType: number;
  18370. /**
  18371. * Strength of the light.
  18372. * Note: By default it is define in the framework own unit.
  18373. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18374. */
  18375. intensity: number;
  18376. private _range;
  18377. protected _inverseSquaredRange: number;
  18378. /**
  18379. * Defines how far from the source the light is impacting in scene units.
  18380. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18381. */
  18382. get range(): number;
  18383. /**
  18384. * Defines how far from the source the light is impacting in scene units.
  18385. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18386. */
  18387. set range(value: number);
  18388. /**
  18389. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18390. * of light.
  18391. */
  18392. private _photometricScale;
  18393. private _intensityMode;
  18394. /**
  18395. * Gets the photometric scale used to interpret the intensity.
  18396. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18397. */
  18398. get intensityMode(): number;
  18399. /**
  18400. * Sets the photometric scale used to interpret the intensity.
  18401. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18402. */
  18403. set intensityMode(value: number);
  18404. private _radius;
  18405. /**
  18406. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18407. */
  18408. get radius(): number;
  18409. /**
  18410. * sets the light radius used by PBR Materials to simulate soft area lights.
  18411. */
  18412. set radius(value: number);
  18413. private _renderPriority;
  18414. /**
  18415. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18416. * exceeding the number allowed of the materials.
  18417. */
  18418. renderPriority: number;
  18419. private _shadowEnabled;
  18420. /**
  18421. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18422. * the current shadow generator.
  18423. */
  18424. get shadowEnabled(): boolean;
  18425. /**
  18426. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18427. * the current shadow generator.
  18428. */
  18429. set shadowEnabled(value: boolean);
  18430. private _includedOnlyMeshes;
  18431. /**
  18432. * Gets the only meshes impacted by this light.
  18433. */
  18434. get includedOnlyMeshes(): AbstractMesh[];
  18435. /**
  18436. * Sets the only meshes impacted by this light.
  18437. */
  18438. set includedOnlyMeshes(value: AbstractMesh[]);
  18439. private _excludedMeshes;
  18440. /**
  18441. * Gets the meshes not impacted by this light.
  18442. */
  18443. get excludedMeshes(): AbstractMesh[];
  18444. /**
  18445. * Sets the meshes not impacted by this light.
  18446. */
  18447. set excludedMeshes(value: AbstractMesh[]);
  18448. private _excludeWithLayerMask;
  18449. /**
  18450. * Gets the layer id use to find what meshes are not impacted by the light.
  18451. * Inactive if 0
  18452. */
  18453. get excludeWithLayerMask(): number;
  18454. /**
  18455. * Sets the layer id use to find what meshes are not impacted by the light.
  18456. * Inactive if 0
  18457. */
  18458. set excludeWithLayerMask(value: number);
  18459. private _includeOnlyWithLayerMask;
  18460. /**
  18461. * Gets the layer id use to find what meshes are impacted by the light.
  18462. * Inactive if 0
  18463. */
  18464. get includeOnlyWithLayerMask(): number;
  18465. /**
  18466. * Sets the layer id use to find what meshes are impacted by the light.
  18467. * Inactive if 0
  18468. */
  18469. set includeOnlyWithLayerMask(value: number);
  18470. private _lightmapMode;
  18471. /**
  18472. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18473. */
  18474. get lightmapMode(): number;
  18475. /**
  18476. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18477. */
  18478. set lightmapMode(value: number);
  18479. /**
  18480. * Shadow generator associted to the light.
  18481. * @hidden Internal use only.
  18482. */
  18483. _shadowGenerator: Nullable<IShadowGenerator>;
  18484. /**
  18485. * @hidden Internal use only.
  18486. */
  18487. _excludedMeshesIds: string[];
  18488. /**
  18489. * @hidden Internal use only.
  18490. */
  18491. _includedOnlyMeshesIds: string[];
  18492. /**
  18493. * The current light unifom buffer.
  18494. * @hidden Internal use only.
  18495. */
  18496. _uniformBuffer: UniformBuffer;
  18497. /** @hidden */
  18498. _renderId: number;
  18499. /**
  18500. * Creates a Light object in the scene.
  18501. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18502. * @param name The firendly name of the light
  18503. * @param scene The scene the light belongs too
  18504. */
  18505. constructor(name: string, scene: Scene);
  18506. protected abstract _buildUniformLayout(): void;
  18507. /**
  18508. * Sets the passed Effect "effect" with the Light information.
  18509. * @param effect The effect to update
  18510. * @param lightIndex The index of the light in the effect to update
  18511. * @returns The light
  18512. */
  18513. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18514. /**
  18515. * Sets the passed Effect "effect" with the Light textures.
  18516. * @param effect The effect to update
  18517. * @param lightIndex The index of the light in the effect to update
  18518. * @returns The light
  18519. */
  18520. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18521. /**
  18522. * Binds the lights information from the scene to the effect for the given mesh.
  18523. * @param lightIndex Light index
  18524. * @param scene The scene where the light belongs to
  18525. * @param effect The effect we are binding the data to
  18526. * @param useSpecular Defines if specular is supported
  18527. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18528. */
  18529. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18530. /**
  18531. * Sets the passed Effect "effect" with the Light information.
  18532. * @param effect The effect to update
  18533. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18534. * @returns The light
  18535. */
  18536. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18537. /**
  18538. * Returns the string "Light".
  18539. * @returns the class name
  18540. */
  18541. getClassName(): string;
  18542. /** @hidden */
  18543. readonly _isLight: boolean;
  18544. /**
  18545. * Converts the light information to a readable string for debug purpose.
  18546. * @param fullDetails Supports for multiple levels of logging within scene loading
  18547. * @returns the human readable light info
  18548. */
  18549. toString(fullDetails?: boolean): string;
  18550. /** @hidden */
  18551. protected _syncParentEnabledState(): void;
  18552. /**
  18553. * Set the enabled state of this node.
  18554. * @param value - the new enabled state
  18555. */
  18556. setEnabled(value: boolean): void;
  18557. /**
  18558. * Returns the Light associated shadow generator if any.
  18559. * @return the associated shadow generator.
  18560. */
  18561. getShadowGenerator(): Nullable<IShadowGenerator>;
  18562. /**
  18563. * Returns a Vector3, the absolute light position in the World.
  18564. * @returns the world space position of the light
  18565. */
  18566. getAbsolutePosition(): Vector3;
  18567. /**
  18568. * Specifies if the light will affect the passed mesh.
  18569. * @param mesh The mesh to test against the light
  18570. * @return true the mesh is affected otherwise, false.
  18571. */
  18572. canAffectMesh(mesh: AbstractMesh): boolean;
  18573. /**
  18574. * Sort function to order lights for rendering.
  18575. * @param a First Light object to compare to second.
  18576. * @param b Second Light object to compare first.
  18577. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18578. */
  18579. static CompareLightsPriority(a: Light, b: Light): number;
  18580. /**
  18581. * Releases resources associated with this node.
  18582. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18583. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18584. */
  18585. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18586. /**
  18587. * Returns the light type ID (integer).
  18588. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18589. */
  18590. getTypeID(): number;
  18591. /**
  18592. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18593. * @returns the scaled intensity in intensity mode unit
  18594. */
  18595. getScaledIntensity(): number;
  18596. /**
  18597. * Returns a new Light object, named "name", from the current one.
  18598. * @param name The name of the cloned light
  18599. * @param newParent The parent of this light, if it has one
  18600. * @returns the new created light
  18601. */
  18602. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18603. /**
  18604. * Serializes the current light into a Serialization object.
  18605. * @returns the serialized object.
  18606. */
  18607. serialize(): any;
  18608. /**
  18609. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18610. * This new light is named "name" and added to the passed scene.
  18611. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18612. * @param name The friendly name of the light
  18613. * @param scene The scene the new light will belong to
  18614. * @returns the constructor function
  18615. */
  18616. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18617. /**
  18618. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18619. * @param parsedLight The JSON representation of the light
  18620. * @param scene The scene to create the parsed light in
  18621. * @returns the created light after parsing
  18622. */
  18623. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18624. private _hookArrayForExcluded;
  18625. private _hookArrayForIncludedOnly;
  18626. private _resyncMeshes;
  18627. /**
  18628. * Forces the meshes to update their light related information in their rendering used effects
  18629. * @hidden Internal Use Only
  18630. */
  18631. _markMeshesAsLightDirty(): void;
  18632. /**
  18633. * Recomputes the cached photometric scale if needed.
  18634. */
  18635. private _computePhotometricScale;
  18636. /**
  18637. * Returns the Photometric Scale according to the light type and intensity mode.
  18638. */
  18639. private _getPhotometricScale;
  18640. /**
  18641. * Reorder the light in the scene according to their defined priority.
  18642. * @hidden Internal Use Only
  18643. */
  18644. _reorderLightsInScene(): void;
  18645. /**
  18646. * Prepares the list of defines specific to the light type.
  18647. * @param defines the list of defines
  18648. * @param lightIndex defines the index of the light for the effect
  18649. */
  18650. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18651. }
  18652. }
  18653. declare module "babylonjs/Cameras/targetCamera" {
  18654. import { Nullable } from "babylonjs/types";
  18655. import { Camera } from "babylonjs/Cameras/camera";
  18656. import { Scene } from "babylonjs/scene";
  18657. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18658. /**
  18659. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18660. * This is the base of the follow, arc rotate cameras and Free camera
  18661. * @see http://doc.babylonjs.com/features/cameras
  18662. */
  18663. export class TargetCamera extends Camera {
  18664. private static _RigCamTransformMatrix;
  18665. private static _TargetTransformMatrix;
  18666. private static _TargetFocalPoint;
  18667. /**
  18668. * Define the current direction the camera is moving to
  18669. */
  18670. cameraDirection: Vector3;
  18671. /**
  18672. * Define the current rotation the camera is rotating to
  18673. */
  18674. cameraRotation: Vector2;
  18675. /**
  18676. * When set, the up vector of the camera will be updated by the rotation of the camera
  18677. */
  18678. updateUpVectorFromRotation: boolean;
  18679. private _tmpQuaternion;
  18680. /**
  18681. * Define the current rotation of the camera
  18682. */
  18683. rotation: Vector3;
  18684. /**
  18685. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18686. */
  18687. rotationQuaternion: Quaternion;
  18688. /**
  18689. * Define the current speed of the camera
  18690. */
  18691. speed: number;
  18692. /**
  18693. * Add constraint to the camera to prevent it to move freely in all directions and
  18694. * around all axis.
  18695. */
  18696. noRotationConstraint: boolean;
  18697. /**
  18698. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18699. * panning
  18700. */
  18701. invertRotation: boolean;
  18702. /**
  18703. * Speed multiplier for inverse camera panning
  18704. */
  18705. inverseRotationSpeed: number;
  18706. /**
  18707. * Define the current target of the camera as an object or a position.
  18708. */
  18709. lockedTarget: any;
  18710. /** @hidden */
  18711. _currentTarget: Vector3;
  18712. /** @hidden */
  18713. _initialFocalDistance: number;
  18714. /** @hidden */
  18715. _viewMatrix: Matrix;
  18716. /** @hidden */
  18717. _camMatrix: Matrix;
  18718. /** @hidden */
  18719. _cameraTransformMatrix: Matrix;
  18720. /** @hidden */
  18721. _cameraRotationMatrix: Matrix;
  18722. /** @hidden */
  18723. _referencePoint: Vector3;
  18724. /** @hidden */
  18725. _transformedReferencePoint: Vector3;
  18726. protected _globalCurrentTarget: Vector3;
  18727. protected _globalCurrentUpVector: Vector3;
  18728. /** @hidden */
  18729. _reset: () => void;
  18730. private _defaultUp;
  18731. /**
  18732. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18733. * This is the base of the follow, arc rotate cameras and Free camera
  18734. * @see http://doc.babylonjs.com/features/cameras
  18735. * @param name Defines the name of the camera in the scene
  18736. * @param position Defines the start position of the camera in the scene
  18737. * @param scene Defines the scene the camera belongs to
  18738. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18739. */
  18740. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18741. /**
  18742. * Gets the position in front of the camera at a given distance.
  18743. * @param distance The distance from the camera we want the position to be
  18744. * @returns the position
  18745. */
  18746. getFrontPosition(distance: number): Vector3;
  18747. /** @hidden */
  18748. _getLockedTargetPosition(): Nullable<Vector3>;
  18749. private _storedPosition;
  18750. private _storedRotation;
  18751. private _storedRotationQuaternion;
  18752. /**
  18753. * Store current camera state of the camera (fov, position, rotation, etc..)
  18754. * @returns the camera
  18755. */
  18756. storeState(): Camera;
  18757. /**
  18758. * Restored camera state. You must call storeState() first
  18759. * @returns whether it was successful or not
  18760. * @hidden
  18761. */
  18762. _restoreStateValues(): boolean;
  18763. /** @hidden */
  18764. _initCache(): void;
  18765. /** @hidden */
  18766. _updateCache(ignoreParentClass?: boolean): void;
  18767. /** @hidden */
  18768. _isSynchronizedViewMatrix(): boolean;
  18769. /** @hidden */
  18770. _computeLocalCameraSpeed(): number;
  18771. /**
  18772. * Defines the target the camera should look at.
  18773. * @param target Defines the new target as a Vector or a mesh
  18774. */
  18775. setTarget(target: Vector3): void;
  18776. /**
  18777. * Return the current target position of the camera. This value is expressed in local space.
  18778. * @returns the target position
  18779. */
  18780. getTarget(): Vector3;
  18781. /** @hidden */
  18782. _decideIfNeedsToMove(): boolean;
  18783. /** @hidden */
  18784. _updatePosition(): void;
  18785. /** @hidden */
  18786. _checkInputs(): void;
  18787. protected _updateCameraRotationMatrix(): void;
  18788. /**
  18789. * 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)
  18790. * @returns the current camera
  18791. */
  18792. private _rotateUpVectorWithCameraRotationMatrix;
  18793. private _cachedRotationZ;
  18794. private _cachedQuaternionRotationZ;
  18795. /** @hidden */
  18796. _getViewMatrix(): Matrix;
  18797. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18798. /**
  18799. * @hidden
  18800. */
  18801. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18802. /**
  18803. * @hidden
  18804. */
  18805. _updateRigCameras(): void;
  18806. private _getRigCamPositionAndTarget;
  18807. /**
  18808. * Gets the current object class name.
  18809. * @return the class name
  18810. */
  18811. getClassName(): string;
  18812. }
  18813. }
  18814. declare module "babylonjs/Events/keyboardEvents" {
  18815. /**
  18816. * Gather the list of keyboard event types as constants.
  18817. */
  18818. export class KeyboardEventTypes {
  18819. /**
  18820. * The keydown event is fired when a key becomes active (pressed).
  18821. */
  18822. static readonly KEYDOWN: number;
  18823. /**
  18824. * The keyup event is fired when a key has been released.
  18825. */
  18826. static readonly KEYUP: number;
  18827. }
  18828. /**
  18829. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18830. */
  18831. export class KeyboardInfo {
  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. * Instantiates a new keyboard info.
  18842. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18843. * @param type Defines the type of event (KeyboardEventTypes)
  18844. * @param event Defines the related dom event
  18845. */
  18846. constructor(
  18847. /**
  18848. * Defines the type of event (KeyboardEventTypes)
  18849. */
  18850. type: number,
  18851. /**
  18852. * Defines the related dom event
  18853. */
  18854. event: KeyboardEvent);
  18855. }
  18856. /**
  18857. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18858. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18859. */
  18860. export class KeyboardInfoPre extends KeyboardInfo {
  18861. /**
  18862. * Defines the type of event (KeyboardEventTypes)
  18863. */
  18864. type: number;
  18865. /**
  18866. * Defines the related dom event
  18867. */
  18868. event: KeyboardEvent;
  18869. /**
  18870. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18871. */
  18872. skipOnPointerObservable: boolean;
  18873. /**
  18874. * Instantiates a new keyboard pre info.
  18875. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18876. * @param type Defines the type of event (KeyboardEventTypes)
  18877. * @param event Defines the related dom event
  18878. */
  18879. constructor(
  18880. /**
  18881. * Defines the type of event (KeyboardEventTypes)
  18882. */
  18883. type: number,
  18884. /**
  18885. * Defines the related dom event
  18886. */
  18887. event: KeyboardEvent);
  18888. }
  18889. }
  18890. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18891. import { Nullable } from "babylonjs/types";
  18892. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18893. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18894. /**
  18895. * Manage the keyboard inputs to control the movement of a free camera.
  18896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18897. */
  18898. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18899. /**
  18900. * Defines the camera the input is attached to.
  18901. */
  18902. camera: FreeCamera;
  18903. /**
  18904. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18905. */
  18906. keysUp: number[];
  18907. /**
  18908. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18909. */
  18910. keysUpward: number[];
  18911. /**
  18912. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18913. */
  18914. keysDown: number[];
  18915. /**
  18916. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18917. */
  18918. keysDownward: number[];
  18919. /**
  18920. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18921. */
  18922. keysLeft: number[];
  18923. /**
  18924. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18925. */
  18926. keysRight: number[];
  18927. private _keys;
  18928. private _onCanvasBlurObserver;
  18929. private _onKeyboardObserver;
  18930. private _engine;
  18931. private _scene;
  18932. /**
  18933. * Attach the input controls to a specific dom element to get the input from.
  18934. * @param element Defines the element the controls should be listened from
  18935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18936. */
  18937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18938. /**
  18939. * Detach the current controls from the specified dom element.
  18940. * @param element Defines the element to stop listening the inputs from
  18941. */
  18942. detachControl(element: Nullable<HTMLElement>): void;
  18943. /**
  18944. * Update the current camera state depending on the inputs that have been used this frame.
  18945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18946. */
  18947. checkInputs(): void;
  18948. /**
  18949. * Gets the class name of the current intput.
  18950. * @returns the class name
  18951. */
  18952. getClassName(): string;
  18953. /** @hidden */
  18954. _onLostFocus(): void;
  18955. /**
  18956. * Get the friendly name associated with the input class.
  18957. * @returns the input friendly name
  18958. */
  18959. getSimpleName(): string;
  18960. }
  18961. }
  18962. declare module "babylonjs/Events/pointerEvents" {
  18963. import { Nullable } from "babylonjs/types";
  18964. import { Vector2 } from "babylonjs/Maths/math.vector";
  18965. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18966. import { Ray } from "babylonjs/Culling/ray";
  18967. /**
  18968. * Gather the list of pointer event types as constants.
  18969. */
  18970. export class PointerEventTypes {
  18971. /**
  18972. * 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.
  18973. */
  18974. static readonly POINTERDOWN: number;
  18975. /**
  18976. * The pointerup event is fired when a pointer is no longer active.
  18977. */
  18978. static readonly POINTERUP: number;
  18979. /**
  18980. * The pointermove event is fired when a pointer changes coordinates.
  18981. */
  18982. static readonly POINTERMOVE: number;
  18983. /**
  18984. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18985. */
  18986. static readonly POINTERWHEEL: number;
  18987. /**
  18988. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18989. */
  18990. static readonly POINTERPICK: number;
  18991. /**
  18992. * The pointertap event is fired when a the object has been touched and released without drag.
  18993. */
  18994. static readonly POINTERTAP: number;
  18995. /**
  18996. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18997. */
  18998. static readonly POINTERDOUBLETAP: number;
  18999. }
  19000. /**
  19001. * Base class of pointer info types.
  19002. */
  19003. export class PointerInfoBase {
  19004. /**
  19005. * Defines the type of event (PointerEventTypes)
  19006. */
  19007. type: number;
  19008. /**
  19009. * Defines the related dom event
  19010. */
  19011. event: PointerEvent | MouseWheelEvent;
  19012. /**
  19013. * Instantiates the base class of pointers info.
  19014. * @param type Defines the type of event (PointerEventTypes)
  19015. * @param event Defines the related dom event
  19016. */
  19017. constructor(
  19018. /**
  19019. * Defines the type of event (PointerEventTypes)
  19020. */
  19021. type: number,
  19022. /**
  19023. * Defines the related dom event
  19024. */
  19025. event: PointerEvent | MouseWheelEvent);
  19026. }
  19027. /**
  19028. * This class is used to store pointer related info for the onPrePointerObservable event.
  19029. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19030. */
  19031. export class PointerInfoPre extends PointerInfoBase {
  19032. /**
  19033. * Ray from a pointer if availible (eg. 6dof controller)
  19034. */
  19035. ray: Nullable<Ray>;
  19036. /**
  19037. * Defines the local position of the pointer on the canvas.
  19038. */
  19039. localPosition: Vector2;
  19040. /**
  19041. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19042. */
  19043. skipOnPointerObservable: boolean;
  19044. /**
  19045. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19046. * @param type Defines the type of event (PointerEventTypes)
  19047. * @param event Defines the related dom event
  19048. * @param localX Defines the local x coordinates of the pointer when the event occured
  19049. * @param localY Defines the local y coordinates of the pointer when the event occured
  19050. */
  19051. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19052. }
  19053. /**
  19054. * This type contains all the data related to a pointer event in Babylon.js.
  19055. * 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.
  19056. */
  19057. export class PointerInfo extends PointerInfoBase {
  19058. /**
  19059. * Defines the picking info associated to the info (if any)\
  19060. */
  19061. pickInfo: Nullable<PickingInfo>;
  19062. /**
  19063. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19064. * @param type Defines the type of event (PointerEventTypes)
  19065. * @param event Defines the related dom event
  19066. * @param pickInfo Defines the picking info associated to the info (if any)\
  19067. */
  19068. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19069. /**
  19070. * Defines the picking info associated to the info (if any)\
  19071. */
  19072. pickInfo: Nullable<PickingInfo>);
  19073. }
  19074. /**
  19075. * Data relating to a touch event on the screen.
  19076. */
  19077. export interface PointerTouch {
  19078. /**
  19079. * X coordinate of touch.
  19080. */
  19081. x: number;
  19082. /**
  19083. * Y coordinate of touch.
  19084. */
  19085. y: number;
  19086. /**
  19087. * Id of touch. Unique for each finger.
  19088. */
  19089. pointerId: number;
  19090. /**
  19091. * Event type passed from DOM.
  19092. */
  19093. type: any;
  19094. }
  19095. }
  19096. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19097. import { Observable } from "babylonjs/Misc/observable";
  19098. import { Nullable } from "babylonjs/types";
  19099. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19100. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19101. /**
  19102. * Manage the mouse inputs to control the movement of a free camera.
  19103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19104. */
  19105. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19106. /**
  19107. * Define if touch is enabled in the mouse input
  19108. */
  19109. touchEnabled: boolean;
  19110. /**
  19111. * Defines the camera the input is attached to.
  19112. */
  19113. camera: FreeCamera;
  19114. /**
  19115. * Defines the buttons associated with the input to handle camera move.
  19116. */
  19117. buttons: number[];
  19118. /**
  19119. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19120. */
  19121. angularSensibility: number;
  19122. private _pointerInput;
  19123. private _onMouseMove;
  19124. private _observer;
  19125. private previousPosition;
  19126. /**
  19127. * Observable for when a pointer move event occurs containing the move offset
  19128. */
  19129. onPointerMovedObservable: Observable<{
  19130. offsetX: number;
  19131. offsetY: number;
  19132. }>;
  19133. /**
  19134. * @hidden
  19135. * If the camera should be rotated automatically based on pointer movement
  19136. */
  19137. _allowCameraRotation: boolean;
  19138. /**
  19139. * Manage the mouse inputs to control the movement of a free camera.
  19140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19141. * @param touchEnabled Defines if touch is enabled or not
  19142. */
  19143. constructor(
  19144. /**
  19145. * Define if touch is enabled in the mouse input
  19146. */
  19147. touchEnabled?: boolean);
  19148. /**
  19149. * Attach the input controls to a specific dom element to get the input from.
  19150. * @param element Defines the element the controls should be listened from
  19151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19152. */
  19153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19154. /**
  19155. * Called on JS contextmenu event.
  19156. * Override this method to provide functionality.
  19157. */
  19158. protected onContextMenu(evt: PointerEvent): void;
  19159. /**
  19160. * Detach the current controls from the specified dom element.
  19161. * @param element Defines the element to stop listening the inputs from
  19162. */
  19163. detachControl(element: Nullable<HTMLElement>): void;
  19164. /**
  19165. * Gets the class name of the current intput.
  19166. * @returns the class name
  19167. */
  19168. getClassName(): string;
  19169. /**
  19170. * Get the friendly name associated with the input class.
  19171. * @returns the input friendly name
  19172. */
  19173. getSimpleName(): string;
  19174. }
  19175. }
  19176. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19177. import { Nullable } from "babylonjs/types";
  19178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19179. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19180. /**
  19181. * Manage the touch inputs to control the movement of a free camera.
  19182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19183. */
  19184. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19185. /**
  19186. * Defines the camera the input is attached to.
  19187. */
  19188. camera: FreeCamera;
  19189. /**
  19190. * Defines the touch sensibility for rotation.
  19191. * The higher the faster.
  19192. */
  19193. touchAngularSensibility: number;
  19194. /**
  19195. * Defines the touch sensibility for move.
  19196. * The higher the faster.
  19197. */
  19198. touchMoveSensibility: number;
  19199. private _offsetX;
  19200. private _offsetY;
  19201. private _pointerPressed;
  19202. private _pointerInput;
  19203. private _observer;
  19204. private _onLostFocus;
  19205. /**
  19206. * Attach the input controls to a specific dom element to get the input from.
  19207. * @param element Defines the element the controls should be listened from
  19208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19209. */
  19210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19211. /**
  19212. * Detach the current controls from the specified dom element.
  19213. * @param element Defines the element to stop listening the inputs from
  19214. */
  19215. detachControl(element: Nullable<HTMLElement>): void;
  19216. /**
  19217. * Update the current camera state depending on the inputs that have been used this frame.
  19218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19219. */
  19220. checkInputs(): void;
  19221. /**
  19222. * Gets the class name of the current intput.
  19223. * @returns the class name
  19224. */
  19225. getClassName(): string;
  19226. /**
  19227. * Get the friendly name associated with the input class.
  19228. * @returns the input friendly name
  19229. */
  19230. getSimpleName(): string;
  19231. }
  19232. }
  19233. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19234. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19235. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19236. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19237. import { Nullable } from "babylonjs/types";
  19238. /**
  19239. * Default Inputs manager for the FreeCamera.
  19240. * It groups all the default supported inputs for ease of use.
  19241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19242. */
  19243. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19244. /**
  19245. * @hidden
  19246. */
  19247. _mouseInput: Nullable<FreeCameraMouseInput>;
  19248. /**
  19249. * Instantiates a new FreeCameraInputsManager.
  19250. * @param camera Defines the camera the inputs belong to
  19251. */
  19252. constructor(camera: FreeCamera);
  19253. /**
  19254. * Add keyboard input support to the input manager.
  19255. * @returns the current input manager
  19256. */
  19257. addKeyboard(): FreeCameraInputsManager;
  19258. /**
  19259. * Add mouse input support to the input manager.
  19260. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19261. * @returns the current input manager
  19262. */
  19263. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19264. /**
  19265. * Removes the mouse input support from the manager
  19266. * @returns the current input manager
  19267. */
  19268. removeMouse(): FreeCameraInputsManager;
  19269. /**
  19270. * Add touch input support to the input manager.
  19271. * @returns the current input manager
  19272. */
  19273. addTouch(): FreeCameraInputsManager;
  19274. /**
  19275. * Remove all attached input methods from a camera
  19276. */
  19277. clear(): void;
  19278. }
  19279. }
  19280. declare module "babylonjs/Cameras/freeCamera" {
  19281. import { Vector3 } from "babylonjs/Maths/math.vector";
  19282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19283. import { Scene } from "babylonjs/scene";
  19284. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19285. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19286. /**
  19287. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19288. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19290. */
  19291. export class FreeCamera extends TargetCamera {
  19292. /**
  19293. * Define the collision ellipsoid of the camera.
  19294. * This is helpful to simulate a camera body like the player body around the camera
  19295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19296. */
  19297. ellipsoid: Vector3;
  19298. /**
  19299. * Define an offset for the position of the ellipsoid around the camera.
  19300. * This can be helpful to determine the center of the body near the gravity center of the body
  19301. * instead of its head.
  19302. */
  19303. ellipsoidOffset: Vector3;
  19304. /**
  19305. * Enable or disable collisions of the camera with the rest of the scene objects.
  19306. */
  19307. checkCollisions: boolean;
  19308. /**
  19309. * Enable or disable gravity on the camera.
  19310. */
  19311. applyGravity: boolean;
  19312. /**
  19313. * Define the input manager associated to the camera.
  19314. */
  19315. inputs: FreeCameraInputsManager;
  19316. /**
  19317. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19318. * Higher values reduce sensitivity.
  19319. */
  19320. get angularSensibility(): number;
  19321. /**
  19322. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19323. * Higher values reduce sensitivity.
  19324. */
  19325. set angularSensibility(value: number);
  19326. /**
  19327. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19328. */
  19329. get keysUp(): number[];
  19330. set keysUp(value: number[]);
  19331. /**
  19332. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19333. */
  19334. get keysUpward(): number[];
  19335. set keysUpward(value: number[]);
  19336. /**
  19337. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19338. */
  19339. get keysDown(): number[];
  19340. set keysDown(value: number[]);
  19341. /**
  19342. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19343. */
  19344. get keysDownward(): number[];
  19345. set keysDownward(value: number[]);
  19346. /**
  19347. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19348. */
  19349. get keysLeft(): number[];
  19350. set keysLeft(value: number[]);
  19351. /**
  19352. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19353. */
  19354. get keysRight(): number[];
  19355. set keysRight(value: number[]);
  19356. /**
  19357. * Event raised when the camera collide with a mesh in the scene.
  19358. */
  19359. onCollide: (collidedMesh: AbstractMesh) => void;
  19360. private _collider;
  19361. private _needMoveForGravity;
  19362. private _oldPosition;
  19363. private _diffPosition;
  19364. private _newPosition;
  19365. /** @hidden */
  19366. _localDirection: Vector3;
  19367. /** @hidden */
  19368. _transformedDirection: Vector3;
  19369. /**
  19370. * Instantiates a Free Camera.
  19371. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19372. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19373. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19374. * @param name Define the name of the camera in the scene
  19375. * @param position Define the start position of the camera in the scene
  19376. * @param scene Define the scene the camera belongs to
  19377. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19378. */
  19379. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19380. /**
  19381. * Attached controls to the current camera.
  19382. * @param element Defines the element the controls should be listened from
  19383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19384. */
  19385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19386. /**
  19387. * Detach the current controls from the camera.
  19388. * The camera will stop reacting to inputs.
  19389. * @param element Defines the element to stop listening the inputs from
  19390. */
  19391. detachControl(element: HTMLElement): void;
  19392. private _collisionMask;
  19393. /**
  19394. * Define a collision mask to limit the list of object the camera can collide with
  19395. */
  19396. get collisionMask(): number;
  19397. set collisionMask(mask: number);
  19398. /** @hidden */
  19399. _collideWithWorld(displacement: Vector3): void;
  19400. private _onCollisionPositionChange;
  19401. /** @hidden */
  19402. _checkInputs(): void;
  19403. /** @hidden */
  19404. _decideIfNeedsToMove(): boolean;
  19405. /** @hidden */
  19406. _updatePosition(): void;
  19407. /**
  19408. * Destroy the camera and release the current resources hold by it.
  19409. */
  19410. dispose(): void;
  19411. /**
  19412. * Gets the current object class name.
  19413. * @return the class name
  19414. */
  19415. getClassName(): string;
  19416. }
  19417. }
  19418. declare module "babylonjs/Gamepads/gamepad" {
  19419. import { Observable } from "babylonjs/Misc/observable";
  19420. /**
  19421. * Represents a gamepad control stick position
  19422. */
  19423. export class StickValues {
  19424. /**
  19425. * The x component of the control stick
  19426. */
  19427. x: number;
  19428. /**
  19429. * The y component of the control stick
  19430. */
  19431. y: number;
  19432. /**
  19433. * Initializes the gamepad x and y control stick values
  19434. * @param x The x component of the gamepad control stick value
  19435. * @param y The y component of the gamepad control stick value
  19436. */
  19437. constructor(
  19438. /**
  19439. * The x component of the control stick
  19440. */
  19441. x: number,
  19442. /**
  19443. * The y component of the control stick
  19444. */
  19445. y: number);
  19446. }
  19447. /**
  19448. * An interface which manages callbacks for gamepad button changes
  19449. */
  19450. export interface GamepadButtonChanges {
  19451. /**
  19452. * Called when a gamepad has been changed
  19453. */
  19454. changed: boolean;
  19455. /**
  19456. * Called when a gamepad press event has been triggered
  19457. */
  19458. pressChanged: boolean;
  19459. /**
  19460. * Called when a touch event has been triggered
  19461. */
  19462. touchChanged: boolean;
  19463. /**
  19464. * Called when a value has changed
  19465. */
  19466. valueChanged: boolean;
  19467. }
  19468. /**
  19469. * Represents a gamepad
  19470. */
  19471. export class Gamepad {
  19472. /**
  19473. * The id of the gamepad
  19474. */
  19475. id: string;
  19476. /**
  19477. * The index of the gamepad
  19478. */
  19479. index: number;
  19480. /**
  19481. * The browser gamepad
  19482. */
  19483. browserGamepad: any;
  19484. /**
  19485. * Specifies what type of gamepad this represents
  19486. */
  19487. type: number;
  19488. private _leftStick;
  19489. private _rightStick;
  19490. /** @hidden */
  19491. _isConnected: boolean;
  19492. private _leftStickAxisX;
  19493. private _leftStickAxisY;
  19494. private _rightStickAxisX;
  19495. private _rightStickAxisY;
  19496. /**
  19497. * Triggered when the left control stick has been changed
  19498. */
  19499. private _onleftstickchanged;
  19500. /**
  19501. * Triggered when the right control stick has been changed
  19502. */
  19503. private _onrightstickchanged;
  19504. /**
  19505. * Represents a gamepad controller
  19506. */
  19507. static GAMEPAD: number;
  19508. /**
  19509. * Represents a generic controller
  19510. */
  19511. static GENERIC: number;
  19512. /**
  19513. * Represents an XBox controller
  19514. */
  19515. static XBOX: number;
  19516. /**
  19517. * Represents a pose-enabled controller
  19518. */
  19519. static POSE_ENABLED: number;
  19520. /**
  19521. * Represents an Dual Shock controller
  19522. */
  19523. static DUALSHOCK: number;
  19524. /**
  19525. * Specifies whether the left control stick should be Y-inverted
  19526. */
  19527. protected _invertLeftStickY: boolean;
  19528. /**
  19529. * Specifies if the gamepad has been connected
  19530. */
  19531. get isConnected(): boolean;
  19532. /**
  19533. * Initializes the gamepad
  19534. * @param id The id of the gamepad
  19535. * @param index The index of the gamepad
  19536. * @param browserGamepad The browser gamepad
  19537. * @param leftStickX The x component of the left joystick
  19538. * @param leftStickY The y component of the left joystick
  19539. * @param rightStickX The x component of the right joystick
  19540. * @param rightStickY The y component of the right joystick
  19541. */
  19542. constructor(
  19543. /**
  19544. * The id of the gamepad
  19545. */
  19546. id: string,
  19547. /**
  19548. * The index of the gamepad
  19549. */
  19550. index: number,
  19551. /**
  19552. * The browser gamepad
  19553. */
  19554. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19555. /**
  19556. * Callback triggered when the left joystick has changed
  19557. * @param callback
  19558. */
  19559. onleftstickchanged(callback: (values: StickValues) => void): void;
  19560. /**
  19561. * Callback triggered when the right joystick has changed
  19562. * @param callback
  19563. */
  19564. onrightstickchanged(callback: (values: StickValues) => void): void;
  19565. /**
  19566. * Gets the left joystick
  19567. */
  19568. get leftStick(): StickValues;
  19569. /**
  19570. * Sets the left joystick values
  19571. */
  19572. set leftStick(newValues: StickValues);
  19573. /**
  19574. * Gets the right joystick
  19575. */
  19576. get rightStick(): StickValues;
  19577. /**
  19578. * Sets the right joystick value
  19579. */
  19580. set rightStick(newValues: StickValues);
  19581. /**
  19582. * Updates the gamepad joystick positions
  19583. */
  19584. update(): void;
  19585. /**
  19586. * Disposes the gamepad
  19587. */
  19588. dispose(): void;
  19589. }
  19590. /**
  19591. * Represents a generic gamepad
  19592. */
  19593. export class GenericPad extends Gamepad {
  19594. private _buttons;
  19595. private _onbuttondown;
  19596. private _onbuttonup;
  19597. /**
  19598. * Observable triggered when a button has been pressed
  19599. */
  19600. onButtonDownObservable: Observable<number>;
  19601. /**
  19602. * Observable triggered when a button has been released
  19603. */
  19604. onButtonUpObservable: Observable<number>;
  19605. /**
  19606. * Callback triggered when a button has been pressed
  19607. * @param callback Called when a button has been pressed
  19608. */
  19609. onbuttondown(callback: (buttonPressed: number) => void): void;
  19610. /**
  19611. * Callback triggered when a button has been released
  19612. * @param callback Called when a button has been released
  19613. */
  19614. onbuttonup(callback: (buttonReleased: number) => void): void;
  19615. /**
  19616. * Initializes the generic gamepad
  19617. * @param id The id of the generic gamepad
  19618. * @param index The index of the generic gamepad
  19619. * @param browserGamepad The browser gamepad
  19620. */
  19621. constructor(id: string, index: number, browserGamepad: any);
  19622. private _setButtonValue;
  19623. /**
  19624. * Updates the generic gamepad
  19625. */
  19626. update(): void;
  19627. /**
  19628. * Disposes the generic gamepad
  19629. */
  19630. dispose(): void;
  19631. }
  19632. }
  19633. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19634. import { Observable } from "babylonjs/Misc/observable";
  19635. import { Nullable } from "babylonjs/types";
  19636. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19637. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19639. import { Ray } from "babylonjs/Culling/ray";
  19640. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19641. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19642. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19643. /**
  19644. * Defines the types of pose enabled controllers that are supported
  19645. */
  19646. export enum PoseEnabledControllerType {
  19647. /**
  19648. * HTC Vive
  19649. */
  19650. VIVE = 0,
  19651. /**
  19652. * Oculus Rift
  19653. */
  19654. OCULUS = 1,
  19655. /**
  19656. * Windows mixed reality
  19657. */
  19658. WINDOWS = 2,
  19659. /**
  19660. * Samsung gear VR
  19661. */
  19662. GEAR_VR = 3,
  19663. /**
  19664. * Google Daydream
  19665. */
  19666. DAYDREAM = 4,
  19667. /**
  19668. * Generic
  19669. */
  19670. GENERIC = 5
  19671. }
  19672. /**
  19673. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19674. */
  19675. export interface MutableGamepadButton {
  19676. /**
  19677. * Value of the button/trigger
  19678. */
  19679. value: number;
  19680. /**
  19681. * If the button/trigger is currently touched
  19682. */
  19683. touched: boolean;
  19684. /**
  19685. * If the button/trigger is currently pressed
  19686. */
  19687. pressed: boolean;
  19688. }
  19689. /**
  19690. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19691. * @hidden
  19692. */
  19693. export interface ExtendedGamepadButton extends GamepadButton {
  19694. /**
  19695. * If the button/trigger is currently pressed
  19696. */
  19697. readonly pressed: boolean;
  19698. /**
  19699. * If the button/trigger is currently touched
  19700. */
  19701. readonly touched: boolean;
  19702. /**
  19703. * Value of the button/trigger
  19704. */
  19705. readonly value: number;
  19706. }
  19707. /** @hidden */
  19708. export interface _GamePadFactory {
  19709. /**
  19710. * Returns whether or not the current gamepad can be created for this type of controller.
  19711. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19712. * @returns true if it can be created, otherwise false
  19713. */
  19714. canCreate(gamepadInfo: any): boolean;
  19715. /**
  19716. * Creates a new instance of the Gamepad.
  19717. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19718. * @returns the new gamepad instance
  19719. */
  19720. create(gamepadInfo: any): Gamepad;
  19721. }
  19722. /**
  19723. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19724. */
  19725. export class PoseEnabledControllerHelper {
  19726. /** @hidden */
  19727. static _ControllerFactories: _GamePadFactory[];
  19728. /** @hidden */
  19729. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19730. /**
  19731. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19732. * @param vrGamepad the gamepad to initialized
  19733. * @returns a vr controller of the type the gamepad identified as
  19734. */
  19735. static InitiateController(vrGamepad: any): Gamepad;
  19736. }
  19737. /**
  19738. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19739. */
  19740. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19741. /**
  19742. * If the controller is used in a webXR session
  19743. */
  19744. isXR: boolean;
  19745. private _deviceRoomPosition;
  19746. private _deviceRoomRotationQuaternion;
  19747. /**
  19748. * The device position in babylon space
  19749. */
  19750. devicePosition: Vector3;
  19751. /**
  19752. * The device rotation in babylon space
  19753. */
  19754. deviceRotationQuaternion: Quaternion;
  19755. /**
  19756. * The scale factor of the device in babylon space
  19757. */
  19758. deviceScaleFactor: number;
  19759. /**
  19760. * (Likely devicePosition should be used instead) The device position in its room space
  19761. */
  19762. position: Vector3;
  19763. /**
  19764. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19765. */
  19766. rotationQuaternion: Quaternion;
  19767. /**
  19768. * The type of controller (Eg. Windows mixed reality)
  19769. */
  19770. controllerType: PoseEnabledControllerType;
  19771. protected _calculatedPosition: Vector3;
  19772. private _calculatedRotation;
  19773. /**
  19774. * The raw pose from the device
  19775. */
  19776. rawPose: DevicePose;
  19777. private _trackPosition;
  19778. private _maxRotationDistFromHeadset;
  19779. private _draggedRoomRotation;
  19780. /**
  19781. * @hidden
  19782. */
  19783. _disableTrackPosition(fixedPosition: Vector3): void;
  19784. /**
  19785. * Internal, the mesh attached to the controller
  19786. * @hidden
  19787. */
  19788. _mesh: Nullable<AbstractMesh>;
  19789. private _poseControlledCamera;
  19790. private _leftHandSystemQuaternion;
  19791. /**
  19792. * Internal, matrix used to convert room space to babylon space
  19793. * @hidden
  19794. */
  19795. _deviceToWorld: Matrix;
  19796. /**
  19797. * Node to be used when casting a ray from the controller
  19798. * @hidden
  19799. */
  19800. _pointingPoseNode: Nullable<TransformNode>;
  19801. /**
  19802. * Name of the child mesh that can be used to cast a ray from the controller
  19803. */
  19804. static readonly POINTING_POSE: string;
  19805. /**
  19806. * Creates a new PoseEnabledController from a gamepad
  19807. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19808. */
  19809. constructor(browserGamepad: any);
  19810. private _workingMatrix;
  19811. /**
  19812. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19813. */
  19814. update(): void;
  19815. /**
  19816. * Updates only the pose device and mesh without doing any button event checking
  19817. */
  19818. protected _updatePoseAndMesh(): void;
  19819. /**
  19820. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19821. * @param poseData raw pose fromthe device
  19822. */
  19823. updateFromDevice(poseData: DevicePose): void;
  19824. /**
  19825. * @hidden
  19826. */
  19827. _meshAttachedObservable: Observable<AbstractMesh>;
  19828. /**
  19829. * Attaches a mesh to the controller
  19830. * @param mesh the mesh to be attached
  19831. */
  19832. attachToMesh(mesh: AbstractMesh): void;
  19833. /**
  19834. * Attaches the controllers mesh to a camera
  19835. * @param camera the camera the mesh should be attached to
  19836. */
  19837. attachToPoseControlledCamera(camera: TargetCamera): void;
  19838. /**
  19839. * Disposes of the controller
  19840. */
  19841. dispose(): void;
  19842. /**
  19843. * The mesh that is attached to the controller
  19844. */
  19845. get mesh(): Nullable<AbstractMesh>;
  19846. /**
  19847. * Gets the ray of the controller in the direction the controller is pointing
  19848. * @param length the length the resulting ray should be
  19849. * @returns a ray in the direction the controller is pointing
  19850. */
  19851. getForwardRay(length?: number): Ray;
  19852. }
  19853. }
  19854. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19855. import { Observable } from "babylonjs/Misc/observable";
  19856. import { Scene } from "babylonjs/scene";
  19857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19858. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19859. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19860. import { Nullable } from "babylonjs/types";
  19861. /**
  19862. * Defines the WebVRController object that represents controllers tracked in 3D space
  19863. */
  19864. export abstract class WebVRController extends PoseEnabledController {
  19865. /**
  19866. * Internal, the default controller model for the controller
  19867. */
  19868. protected _defaultModel: Nullable<AbstractMesh>;
  19869. /**
  19870. * Fired when the trigger state has changed
  19871. */
  19872. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19873. /**
  19874. * Fired when the main button state has changed
  19875. */
  19876. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19877. /**
  19878. * Fired when the secondary button state has changed
  19879. */
  19880. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19881. /**
  19882. * Fired when the pad state has changed
  19883. */
  19884. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19885. /**
  19886. * Fired when controllers stick values have changed
  19887. */
  19888. onPadValuesChangedObservable: Observable<StickValues>;
  19889. /**
  19890. * Array of button availible on the controller
  19891. */
  19892. protected _buttons: Array<MutableGamepadButton>;
  19893. private _onButtonStateChange;
  19894. /**
  19895. * Fired when a controller button's state has changed
  19896. * @param callback the callback containing the button that was modified
  19897. */
  19898. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19899. /**
  19900. * X and Y axis corresponding to the controllers joystick
  19901. */
  19902. pad: StickValues;
  19903. /**
  19904. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19905. */
  19906. hand: string;
  19907. /**
  19908. * The default controller model for the controller
  19909. */
  19910. get defaultModel(): Nullable<AbstractMesh>;
  19911. /**
  19912. * Creates a new WebVRController from a gamepad
  19913. * @param vrGamepad the gamepad that the WebVRController should be created from
  19914. */
  19915. constructor(vrGamepad: any);
  19916. /**
  19917. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19918. */
  19919. update(): void;
  19920. /**
  19921. * Function to be called when a button is modified
  19922. */
  19923. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19924. /**
  19925. * Loads a mesh and attaches it to the controller
  19926. * @param scene the scene the mesh should be added to
  19927. * @param meshLoaded callback for when the mesh has been loaded
  19928. */
  19929. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19930. private _setButtonValue;
  19931. private _changes;
  19932. private _checkChanges;
  19933. /**
  19934. * Disposes of th webVRCOntroller
  19935. */
  19936. dispose(): void;
  19937. }
  19938. }
  19939. declare module "babylonjs/Lights/hemisphericLight" {
  19940. import { Nullable } from "babylonjs/types";
  19941. import { Scene } from "babylonjs/scene";
  19942. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19943. import { Color3 } from "babylonjs/Maths/math.color";
  19944. import { Effect } from "babylonjs/Materials/effect";
  19945. import { Light } from "babylonjs/Lights/light";
  19946. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19947. /**
  19948. * The HemisphericLight simulates the ambient environment light,
  19949. * so the passed direction is the light reflection direction, not the incoming direction.
  19950. */
  19951. export class HemisphericLight extends Light {
  19952. /**
  19953. * The groundColor is the light in the opposite direction to the one specified during creation.
  19954. * 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.
  19955. */
  19956. groundColor: Color3;
  19957. /**
  19958. * The light reflection direction, not the incoming direction.
  19959. */
  19960. direction: Vector3;
  19961. /**
  19962. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19963. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19964. * The HemisphericLight can't cast shadows.
  19965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19966. * @param name The friendly name of the light
  19967. * @param direction The direction of the light reflection
  19968. * @param scene The scene the light belongs to
  19969. */
  19970. constructor(name: string, direction: Vector3, scene: Scene);
  19971. protected _buildUniformLayout(): void;
  19972. /**
  19973. * Returns the string "HemisphericLight".
  19974. * @return The class name
  19975. */
  19976. getClassName(): string;
  19977. /**
  19978. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19979. * Returns the updated direction.
  19980. * @param target The target the direction should point to
  19981. * @return The computed direction
  19982. */
  19983. setDirectionToTarget(target: Vector3): Vector3;
  19984. /**
  19985. * Returns the shadow generator associated to the light.
  19986. * @returns Always null for hemispheric lights because it does not support shadows.
  19987. */
  19988. getShadowGenerator(): Nullable<IShadowGenerator>;
  19989. /**
  19990. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19991. * @param effect The effect to update
  19992. * @param lightIndex The index of the light in the effect to update
  19993. * @returns The hemispheric light
  19994. */
  19995. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19996. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19997. /**
  19998. * Computes the world matrix of the node
  19999. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20000. * @param useWasUpdatedFlag defines a reserved property
  20001. * @returns the world matrix
  20002. */
  20003. computeWorldMatrix(): Matrix;
  20004. /**
  20005. * Returns the integer 3.
  20006. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20007. */
  20008. getTypeID(): number;
  20009. /**
  20010. * Prepares the list of defines specific to the light type.
  20011. * @param defines the list of defines
  20012. * @param lightIndex defines the index of the light for the effect
  20013. */
  20014. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20015. }
  20016. }
  20017. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20018. /** @hidden */
  20019. export var vrMultiviewToSingleviewPixelShader: {
  20020. name: string;
  20021. shader: string;
  20022. };
  20023. }
  20024. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20025. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20026. import { Scene } from "babylonjs/scene";
  20027. /**
  20028. * Renders to multiple views with a single draw call
  20029. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20030. */
  20031. export class MultiviewRenderTarget extends RenderTargetTexture {
  20032. /**
  20033. * Creates a multiview render target
  20034. * @param scene scene used with the render target
  20035. * @param size the size of the render target (used for each view)
  20036. */
  20037. constructor(scene: Scene, size?: number | {
  20038. width: number;
  20039. height: number;
  20040. } | {
  20041. ratio: number;
  20042. });
  20043. /**
  20044. * @hidden
  20045. * @param faceIndex the face index, if its a cube texture
  20046. */
  20047. _bindFrameBuffer(faceIndex?: number): void;
  20048. /**
  20049. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20050. * @returns the view count
  20051. */
  20052. getViewCount(): number;
  20053. }
  20054. }
  20055. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20056. import { Camera } from "babylonjs/Cameras/camera";
  20057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20058. import { Nullable } from "babylonjs/types";
  20059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20060. import { Matrix } from "babylonjs/Maths/math.vector";
  20061. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20062. module "babylonjs/Engines/engine" {
  20063. interface Engine {
  20064. /**
  20065. * Creates a new multiview render target
  20066. * @param width defines the width of the texture
  20067. * @param height defines the height of the texture
  20068. * @returns the created multiview texture
  20069. */
  20070. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20071. /**
  20072. * Binds a multiview framebuffer to be drawn to
  20073. * @param multiviewTexture texture to bind
  20074. */
  20075. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20076. }
  20077. }
  20078. module "babylonjs/Cameras/camera" {
  20079. interface Camera {
  20080. /**
  20081. * @hidden
  20082. * 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)
  20083. */
  20084. _useMultiviewToSingleView: boolean;
  20085. /**
  20086. * @hidden
  20087. * 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)
  20088. */
  20089. _multiviewTexture: Nullable<RenderTargetTexture>;
  20090. /**
  20091. * @hidden
  20092. * ensures the multiview texture of the camera exists and has the specified width/height
  20093. * @param width height to set on the multiview texture
  20094. * @param height width to set on the multiview texture
  20095. */
  20096. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20097. }
  20098. }
  20099. module "babylonjs/scene" {
  20100. interface Scene {
  20101. /** @hidden */
  20102. _transformMatrixR: Matrix;
  20103. /** @hidden */
  20104. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20105. /** @hidden */
  20106. _createMultiviewUbo(): void;
  20107. /** @hidden */
  20108. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20109. /** @hidden */
  20110. _renderMultiviewToSingleView(camera: Camera): void;
  20111. }
  20112. }
  20113. }
  20114. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20115. import { Camera } from "babylonjs/Cameras/camera";
  20116. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20117. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20118. import "babylonjs/Engines/Extensions/engine.multiview";
  20119. /**
  20120. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20121. * This will not be used for webXR as it supports displaying texture arrays directly
  20122. */
  20123. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20124. /**
  20125. * Initializes a VRMultiviewToSingleview
  20126. * @param name name of the post process
  20127. * @param camera camera to be applied to
  20128. * @param scaleFactor scaling factor to the size of the output texture
  20129. */
  20130. constructor(name: string, camera: Camera, scaleFactor: number);
  20131. }
  20132. }
  20133. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20134. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20135. import { Nullable } from "babylonjs/types";
  20136. import { Size } from "babylonjs/Maths/math.size";
  20137. import { Observable } from "babylonjs/Misc/observable";
  20138. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20139. /**
  20140. * Interface used to define additional presentation attributes
  20141. */
  20142. export interface IVRPresentationAttributes {
  20143. /**
  20144. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20145. */
  20146. highRefreshRate: boolean;
  20147. /**
  20148. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20149. */
  20150. foveationLevel: number;
  20151. }
  20152. module "babylonjs/Engines/engine" {
  20153. interface Engine {
  20154. /** @hidden */
  20155. _vrDisplay: any;
  20156. /** @hidden */
  20157. _vrSupported: boolean;
  20158. /** @hidden */
  20159. _oldSize: Size;
  20160. /** @hidden */
  20161. _oldHardwareScaleFactor: number;
  20162. /** @hidden */
  20163. _vrExclusivePointerMode: boolean;
  20164. /** @hidden */
  20165. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20166. /** @hidden */
  20167. _onVRDisplayPointerRestricted: () => void;
  20168. /** @hidden */
  20169. _onVRDisplayPointerUnrestricted: () => void;
  20170. /** @hidden */
  20171. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20172. /** @hidden */
  20173. _onVrDisplayDisconnect: Nullable<() => void>;
  20174. /** @hidden */
  20175. _onVrDisplayPresentChange: Nullable<() => void>;
  20176. /**
  20177. * Observable signaled when VR display mode changes
  20178. */
  20179. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20180. /**
  20181. * Observable signaled when VR request present is complete
  20182. */
  20183. onVRRequestPresentComplete: Observable<boolean>;
  20184. /**
  20185. * Observable signaled when VR request present starts
  20186. */
  20187. onVRRequestPresentStart: Observable<Engine>;
  20188. /**
  20189. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20190. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20191. */
  20192. isInVRExclusivePointerMode: boolean;
  20193. /**
  20194. * Gets a boolean indicating if a webVR device was detected
  20195. * @returns true if a webVR device was detected
  20196. */
  20197. isVRDevicePresent(): boolean;
  20198. /**
  20199. * Gets the current webVR device
  20200. * @returns the current webVR device (or null)
  20201. */
  20202. getVRDevice(): any;
  20203. /**
  20204. * Initializes a webVR display and starts listening to display change events
  20205. * The onVRDisplayChangedObservable will be notified upon these changes
  20206. * @returns A promise containing a VRDisplay and if vr is supported
  20207. */
  20208. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20209. /** @hidden */
  20210. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20211. /**
  20212. * Gets or sets the presentation attributes used to configure VR rendering
  20213. */
  20214. vrPresentationAttributes?: IVRPresentationAttributes;
  20215. /**
  20216. * Call this function to switch to webVR mode
  20217. * Will do nothing if webVR is not supported or if there is no webVR device
  20218. * @param options the webvr options provided to the camera. mainly used for multiview
  20219. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20220. */
  20221. enableVR(options: WebVROptions): void;
  20222. /** @hidden */
  20223. _onVRFullScreenTriggered(): void;
  20224. }
  20225. }
  20226. }
  20227. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20228. import { Nullable } from "babylonjs/types";
  20229. import { Observable } from "babylonjs/Misc/observable";
  20230. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20231. import { Scene } from "babylonjs/scene";
  20232. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20233. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20234. import { Node } from "babylonjs/node";
  20235. import { Ray } from "babylonjs/Culling/ray";
  20236. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20237. import "babylonjs/Engines/Extensions/engine.webVR";
  20238. /**
  20239. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20240. * IMPORTANT!! The data is right-hand data.
  20241. * @export
  20242. * @interface DevicePose
  20243. */
  20244. export interface DevicePose {
  20245. /**
  20246. * The position of the device, values in array are [x,y,z].
  20247. */
  20248. readonly position: Nullable<Float32Array>;
  20249. /**
  20250. * The linearVelocity of the device, values in array are [x,y,z].
  20251. */
  20252. readonly linearVelocity: Nullable<Float32Array>;
  20253. /**
  20254. * The linearAcceleration of the device, values in array are [x,y,z].
  20255. */
  20256. readonly linearAcceleration: Nullable<Float32Array>;
  20257. /**
  20258. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20259. */
  20260. readonly orientation: Nullable<Float32Array>;
  20261. /**
  20262. * The angularVelocity of the device, values in array are [x,y,z].
  20263. */
  20264. readonly angularVelocity: Nullable<Float32Array>;
  20265. /**
  20266. * The angularAcceleration of the device, values in array are [x,y,z].
  20267. */
  20268. readonly angularAcceleration: Nullable<Float32Array>;
  20269. }
  20270. /**
  20271. * Interface representing a pose controlled object in Babylon.
  20272. * A pose controlled object has both regular pose values as well as pose values
  20273. * from an external device such as a VR head mounted display
  20274. */
  20275. export interface PoseControlled {
  20276. /**
  20277. * The position of the object in babylon space.
  20278. */
  20279. position: Vector3;
  20280. /**
  20281. * The rotation quaternion of the object in babylon space.
  20282. */
  20283. rotationQuaternion: Quaternion;
  20284. /**
  20285. * The position of the device in babylon space.
  20286. */
  20287. devicePosition?: Vector3;
  20288. /**
  20289. * The rotation quaternion of the device in babylon space.
  20290. */
  20291. deviceRotationQuaternion: Quaternion;
  20292. /**
  20293. * The raw pose coming from the device.
  20294. */
  20295. rawPose: Nullable<DevicePose>;
  20296. /**
  20297. * The scale of the device to be used when translating from device space to babylon space.
  20298. */
  20299. deviceScaleFactor: number;
  20300. /**
  20301. * Updates the poseControlled values based on the input device pose.
  20302. * @param poseData the pose data to update the object with
  20303. */
  20304. updateFromDevice(poseData: DevicePose): void;
  20305. }
  20306. /**
  20307. * Set of options to customize the webVRCamera
  20308. */
  20309. export interface WebVROptions {
  20310. /**
  20311. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20312. */
  20313. trackPosition?: boolean;
  20314. /**
  20315. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20316. */
  20317. positionScale?: number;
  20318. /**
  20319. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20320. */
  20321. displayName?: string;
  20322. /**
  20323. * Should the native controller meshes be initialized. (default: true)
  20324. */
  20325. controllerMeshes?: boolean;
  20326. /**
  20327. * Creating a default HemiLight only on controllers. (default: true)
  20328. */
  20329. defaultLightingOnControllers?: boolean;
  20330. /**
  20331. * If you don't want to use the default VR button of the helper. (default: false)
  20332. */
  20333. useCustomVRButton?: boolean;
  20334. /**
  20335. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20336. */
  20337. customVRButton?: HTMLButtonElement;
  20338. /**
  20339. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20340. */
  20341. rayLength?: number;
  20342. /**
  20343. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20344. */
  20345. defaultHeight?: number;
  20346. /**
  20347. * If multiview should be used if availible (default: false)
  20348. */
  20349. useMultiview?: boolean;
  20350. }
  20351. /**
  20352. * This represents a WebVR camera.
  20353. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20354. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20355. */
  20356. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20357. private webVROptions;
  20358. /**
  20359. * @hidden
  20360. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20361. */
  20362. _vrDevice: any;
  20363. /**
  20364. * The rawPose of the vrDevice.
  20365. */
  20366. rawPose: Nullable<DevicePose>;
  20367. private _onVREnabled;
  20368. private _specsVersion;
  20369. private _attached;
  20370. private _frameData;
  20371. protected _descendants: Array<Node>;
  20372. private _deviceRoomPosition;
  20373. /** @hidden */
  20374. _deviceRoomRotationQuaternion: Quaternion;
  20375. private _standingMatrix;
  20376. /**
  20377. * Represents device position in babylon space.
  20378. */
  20379. devicePosition: Vector3;
  20380. /**
  20381. * Represents device rotation in babylon space.
  20382. */
  20383. deviceRotationQuaternion: Quaternion;
  20384. /**
  20385. * The scale of the device to be used when translating from device space to babylon space.
  20386. */
  20387. deviceScaleFactor: number;
  20388. private _deviceToWorld;
  20389. private _worldToDevice;
  20390. /**
  20391. * References to the webVR controllers for the vrDevice.
  20392. */
  20393. controllers: Array<WebVRController>;
  20394. /**
  20395. * Emits an event when a controller is attached.
  20396. */
  20397. onControllersAttachedObservable: Observable<WebVRController[]>;
  20398. /**
  20399. * Emits an event when a controller's mesh has been loaded;
  20400. */
  20401. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20402. /**
  20403. * Emits an event when the HMD's pose has been updated.
  20404. */
  20405. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20406. private _poseSet;
  20407. /**
  20408. * If the rig cameras be used as parent instead of this camera.
  20409. */
  20410. rigParenting: boolean;
  20411. private _lightOnControllers;
  20412. private _defaultHeight?;
  20413. /**
  20414. * Instantiates a WebVRFreeCamera.
  20415. * @param name The name of the WebVRFreeCamera
  20416. * @param position The starting anchor position for the camera
  20417. * @param scene The scene the camera belongs to
  20418. * @param webVROptions a set of customizable options for the webVRCamera
  20419. */
  20420. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20421. /**
  20422. * Gets the device distance from the ground in meters.
  20423. * @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.
  20424. */
  20425. deviceDistanceToRoomGround(): number;
  20426. /**
  20427. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20428. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20429. */
  20430. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20431. /**
  20432. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20433. * @returns A promise with a boolean set to if the standing matrix is supported.
  20434. */
  20435. useStandingMatrixAsync(): Promise<boolean>;
  20436. /**
  20437. * Disposes the camera
  20438. */
  20439. dispose(): void;
  20440. /**
  20441. * Gets a vrController by name.
  20442. * @param name The name of the controller to retreive
  20443. * @returns the controller matching the name specified or null if not found
  20444. */
  20445. getControllerByName(name: string): Nullable<WebVRController>;
  20446. private _leftController;
  20447. /**
  20448. * The controller corresponding to the users left hand.
  20449. */
  20450. get leftController(): Nullable<WebVRController>;
  20451. private _rightController;
  20452. /**
  20453. * The controller corresponding to the users right hand.
  20454. */
  20455. get rightController(): Nullable<WebVRController>;
  20456. /**
  20457. * Casts a ray forward from the vrCamera's gaze.
  20458. * @param length Length of the ray (default: 100)
  20459. * @returns the ray corresponding to the gaze
  20460. */
  20461. getForwardRay(length?: number): Ray;
  20462. /**
  20463. * @hidden
  20464. * Updates the camera based on device's frame data
  20465. */
  20466. _checkInputs(): void;
  20467. /**
  20468. * Updates the poseControlled values based on the input device pose.
  20469. * @param poseData Pose coming from the device
  20470. */
  20471. updateFromDevice(poseData: DevicePose): void;
  20472. private _htmlElementAttached;
  20473. private _detachIfAttached;
  20474. /**
  20475. * WebVR's attach control will start broadcasting frames to the device.
  20476. * Note that in certain browsers (chrome for example) this function must be called
  20477. * within a user-interaction callback. Example:
  20478. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20479. *
  20480. * @param element html element to attach the vrDevice to
  20481. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20482. */
  20483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20484. /**
  20485. * Detaches the camera from the html element and disables VR
  20486. *
  20487. * @param element html element to detach from
  20488. */
  20489. detachControl(element: HTMLElement): void;
  20490. /**
  20491. * @returns the name of this class
  20492. */
  20493. getClassName(): string;
  20494. /**
  20495. * Calls resetPose on the vrDisplay
  20496. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20497. */
  20498. resetToCurrentRotation(): void;
  20499. /**
  20500. * @hidden
  20501. * Updates the rig cameras (left and right eye)
  20502. */
  20503. _updateRigCameras(): void;
  20504. private _workingVector;
  20505. private _oneVector;
  20506. private _workingMatrix;
  20507. private updateCacheCalled;
  20508. private _correctPositionIfNotTrackPosition;
  20509. /**
  20510. * @hidden
  20511. * Updates the cached values of the camera
  20512. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20513. */
  20514. _updateCache(ignoreParentClass?: boolean): void;
  20515. /**
  20516. * @hidden
  20517. * Get current device position in babylon world
  20518. */
  20519. _computeDevicePosition(): void;
  20520. /**
  20521. * Updates the current device position and rotation in the babylon world
  20522. */
  20523. update(): void;
  20524. /**
  20525. * @hidden
  20526. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20527. * @returns an identity matrix
  20528. */
  20529. _getViewMatrix(): Matrix;
  20530. private _tmpMatrix;
  20531. /**
  20532. * This function is called by the two RIG cameras.
  20533. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20534. * @hidden
  20535. */
  20536. _getWebVRViewMatrix(): Matrix;
  20537. /** @hidden */
  20538. _getWebVRProjectionMatrix(): Matrix;
  20539. private _onGamepadConnectedObserver;
  20540. private _onGamepadDisconnectedObserver;
  20541. private _updateCacheWhenTrackingDisabledObserver;
  20542. /**
  20543. * Initializes the controllers and their meshes
  20544. */
  20545. initControllers(): void;
  20546. }
  20547. }
  20548. declare module "babylonjs/Materials/materialHelper" {
  20549. import { Nullable } from "babylonjs/types";
  20550. import { Scene } from "babylonjs/scene";
  20551. import { Engine } from "babylonjs/Engines/engine";
  20552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20553. import { Light } from "babylonjs/Lights/light";
  20554. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20555. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20556. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20557. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20558. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20559. /**
  20560. * "Static Class" containing the most commonly used helper while dealing with material for
  20561. * rendering purpose.
  20562. *
  20563. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20564. *
  20565. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20566. */
  20567. export class MaterialHelper {
  20568. /**
  20569. * Bind the current view position to an effect.
  20570. * @param effect The effect to be bound
  20571. * @param scene The scene the eyes position is used from
  20572. * @param variableName name of the shader variable that will hold the eye position
  20573. */
  20574. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20575. /**
  20576. * Helps preparing the defines values about the UVs in used in the effect.
  20577. * UVs are shared as much as we can accross channels in the shaders.
  20578. * @param texture The texture we are preparing the UVs for
  20579. * @param defines The defines to update
  20580. * @param key The channel key "diffuse", "specular"... used in the shader
  20581. */
  20582. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20583. /**
  20584. * Binds a texture matrix value to its corrsponding uniform
  20585. * @param texture The texture to bind the matrix for
  20586. * @param uniformBuffer The uniform buffer receivin the data
  20587. * @param key The channel key "diffuse", "specular"... used in the shader
  20588. */
  20589. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20590. /**
  20591. * Gets the current status of the fog (should it be enabled?)
  20592. * @param mesh defines the mesh to evaluate for fog support
  20593. * @param scene defines the hosting scene
  20594. * @returns true if fog must be enabled
  20595. */
  20596. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20597. /**
  20598. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20599. * @param mesh defines the current mesh
  20600. * @param scene defines the current scene
  20601. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20602. * @param pointsCloud defines if point cloud rendering has to be turned on
  20603. * @param fogEnabled defines if fog has to be turned on
  20604. * @param alphaTest defines if alpha testing has to be turned on
  20605. * @param defines defines the current list of defines
  20606. */
  20607. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20608. /**
  20609. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20610. * @param scene defines the current scene
  20611. * @param engine defines the current engine
  20612. * @param defines specifies the list of active defines
  20613. * @param useInstances defines if instances have to be turned on
  20614. * @param useClipPlane defines if clip plane have to be turned on
  20615. * @param useInstances defines if instances have to be turned on
  20616. * @param useThinInstances defines if thin instances have to be turned on
  20617. */
  20618. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20619. /**
  20620. * Prepares the defines for bones
  20621. * @param mesh The mesh containing the geometry data we will draw
  20622. * @param defines The defines to update
  20623. */
  20624. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20625. /**
  20626. * Prepares the defines for morph targets
  20627. * @param mesh The mesh containing the geometry data we will draw
  20628. * @param defines The defines to update
  20629. */
  20630. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20631. /**
  20632. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20633. * @param mesh The mesh containing the geometry data we will draw
  20634. * @param defines The defines to update
  20635. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20636. * @param useBones Precise whether bones should be used or not (override mesh info)
  20637. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20638. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20639. * @returns false if defines are considered not dirty and have not been checked
  20640. */
  20641. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20642. /**
  20643. * Prepares the defines related to multiview
  20644. * @param scene The scene we are intending to draw
  20645. * @param defines The defines to update
  20646. */
  20647. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20648. /**
  20649. * Prepares the defines related to the light information passed in parameter
  20650. * @param scene The scene we are intending to draw
  20651. * @param mesh The mesh the effect is compiling for
  20652. * @param light The light the effect is compiling for
  20653. * @param lightIndex The index of the light
  20654. * @param defines The defines to update
  20655. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20656. * @param state Defines the current state regarding what is needed (normals, etc...)
  20657. */
  20658. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20659. needNormals: boolean;
  20660. needRebuild: boolean;
  20661. shadowEnabled: boolean;
  20662. specularEnabled: boolean;
  20663. lightmapMode: boolean;
  20664. }): void;
  20665. /**
  20666. * Prepares the defines related to the light information passed in parameter
  20667. * @param scene The scene we are intending to draw
  20668. * @param mesh The mesh the effect is compiling for
  20669. * @param defines The defines to update
  20670. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20671. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20672. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20673. * @returns true if normals will be required for the rest of the effect
  20674. */
  20675. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20676. /**
  20677. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20678. * @param lightIndex defines the light index
  20679. * @param uniformsList The uniform list
  20680. * @param samplersList The sampler list
  20681. * @param projectedLightTexture defines if projected texture must be used
  20682. * @param uniformBuffersList defines an optional list of uniform buffers
  20683. */
  20684. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20685. /**
  20686. * Prepares the uniforms and samplers list to be used in the effect
  20687. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20688. * @param samplersList The sampler list
  20689. * @param defines The defines helping in the list generation
  20690. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20691. */
  20692. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20693. /**
  20694. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20695. * @param defines The defines to update while falling back
  20696. * @param fallbacks The authorized effect fallbacks
  20697. * @param maxSimultaneousLights The maximum number of lights allowed
  20698. * @param rank the current rank of the Effect
  20699. * @returns The newly affected rank
  20700. */
  20701. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20702. private static _TmpMorphInfluencers;
  20703. /**
  20704. * Prepares the list of attributes required for morph targets according to the effect defines.
  20705. * @param attribs The current list of supported attribs
  20706. * @param mesh The mesh to prepare the morph targets attributes for
  20707. * @param influencers The number of influencers
  20708. */
  20709. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20710. /**
  20711. * Prepares the list of attributes required for morph targets according to the effect defines.
  20712. * @param attribs The current list of supported attribs
  20713. * @param mesh The mesh to prepare the morph targets attributes for
  20714. * @param defines The current Defines of the effect
  20715. */
  20716. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20717. /**
  20718. * Prepares the list of attributes required for bones according to the effect defines.
  20719. * @param attribs The current list of supported attribs
  20720. * @param mesh The mesh to prepare the bones attributes for
  20721. * @param defines The current Defines of the effect
  20722. * @param fallbacks The current efffect fallback strategy
  20723. */
  20724. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20725. /**
  20726. * Check and prepare the list of attributes required for instances according to the effect defines.
  20727. * @param attribs The current list of supported attribs
  20728. * @param defines The current MaterialDefines of the effect
  20729. */
  20730. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20731. /**
  20732. * Add the list of attributes required for instances to the attribs array.
  20733. * @param attribs The current list of supported attribs
  20734. */
  20735. static PushAttributesForInstances(attribs: string[]): void;
  20736. /**
  20737. * Binds the light information to the effect.
  20738. * @param light The light containing the generator
  20739. * @param effect The effect we are binding the data to
  20740. * @param lightIndex The light index in the effect used to render
  20741. */
  20742. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20743. /**
  20744. * Binds the lights information from the scene to the effect for the given mesh.
  20745. * @param light Light to bind
  20746. * @param lightIndex Light index
  20747. * @param scene The scene where the light belongs to
  20748. * @param effect The effect we are binding the data to
  20749. * @param useSpecular Defines if specular is supported
  20750. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20751. */
  20752. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20753. /**
  20754. * Binds the lights information from the scene to the effect for the given mesh.
  20755. * @param scene The scene the lights belongs to
  20756. * @param mesh The mesh we are binding the information to render
  20757. * @param effect The effect we are binding the data to
  20758. * @param defines The generated defines for the effect
  20759. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20760. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20761. */
  20762. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20763. private static _tempFogColor;
  20764. /**
  20765. * Binds the fog information from the scene to the effect for the given mesh.
  20766. * @param scene The scene the lights belongs to
  20767. * @param mesh The mesh we are binding the information to render
  20768. * @param effect The effect we are binding the data to
  20769. * @param linearSpace Defines if the fog effect is applied in linear space
  20770. */
  20771. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20772. /**
  20773. * Binds the bones information from the mesh to the effect.
  20774. * @param mesh The mesh we are binding the information to render
  20775. * @param effect The effect we are binding the data to
  20776. */
  20777. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20778. /**
  20779. * Binds the morph targets information from the mesh to the effect.
  20780. * @param abstractMesh The mesh we are binding the information to render
  20781. * @param effect The effect we are binding the data to
  20782. */
  20783. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20784. /**
  20785. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20786. * @param defines The generated defines used in the effect
  20787. * @param effect The effect we are binding the data to
  20788. * @param scene The scene we are willing to render with logarithmic scale for
  20789. */
  20790. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20791. /**
  20792. * Binds the clip plane information from the scene to the effect.
  20793. * @param scene The scene the clip plane information are extracted from
  20794. * @param effect The effect we are binding the data to
  20795. */
  20796. static BindClipPlane(effect: Effect, scene: Scene): void;
  20797. }
  20798. }
  20799. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20801. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20802. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20803. import { Nullable } from "babylonjs/types";
  20804. import { Effect } from "babylonjs/Materials/effect";
  20805. import { Matrix } from "babylonjs/Maths/math.vector";
  20806. import { Scene } from "babylonjs/scene";
  20807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20809. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20810. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20811. import { Observable } from "babylonjs/Misc/observable";
  20812. /**
  20813. * Block used to expose an input value
  20814. */
  20815. export class InputBlock extends NodeMaterialBlock {
  20816. private _mode;
  20817. private _associatedVariableName;
  20818. private _storedValue;
  20819. private _valueCallback;
  20820. private _type;
  20821. private _animationType;
  20822. /** Gets or set a value used to limit the range of float values */
  20823. min: number;
  20824. /** Gets or set a value used to limit the range of float values */
  20825. max: number;
  20826. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20827. isBoolean: boolean;
  20828. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20829. matrixMode: number;
  20830. /** @hidden */
  20831. _systemValue: Nullable<NodeMaterialSystemValues>;
  20832. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20833. visibleInInspector: boolean;
  20834. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20835. isConstant: boolean;
  20836. /** Gets or sets the group to use to display this block in the Inspector */
  20837. groupInInspector: string;
  20838. /** Gets an observable raised when the value is changed */
  20839. onValueChangedObservable: Observable<InputBlock>;
  20840. /**
  20841. * Gets or sets the connection point type (default is float)
  20842. */
  20843. get type(): NodeMaterialBlockConnectionPointTypes;
  20844. /**
  20845. * Creates a new InputBlock
  20846. * @param name defines the block name
  20847. * @param target defines the target of that block (Vertex by default)
  20848. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20849. */
  20850. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20851. /**
  20852. * Gets the output component
  20853. */
  20854. get output(): NodeMaterialConnectionPoint;
  20855. /**
  20856. * Set the source of this connection point to a vertex attribute
  20857. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20858. * @returns the current connection point
  20859. */
  20860. setAsAttribute(attributeName?: string): InputBlock;
  20861. /**
  20862. * Set the source of this connection point to a system value
  20863. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20864. * @returns the current connection point
  20865. */
  20866. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20867. /**
  20868. * Gets or sets the value of that point.
  20869. * Please note that this value will be ignored if valueCallback is defined
  20870. */
  20871. get value(): any;
  20872. set value(value: any);
  20873. /**
  20874. * Gets or sets a callback used to get the value of that point.
  20875. * Please note that setting this value will force the connection point to ignore the value property
  20876. */
  20877. get valueCallback(): () => any;
  20878. set valueCallback(value: () => any);
  20879. /**
  20880. * Gets or sets the associated variable name in the shader
  20881. */
  20882. get associatedVariableName(): string;
  20883. set associatedVariableName(value: string);
  20884. /** Gets or sets the type of animation applied to the input */
  20885. get animationType(): AnimatedInputBlockTypes;
  20886. set animationType(value: AnimatedInputBlockTypes);
  20887. /**
  20888. * Gets a boolean indicating that this connection point not defined yet
  20889. */
  20890. get isUndefined(): boolean;
  20891. /**
  20892. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20893. * In this case the connection point name must be the name of the uniform to use.
  20894. * Can only be set on inputs
  20895. */
  20896. get isUniform(): boolean;
  20897. set isUniform(value: boolean);
  20898. /**
  20899. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20900. * In this case the connection point name must be the name of the attribute to use
  20901. * Can only be set on inputs
  20902. */
  20903. get isAttribute(): boolean;
  20904. set isAttribute(value: boolean);
  20905. /**
  20906. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20907. * Can only be set on exit points
  20908. */
  20909. get isVarying(): boolean;
  20910. set isVarying(value: boolean);
  20911. /**
  20912. * Gets a boolean indicating that the current connection point is a system value
  20913. */
  20914. get isSystemValue(): boolean;
  20915. /**
  20916. * Gets or sets the current well known value or null if not defined as a system value
  20917. */
  20918. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20919. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20920. /**
  20921. * Gets the current class name
  20922. * @returns the class name
  20923. */
  20924. getClassName(): string;
  20925. /**
  20926. * Animate the input if animationType !== None
  20927. * @param scene defines the rendering scene
  20928. */
  20929. animate(scene: Scene): void;
  20930. private _emitDefine;
  20931. initialize(state: NodeMaterialBuildState): void;
  20932. /**
  20933. * Set the input block to its default value (based on its type)
  20934. */
  20935. setDefaultValue(): void;
  20936. private _emitConstant;
  20937. /** @hidden */
  20938. get _noContextSwitch(): boolean;
  20939. private _emit;
  20940. /** @hidden */
  20941. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20942. /** @hidden */
  20943. _transmit(effect: Effect, scene: Scene): void;
  20944. protected _buildBlock(state: NodeMaterialBuildState): void;
  20945. protected _dumpPropertiesCode(): string;
  20946. dispose(): void;
  20947. serialize(): any;
  20948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20949. }
  20950. }
  20951. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20952. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20953. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20954. import { Nullable } from "babylonjs/types";
  20955. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20956. import { Observable } from "babylonjs/Misc/observable";
  20957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20958. /**
  20959. * Enum used to define the compatibility state between two connection points
  20960. */
  20961. export enum NodeMaterialConnectionPointCompatibilityStates {
  20962. /** Points are compatibles */
  20963. Compatible = 0,
  20964. /** Points are incompatible because of their types */
  20965. TypeIncompatible = 1,
  20966. /** Points are incompatible because of their targets (vertex vs fragment) */
  20967. TargetIncompatible = 2
  20968. }
  20969. /**
  20970. * Defines the direction of a connection point
  20971. */
  20972. export enum NodeMaterialConnectionPointDirection {
  20973. /** Input */
  20974. Input = 0,
  20975. /** Output */
  20976. Output = 1
  20977. }
  20978. /**
  20979. * Defines a connection point for a block
  20980. */
  20981. export class NodeMaterialConnectionPoint {
  20982. /** @hidden */
  20983. _ownerBlock: NodeMaterialBlock;
  20984. /** @hidden */
  20985. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20986. private _endpoints;
  20987. private _associatedVariableName;
  20988. private _direction;
  20989. /** @hidden */
  20990. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20991. /** @hidden */
  20992. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20993. private _type;
  20994. /** @hidden */
  20995. _enforceAssociatedVariableName: boolean;
  20996. /** Gets the direction of the point */
  20997. get direction(): NodeMaterialConnectionPointDirection;
  20998. /** Indicates that this connection point needs dual validation before being connected to another point */
  20999. needDualDirectionValidation: boolean;
  21000. /**
  21001. * Gets or sets the additional types supported by this connection point
  21002. */
  21003. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21004. /**
  21005. * Gets or sets the additional types excluded by this connection point
  21006. */
  21007. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21008. /**
  21009. * Observable triggered when this point is connected
  21010. */
  21011. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21012. /**
  21013. * Gets or sets the associated variable name in the shader
  21014. */
  21015. get associatedVariableName(): string;
  21016. set associatedVariableName(value: string);
  21017. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21018. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21019. /**
  21020. * Gets or sets the connection point type (default is float)
  21021. */
  21022. get type(): NodeMaterialBlockConnectionPointTypes;
  21023. set type(value: NodeMaterialBlockConnectionPointTypes);
  21024. /**
  21025. * Gets or sets the connection point name
  21026. */
  21027. name: string;
  21028. /**
  21029. * Gets or sets the connection point name
  21030. */
  21031. displayName: string;
  21032. /**
  21033. * Gets or sets a boolean indicating that this connection point can be omitted
  21034. */
  21035. isOptional: boolean;
  21036. /**
  21037. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21038. */
  21039. define: string;
  21040. /** @hidden */
  21041. _prioritizeVertex: boolean;
  21042. private _target;
  21043. /** Gets or sets the target of that connection point */
  21044. get target(): NodeMaterialBlockTargets;
  21045. set target(value: NodeMaterialBlockTargets);
  21046. /**
  21047. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21048. */
  21049. get isConnected(): boolean;
  21050. /**
  21051. * Gets a boolean indicating that the current point is connected to an input block
  21052. */
  21053. get isConnectedToInputBlock(): boolean;
  21054. /**
  21055. * Gets a the connected input block (if any)
  21056. */
  21057. get connectInputBlock(): Nullable<InputBlock>;
  21058. /** Get the other side of the connection (if any) */
  21059. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21060. /** Get the block that owns this connection point */
  21061. get ownerBlock(): NodeMaterialBlock;
  21062. /** Get the block connected on the other side of this connection (if any) */
  21063. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21064. /** Get the block connected on the endpoints of this connection (if any) */
  21065. get connectedBlocks(): Array<NodeMaterialBlock>;
  21066. /** Gets the list of connected endpoints */
  21067. get endpoints(): NodeMaterialConnectionPoint[];
  21068. /** Gets a boolean indicating if that output point is connected to at least one input */
  21069. get hasEndpoints(): boolean;
  21070. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21071. get isConnectedInVertexShader(): boolean;
  21072. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21073. get isConnectedInFragmentShader(): boolean;
  21074. /**
  21075. * Creates a block suitable to be used as an input for this input point.
  21076. * If null is returned, a block based on the point type will be created.
  21077. * @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
  21078. */
  21079. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21080. /**
  21081. * Creates a new connection point
  21082. * @param name defines the connection point name
  21083. * @param ownerBlock defines the block hosting this connection point
  21084. * @param direction defines the direction of the connection point
  21085. */
  21086. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21087. /**
  21088. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21089. * @returns the class name
  21090. */
  21091. getClassName(): string;
  21092. /**
  21093. * Gets a boolean indicating if the current point can be connected to another point
  21094. * @param connectionPoint defines the other connection point
  21095. * @returns a boolean
  21096. */
  21097. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21098. /**
  21099. * Gets a number indicating if the current point can be connected to another point
  21100. * @param connectionPoint defines the other connection point
  21101. * @returns a number defining the compatibility state
  21102. */
  21103. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21104. /**
  21105. * Connect this point to another connection point
  21106. * @param connectionPoint defines the other connection point
  21107. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21108. * @returns the current connection point
  21109. */
  21110. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21111. /**
  21112. * Disconnect this point from one of his endpoint
  21113. * @param endpoint defines the other connection point
  21114. * @returns the current connection point
  21115. */
  21116. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21117. /**
  21118. * Serializes this point in a JSON representation
  21119. * @param isInput defines if the connection point is an input (default is true)
  21120. * @returns the serialized point object
  21121. */
  21122. serialize(isInput?: boolean): any;
  21123. /**
  21124. * Release resources
  21125. */
  21126. dispose(): void;
  21127. }
  21128. }
  21129. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21130. /**
  21131. * Enum used to define the material modes
  21132. */
  21133. export enum NodeMaterialModes {
  21134. /** Regular material */
  21135. Material = 0,
  21136. /** For post process */
  21137. PostProcess = 1,
  21138. /** For particle system */
  21139. Particle = 2
  21140. }
  21141. }
  21142. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21145. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21148. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21149. import { Effect } from "babylonjs/Materials/effect";
  21150. import { Mesh } from "babylonjs/Meshes/mesh";
  21151. import { Nullable } from "babylonjs/types";
  21152. import { Texture } from "babylonjs/Materials/Textures/texture";
  21153. import { Scene } from "babylonjs/scene";
  21154. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21155. /**
  21156. * Block used to read a texture from a sampler
  21157. */
  21158. export class TextureBlock extends NodeMaterialBlock {
  21159. private _defineName;
  21160. private _linearDefineName;
  21161. private _gammaDefineName;
  21162. private _tempTextureRead;
  21163. private _samplerName;
  21164. private _transformedUVName;
  21165. private _textureTransformName;
  21166. private _textureInfoName;
  21167. private _mainUVName;
  21168. private _mainUVDefineName;
  21169. private _fragmentOnly;
  21170. /**
  21171. * Gets or sets the texture associated with the node
  21172. */
  21173. texture: Nullable<Texture>;
  21174. /**
  21175. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21176. */
  21177. convertToGammaSpace: boolean;
  21178. /**
  21179. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21180. */
  21181. convertToLinearSpace: boolean;
  21182. /**
  21183. * Create a new TextureBlock
  21184. * @param name defines the block name
  21185. */
  21186. constructor(name: string, fragmentOnly?: boolean);
  21187. /**
  21188. * Gets the current class name
  21189. * @returns the class name
  21190. */
  21191. getClassName(): string;
  21192. /**
  21193. * Gets the uv input component
  21194. */
  21195. get uv(): NodeMaterialConnectionPoint;
  21196. /**
  21197. * Gets the rgba output component
  21198. */
  21199. get rgba(): NodeMaterialConnectionPoint;
  21200. /**
  21201. * Gets the rgb output component
  21202. */
  21203. get rgb(): NodeMaterialConnectionPoint;
  21204. /**
  21205. * Gets the r output component
  21206. */
  21207. get r(): NodeMaterialConnectionPoint;
  21208. /**
  21209. * Gets the g output component
  21210. */
  21211. get g(): NodeMaterialConnectionPoint;
  21212. /**
  21213. * Gets the b output component
  21214. */
  21215. get b(): NodeMaterialConnectionPoint;
  21216. /**
  21217. * Gets the a output component
  21218. */
  21219. get a(): NodeMaterialConnectionPoint;
  21220. get target(): NodeMaterialBlockTargets;
  21221. autoConfigure(material: NodeMaterial): void;
  21222. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21224. isReady(): boolean;
  21225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21226. private get _isMixed();
  21227. private _injectVertexCode;
  21228. private _writeTextureRead;
  21229. private _writeOutput;
  21230. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21231. protected _dumpPropertiesCode(): string;
  21232. serialize(): any;
  21233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21234. }
  21235. }
  21236. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21237. /** @hidden */
  21238. export var reflectionFunction: {
  21239. name: string;
  21240. shader: string;
  21241. };
  21242. }
  21243. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21249. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21250. import { Effect } from "babylonjs/Materials/effect";
  21251. import { Mesh } from "babylonjs/Meshes/mesh";
  21252. import { Nullable } from "babylonjs/types";
  21253. import { Scene } from "babylonjs/scene";
  21254. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21255. /**
  21256. * Base block used to read a reflection texture from a sampler
  21257. */
  21258. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21259. /** @hidden */
  21260. _define3DName: string;
  21261. /** @hidden */
  21262. _defineCubicName: string;
  21263. /** @hidden */
  21264. _defineExplicitName: string;
  21265. /** @hidden */
  21266. _defineProjectionName: string;
  21267. /** @hidden */
  21268. _defineLocalCubicName: string;
  21269. /** @hidden */
  21270. _defineSphericalName: string;
  21271. /** @hidden */
  21272. _definePlanarName: string;
  21273. /** @hidden */
  21274. _defineEquirectangularName: string;
  21275. /** @hidden */
  21276. _defineMirroredEquirectangularFixedName: string;
  21277. /** @hidden */
  21278. _defineEquirectangularFixedName: string;
  21279. /** @hidden */
  21280. _defineSkyboxName: string;
  21281. /** @hidden */
  21282. _defineOppositeZ: string;
  21283. /** @hidden */
  21284. _cubeSamplerName: string;
  21285. /** @hidden */
  21286. _2DSamplerName: string;
  21287. protected _positionUVWName: string;
  21288. protected _directionWName: string;
  21289. protected _reflectionVectorName: string;
  21290. /** @hidden */
  21291. _reflectionCoordsName: string;
  21292. /** @hidden */
  21293. _reflectionMatrixName: string;
  21294. protected _reflectionColorName: string;
  21295. /**
  21296. * Gets or sets the texture associated with the node
  21297. */
  21298. texture: Nullable<BaseTexture>;
  21299. /**
  21300. * Create a new ReflectionTextureBaseBlock
  21301. * @param name defines the block name
  21302. */
  21303. constructor(name: string);
  21304. /**
  21305. * Gets the current class name
  21306. * @returns the class name
  21307. */
  21308. getClassName(): string;
  21309. /**
  21310. * Gets the world position input component
  21311. */
  21312. abstract get position(): NodeMaterialConnectionPoint;
  21313. /**
  21314. * Gets the world position input component
  21315. */
  21316. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21317. /**
  21318. * Gets the world normal input component
  21319. */
  21320. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21321. /**
  21322. * Gets the world input component
  21323. */
  21324. abstract get world(): NodeMaterialConnectionPoint;
  21325. /**
  21326. * Gets the camera (or eye) position component
  21327. */
  21328. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21329. /**
  21330. * Gets the view input component
  21331. */
  21332. abstract get view(): NodeMaterialConnectionPoint;
  21333. protected _getTexture(): Nullable<BaseTexture>;
  21334. autoConfigure(material: NodeMaterial): void;
  21335. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21336. isReady(): boolean;
  21337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21338. /**
  21339. * Gets the code to inject in the vertex shader
  21340. * @param state current state of the node material building
  21341. * @returns the shader code
  21342. */
  21343. handleVertexSide(state: NodeMaterialBuildState): string;
  21344. /**
  21345. * Handles the inits for the fragment code path
  21346. * @param state node material build state
  21347. */
  21348. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21349. /**
  21350. * Generates the reflection coords code for the fragment code path
  21351. * @param worldNormalVarName name of the world normal variable
  21352. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21353. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21354. * @returns the shader code
  21355. */
  21356. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21357. /**
  21358. * Generates the reflection color code for the fragment code path
  21359. * @param lodVarName name of the lod variable
  21360. * @param swizzleLookupTexture swizzle to use for the final color variable
  21361. * @returns the shader code
  21362. */
  21363. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21364. /**
  21365. * Generates the code corresponding to the connected output points
  21366. * @param state node material build state
  21367. * @param varName name of the variable to output
  21368. * @returns the shader code
  21369. */
  21370. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21371. protected _buildBlock(state: NodeMaterialBuildState): this;
  21372. protected _dumpPropertiesCode(): string;
  21373. serialize(): any;
  21374. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21375. }
  21376. }
  21377. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21379. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21380. import { Nullable } from "babylonjs/types";
  21381. /**
  21382. * Defines a connection point to be used for points with a custom object type
  21383. */
  21384. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21385. private _blockType;
  21386. private _blockName;
  21387. private _nameForCheking?;
  21388. /**
  21389. * Creates a new connection point
  21390. * @param name defines the connection point name
  21391. * @param ownerBlock defines the block hosting this connection point
  21392. * @param direction defines the direction of the connection point
  21393. */
  21394. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21395. /**
  21396. * Gets a number indicating if the current point can be connected to another point
  21397. * @param connectionPoint defines the other connection point
  21398. * @returns a number defining the compatibility state
  21399. */
  21400. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21401. /**
  21402. * Creates a block suitable to be used as an input for this input point.
  21403. * If null is returned, a block based on the point type will be created.
  21404. * @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
  21405. */
  21406. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21407. }
  21408. }
  21409. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21410. /**
  21411. * Enum defining the type of properties that can be edited in the property pages in the NME
  21412. */
  21413. export enum PropertyTypeForEdition {
  21414. /** property is a boolean */
  21415. Boolean = 0,
  21416. /** property is a float */
  21417. Float = 1,
  21418. /** property is a Vector2 */
  21419. Vector2 = 2,
  21420. /** property is a list of values */
  21421. List = 3
  21422. }
  21423. /**
  21424. * Interface that defines an option in a variable of type list
  21425. */
  21426. export interface IEditablePropertyListOption {
  21427. /** label of the option */
  21428. "label": string;
  21429. /** value of the option */
  21430. "value": number;
  21431. }
  21432. /**
  21433. * Interface that defines the options available for an editable property
  21434. */
  21435. export interface IEditablePropertyOption {
  21436. /** min value */
  21437. "min"?: number;
  21438. /** max value */
  21439. "max"?: number;
  21440. /** notifiers: indicates which actions to take when the property is changed */
  21441. "notifiers"?: {
  21442. /** the material should be rebuilt */
  21443. "rebuild"?: boolean;
  21444. /** the preview should be updated */
  21445. "update"?: boolean;
  21446. };
  21447. /** list of the options for a variable of type list */
  21448. "options"?: IEditablePropertyListOption[];
  21449. }
  21450. /**
  21451. * Interface that describes an editable property
  21452. */
  21453. export interface IPropertyDescriptionForEdition {
  21454. /** name of the property */
  21455. "propertyName": string;
  21456. /** display name of the property */
  21457. "displayName": string;
  21458. /** type of the property */
  21459. "type": PropertyTypeForEdition;
  21460. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21461. "groupName": string;
  21462. /** options for the property */
  21463. "options": IEditablePropertyOption;
  21464. }
  21465. /**
  21466. * Decorator that flags a property in a node material block as being editable
  21467. */
  21468. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21469. }
  21470. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21473. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21475. import { Nullable } from "babylonjs/types";
  21476. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21477. import { Mesh } from "babylonjs/Meshes/mesh";
  21478. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21479. import { Effect } from "babylonjs/Materials/effect";
  21480. import { Scene } from "babylonjs/scene";
  21481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21482. /**
  21483. * Block used to implement the refraction part of the sub surface module of the PBR material
  21484. */
  21485. export class RefractionBlock extends NodeMaterialBlock {
  21486. /** @hidden */
  21487. _define3DName: string;
  21488. /** @hidden */
  21489. _refractionMatrixName: string;
  21490. /** @hidden */
  21491. _defineLODRefractionAlpha: string;
  21492. /** @hidden */
  21493. _defineLinearSpecularRefraction: string;
  21494. /** @hidden */
  21495. _defineOppositeZ: string;
  21496. /** @hidden */
  21497. _cubeSamplerName: string;
  21498. /** @hidden */
  21499. _2DSamplerName: string;
  21500. /** @hidden */
  21501. _vRefractionMicrosurfaceInfosName: string;
  21502. /** @hidden */
  21503. _vRefractionInfosName: string;
  21504. private _scene;
  21505. /**
  21506. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21507. * Materials half opaque for instance using refraction could benefit from this control.
  21508. */
  21509. linkRefractionWithTransparency: boolean;
  21510. /**
  21511. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21512. */
  21513. invertRefractionY: boolean;
  21514. /**
  21515. * Gets or sets the texture associated with the node
  21516. */
  21517. texture: Nullable<BaseTexture>;
  21518. /**
  21519. * Create a new RefractionBlock
  21520. * @param name defines the block name
  21521. */
  21522. constructor(name: string);
  21523. /**
  21524. * Gets the current class name
  21525. * @returns the class name
  21526. */
  21527. getClassName(): string;
  21528. /**
  21529. * Gets the intensity input component
  21530. */
  21531. get intensity(): NodeMaterialConnectionPoint;
  21532. /**
  21533. * Gets the index of refraction input component
  21534. */
  21535. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21536. /**
  21537. * Gets the tint at distance input component
  21538. */
  21539. get tintAtDistance(): NodeMaterialConnectionPoint;
  21540. /**
  21541. * Gets the view input component
  21542. */
  21543. get view(): NodeMaterialConnectionPoint;
  21544. /**
  21545. * Gets the refraction object output component
  21546. */
  21547. get refraction(): NodeMaterialConnectionPoint;
  21548. /**
  21549. * Returns true if the block has a texture
  21550. */
  21551. get hasTexture(): boolean;
  21552. protected _getTexture(): Nullable<BaseTexture>;
  21553. autoConfigure(material: NodeMaterial): void;
  21554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21555. isReady(): boolean;
  21556. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21557. /**
  21558. * Gets the main code of the block (fragment side)
  21559. * @param state current state of the node material building
  21560. * @returns the shader code
  21561. */
  21562. getCode(state: NodeMaterialBuildState): string;
  21563. protected _buildBlock(state: NodeMaterialBuildState): this;
  21564. protected _dumpPropertiesCode(): string;
  21565. serialize(): any;
  21566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21567. }
  21568. }
  21569. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21571. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21572. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21575. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21577. import { Nullable } from "babylonjs/types";
  21578. import { Scene } from "babylonjs/scene";
  21579. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21580. /**
  21581. * Base block used as input for post process
  21582. */
  21583. export class CurrentScreenBlock extends NodeMaterialBlock {
  21584. private _samplerName;
  21585. private _linearDefineName;
  21586. private _gammaDefineName;
  21587. private _mainUVName;
  21588. private _tempTextureRead;
  21589. /**
  21590. * Gets or sets the texture associated with the node
  21591. */
  21592. texture: Nullable<BaseTexture>;
  21593. /**
  21594. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21595. */
  21596. convertToGammaSpace: boolean;
  21597. /**
  21598. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21599. */
  21600. convertToLinearSpace: boolean;
  21601. /**
  21602. * Create a new CurrentScreenBlock
  21603. * @param name defines the block name
  21604. */
  21605. constructor(name: string);
  21606. /**
  21607. * Gets the current class name
  21608. * @returns the class name
  21609. */
  21610. getClassName(): string;
  21611. /**
  21612. * Gets the uv input component
  21613. */
  21614. get uv(): NodeMaterialConnectionPoint;
  21615. /**
  21616. * Gets the rgba output component
  21617. */
  21618. get rgba(): NodeMaterialConnectionPoint;
  21619. /**
  21620. * Gets the rgb output component
  21621. */
  21622. get rgb(): NodeMaterialConnectionPoint;
  21623. /**
  21624. * Gets the r output component
  21625. */
  21626. get r(): NodeMaterialConnectionPoint;
  21627. /**
  21628. * Gets the g output component
  21629. */
  21630. get g(): NodeMaterialConnectionPoint;
  21631. /**
  21632. * Gets the b output component
  21633. */
  21634. get b(): NodeMaterialConnectionPoint;
  21635. /**
  21636. * Gets the a output component
  21637. */
  21638. get a(): NodeMaterialConnectionPoint;
  21639. /**
  21640. * Initialize the block and prepare the context for build
  21641. * @param state defines the state that will be used for the build
  21642. */
  21643. initialize(state: NodeMaterialBuildState): void;
  21644. get target(): NodeMaterialBlockTargets;
  21645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21646. isReady(): boolean;
  21647. private _injectVertexCode;
  21648. private _writeTextureRead;
  21649. private _writeOutput;
  21650. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21651. serialize(): any;
  21652. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21653. }
  21654. }
  21655. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21660. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21662. import { Nullable } from "babylonjs/types";
  21663. import { Scene } from "babylonjs/scene";
  21664. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21665. /**
  21666. * Base block used for the particle texture
  21667. */
  21668. export class ParticleTextureBlock extends NodeMaterialBlock {
  21669. private _samplerName;
  21670. private _linearDefineName;
  21671. private _gammaDefineName;
  21672. private _tempTextureRead;
  21673. /**
  21674. * Gets or sets the texture associated with the node
  21675. */
  21676. texture: Nullable<BaseTexture>;
  21677. /**
  21678. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21679. */
  21680. convertToGammaSpace: boolean;
  21681. /**
  21682. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21683. */
  21684. convertToLinearSpace: boolean;
  21685. /**
  21686. * Create a new ParticleTextureBlock
  21687. * @param name defines the block name
  21688. */
  21689. constructor(name: string);
  21690. /**
  21691. * Gets the current class name
  21692. * @returns the class name
  21693. */
  21694. getClassName(): string;
  21695. /**
  21696. * Gets the uv input component
  21697. */
  21698. get uv(): NodeMaterialConnectionPoint;
  21699. /**
  21700. * Gets the rgba output component
  21701. */
  21702. get rgba(): NodeMaterialConnectionPoint;
  21703. /**
  21704. * Gets the rgb output component
  21705. */
  21706. get rgb(): NodeMaterialConnectionPoint;
  21707. /**
  21708. * Gets the r output component
  21709. */
  21710. get r(): NodeMaterialConnectionPoint;
  21711. /**
  21712. * Gets the g output component
  21713. */
  21714. get g(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the b output component
  21717. */
  21718. get b(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the a output component
  21721. */
  21722. get a(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Initialize the block and prepare the context for build
  21725. * @param state defines the state that will be used for the build
  21726. */
  21727. initialize(state: NodeMaterialBuildState): void;
  21728. autoConfigure(material: NodeMaterial): void;
  21729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21730. isReady(): boolean;
  21731. private _writeOutput;
  21732. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21733. serialize(): any;
  21734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21735. }
  21736. }
  21737. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21738. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21740. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21741. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21742. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21743. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21744. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21745. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21746. import { Scene } from "babylonjs/scene";
  21747. /**
  21748. * Class used to store shared data between 2 NodeMaterialBuildState
  21749. */
  21750. export class NodeMaterialBuildStateSharedData {
  21751. /**
  21752. * Gets the list of emitted varyings
  21753. */
  21754. temps: string[];
  21755. /**
  21756. * Gets the list of emitted varyings
  21757. */
  21758. varyings: string[];
  21759. /**
  21760. * Gets the varying declaration string
  21761. */
  21762. varyingDeclaration: string;
  21763. /**
  21764. * Input blocks
  21765. */
  21766. inputBlocks: InputBlock[];
  21767. /**
  21768. * Input blocks
  21769. */
  21770. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21771. /**
  21772. * Bindable blocks (Blocks that need to set data to the effect)
  21773. */
  21774. bindableBlocks: NodeMaterialBlock[];
  21775. /**
  21776. * List of blocks that can provide a compilation fallback
  21777. */
  21778. blocksWithFallbacks: NodeMaterialBlock[];
  21779. /**
  21780. * List of blocks that can provide a define update
  21781. */
  21782. blocksWithDefines: NodeMaterialBlock[];
  21783. /**
  21784. * List of blocks that can provide a repeatable content
  21785. */
  21786. repeatableContentBlocks: NodeMaterialBlock[];
  21787. /**
  21788. * List of blocks that can provide a dynamic list of uniforms
  21789. */
  21790. dynamicUniformBlocks: NodeMaterialBlock[];
  21791. /**
  21792. * List of blocks that can block the isReady function for the material
  21793. */
  21794. blockingBlocks: NodeMaterialBlock[];
  21795. /**
  21796. * Gets the list of animated inputs
  21797. */
  21798. animatedInputs: InputBlock[];
  21799. /**
  21800. * Build Id used to avoid multiple recompilations
  21801. */
  21802. buildId: number;
  21803. /** List of emitted variables */
  21804. variableNames: {
  21805. [key: string]: number;
  21806. };
  21807. /** List of emitted defines */
  21808. defineNames: {
  21809. [key: string]: number;
  21810. };
  21811. /** Should emit comments? */
  21812. emitComments: boolean;
  21813. /** Emit build activity */
  21814. verbose: boolean;
  21815. /** Gets or sets the hosting scene */
  21816. scene: Scene;
  21817. /**
  21818. * Gets the compilation hints emitted at compilation time
  21819. */
  21820. hints: {
  21821. needWorldViewMatrix: boolean;
  21822. needWorldViewProjectionMatrix: boolean;
  21823. needAlphaBlending: boolean;
  21824. needAlphaTesting: boolean;
  21825. };
  21826. /**
  21827. * List of compilation checks
  21828. */
  21829. checks: {
  21830. emitVertex: boolean;
  21831. emitFragment: boolean;
  21832. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21833. };
  21834. /**
  21835. * Is vertex program allowed to be empty?
  21836. */
  21837. allowEmptyVertexProgram: boolean;
  21838. /** Creates a new shared data */
  21839. constructor();
  21840. /**
  21841. * Emits console errors and exceptions if there is a failing check
  21842. */
  21843. emitErrors(): void;
  21844. }
  21845. }
  21846. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21847. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21848. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21849. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21850. /**
  21851. * Class used to store node based material build state
  21852. */
  21853. export class NodeMaterialBuildState {
  21854. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21855. supportUniformBuffers: boolean;
  21856. /**
  21857. * Gets the list of emitted attributes
  21858. */
  21859. attributes: string[];
  21860. /**
  21861. * Gets the list of emitted uniforms
  21862. */
  21863. uniforms: string[];
  21864. /**
  21865. * Gets the list of emitted constants
  21866. */
  21867. constants: string[];
  21868. /**
  21869. * Gets the list of emitted samplers
  21870. */
  21871. samplers: string[];
  21872. /**
  21873. * Gets the list of emitted functions
  21874. */
  21875. functions: {
  21876. [key: string]: string;
  21877. };
  21878. /**
  21879. * Gets the list of emitted extensions
  21880. */
  21881. extensions: {
  21882. [key: string]: string;
  21883. };
  21884. /**
  21885. * Gets the target of the compilation state
  21886. */
  21887. target: NodeMaterialBlockTargets;
  21888. /**
  21889. * Gets the list of emitted counters
  21890. */
  21891. counters: {
  21892. [key: string]: number;
  21893. };
  21894. /**
  21895. * Shared data between multiple NodeMaterialBuildState instances
  21896. */
  21897. sharedData: NodeMaterialBuildStateSharedData;
  21898. /** @hidden */
  21899. _vertexState: NodeMaterialBuildState;
  21900. /** @hidden */
  21901. _attributeDeclaration: string;
  21902. /** @hidden */
  21903. _uniformDeclaration: string;
  21904. /** @hidden */
  21905. _constantDeclaration: string;
  21906. /** @hidden */
  21907. _samplerDeclaration: string;
  21908. /** @hidden */
  21909. _varyingTransfer: string;
  21910. /** @hidden */
  21911. _injectAtEnd: string;
  21912. private _repeatableContentAnchorIndex;
  21913. /** @hidden */
  21914. _builtCompilationString: string;
  21915. /**
  21916. * Gets the emitted compilation strings
  21917. */
  21918. compilationString: string;
  21919. /**
  21920. * Finalize the compilation strings
  21921. * @param state defines the current compilation state
  21922. */
  21923. finalize(state: NodeMaterialBuildState): void;
  21924. /** @hidden */
  21925. get _repeatableContentAnchor(): string;
  21926. /** @hidden */
  21927. _getFreeVariableName(prefix: string): string;
  21928. /** @hidden */
  21929. _getFreeDefineName(prefix: string): string;
  21930. /** @hidden */
  21931. _excludeVariableName(name: string): void;
  21932. /** @hidden */
  21933. _emit2DSampler(name: string): void;
  21934. /** @hidden */
  21935. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21936. /** @hidden */
  21937. _emitExtension(name: string, extension: string, define?: string): void;
  21938. /** @hidden */
  21939. _emitFunction(name: string, code: string, comments: string): void;
  21940. /** @hidden */
  21941. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21942. replaceStrings?: {
  21943. search: RegExp;
  21944. replace: string;
  21945. }[];
  21946. repeatKey?: string;
  21947. }): string;
  21948. /** @hidden */
  21949. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21950. repeatKey?: string;
  21951. removeAttributes?: boolean;
  21952. removeUniforms?: boolean;
  21953. removeVaryings?: boolean;
  21954. removeIfDef?: boolean;
  21955. replaceStrings?: {
  21956. search: RegExp;
  21957. replace: string;
  21958. }[];
  21959. }, storeKey?: string): void;
  21960. /** @hidden */
  21961. _registerTempVariable(name: string): boolean;
  21962. /** @hidden */
  21963. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21964. /** @hidden */
  21965. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21966. /** @hidden */
  21967. _emitFloat(value: number): string;
  21968. }
  21969. }
  21970. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21971. /**
  21972. * Helper class used to generate session unique ID
  21973. */
  21974. export class UniqueIdGenerator {
  21975. private static _UniqueIdCounter;
  21976. /**
  21977. * Gets an unique (relatively to the current scene) Id
  21978. */
  21979. static get UniqueId(): number;
  21980. }
  21981. }
  21982. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21983. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21985. import { Nullable } from "babylonjs/types";
  21986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21987. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21988. import { Effect } from "babylonjs/Materials/effect";
  21989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21990. import { Mesh } from "babylonjs/Meshes/mesh";
  21991. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21992. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21993. import { Scene } from "babylonjs/scene";
  21994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21995. /**
  21996. * Defines a block that can be used inside a node based material
  21997. */
  21998. export class NodeMaterialBlock {
  21999. private _buildId;
  22000. private _buildTarget;
  22001. private _target;
  22002. private _isFinalMerger;
  22003. private _isInput;
  22004. protected _isUnique: boolean;
  22005. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22006. inputsAreExclusive: boolean;
  22007. /** @hidden */
  22008. _codeVariableName: string;
  22009. /** @hidden */
  22010. _inputs: NodeMaterialConnectionPoint[];
  22011. /** @hidden */
  22012. _outputs: NodeMaterialConnectionPoint[];
  22013. /** @hidden */
  22014. _preparationId: number;
  22015. /**
  22016. * Gets or sets the name of the block
  22017. */
  22018. name: string;
  22019. /**
  22020. * Gets or sets the unique id of the node
  22021. */
  22022. uniqueId: number;
  22023. /**
  22024. * Gets or sets the comments associated with this block
  22025. */
  22026. comments: string;
  22027. /**
  22028. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22029. */
  22030. get isUnique(): boolean;
  22031. /**
  22032. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22033. */
  22034. get isFinalMerger(): boolean;
  22035. /**
  22036. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22037. */
  22038. get isInput(): boolean;
  22039. /**
  22040. * Gets or sets the build Id
  22041. */
  22042. get buildId(): number;
  22043. set buildId(value: number);
  22044. /**
  22045. * Gets or sets the target of the block
  22046. */
  22047. get target(): NodeMaterialBlockTargets;
  22048. set target(value: NodeMaterialBlockTargets);
  22049. /**
  22050. * Gets the list of input points
  22051. */
  22052. get inputs(): NodeMaterialConnectionPoint[];
  22053. /** Gets the list of output points */
  22054. get outputs(): NodeMaterialConnectionPoint[];
  22055. /**
  22056. * Find an input by its name
  22057. * @param name defines the name of the input to look for
  22058. * @returns the input or null if not found
  22059. */
  22060. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22061. /**
  22062. * Find an output by its name
  22063. * @param name defines the name of the outputto look for
  22064. * @returns the output or null if not found
  22065. */
  22066. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22067. /**
  22068. * Creates a new NodeMaterialBlock
  22069. * @param name defines the block name
  22070. * @param target defines the target of that block (Vertex by default)
  22071. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22072. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22073. */
  22074. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22075. /**
  22076. * Initialize the block and prepare the context for build
  22077. * @param state defines the state that will be used for the build
  22078. */
  22079. initialize(state: NodeMaterialBuildState): void;
  22080. /**
  22081. * Bind data to effect. Will only be called for blocks with isBindable === true
  22082. * @param effect defines the effect to bind data to
  22083. * @param nodeMaterial defines the hosting NodeMaterial
  22084. * @param mesh defines the mesh that will be rendered
  22085. * @param subMesh defines the submesh that will be rendered
  22086. */
  22087. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22088. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22089. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22090. protected _writeFloat(value: number): string;
  22091. /**
  22092. * Gets the current class name e.g. "NodeMaterialBlock"
  22093. * @returns the class name
  22094. */
  22095. getClassName(): string;
  22096. /**
  22097. * Register a new input. Must be called inside a block constructor
  22098. * @param name defines the connection point name
  22099. * @param type defines the connection point type
  22100. * @param isOptional defines a boolean indicating that this input can be omitted
  22101. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22102. * @param point an already created connection point. If not provided, create a new one
  22103. * @returns the current block
  22104. */
  22105. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22106. /**
  22107. * Register a new output. Must be called inside a block constructor
  22108. * @param name defines the connection point name
  22109. * @param type defines the connection point type
  22110. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22111. * @param point an already created connection point. If not provided, create a new one
  22112. * @returns the current block
  22113. */
  22114. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22115. /**
  22116. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22117. * @param forOutput defines an optional connection point to check compatibility with
  22118. * @returns the first available input or null
  22119. */
  22120. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22121. /**
  22122. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22123. * @param forBlock defines an optional block to check compatibility with
  22124. * @returns the first available input or null
  22125. */
  22126. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22127. /**
  22128. * Gets the sibling of the given output
  22129. * @param current defines the current output
  22130. * @returns the next output in the list or null
  22131. */
  22132. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22133. /**
  22134. * Connect current block with another block
  22135. * @param other defines the block to connect with
  22136. * @param options define the various options to help pick the right connections
  22137. * @returns the current block
  22138. */
  22139. connectTo(other: NodeMaterialBlock, options?: {
  22140. input?: string;
  22141. output?: string;
  22142. outputSwizzle?: string;
  22143. }): this | undefined;
  22144. protected _buildBlock(state: NodeMaterialBuildState): void;
  22145. /**
  22146. * Add uniforms, samplers and uniform buffers at compilation time
  22147. * @param state defines the state to update
  22148. * @param nodeMaterial defines the node material requesting the update
  22149. * @param defines defines the material defines to update
  22150. * @param uniformBuffers defines the list of uniform buffer names
  22151. */
  22152. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22153. /**
  22154. * Add potential fallbacks if shader compilation fails
  22155. * @param mesh defines the mesh to be rendered
  22156. * @param fallbacks defines the current prioritized list of fallbacks
  22157. */
  22158. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22159. /**
  22160. * Initialize defines for shader compilation
  22161. * @param mesh defines the mesh to be rendered
  22162. * @param nodeMaterial defines the node material requesting the update
  22163. * @param defines defines the material defines to update
  22164. * @param useInstances specifies that instances should be used
  22165. */
  22166. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22167. /**
  22168. * Update defines for shader compilation
  22169. * @param mesh defines the mesh to be rendered
  22170. * @param nodeMaterial defines the node material requesting the update
  22171. * @param defines defines the material defines to update
  22172. * @param useInstances specifies that instances should be used
  22173. * @param subMesh defines which submesh to render
  22174. */
  22175. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22176. /**
  22177. * Lets the block try to connect some inputs automatically
  22178. * @param material defines the hosting NodeMaterial
  22179. */
  22180. autoConfigure(material: NodeMaterial): void;
  22181. /**
  22182. * Function called when a block is declared as repeatable content generator
  22183. * @param vertexShaderState defines the current compilation state for the vertex shader
  22184. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22185. * @param mesh defines the mesh to be rendered
  22186. * @param defines defines the material defines to update
  22187. */
  22188. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22189. /**
  22190. * Checks if the block is ready
  22191. * @param mesh defines the mesh to be rendered
  22192. * @param nodeMaterial defines the node material requesting the update
  22193. * @param defines defines the material defines to update
  22194. * @param useInstances specifies that instances should be used
  22195. * @returns true if the block is ready
  22196. */
  22197. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22198. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22199. private _processBuild;
  22200. /**
  22201. * Compile the current node and generate the shader code
  22202. * @param state defines the current compilation state (uniforms, samplers, current string)
  22203. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22204. * @returns true if already built
  22205. */
  22206. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22207. protected _inputRename(name: string): string;
  22208. protected _outputRename(name: string): string;
  22209. protected _dumpPropertiesCode(): string;
  22210. /** @hidden */
  22211. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22212. /** @hidden */
  22213. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22214. /**
  22215. * Clone the current block to a new identical block
  22216. * @param scene defines the hosting scene
  22217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22218. * @returns a copy of the current block
  22219. */
  22220. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22221. /**
  22222. * Serializes this block in a JSON representation
  22223. * @returns the serialized block object
  22224. */
  22225. serialize(): any;
  22226. /** @hidden */
  22227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22228. private _deserializePortDisplayNames;
  22229. /**
  22230. * Release resources
  22231. */
  22232. dispose(): void;
  22233. }
  22234. }
  22235. declare module "babylonjs/Materials/pushMaterial" {
  22236. import { Nullable } from "babylonjs/types";
  22237. import { Scene } from "babylonjs/scene";
  22238. import { Matrix } from "babylonjs/Maths/math.vector";
  22239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22240. import { Mesh } from "babylonjs/Meshes/mesh";
  22241. import { Material } from "babylonjs/Materials/material";
  22242. import { Effect } from "babylonjs/Materials/effect";
  22243. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22244. /**
  22245. * Base class of materials working in push mode in babylon JS
  22246. * @hidden
  22247. */
  22248. export class PushMaterial extends Material {
  22249. protected _activeEffect: Effect;
  22250. protected _normalMatrix: Matrix;
  22251. /**
  22252. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  22253. * This means that the material can keep using a previous shader while a new one is being compiled.
  22254. * This is mostly used when shader parallel compilation is supported (true by default)
  22255. */
  22256. allowShaderHotSwapping: boolean;
  22257. constructor(name: string, scene: Scene);
  22258. getEffect(): Effect;
  22259. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22260. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22261. /**
  22262. * Binds the given world matrix to the active effect
  22263. *
  22264. * @param world the matrix to bind
  22265. */
  22266. bindOnlyWorldMatrix(world: Matrix): void;
  22267. /**
  22268. * Binds the given normal matrix to the active effect
  22269. *
  22270. * @param normalMatrix the matrix to bind
  22271. */
  22272. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22273. bind(world: Matrix, mesh?: Mesh): void;
  22274. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22275. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22276. }
  22277. }
  22278. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22280. /**
  22281. * Root class for all node material optimizers
  22282. */
  22283. export class NodeMaterialOptimizer {
  22284. /**
  22285. * Function used to optimize a NodeMaterial graph
  22286. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22287. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22288. */
  22289. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22290. }
  22291. }
  22292. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22296. import { Scene } from "babylonjs/scene";
  22297. /**
  22298. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22299. */
  22300. export class TransformBlock extends NodeMaterialBlock {
  22301. /**
  22302. * Defines the value to use to complement W value to transform it to a Vector4
  22303. */
  22304. complementW: number;
  22305. /**
  22306. * Defines the value to use to complement z value to transform it to a Vector4
  22307. */
  22308. complementZ: number;
  22309. /**
  22310. * Creates a new TransformBlock
  22311. * @param name defines the block name
  22312. */
  22313. constructor(name: string);
  22314. /**
  22315. * Gets the current class name
  22316. * @returns the class name
  22317. */
  22318. getClassName(): string;
  22319. /**
  22320. * Gets the vector input
  22321. */
  22322. get vector(): NodeMaterialConnectionPoint;
  22323. /**
  22324. * Gets the output component
  22325. */
  22326. get output(): NodeMaterialConnectionPoint;
  22327. /**
  22328. * Gets the xyz output component
  22329. */
  22330. get xyz(): NodeMaterialConnectionPoint;
  22331. /**
  22332. * Gets the matrix transform input
  22333. */
  22334. get transform(): NodeMaterialConnectionPoint;
  22335. protected _buildBlock(state: NodeMaterialBuildState): this;
  22336. serialize(): any;
  22337. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22338. protected _dumpPropertiesCode(): string;
  22339. }
  22340. }
  22341. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22345. /**
  22346. * Block used to output the vertex position
  22347. */
  22348. export class VertexOutputBlock extends NodeMaterialBlock {
  22349. /**
  22350. * Creates a new VertexOutputBlock
  22351. * @param name defines the block name
  22352. */
  22353. constructor(name: string);
  22354. /**
  22355. * Gets the current class name
  22356. * @returns the class name
  22357. */
  22358. getClassName(): string;
  22359. /**
  22360. * Gets the vector input component
  22361. */
  22362. get vector(): NodeMaterialConnectionPoint;
  22363. protected _buildBlock(state: NodeMaterialBuildState): this;
  22364. }
  22365. }
  22366. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22370. /**
  22371. * Block used to output the final color
  22372. */
  22373. export class FragmentOutputBlock extends NodeMaterialBlock {
  22374. /**
  22375. * Create a new FragmentOutputBlock
  22376. * @param name defines the block name
  22377. */
  22378. constructor(name: string);
  22379. /**
  22380. * Gets the current class name
  22381. * @returns the class name
  22382. */
  22383. getClassName(): string;
  22384. /**
  22385. * Gets the rgba input component
  22386. */
  22387. get rgba(): NodeMaterialConnectionPoint;
  22388. /**
  22389. * Gets the rgb input component
  22390. */
  22391. get rgb(): NodeMaterialConnectionPoint;
  22392. /**
  22393. * Gets the a input component
  22394. */
  22395. get a(): NodeMaterialConnectionPoint;
  22396. protected _buildBlock(state: NodeMaterialBuildState): this;
  22397. }
  22398. }
  22399. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22403. /**
  22404. * Block used for the particle ramp gradient section
  22405. */
  22406. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22407. /**
  22408. * Create a new ParticleRampGradientBlock
  22409. * @param name defines the block name
  22410. */
  22411. constructor(name: string);
  22412. /**
  22413. * Gets the current class name
  22414. * @returns the class name
  22415. */
  22416. getClassName(): string;
  22417. /**
  22418. * Gets the color input component
  22419. */
  22420. get color(): NodeMaterialConnectionPoint;
  22421. /**
  22422. * Gets the rampColor output component
  22423. */
  22424. get rampColor(): NodeMaterialConnectionPoint;
  22425. /**
  22426. * Initialize the block and prepare the context for build
  22427. * @param state defines the state that will be used for the build
  22428. */
  22429. initialize(state: NodeMaterialBuildState): void;
  22430. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22431. }
  22432. }
  22433. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22437. /**
  22438. * Block used for the particle blend multiply section
  22439. */
  22440. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22441. /**
  22442. * Create a new ParticleBlendMultiplyBlock
  22443. * @param name defines the block name
  22444. */
  22445. constructor(name: string);
  22446. /**
  22447. * Gets the current class name
  22448. * @returns the class name
  22449. */
  22450. getClassName(): string;
  22451. /**
  22452. * Gets the color input component
  22453. */
  22454. get color(): NodeMaterialConnectionPoint;
  22455. /**
  22456. * Gets the alphaTexture input component
  22457. */
  22458. get alphaTexture(): NodeMaterialConnectionPoint;
  22459. /**
  22460. * Gets the alphaColor input component
  22461. */
  22462. get alphaColor(): NodeMaterialConnectionPoint;
  22463. /**
  22464. * Gets the blendColor output component
  22465. */
  22466. get blendColor(): NodeMaterialConnectionPoint;
  22467. /**
  22468. * Initialize the block and prepare the context for build
  22469. * @param state defines the state that will be used for the build
  22470. */
  22471. initialize(state: NodeMaterialBuildState): void;
  22472. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22473. }
  22474. }
  22475. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22479. /**
  22480. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22481. */
  22482. export class VectorMergerBlock extends NodeMaterialBlock {
  22483. /**
  22484. * Create a new VectorMergerBlock
  22485. * @param name defines the block name
  22486. */
  22487. constructor(name: string);
  22488. /**
  22489. * Gets the current class name
  22490. * @returns the class name
  22491. */
  22492. getClassName(): string;
  22493. /**
  22494. * Gets the xyz component (input)
  22495. */
  22496. get xyzIn(): NodeMaterialConnectionPoint;
  22497. /**
  22498. * Gets the xy component (input)
  22499. */
  22500. get xyIn(): NodeMaterialConnectionPoint;
  22501. /**
  22502. * Gets the x component (input)
  22503. */
  22504. get x(): NodeMaterialConnectionPoint;
  22505. /**
  22506. * Gets the y component (input)
  22507. */
  22508. get y(): NodeMaterialConnectionPoint;
  22509. /**
  22510. * Gets the z component (input)
  22511. */
  22512. get z(): NodeMaterialConnectionPoint;
  22513. /**
  22514. * Gets the w component (input)
  22515. */
  22516. get w(): NodeMaterialConnectionPoint;
  22517. /**
  22518. * Gets the xyzw component (output)
  22519. */
  22520. get xyzw(): NodeMaterialConnectionPoint;
  22521. /**
  22522. * Gets the xyz component (output)
  22523. */
  22524. get xyzOut(): NodeMaterialConnectionPoint;
  22525. /**
  22526. * Gets the xy component (output)
  22527. */
  22528. get xyOut(): NodeMaterialConnectionPoint;
  22529. /**
  22530. * Gets the xy component (output)
  22531. * @deprecated Please use xyOut instead.
  22532. */
  22533. get xy(): NodeMaterialConnectionPoint;
  22534. /**
  22535. * Gets the xyz component (output)
  22536. * @deprecated Please use xyzOut instead.
  22537. */
  22538. get xyz(): NodeMaterialConnectionPoint;
  22539. protected _buildBlock(state: NodeMaterialBuildState): this;
  22540. }
  22541. }
  22542. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22543. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22544. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22545. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22546. import { Vector2 } from "babylonjs/Maths/math.vector";
  22547. import { Scene } from "babylonjs/scene";
  22548. /**
  22549. * Block used to remap a float from a range to a new one
  22550. */
  22551. export class RemapBlock extends NodeMaterialBlock {
  22552. /**
  22553. * Gets or sets the source range
  22554. */
  22555. sourceRange: Vector2;
  22556. /**
  22557. * Gets or sets the target range
  22558. */
  22559. targetRange: Vector2;
  22560. /**
  22561. * Creates a new RemapBlock
  22562. * @param name defines the block name
  22563. */
  22564. constructor(name: string);
  22565. /**
  22566. * Gets the current class name
  22567. * @returns the class name
  22568. */
  22569. getClassName(): string;
  22570. /**
  22571. * Gets the input component
  22572. */
  22573. get input(): NodeMaterialConnectionPoint;
  22574. /**
  22575. * Gets the source min input component
  22576. */
  22577. get sourceMin(): NodeMaterialConnectionPoint;
  22578. /**
  22579. * Gets the source max input component
  22580. */
  22581. get sourceMax(): NodeMaterialConnectionPoint;
  22582. /**
  22583. * Gets the target min input component
  22584. */
  22585. get targetMin(): NodeMaterialConnectionPoint;
  22586. /**
  22587. * Gets the target max input component
  22588. */
  22589. get targetMax(): NodeMaterialConnectionPoint;
  22590. /**
  22591. * Gets the output component
  22592. */
  22593. get output(): NodeMaterialConnectionPoint;
  22594. protected _buildBlock(state: NodeMaterialBuildState): this;
  22595. protected _dumpPropertiesCode(): string;
  22596. serialize(): any;
  22597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22598. }
  22599. }
  22600. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22604. /**
  22605. * Block used to multiply 2 values
  22606. */
  22607. export class MultiplyBlock extends NodeMaterialBlock {
  22608. /**
  22609. * Creates a new MultiplyBlock
  22610. * @param name defines the block name
  22611. */
  22612. constructor(name: string);
  22613. /**
  22614. * Gets the current class name
  22615. * @returns the class name
  22616. */
  22617. getClassName(): string;
  22618. /**
  22619. * Gets the left operand input component
  22620. */
  22621. get left(): NodeMaterialConnectionPoint;
  22622. /**
  22623. * Gets the right operand input component
  22624. */
  22625. get right(): NodeMaterialConnectionPoint;
  22626. /**
  22627. * Gets the output component
  22628. */
  22629. get output(): NodeMaterialConnectionPoint;
  22630. protected _buildBlock(state: NodeMaterialBuildState): this;
  22631. }
  22632. }
  22633. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22635. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22636. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22637. /**
  22638. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22639. */
  22640. export class ColorSplitterBlock extends NodeMaterialBlock {
  22641. /**
  22642. * Create a new ColorSplitterBlock
  22643. * @param name defines the block name
  22644. */
  22645. constructor(name: string);
  22646. /**
  22647. * Gets the current class name
  22648. * @returns the class name
  22649. */
  22650. getClassName(): string;
  22651. /**
  22652. * Gets the rgba component (input)
  22653. */
  22654. get rgba(): NodeMaterialConnectionPoint;
  22655. /**
  22656. * Gets the rgb component (input)
  22657. */
  22658. get rgbIn(): NodeMaterialConnectionPoint;
  22659. /**
  22660. * Gets the rgb component (output)
  22661. */
  22662. get rgbOut(): NodeMaterialConnectionPoint;
  22663. /**
  22664. * Gets the r component (output)
  22665. */
  22666. get r(): NodeMaterialConnectionPoint;
  22667. /**
  22668. * Gets the g component (output)
  22669. */
  22670. get g(): NodeMaterialConnectionPoint;
  22671. /**
  22672. * Gets the b component (output)
  22673. */
  22674. get b(): NodeMaterialConnectionPoint;
  22675. /**
  22676. * Gets the a component (output)
  22677. */
  22678. get a(): NodeMaterialConnectionPoint;
  22679. protected _inputRename(name: string): string;
  22680. protected _outputRename(name: string): string;
  22681. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22682. }
  22683. }
  22684. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22686. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22687. import { Scene } from "babylonjs/scene";
  22688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22689. import { Matrix } from "babylonjs/Maths/math.vector";
  22690. import { Mesh } from "babylonjs/Meshes/mesh";
  22691. import { Engine } from "babylonjs/Engines/engine";
  22692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22693. import { Observable } from "babylonjs/Misc/observable";
  22694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22695. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22696. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22697. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22698. import { Nullable } from "babylonjs/types";
  22699. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22700. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22701. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22702. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22703. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22704. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22705. import { Effect } from "babylonjs/Materials/effect";
  22706. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22707. import { Camera } from "babylonjs/Cameras/camera";
  22708. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22709. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22710. /**
  22711. * Interface used to configure the node material editor
  22712. */
  22713. export interface INodeMaterialEditorOptions {
  22714. /** Define the URl to load node editor script */
  22715. editorURL?: string;
  22716. }
  22717. /** @hidden */
  22718. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22719. NORMAL: boolean;
  22720. TANGENT: boolean;
  22721. UV1: boolean;
  22722. /** BONES */
  22723. NUM_BONE_INFLUENCERS: number;
  22724. BonesPerMesh: number;
  22725. BONETEXTURE: boolean;
  22726. /** MORPH TARGETS */
  22727. MORPHTARGETS: boolean;
  22728. MORPHTARGETS_NORMAL: boolean;
  22729. MORPHTARGETS_TANGENT: boolean;
  22730. MORPHTARGETS_UV: boolean;
  22731. NUM_MORPH_INFLUENCERS: number;
  22732. /** IMAGE PROCESSING */
  22733. IMAGEPROCESSING: boolean;
  22734. VIGNETTE: boolean;
  22735. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22736. VIGNETTEBLENDMODEOPAQUE: boolean;
  22737. TONEMAPPING: boolean;
  22738. TONEMAPPING_ACES: boolean;
  22739. CONTRAST: boolean;
  22740. EXPOSURE: boolean;
  22741. COLORCURVES: boolean;
  22742. COLORGRADING: boolean;
  22743. COLORGRADING3D: boolean;
  22744. SAMPLER3DGREENDEPTH: boolean;
  22745. SAMPLER3DBGRMAP: boolean;
  22746. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22747. /** MISC. */
  22748. BUMPDIRECTUV: number;
  22749. constructor();
  22750. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22751. }
  22752. /**
  22753. * Class used to configure NodeMaterial
  22754. */
  22755. export interface INodeMaterialOptions {
  22756. /**
  22757. * Defines if blocks should emit comments
  22758. */
  22759. emitComments: boolean;
  22760. }
  22761. /**
  22762. * Class used to create a node based material built by assembling shader blocks
  22763. */
  22764. export class NodeMaterial extends PushMaterial {
  22765. private static _BuildIdGenerator;
  22766. private _options;
  22767. private _vertexCompilationState;
  22768. private _fragmentCompilationState;
  22769. private _sharedData;
  22770. private _buildId;
  22771. private _buildWasSuccessful;
  22772. private _cachedWorldViewMatrix;
  22773. private _cachedWorldViewProjectionMatrix;
  22774. private _optimizers;
  22775. private _animationFrame;
  22776. /** Define the Url to load node editor script */
  22777. static EditorURL: string;
  22778. /** Define the Url to load snippets */
  22779. static SnippetUrl: string;
  22780. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22781. static IgnoreTexturesAtLoadTime: boolean;
  22782. private BJSNODEMATERIALEDITOR;
  22783. /** Get the inspector from bundle or global */
  22784. private _getGlobalNodeMaterialEditor;
  22785. /**
  22786. * Snippet ID if the material was created from the snippet server
  22787. */
  22788. snippetId: string;
  22789. /**
  22790. * Gets or sets data used by visual editor
  22791. * @see https://nme.babylonjs.com
  22792. */
  22793. editorData: any;
  22794. /**
  22795. * 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)
  22796. */
  22797. ignoreAlpha: boolean;
  22798. /**
  22799. * Defines the maximum number of lights that can be used in the material
  22800. */
  22801. maxSimultaneousLights: number;
  22802. /**
  22803. * Observable raised when the material is built
  22804. */
  22805. onBuildObservable: Observable<NodeMaterial>;
  22806. /**
  22807. * Gets or sets the root nodes of the material vertex shader
  22808. */
  22809. _vertexOutputNodes: NodeMaterialBlock[];
  22810. /**
  22811. * Gets or sets the root nodes of the material fragment (pixel) shader
  22812. */
  22813. _fragmentOutputNodes: NodeMaterialBlock[];
  22814. /** Gets or sets options to control the node material overall behavior */
  22815. get options(): INodeMaterialOptions;
  22816. set options(options: INodeMaterialOptions);
  22817. /**
  22818. * Default configuration related to image processing available in the standard Material.
  22819. */
  22820. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22821. /**
  22822. * Gets the image processing configuration used either in this material.
  22823. */
  22824. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22825. /**
  22826. * Sets the Default image processing configuration used either in the this material.
  22827. *
  22828. * If sets to null, the scene one is in use.
  22829. */
  22830. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22831. /**
  22832. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22833. */
  22834. attachedBlocks: NodeMaterialBlock[];
  22835. /**
  22836. * Specifies the mode of the node material
  22837. * @hidden
  22838. */
  22839. _mode: NodeMaterialModes;
  22840. /**
  22841. * Gets the mode property
  22842. */
  22843. get mode(): NodeMaterialModes;
  22844. /**
  22845. * Create a new node based material
  22846. * @param name defines the material name
  22847. * @param scene defines the hosting scene
  22848. * @param options defines creation option
  22849. */
  22850. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22851. /**
  22852. * Gets the current class name of the material e.g. "NodeMaterial"
  22853. * @returns the class name
  22854. */
  22855. getClassName(): string;
  22856. /**
  22857. * Keep track of the image processing observer to allow dispose and replace.
  22858. */
  22859. private _imageProcessingObserver;
  22860. /**
  22861. * Attaches a new image processing configuration to the Standard Material.
  22862. * @param configuration
  22863. */
  22864. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22865. /**
  22866. * Get a block by its name
  22867. * @param name defines the name of the block to retrieve
  22868. * @returns the required block or null if not found
  22869. */
  22870. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22871. /**
  22872. * Get a block by its name
  22873. * @param predicate defines the predicate used to find the good candidate
  22874. * @returns the required block or null if not found
  22875. */
  22876. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22877. /**
  22878. * Get an input block by its name
  22879. * @param predicate defines the predicate used to find the good candidate
  22880. * @returns the required input block or null if not found
  22881. */
  22882. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22883. /**
  22884. * Gets the list of input blocks attached to this material
  22885. * @returns an array of InputBlocks
  22886. */
  22887. getInputBlocks(): InputBlock[];
  22888. /**
  22889. * Adds a new optimizer to the list of optimizers
  22890. * @param optimizer defines the optimizers to add
  22891. * @returns the current material
  22892. */
  22893. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22894. /**
  22895. * Remove an optimizer from the list of optimizers
  22896. * @param optimizer defines the optimizers to remove
  22897. * @returns the current material
  22898. */
  22899. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22900. /**
  22901. * Add a new block to the list of output nodes
  22902. * @param node defines the node to add
  22903. * @returns the current material
  22904. */
  22905. addOutputNode(node: NodeMaterialBlock): this;
  22906. /**
  22907. * Remove a block from the list of root nodes
  22908. * @param node defines the node to remove
  22909. * @returns the current material
  22910. */
  22911. removeOutputNode(node: NodeMaterialBlock): this;
  22912. private _addVertexOutputNode;
  22913. private _removeVertexOutputNode;
  22914. private _addFragmentOutputNode;
  22915. private _removeFragmentOutputNode;
  22916. /**
  22917. * Specifies if the material will require alpha blending
  22918. * @returns a boolean specifying if alpha blending is needed
  22919. */
  22920. needAlphaBlending(): boolean;
  22921. /**
  22922. * Specifies if this material should be rendered in alpha test mode
  22923. * @returns a boolean specifying if an alpha test is needed.
  22924. */
  22925. needAlphaTesting(): boolean;
  22926. private _initializeBlock;
  22927. private _resetDualBlocks;
  22928. /**
  22929. * Remove a block from the current node material
  22930. * @param block defines the block to remove
  22931. */
  22932. removeBlock(block: NodeMaterialBlock): void;
  22933. /**
  22934. * Build the material and generates the inner effect
  22935. * @param verbose defines if the build should log activity
  22936. */
  22937. build(verbose?: boolean): void;
  22938. /**
  22939. * Runs an otpimization phase to try to improve the shader code
  22940. */
  22941. optimize(): void;
  22942. private _prepareDefinesForAttributes;
  22943. /**
  22944. * Create a post process from the material
  22945. * @param camera The camera to apply the render pass to.
  22946. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22948. * @param engine The engine which the post process will be applied. (default: current engine)
  22949. * @param reusable If the post process can be reused on the same frame. (default: false)
  22950. * @param textureType Type of textures used when performing the post process. (default: 0)
  22951. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22952. * @returns the post process created
  22953. */
  22954. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22955. /**
  22956. * Create the post process effect from the material
  22957. * @param postProcess The post process to create the effect for
  22958. */
  22959. createEffectForPostProcess(postProcess: PostProcess): void;
  22960. private _createEffectOrPostProcess;
  22961. private _createEffectForParticles;
  22962. /**
  22963. * Create the effect to be used as the custom effect for a particle system
  22964. * @param particleSystem Particle system to create the effect for
  22965. * @param onCompiled defines a function to call when the effect creation is successful
  22966. * @param onError defines a function to call when the effect creation has failed
  22967. */
  22968. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22969. private _processDefines;
  22970. /**
  22971. * Get if the submesh is ready to be used and all its information available.
  22972. * Child classes can use it to update shaders
  22973. * @param mesh defines the mesh to check
  22974. * @param subMesh defines which submesh to check
  22975. * @param useInstances specifies that instances should be used
  22976. * @returns a boolean indicating that the submesh is ready or not
  22977. */
  22978. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22979. /**
  22980. * Get a string representing the shaders built by the current node graph
  22981. */
  22982. get compiledShaders(): string;
  22983. /**
  22984. * Binds the world matrix to the material
  22985. * @param world defines the world transformation matrix
  22986. */
  22987. bindOnlyWorldMatrix(world: Matrix): void;
  22988. /**
  22989. * Binds the submesh to this material by preparing the effect and shader to draw
  22990. * @param world defines the world transformation matrix
  22991. * @param mesh defines the mesh containing the submesh
  22992. * @param subMesh defines the submesh to bind the material to
  22993. */
  22994. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22995. /**
  22996. * Gets the active textures from the material
  22997. * @returns an array of textures
  22998. */
  22999. getActiveTextures(): BaseTexture[];
  23000. /**
  23001. * Gets the list of texture blocks
  23002. * @returns an array of texture blocks
  23003. */
  23004. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23005. /**
  23006. * Specifies if the material uses a texture
  23007. * @param texture defines the texture to check against the material
  23008. * @returns a boolean specifying if the material uses the texture
  23009. */
  23010. hasTexture(texture: BaseTexture): boolean;
  23011. /**
  23012. * Disposes the material
  23013. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23014. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23015. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23016. */
  23017. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23018. /** Creates the node editor window. */
  23019. private _createNodeEditor;
  23020. /**
  23021. * Launch the node material editor
  23022. * @param config Define the configuration of the editor
  23023. * @return a promise fulfilled when the node editor is visible
  23024. */
  23025. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23026. /**
  23027. * Clear the current material
  23028. */
  23029. clear(): void;
  23030. /**
  23031. * Clear the current material and set it to a default state
  23032. */
  23033. setToDefault(): void;
  23034. /**
  23035. * Clear the current material and set it to a default state for post process
  23036. */
  23037. setToDefaultPostProcess(): void;
  23038. /**
  23039. * Clear the current material and set it to a default state for particle
  23040. */
  23041. setToDefaultParticle(): void;
  23042. /**
  23043. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23044. * @param url defines the url to load from
  23045. * @returns a promise that will fullfil when the material is fully loaded
  23046. */
  23047. loadAsync(url: string): Promise<void>;
  23048. private _gatherBlocks;
  23049. /**
  23050. * Generate a string containing the code declaration required to create an equivalent of this material
  23051. * @returns a string
  23052. */
  23053. generateCode(): string;
  23054. /**
  23055. * Serializes this material in a JSON representation
  23056. * @returns the serialized material object
  23057. */
  23058. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23059. private _restoreConnections;
  23060. /**
  23061. * Clear the current graph and load a new one from a serialization object
  23062. * @param source defines the JSON representation of the material
  23063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23064. */
  23065. loadFromSerialization(source: any, rootUrl?: string): void;
  23066. /**
  23067. * Makes a duplicate of the current material.
  23068. * @param name - name to use for the new material.
  23069. */
  23070. clone(name: string): NodeMaterial;
  23071. /**
  23072. * Creates a node material from parsed material data
  23073. * @param source defines the JSON representation of the material
  23074. * @param scene defines the hosting scene
  23075. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23076. * @returns a new node material
  23077. */
  23078. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23079. /**
  23080. * Creates a node material from a snippet saved in a remote file
  23081. * @param name defines the name of the material to create
  23082. * @param url defines the url to load from
  23083. * @param scene defines the hosting scene
  23084. * @returns a promise that will resolve to the new node material
  23085. */
  23086. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23087. /**
  23088. * Creates a node material from a snippet saved by the node material editor
  23089. * @param snippetId defines the snippet to load
  23090. * @param scene defines the hosting scene
  23091. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23092. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23093. * @returns a promise that will resolve to the new node material
  23094. */
  23095. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23096. /**
  23097. * Creates a new node material set to default basic configuration
  23098. * @param name defines the name of the material
  23099. * @param scene defines the hosting scene
  23100. * @returns a new NodeMaterial
  23101. */
  23102. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23103. }
  23104. }
  23105. declare module "babylonjs/PostProcesses/postProcess" {
  23106. import { Nullable } from "babylonjs/types";
  23107. import { SmartArray } from "babylonjs/Misc/smartArray";
  23108. import { Observable } from "babylonjs/Misc/observable";
  23109. import { Vector2 } from "babylonjs/Maths/math.vector";
  23110. import { Camera } from "babylonjs/Cameras/camera";
  23111. import { Effect } from "babylonjs/Materials/effect";
  23112. import "babylonjs/Shaders/postprocess.vertex";
  23113. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23114. import { Engine } from "babylonjs/Engines/engine";
  23115. import { Color4 } from "babylonjs/Maths/math.color";
  23116. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23117. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23118. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23119. /**
  23120. * Size options for a post process
  23121. */
  23122. export type PostProcessOptions = {
  23123. width: number;
  23124. height: number;
  23125. };
  23126. /**
  23127. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23128. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23129. */
  23130. export class PostProcess {
  23131. /** Name of the PostProcess. */
  23132. name: string;
  23133. /**
  23134. * Gets or sets the unique id of the post process
  23135. */
  23136. uniqueId: number;
  23137. /**
  23138. * Width of the texture to apply the post process on
  23139. */
  23140. width: number;
  23141. /**
  23142. * Height of the texture to apply the post process on
  23143. */
  23144. height: number;
  23145. /**
  23146. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23147. */
  23148. nodeMaterialSource: Nullable<NodeMaterial>;
  23149. /**
  23150. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23151. * @hidden
  23152. */
  23153. _outputTexture: Nullable<InternalTexture>;
  23154. /**
  23155. * Sampling mode used by the shader
  23156. * See https://doc.babylonjs.com/classes/3.1/texture
  23157. */
  23158. renderTargetSamplingMode: number;
  23159. /**
  23160. * Clear color to use when screen clearing
  23161. */
  23162. clearColor: Color4;
  23163. /**
  23164. * If the buffer needs to be cleared before applying the post process. (default: true)
  23165. * Should be set to false if shader will overwrite all previous pixels.
  23166. */
  23167. autoClear: boolean;
  23168. /**
  23169. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23170. */
  23171. alphaMode: number;
  23172. /**
  23173. * Sets the setAlphaBlendConstants of the babylon engine
  23174. */
  23175. alphaConstants: Color4;
  23176. /**
  23177. * Animations to be used for the post processing
  23178. */
  23179. animations: import("babylonjs/Animations/animation").Animation[];
  23180. /**
  23181. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23182. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23183. */
  23184. enablePixelPerfectMode: boolean;
  23185. /**
  23186. * Force the postprocess to be applied without taking in account viewport
  23187. */
  23188. forceFullscreenViewport: boolean;
  23189. /**
  23190. * List of inspectable custom properties (used by the Inspector)
  23191. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23192. */
  23193. inspectableCustomProperties: IInspectable[];
  23194. /**
  23195. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23196. *
  23197. * | Value | Type | Description |
  23198. * | ----- | ----------------------------------- | ----------- |
  23199. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23200. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23201. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23202. *
  23203. */
  23204. scaleMode: number;
  23205. /**
  23206. * Force textures to be a power of two (default: false)
  23207. */
  23208. alwaysForcePOT: boolean;
  23209. private _samples;
  23210. /**
  23211. * Number of sample textures (default: 1)
  23212. */
  23213. get samples(): number;
  23214. set samples(n: number);
  23215. /**
  23216. * Modify the scale of the post process to be the same as the viewport (default: false)
  23217. */
  23218. adaptScaleToCurrentViewport: boolean;
  23219. private _camera;
  23220. private _scene;
  23221. private _engine;
  23222. private _options;
  23223. private _reusable;
  23224. private _textureType;
  23225. private _textureFormat;
  23226. /**
  23227. * Smart array of input and output textures for the post process.
  23228. * @hidden
  23229. */
  23230. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23231. /**
  23232. * The index in _textures that corresponds to the output texture.
  23233. * @hidden
  23234. */
  23235. _currentRenderTextureInd: number;
  23236. private _effect;
  23237. private _samplers;
  23238. private _fragmentUrl;
  23239. private _vertexUrl;
  23240. private _parameters;
  23241. private _scaleRatio;
  23242. protected _indexParameters: any;
  23243. private _shareOutputWithPostProcess;
  23244. private _texelSize;
  23245. private _forcedOutputTexture;
  23246. /**
  23247. * Returns the fragment url or shader name used in the post process.
  23248. * @returns the fragment url or name in the shader store.
  23249. */
  23250. getEffectName(): string;
  23251. /**
  23252. * An event triggered when the postprocess is activated.
  23253. */
  23254. onActivateObservable: Observable<Camera>;
  23255. private _onActivateObserver;
  23256. /**
  23257. * A function that is added to the onActivateObservable
  23258. */
  23259. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23260. /**
  23261. * An event triggered when the postprocess changes its size.
  23262. */
  23263. onSizeChangedObservable: Observable<PostProcess>;
  23264. private _onSizeChangedObserver;
  23265. /**
  23266. * A function that is added to the onSizeChangedObservable
  23267. */
  23268. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23269. /**
  23270. * An event triggered when the postprocess applies its effect.
  23271. */
  23272. onApplyObservable: Observable<Effect>;
  23273. private _onApplyObserver;
  23274. /**
  23275. * A function that is added to the onApplyObservable
  23276. */
  23277. set onApply(callback: (effect: Effect) => void);
  23278. /**
  23279. * An event triggered before rendering the postprocess
  23280. */
  23281. onBeforeRenderObservable: Observable<Effect>;
  23282. private _onBeforeRenderObserver;
  23283. /**
  23284. * A function that is added to the onBeforeRenderObservable
  23285. */
  23286. set onBeforeRender(callback: (effect: Effect) => void);
  23287. /**
  23288. * An event triggered after rendering the postprocess
  23289. */
  23290. onAfterRenderObservable: Observable<Effect>;
  23291. private _onAfterRenderObserver;
  23292. /**
  23293. * A function that is added to the onAfterRenderObservable
  23294. */
  23295. set onAfterRender(callback: (efect: Effect) => void);
  23296. /**
  23297. * 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
  23298. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23299. */
  23300. get inputTexture(): InternalTexture;
  23301. set inputTexture(value: InternalTexture);
  23302. /**
  23303. * Gets the camera which post process is applied to.
  23304. * @returns The camera the post process is applied to.
  23305. */
  23306. getCamera(): Camera;
  23307. /**
  23308. * Gets the texel size of the postprocess.
  23309. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23310. */
  23311. get texelSize(): Vector2;
  23312. /**
  23313. * Creates a new instance PostProcess
  23314. * @param name The name of the PostProcess.
  23315. * @param fragmentUrl The url of the fragment shader to be used.
  23316. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23317. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23318. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23319. * @param camera The camera to apply the render pass to.
  23320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23321. * @param engine The engine which the post process will be applied. (default: current engine)
  23322. * @param reusable If the post process can be reused on the same frame. (default: false)
  23323. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23324. * @param textureType Type of textures used when performing the post process. (default: 0)
  23325. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23326. * @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
  23327. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23328. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23329. */
  23330. constructor(
  23331. /** Name of the PostProcess. */
  23332. 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);
  23333. /**
  23334. * Gets a string idenfifying the name of the class
  23335. * @returns "PostProcess" string
  23336. */
  23337. getClassName(): string;
  23338. /**
  23339. * Gets the engine which this post process belongs to.
  23340. * @returns The engine the post process was enabled with.
  23341. */
  23342. getEngine(): Engine;
  23343. /**
  23344. * The effect that is created when initializing the post process.
  23345. * @returns The created effect corresponding the the postprocess.
  23346. */
  23347. getEffect(): Effect;
  23348. /**
  23349. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23350. * @param postProcess The post process to share the output with.
  23351. * @returns This post process.
  23352. */
  23353. shareOutputWith(postProcess: PostProcess): PostProcess;
  23354. /**
  23355. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23356. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23357. */
  23358. useOwnOutput(): void;
  23359. /**
  23360. * Updates the effect with the current post process compile time values and recompiles the shader.
  23361. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23362. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23363. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23364. * @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
  23365. * @param onCompiled Called when the shader has been compiled.
  23366. * @param onError Called if there is an error when compiling a shader.
  23367. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23368. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23369. */
  23370. 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;
  23371. /**
  23372. * The post process is reusable if it can be used multiple times within one frame.
  23373. * @returns If the post process is reusable
  23374. */
  23375. isReusable(): boolean;
  23376. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23377. markTextureDirty(): void;
  23378. /**
  23379. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23380. * 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.
  23381. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23382. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23383. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23384. * @returns The target texture that was bound to be written to.
  23385. */
  23386. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23387. /**
  23388. * If the post process is supported.
  23389. */
  23390. get isSupported(): boolean;
  23391. /**
  23392. * The aspect ratio of the output texture.
  23393. */
  23394. get aspectRatio(): number;
  23395. /**
  23396. * Get a value indicating if the post-process is ready to be used
  23397. * @returns true if the post-process is ready (shader is compiled)
  23398. */
  23399. isReady(): boolean;
  23400. /**
  23401. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23402. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23403. */
  23404. apply(): Nullable<Effect>;
  23405. private _disposeTextures;
  23406. /**
  23407. * Disposes the post process.
  23408. * @param camera The camera to dispose the post process on.
  23409. */
  23410. dispose(camera?: Camera): void;
  23411. }
  23412. }
  23413. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23414. /** @hidden */
  23415. export var kernelBlurVaryingDeclaration: {
  23416. name: string;
  23417. shader: string;
  23418. };
  23419. }
  23420. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23421. /** @hidden */
  23422. export var kernelBlurFragment: {
  23423. name: string;
  23424. shader: string;
  23425. };
  23426. }
  23427. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23428. /** @hidden */
  23429. export var kernelBlurFragment2: {
  23430. name: string;
  23431. shader: string;
  23432. };
  23433. }
  23434. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23435. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23436. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23437. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23438. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23439. /** @hidden */
  23440. export var kernelBlurPixelShader: {
  23441. name: string;
  23442. shader: string;
  23443. };
  23444. }
  23445. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23446. /** @hidden */
  23447. export var kernelBlurVertex: {
  23448. name: string;
  23449. shader: string;
  23450. };
  23451. }
  23452. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23453. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23454. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23455. /** @hidden */
  23456. export var kernelBlurVertexShader: {
  23457. name: string;
  23458. shader: string;
  23459. };
  23460. }
  23461. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23462. import { Vector2 } from "babylonjs/Maths/math.vector";
  23463. import { Nullable } from "babylonjs/types";
  23464. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23465. import { Camera } from "babylonjs/Cameras/camera";
  23466. import { Effect } from "babylonjs/Materials/effect";
  23467. import { Engine } from "babylonjs/Engines/engine";
  23468. import "babylonjs/Shaders/kernelBlur.fragment";
  23469. import "babylonjs/Shaders/kernelBlur.vertex";
  23470. /**
  23471. * The Blur Post Process which blurs an image based on a kernel and direction.
  23472. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23473. */
  23474. export class BlurPostProcess extends PostProcess {
  23475. /** The direction in which to blur the image. */
  23476. direction: Vector2;
  23477. private blockCompilation;
  23478. protected _kernel: number;
  23479. protected _idealKernel: number;
  23480. protected _packedFloat: boolean;
  23481. private _staticDefines;
  23482. /**
  23483. * Sets the length in pixels of the blur sample region
  23484. */
  23485. set kernel(v: number);
  23486. /**
  23487. * Gets the length in pixels of the blur sample region
  23488. */
  23489. get kernel(): number;
  23490. /**
  23491. * Sets wether or not the blur needs to unpack/repack floats
  23492. */
  23493. set packedFloat(v: boolean);
  23494. /**
  23495. * Gets wether or not the blur is unpacking/repacking floats
  23496. */
  23497. get packedFloat(): boolean;
  23498. /**
  23499. * Creates a new instance BlurPostProcess
  23500. * @param name The name of the effect.
  23501. * @param direction The direction in which to blur the image.
  23502. * @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.
  23503. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23504. * @param camera The camera to apply the render pass to.
  23505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23506. * @param engine The engine which the post process will be applied. (default: current engine)
  23507. * @param reusable If the post process can be reused on the same frame. (default: false)
  23508. * @param textureType Type of textures used when performing the post process. (default: 0)
  23509. * @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)
  23510. */
  23511. constructor(name: string,
  23512. /** The direction in which to blur the image. */
  23513. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23514. /**
  23515. * Updates the effect with the current post process compile time values and recompiles the shader.
  23516. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23517. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23518. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23519. * @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
  23520. * @param onCompiled Called when the shader has been compiled.
  23521. * @param onError Called if there is an error when compiling a shader.
  23522. */
  23523. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23524. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23525. /**
  23526. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23527. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23528. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23529. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23530. * The gaps between physical kernels are compensated for in the weighting of the samples
  23531. * @param idealKernel Ideal blur kernel.
  23532. * @return Nearest best kernel.
  23533. */
  23534. protected _nearestBestKernel(idealKernel: number): number;
  23535. /**
  23536. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23537. * @param x The point on the Gaussian distribution to sample.
  23538. * @return the value of the Gaussian function at x.
  23539. */
  23540. protected _gaussianWeight(x: number): number;
  23541. /**
  23542. * Generates a string that can be used as a floating point number in GLSL.
  23543. * @param x Value to print.
  23544. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23545. * @return GLSL float string.
  23546. */
  23547. protected _glslFloat(x: number, decimalFigures?: number): string;
  23548. }
  23549. }
  23550. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23551. import { Scene } from "babylonjs/scene";
  23552. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23553. import { Plane } from "babylonjs/Maths/math.plane";
  23554. /**
  23555. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23556. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23557. * You can then easily use it as a reflectionTexture on a flat surface.
  23558. * In case the surface is not a plane, please consider relying on reflection probes.
  23559. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23560. */
  23561. export class MirrorTexture extends RenderTargetTexture {
  23562. private scene;
  23563. /**
  23564. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23565. * 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.
  23566. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23567. */
  23568. mirrorPlane: Plane;
  23569. /**
  23570. * Define the blur ratio used to blur the reflection if needed.
  23571. */
  23572. set blurRatio(value: number);
  23573. get blurRatio(): number;
  23574. /**
  23575. * Define the adaptive blur kernel used to blur the reflection if needed.
  23576. * This will autocompute the closest best match for the `blurKernel`
  23577. */
  23578. set adaptiveBlurKernel(value: number);
  23579. /**
  23580. * Define the blur kernel used to blur the reflection if needed.
  23581. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23582. */
  23583. set blurKernel(value: number);
  23584. /**
  23585. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23586. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23587. */
  23588. set blurKernelX(value: number);
  23589. get blurKernelX(): number;
  23590. /**
  23591. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23592. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23593. */
  23594. set blurKernelY(value: number);
  23595. get blurKernelY(): number;
  23596. private _autoComputeBlurKernel;
  23597. protected _onRatioRescale(): void;
  23598. private _updateGammaSpace;
  23599. private _imageProcessingConfigChangeObserver;
  23600. private _transformMatrix;
  23601. private _mirrorMatrix;
  23602. private _savedViewMatrix;
  23603. private _blurX;
  23604. private _blurY;
  23605. private _adaptiveBlurKernel;
  23606. private _blurKernelX;
  23607. private _blurKernelY;
  23608. private _blurRatio;
  23609. /**
  23610. * Instantiates a Mirror Texture.
  23611. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23612. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23613. * You can then easily use it as a reflectionTexture on a flat surface.
  23614. * In case the surface is not a plane, please consider relying on reflection probes.
  23615. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23616. * @param name
  23617. * @param size
  23618. * @param scene
  23619. * @param generateMipMaps
  23620. * @param type
  23621. * @param samplingMode
  23622. * @param generateDepthBuffer
  23623. */
  23624. constructor(name: string, size: number | {
  23625. width: number;
  23626. height: number;
  23627. } | {
  23628. ratio: number;
  23629. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23630. private _preparePostProcesses;
  23631. /**
  23632. * Clone the mirror texture.
  23633. * @returns the cloned texture
  23634. */
  23635. clone(): MirrorTexture;
  23636. /**
  23637. * Serialize the texture to a JSON representation you could use in Parse later on
  23638. * @returns the serialized JSON representation
  23639. */
  23640. serialize(): any;
  23641. /**
  23642. * Dispose the texture and release its associated resources.
  23643. */
  23644. dispose(): void;
  23645. }
  23646. }
  23647. declare module "babylonjs/Materials/Textures/texture" {
  23648. import { Observable } from "babylonjs/Misc/observable";
  23649. import { Nullable } from "babylonjs/types";
  23650. import { Matrix } from "babylonjs/Maths/math.vector";
  23651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23652. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23653. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23654. import { Scene } from "babylonjs/scene";
  23655. /**
  23656. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23657. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23658. */
  23659. export class Texture extends BaseTexture {
  23660. /**
  23661. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23662. */
  23663. static SerializeBuffers: boolean;
  23664. /** @hidden */
  23665. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23666. /** @hidden */
  23667. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23668. /** @hidden */
  23669. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23670. /** nearest is mag = nearest and min = nearest and mip = linear */
  23671. static readonly NEAREST_SAMPLINGMODE: number;
  23672. /** nearest is mag = nearest and min = nearest and mip = linear */
  23673. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23674. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23675. static readonly BILINEAR_SAMPLINGMODE: number;
  23676. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23677. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23678. /** Trilinear is mag = linear and min = linear and mip = linear */
  23679. static readonly TRILINEAR_SAMPLINGMODE: number;
  23680. /** Trilinear is mag = linear and min = linear and mip = linear */
  23681. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23682. /** mag = nearest and min = nearest and mip = nearest */
  23683. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23684. /** mag = nearest and min = linear and mip = nearest */
  23685. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23686. /** mag = nearest and min = linear and mip = linear */
  23687. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23688. /** mag = nearest and min = linear and mip = none */
  23689. static readonly NEAREST_LINEAR: number;
  23690. /** mag = nearest and min = nearest and mip = none */
  23691. static readonly NEAREST_NEAREST: number;
  23692. /** mag = linear and min = nearest and mip = nearest */
  23693. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23694. /** mag = linear and min = nearest and mip = linear */
  23695. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23696. /** mag = linear and min = linear and mip = none */
  23697. static readonly LINEAR_LINEAR: number;
  23698. /** mag = linear and min = nearest and mip = none */
  23699. static readonly LINEAR_NEAREST: number;
  23700. /** Explicit coordinates mode */
  23701. static readonly EXPLICIT_MODE: number;
  23702. /** Spherical coordinates mode */
  23703. static readonly SPHERICAL_MODE: number;
  23704. /** Planar coordinates mode */
  23705. static readonly PLANAR_MODE: number;
  23706. /** Cubic coordinates mode */
  23707. static readonly CUBIC_MODE: number;
  23708. /** Projection coordinates mode */
  23709. static readonly PROJECTION_MODE: number;
  23710. /** Inverse Cubic coordinates mode */
  23711. static readonly SKYBOX_MODE: number;
  23712. /** Inverse Cubic coordinates mode */
  23713. static readonly INVCUBIC_MODE: number;
  23714. /** Equirectangular coordinates mode */
  23715. static readonly EQUIRECTANGULAR_MODE: number;
  23716. /** Equirectangular Fixed coordinates mode */
  23717. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23718. /** Equirectangular Fixed Mirrored coordinates mode */
  23719. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23720. /** Texture is not repeating outside of 0..1 UVs */
  23721. static readonly CLAMP_ADDRESSMODE: number;
  23722. /** Texture is repeating outside of 0..1 UVs */
  23723. static readonly WRAP_ADDRESSMODE: number;
  23724. /** Texture is repeating and mirrored */
  23725. static readonly MIRROR_ADDRESSMODE: number;
  23726. /**
  23727. * 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
  23728. */
  23729. static UseSerializedUrlIfAny: boolean;
  23730. /**
  23731. * Define the url of the texture.
  23732. */
  23733. url: Nullable<string>;
  23734. /**
  23735. * Define an offset on the texture to offset the u coordinates of the UVs
  23736. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23737. */
  23738. uOffset: number;
  23739. /**
  23740. * Define an offset on the texture to offset the v coordinates of the UVs
  23741. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23742. */
  23743. vOffset: number;
  23744. /**
  23745. * Define an offset on the texture to scale the u coordinates of the UVs
  23746. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23747. */
  23748. uScale: number;
  23749. /**
  23750. * Define an offset on the texture to scale the v coordinates of the UVs
  23751. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23752. */
  23753. vScale: number;
  23754. /**
  23755. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23756. * @see http://doc.babylonjs.com/how_to/more_materials
  23757. */
  23758. uAng: number;
  23759. /**
  23760. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23761. * @see http://doc.babylonjs.com/how_to/more_materials
  23762. */
  23763. vAng: number;
  23764. /**
  23765. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23766. * @see http://doc.babylonjs.com/how_to/more_materials
  23767. */
  23768. wAng: number;
  23769. /**
  23770. * Defines the center of rotation (U)
  23771. */
  23772. uRotationCenter: number;
  23773. /**
  23774. * Defines the center of rotation (V)
  23775. */
  23776. vRotationCenter: number;
  23777. /**
  23778. * Defines the center of rotation (W)
  23779. */
  23780. wRotationCenter: number;
  23781. /**
  23782. * Are mip maps generated for this texture or not.
  23783. */
  23784. get noMipmap(): boolean;
  23785. /**
  23786. * List of inspectable custom properties (used by the Inspector)
  23787. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23788. */
  23789. inspectableCustomProperties: Nullable<IInspectable[]>;
  23790. private _noMipmap;
  23791. /** @hidden */
  23792. _invertY: boolean;
  23793. private _rowGenerationMatrix;
  23794. private _cachedTextureMatrix;
  23795. private _projectionModeMatrix;
  23796. private _t0;
  23797. private _t1;
  23798. private _t2;
  23799. private _cachedUOffset;
  23800. private _cachedVOffset;
  23801. private _cachedUScale;
  23802. private _cachedVScale;
  23803. private _cachedUAng;
  23804. private _cachedVAng;
  23805. private _cachedWAng;
  23806. private _cachedProjectionMatrixId;
  23807. private _cachedCoordinatesMode;
  23808. /** @hidden */
  23809. protected _initialSamplingMode: number;
  23810. /** @hidden */
  23811. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23812. private _deleteBuffer;
  23813. protected _format: Nullable<number>;
  23814. private _delayedOnLoad;
  23815. private _delayedOnError;
  23816. private _mimeType?;
  23817. /**
  23818. * Observable triggered once the texture has been loaded.
  23819. */
  23820. onLoadObservable: Observable<Texture>;
  23821. protected _isBlocking: boolean;
  23822. /**
  23823. * Is the texture preventing material to render while loading.
  23824. * If false, a default texture will be used instead of the loading one during the preparation step.
  23825. */
  23826. set isBlocking(value: boolean);
  23827. get isBlocking(): boolean;
  23828. /**
  23829. * Get the current sampling mode associated with the texture.
  23830. */
  23831. get samplingMode(): number;
  23832. /**
  23833. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23834. */
  23835. get invertY(): boolean;
  23836. /**
  23837. * Instantiates a new texture.
  23838. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23839. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23840. * @param url defines the url of the picture to load as a texture
  23841. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23842. * @param noMipmap defines if the texture will require mip maps or not
  23843. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23844. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23845. * @param onLoad defines a callback triggered when the texture has been loaded
  23846. * @param onError defines a callback triggered when an error occurred during the loading session
  23847. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23848. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23849. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23850. * @param mimeType defines an optional mime type information
  23851. */
  23852. 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);
  23853. /**
  23854. * Update the url (and optional buffer) of this texture if url was null during construction.
  23855. * @param url the url of the texture
  23856. * @param buffer the buffer of the texture (defaults to null)
  23857. * @param onLoad callback called when the texture is loaded (defaults to null)
  23858. */
  23859. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23860. /**
  23861. * Finish the loading sequence of a texture flagged as delayed load.
  23862. * @hidden
  23863. */
  23864. delayLoad(): void;
  23865. private _prepareRowForTextureGeneration;
  23866. /**
  23867. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23868. * @returns the transform matrix of the texture.
  23869. */
  23870. getTextureMatrix(uBase?: number): Matrix;
  23871. /**
  23872. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23873. * @returns The reflection texture transform
  23874. */
  23875. getReflectionTextureMatrix(): Matrix;
  23876. /**
  23877. * Clones the texture.
  23878. * @returns the cloned texture
  23879. */
  23880. clone(): Texture;
  23881. /**
  23882. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23883. * @returns The JSON representation of the texture
  23884. */
  23885. serialize(): any;
  23886. /**
  23887. * Get the current class name of the texture useful for serialization or dynamic coding.
  23888. * @returns "Texture"
  23889. */
  23890. getClassName(): string;
  23891. /**
  23892. * Dispose the texture and release its associated resources.
  23893. */
  23894. dispose(): void;
  23895. /**
  23896. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23897. * @param parsedTexture Define the JSON representation of the texture
  23898. * @param scene Define the scene the parsed texture should be instantiated in
  23899. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23900. * @returns The parsed texture if successful
  23901. */
  23902. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23903. /**
  23904. * Creates a texture from its base 64 representation.
  23905. * @param data Define the base64 payload without the data: prefix
  23906. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23907. * @param scene Define the scene the texture should belong to
  23908. * @param noMipmap Forces the texture to not create mip map information if true
  23909. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23910. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23911. * @param onLoad define a callback triggered when the texture has been loaded
  23912. * @param onError define a callback triggered when an error occurred during the loading session
  23913. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23914. * @returns the created texture
  23915. */
  23916. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23917. /**
  23918. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23919. * @param data Define the base64 payload without the data: prefix
  23920. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23921. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23922. * @param scene Define the scene the texture should belong to
  23923. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23924. * @param noMipmap Forces the texture to not create mip map information if true
  23925. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23926. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23927. * @param onLoad define a callback triggered when the texture has been loaded
  23928. * @param onError define a callback triggered when an error occurred during the loading session
  23929. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23930. * @returns the created texture
  23931. */
  23932. 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;
  23933. }
  23934. }
  23935. declare module "babylonjs/PostProcesses/postProcessManager" {
  23936. import { Nullable } from "babylonjs/types";
  23937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23938. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23939. import { Scene } from "babylonjs/scene";
  23940. /**
  23941. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23942. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23943. */
  23944. export class PostProcessManager {
  23945. private _scene;
  23946. private _indexBuffer;
  23947. private _vertexBuffers;
  23948. /**
  23949. * Creates a new instance PostProcess
  23950. * @param scene The scene that the post process is associated with.
  23951. */
  23952. constructor(scene: Scene);
  23953. private _prepareBuffers;
  23954. private _buildIndexBuffer;
  23955. /**
  23956. * Rebuilds the vertex buffers of the manager.
  23957. * @hidden
  23958. */
  23959. _rebuild(): void;
  23960. /**
  23961. * Prepares a frame to be run through a post process.
  23962. * @param sourceTexture The input texture to the post procesess. (default: null)
  23963. * @param postProcesses An array of post processes to be run. (default: null)
  23964. * @returns True if the post processes were able to be run.
  23965. * @hidden
  23966. */
  23967. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23968. /**
  23969. * Manually render a set of post processes to a texture.
  23970. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23971. * @param postProcesses An array of post processes to be run.
  23972. * @param targetTexture The target texture to render to.
  23973. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23974. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23975. * @param lodLevel defines which lod of the texture to render to
  23976. */
  23977. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23978. /**
  23979. * Finalize the result of the output of the postprocesses.
  23980. * @param doNotPresent If true the result will not be displayed to the screen.
  23981. * @param targetTexture The target texture to render to.
  23982. * @param faceIndex The index of the face to bind the target texture to.
  23983. * @param postProcesses The array of post processes to render.
  23984. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23985. * @hidden
  23986. */
  23987. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23988. /**
  23989. * Disposes of the post process manager.
  23990. */
  23991. dispose(): void;
  23992. }
  23993. }
  23994. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  23995. import { Observable } from "babylonjs/Misc/observable";
  23996. import { SmartArray } from "babylonjs/Misc/smartArray";
  23997. import { Nullable, Immutable } from "babylonjs/types";
  23998. import { Camera } from "babylonjs/Cameras/camera";
  23999. import { Scene } from "babylonjs/scene";
  24000. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24001. import { Color4 } from "babylonjs/Maths/math.color";
  24002. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24004. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24006. import { Texture } from "babylonjs/Materials/Textures/texture";
  24007. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24008. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24009. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24010. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24011. import { Engine } from "babylonjs/Engines/engine";
  24012. /**
  24013. * This Helps creating a texture that will be created from a camera in your scene.
  24014. * It is basically a dynamic texture that could be used to create special effects for instance.
  24015. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24016. */
  24017. export class RenderTargetTexture extends Texture {
  24018. isCube: boolean;
  24019. /**
  24020. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24021. */
  24022. static readonly REFRESHRATE_RENDER_ONCE: number;
  24023. /**
  24024. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24025. */
  24026. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24027. /**
  24028. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24029. * the central point of your effect and can save a lot of performances.
  24030. */
  24031. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24032. /**
  24033. * Use this predicate to dynamically define the list of mesh you want to render.
  24034. * If set, the renderList property will be overwritten.
  24035. */
  24036. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24037. private _renderList;
  24038. /**
  24039. * Use this list to define the list of mesh you want to render.
  24040. */
  24041. get renderList(): Nullable<Array<AbstractMesh>>;
  24042. set renderList(value: Nullable<Array<AbstractMesh>>);
  24043. /**
  24044. * Use this function to overload the renderList array at rendering time.
  24045. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24046. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24047. * the cube (if the RTT is a cube, else layerOrFace=0).
  24048. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24049. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24050. * hold dummy elements!
  24051. */
  24052. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24053. private _hookArray;
  24054. /**
  24055. * Define if particles should be rendered in your texture.
  24056. */
  24057. renderParticles: boolean;
  24058. /**
  24059. * Define if sprites should be rendered in your texture.
  24060. */
  24061. renderSprites: boolean;
  24062. /**
  24063. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24064. */
  24065. coordinatesMode: number;
  24066. /**
  24067. * Define the camera used to render the texture.
  24068. */
  24069. activeCamera: Nullable<Camera>;
  24070. /**
  24071. * Override the mesh isReady function with your own one.
  24072. */
  24073. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24074. /**
  24075. * Override the render function of the texture with your own one.
  24076. */
  24077. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24078. /**
  24079. * Define if camera post processes should be use while rendering the texture.
  24080. */
  24081. useCameraPostProcesses: boolean;
  24082. /**
  24083. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24084. */
  24085. ignoreCameraViewport: boolean;
  24086. private _postProcessManager;
  24087. private _postProcesses;
  24088. private _resizeObserver;
  24089. /**
  24090. * An event triggered when the texture is unbind.
  24091. */
  24092. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24093. /**
  24094. * An event triggered when the texture is unbind.
  24095. */
  24096. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24097. private _onAfterUnbindObserver;
  24098. /**
  24099. * Set a after unbind callback in the texture.
  24100. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24101. */
  24102. set onAfterUnbind(callback: () => void);
  24103. /**
  24104. * An event triggered before rendering the texture
  24105. */
  24106. onBeforeRenderObservable: Observable<number>;
  24107. private _onBeforeRenderObserver;
  24108. /**
  24109. * Set a before render callback in the texture.
  24110. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24111. */
  24112. set onBeforeRender(callback: (faceIndex: number) => void);
  24113. /**
  24114. * An event triggered after rendering the texture
  24115. */
  24116. onAfterRenderObservable: Observable<number>;
  24117. private _onAfterRenderObserver;
  24118. /**
  24119. * Set a after render callback in the texture.
  24120. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24121. */
  24122. set onAfterRender(callback: (faceIndex: number) => void);
  24123. /**
  24124. * An event triggered after the texture clear
  24125. */
  24126. onClearObservable: Observable<Engine>;
  24127. private _onClearObserver;
  24128. /**
  24129. * Set a clear callback in the texture.
  24130. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24131. */
  24132. set onClear(callback: (Engine: Engine) => void);
  24133. /**
  24134. * An event triggered when the texture is resized.
  24135. */
  24136. onResizeObservable: Observable<RenderTargetTexture>;
  24137. /**
  24138. * Define the clear color of the Render Target if it should be different from the scene.
  24139. */
  24140. clearColor: Color4;
  24141. protected _size: number | {
  24142. width: number;
  24143. height: number;
  24144. layers?: number;
  24145. };
  24146. protected _initialSizeParameter: number | {
  24147. width: number;
  24148. height: number;
  24149. } | {
  24150. ratio: number;
  24151. };
  24152. protected _sizeRatio: Nullable<number>;
  24153. /** @hidden */
  24154. _generateMipMaps: boolean;
  24155. protected _renderingManager: RenderingManager;
  24156. /** @hidden */
  24157. _waitingRenderList: string[];
  24158. protected _doNotChangeAspectRatio: boolean;
  24159. protected _currentRefreshId: number;
  24160. protected _refreshRate: number;
  24161. protected _textureMatrix: Matrix;
  24162. protected _samples: number;
  24163. protected _renderTargetOptions: RenderTargetCreationOptions;
  24164. /**
  24165. * Gets render target creation options that were used.
  24166. */
  24167. get renderTargetOptions(): RenderTargetCreationOptions;
  24168. protected _onRatioRescale(): void;
  24169. /**
  24170. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24171. * It must define where the camera used to render the texture is set
  24172. */
  24173. boundingBoxPosition: Vector3;
  24174. private _boundingBoxSize;
  24175. /**
  24176. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24177. * When defined, the cubemap will switch to local mode
  24178. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24179. * @example https://www.babylonjs-playground.com/#RNASML
  24180. */
  24181. set boundingBoxSize(value: Vector3);
  24182. get boundingBoxSize(): Vector3;
  24183. /**
  24184. * In case the RTT has been created with a depth texture, get the associated
  24185. * depth texture.
  24186. * Otherwise, return null.
  24187. */
  24188. get depthStencilTexture(): Nullable<InternalTexture>;
  24189. /**
  24190. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24191. * or used a shadow, depth texture...
  24192. * @param name The friendly name of the texture
  24193. * @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)
  24194. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24195. * @param generateMipMaps True if mip maps need to be generated after render.
  24196. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24197. * @param type The type of the buffer in the RTT (int, half float, float...)
  24198. * @param isCube True if a cube texture needs to be created
  24199. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24200. * @param generateDepthBuffer True to generate a depth buffer
  24201. * @param generateStencilBuffer True to generate a stencil buffer
  24202. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24203. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24204. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24205. */
  24206. constructor(name: string, size: number | {
  24207. width: number;
  24208. height: number;
  24209. layers?: number;
  24210. } | {
  24211. ratio: number;
  24212. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24213. /**
  24214. * Creates a depth stencil texture.
  24215. * This is only available in WebGL 2 or with the depth texture extension available.
  24216. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24217. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24218. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24219. */
  24220. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24221. private _processSizeParameter;
  24222. /**
  24223. * Define the number of samples to use in case of MSAA.
  24224. * It defaults to one meaning no MSAA has been enabled.
  24225. */
  24226. get samples(): number;
  24227. set samples(value: number);
  24228. /**
  24229. * Resets the refresh counter of the texture and start bak from scratch.
  24230. * Could be useful to regenerate the texture if it is setup to render only once.
  24231. */
  24232. resetRefreshCounter(): void;
  24233. /**
  24234. * Define the refresh rate of the texture or the rendering frequency.
  24235. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24236. */
  24237. get refreshRate(): number;
  24238. set refreshRate(value: number);
  24239. /**
  24240. * Adds a post process to the render target rendering passes.
  24241. * @param postProcess define the post process to add
  24242. */
  24243. addPostProcess(postProcess: PostProcess): void;
  24244. /**
  24245. * Clear all the post processes attached to the render target
  24246. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24247. */
  24248. clearPostProcesses(dispose?: boolean): void;
  24249. /**
  24250. * Remove one of the post process from the list of attached post processes to the texture
  24251. * @param postProcess define the post process to remove from the list
  24252. */
  24253. removePostProcess(postProcess: PostProcess): void;
  24254. /** @hidden */
  24255. _shouldRender(): boolean;
  24256. /**
  24257. * Gets the actual render size of the texture.
  24258. * @returns the width of the render size
  24259. */
  24260. getRenderSize(): number;
  24261. /**
  24262. * Gets the actual render width of the texture.
  24263. * @returns the width of the render size
  24264. */
  24265. getRenderWidth(): number;
  24266. /**
  24267. * Gets the actual render height of the texture.
  24268. * @returns the height of the render size
  24269. */
  24270. getRenderHeight(): number;
  24271. /**
  24272. * Gets the actual number of layers of the texture.
  24273. * @returns the number of layers
  24274. */
  24275. getRenderLayers(): number;
  24276. /**
  24277. * Get if the texture can be rescaled or not.
  24278. */
  24279. get canRescale(): boolean;
  24280. /**
  24281. * Resize the texture using a ratio.
  24282. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24283. */
  24284. scale(ratio: number): void;
  24285. /**
  24286. * Get the texture reflection matrix used to rotate/transform the reflection.
  24287. * @returns the reflection matrix
  24288. */
  24289. getReflectionTextureMatrix(): Matrix;
  24290. /**
  24291. * Resize the texture to a new desired size.
  24292. * Be carrefull as it will recreate all the data in the new texture.
  24293. * @param size Define the new size. It can be:
  24294. * - a number for squared texture,
  24295. * - an object containing { width: number, height: number }
  24296. * - or an object containing a ratio { ratio: number }
  24297. */
  24298. resize(size: number | {
  24299. width: number;
  24300. height: number;
  24301. } | {
  24302. ratio: number;
  24303. }): void;
  24304. private _defaultRenderListPrepared;
  24305. /**
  24306. * Renders all the objects from the render list into the texture.
  24307. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24308. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24309. */
  24310. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24311. private _bestReflectionRenderTargetDimension;
  24312. private _prepareRenderingManager;
  24313. /**
  24314. * @hidden
  24315. * @param faceIndex face index to bind to if this is a cubetexture
  24316. * @param layer defines the index of the texture to bind in the array
  24317. */
  24318. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24319. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24320. private renderToTarget;
  24321. /**
  24322. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24323. * This allowed control for front to back rendering or reversly depending of the special needs.
  24324. *
  24325. * @param renderingGroupId The rendering group id corresponding to its index
  24326. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24327. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24328. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24329. */
  24330. 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;
  24331. /**
  24332. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24333. *
  24334. * @param renderingGroupId The rendering group id corresponding to its index
  24335. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24336. */
  24337. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24338. /**
  24339. * Clones the texture.
  24340. * @returns the cloned texture
  24341. */
  24342. clone(): RenderTargetTexture;
  24343. /**
  24344. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24345. * @returns The JSON representation of the texture
  24346. */
  24347. serialize(): any;
  24348. /**
  24349. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24350. */
  24351. disposeFramebufferObjects(): void;
  24352. /**
  24353. * Dispose the texture and release its associated resources.
  24354. */
  24355. dispose(): void;
  24356. /** @hidden */
  24357. _rebuild(): void;
  24358. /**
  24359. * Clear the info related to rendering groups preventing retention point in material dispose.
  24360. */
  24361. freeRenderingGroups(): void;
  24362. /**
  24363. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24364. * @returns the view count
  24365. */
  24366. getViewCount(): number;
  24367. }
  24368. }
  24369. declare module "babylonjs/Misc/guid" {
  24370. /**
  24371. * Class used to manipulate GUIDs
  24372. */
  24373. export class GUID {
  24374. /**
  24375. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24376. * Be aware Math.random() could cause collisions, but:
  24377. * "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"
  24378. * @returns a pseudo random id
  24379. */
  24380. static RandomId(): string;
  24381. }
  24382. }
  24383. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24384. import { Nullable } from "babylonjs/types";
  24385. import { Scene } from "babylonjs/scene";
  24386. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24387. import { Material } from "babylonjs/Materials/material";
  24388. import { Effect } from "babylonjs/Materials/effect";
  24389. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24390. /**
  24391. * Options to be used when creating a shadow depth material
  24392. */
  24393. export interface IIOptionShadowDepthMaterial {
  24394. /** Variables in the vertex shader code that need to have their names remapped.
  24395. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24396. * "var_name" should be either: worldPos or vNormalW
  24397. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24398. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24399. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24400. */
  24401. remappedVariables?: string[];
  24402. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24403. standalone?: boolean;
  24404. }
  24405. /**
  24406. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24407. */
  24408. export class ShadowDepthWrapper {
  24409. private _scene;
  24410. private _options?;
  24411. private _baseMaterial;
  24412. private _onEffectCreatedObserver;
  24413. private _subMeshToEffect;
  24414. private _subMeshToDepthEffect;
  24415. private _meshes;
  24416. /** @hidden */
  24417. _matriceNames: any;
  24418. /** Gets the standalone status of the wrapper */
  24419. get standalone(): boolean;
  24420. /** Gets the base material the wrapper is built upon */
  24421. get baseMaterial(): Material;
  24422. /**
  24423. * Instantiate a new shadow depth wrapper.
  24424. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24425. * generate the shadow depth map. For more information, please refer to the documentation:
  24426. * https://doc.babylonjs.com/babylon101/shadows
  24427. * @param baseMaterial Material to wrap
  24428. * @param scene Define the scene the material belongs to
  24429. * @param options Options used to create the wrapper
  24430. */
  24431. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24432. /**
  24433. * Gets the effect to use to generate the depth map
  24434. * @param subMesh subMesh to get the effect for
  24435. * @param shadowGenerator shadow generator to get the effect for
  24436. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24437. */
  24438. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24439. /**
  24440. * Specifies that the submesh is ready to be used for depth rendering
  24441. * @param subMesh submesh to check
  24442. * @param defines the list of defines to take into account when checking the effect
  24443. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24444. * @param useInstances specifies that instances should be used
  24445. * @returns a boolean indicating that the submesh is ready or not
  24446. */
  24447. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24448. /**
  24449. * Disposes the resources
  24450. */
  24451. dispose(): void;
  24452. private _makeEffect;
  24453. }
  24454. }
  24455. declare module "babylonjs/Materials/material" {
  24456. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24457. import { SmartArray } from "babylonjs/Misc/smartArray";
  24458. import { Observable } from "babylonjs/Misc/observable";
  24459. import { Nullable } from "babylonjs/types";
  24460. import { Scene } from "babylonjs/scene";
  24461. import { Matrix } from "babylonjs/Maths/math.vector";
  24462. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  24463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24464. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24465. import { Effect } from "babylonjs/Materials/effect";
  24466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24467. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24468. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24469. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24470. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24471. import { Mesh } from "babylonjs/Meshes/mesh";
  24472. import { Animation } from "babylonjs/Animations/animation";
  24473. /**
  24474. * Options for compiling materials.
  24475. */
  24476. export interface IMaterialCompilationOptions {
  24477. /**
  24478. * Defines whether clip planes are enabled.
  24479. */
  24480. clipPlane: boolean;
  24481. /**
  24482. * Defines whether instances are enabled.
  24483. */
  24484. useInstances: boolean;
  24485. }
  24486. /**
  24487. * Options passed when calling customShaderNameResolve
  24488. */
  24489. export interface ICustomShaderNameResolveOptions {
  24490. /**
  24491. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  24492. */
  24493. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24494. }
  24495. /**
  24496. * Base class for the main features of a material in Babylon.js
  24497. */
  24498. export class Material implements IAnimatable {
  24499. /**
  24500. * Returns the triangle fill mode
  24501. */
  24502. static readonly TriangleFillMode: number;
  24503. /**
  24504. * Returns the wireframe mode
  24505. */
  24506. static readonly WireFrameFillMode: number;
  24507. /**
  24508. * Returns the point fill mode
  24509. */
  24510. static readonly PointFillMode: number;
  24511. /**
  24512. * Returns the point list draw mode
  24513. */
  24514. static readonly PointListDrawMode: number;
  24515. /**
  24516. * Returns the line list draw mode
  24517. */
  24518. static readonly LineListDrawMode: number;
  24519. /**
  24520. * Returns the line loop draw mode
  24521. */
  24522. static readonly LineLoopDrawMode: number;
  24523. /**
  24524. * Returns the line strip draw mode
  24525. */
  24526. static readonly LineStripDrawMode: number;
  24527. /**
  24528. * Returns the triangle strip draw mode
  24529. */
  24530. static readonly TriangleStripDrawMode: number;
  24531. /**
  24532. * Returns the triangle fan draw mode
  24533. */
  24534. static readonly TriangleFanDrawMode: number;
  24535. /**
  24536. * Stores the clock-wise side orientation
  24537. */
  24538. static readonly ClockWiseSideOrientation: number;
  24539. /**
  24540. * Stores the counter clock-wise side orientation
  24541. */
  24542. static readonly CounterClockWiseSideOrientation: number;
  24543. /**
  24544. * The dirty texture flag value
  24545. */
  24546. static readonly TextureDirtyFlag: number;
  24547. /**
  24548. * The dirty light flag value
  24549. */
  24550. static readonly LightDirtyFlag: number;
  24551. /**
  24552. * The dirty fresnel flag value
  24553. */
  24554. static readonly FresnelDirtyFlag: number;
  24555. /**
  24556. * The dirty attribute flag value
  24557. */
  24558. static readonly AttributesDirtyFlag: number;
  24559. /**
  24560. * The dirty misc flag value
  24561. */
  24562. static readonly MiscDirtyFlag: number;
  24563. /**
  24564. * The all dirty flag value
  24565. */
  24566. static readonly AllDirtyFlag: number;
  24567. /**
  24568. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24569. */
  24570. static readonly MATERIAL_OPAQUE: number;
  24571. /**
  24572. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24573. */
  24574. static readonly MATERIAL_ALPHATEST: number;
  24575. /**
  24576. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24577. */
  24578. static readonly MATERIAL_ALPHABLEND: number;
  24579. /**
  24580. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24581. * They are also discarded below the alpha cutoff threshold to improve performances.
  24582. */
  24583. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24584. /**
  24585. * Custom callback helping to override the default shader used in the material.
  24586. */
  24587. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24588. /**
  24589. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24590. */
  24591. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24592. /**
  24593. * The ID of the material
  24594. */
  24595. id: string;
  24596. /**
  24597. * Gets or sets the unique id of the material
  24598. */
  24599. uniqueId: number;
  24600. /**
  24601. * The name of the material
  24602. */
  24603. name: string;
  24604. /**
  24605. * Gets or sets user defined metadata
  24606. */
  24607. metadata: any;
  24608. /**
  24609. * For internal use only. Please do not use.
  24610. */
  24611. reservedDataStore: any;
  24612. /**
  24613. * Specifies if the ready state should be checked on each call
  24614. */
  24615. checkReadyOnEveryCall: boolean;
  24616. /**
  24617. * Specifies if the ready state should be checked once
  24618. */
  24619. checkReadyOnlyOnce: boolean;
  24620. /**
  24621. * The state of the material
  24622. */
  24623. state: string;
  24624. /**
  24625. * The alpha value of the material
  24626. */
  24627. protected _alpha: number;
  24628. /**
  24629. * List of inspectable custom properties (used by the Inspector)
  24630. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24631. */
  24632. inspectableCustomProperties: IInspectable[];
  24633. /**
  24634. * Sets the alpha value of the material
  24635. */
  24636. set alpha(value: number);
  24637. /**
  24638. * Gets the alpha value of the material
  24639. */
  24640. get alpha(): number;
  24641. /**
  24642. * Specifies if back face culling is enabled
  24643. */
  24644. protected _backFaceCulling: boolean;
  24645. /**
  24646. * Sets the back-face culling state
  24647. */
  24648. set backFaceCulling(value: boolean);
  24649. /**
  24650. * Gets the back-face culling state
  24651. */
  24652. get backFaceCulling(): boolean;
  24653. /**
  24654. * Stores the value for side orientation
  24655. */
  24656. sideOrientation: number;
  24657. /**
  24658. * Callback triggered when the material is compiled
  24659. */
  24660. onCompiled: Nullable<(effect: Effect) => void>;
  24661. /**
  24662. * Callback triggered when an error occurs
  24663. */
  24664. onError: Nullable<(effect: Effect, errors: string) => void>;
  24665. /**
  24666. * Callback triggered to get the render target textures
  24667. */
  24668. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24669. /**
  24670. * Gets a boolean indicating that current material needs to register RTT
  24671. */
  24672. get hasRenderTargetTextures(): boolean;
  24673. /**
  24674. * Specifies if the material should be serialized
  24675. */
  24676. doNotSerialize: boolean;
  24677. /**
  24678. * @hidden
  24679. */
  24680. _storeEffectOnSubMeshes: boolean;
  24681. /**
  24682. * Stores the animations for the material
  24683. */
  24684. animations: Nullable<Array<Animation>>;
  24685. /**
  24686. * An event triggered when the material is disposed
  24687. */
  24688. onDisposeObservable: Observable<Material>;
  24689. /**
  24690. * An observer which watches for dispose events
  24691. */
  24692. private _onDisposeObserver;
  24693. private _onUnBindObservable;
  24694. /**
  24695. * Called during a dispose event
  24696. */
  24697. set onDispose(callback: () => void);
  24698. private _onBindObservable;
  24699. /**
  24700. * An event triggered when the material is bound
  24701. */
  24702. get onBindObservable(): Observable<AbstractMesh>;
  24703. /**
  24704. * An observer which watches for bind events
  24705. */
  24706. private _onBindObserver;
  24707. /**
  24708. * Called during a bind event
  24709. */
  24710. set onBind(callback: (Mesh: AbstractMesh) => void);
  24711. /**
  24712. * An event triggered when the material is unbound
  24713. */
  24714. get onUnBindObservable(): Observable<Material>;
  24715. protected _onEffectCreatedObservable: Nullable<Observable<{
  24716. effect: Effect;
  24717. subMesh: Nullable<SubMesh>;
  24718. }>>;
  24719. /**
  24720. * An event triggered when the effect is (re)created
  24721. */
  24722. get onEffectCreatedObservable(): Observable<{
  24723. effect: Effect;
  24724. subMesh: Nullable<SubMesh>;
  24725. }>;
  24726. /**
  24727. * Stores the value of the alpha mode
  24728. */
  24729. private _alphaMode;
  24730. /**
  24731. * Sets the value of the alpha mode.
  24732. *
  24733. * | Value | Type | Description |
  24734. * | --- | --- | --- |
  24735. * | 0 | ALPHA_DISABLE | |
  24736. * | 1 | ALPHA_ADD | |
  24737. * | 2 | ALPHA_COMBINE | |
  24738. * | 3 | ALPHA_SUBTRACT | |
  24739. * | 4 | ALPHA_MULTIPLY | |
  24740. * | 5 | ALPHA_MAXIMIZED | |
  24741. * | 6 | ALPHA_ONEONE | |
  24742. * | 7 | ALPHA_PREMULTIPLIED | |
  24743. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24744. * | 9 | ALPHA_INTERPOLATE | |
  24745. * | 10 | ALPHA_SCREENMODE | |
  24746. *
  24747. */
  24748. set alphaMode(value: number);
  24749. /**
  24750. * Gets the value of the alpha mode
  24751. */
  24752. get alphaMode(): number;
  24753. /**
  24754. * Stores the state of the need depth pre-pass value
  24755. */
  24756. private _needDepthPrePass;
  24757. /**
  24758. * Sets the need depth pre-pass value
  24759. */
  24760. set needDepthPrePass(value: boolean);
  24761. /**
  24762. * Gets the depth pre-pass value
  24763. */
  24764. get needDepthPrePass(): boolean;
  24765. /**
  24766. * Specifies if depth writing should be disabled
  24767. */
  24768. disableDepthWrite: boolean;
  24769. /**
  24770. * Specifies if color writing should be disabled
  24771. */
  24772. disableColorWrite: boolean;
  24773. /**
  24774. * Specifies if depth writing should be forced
  24775. */
  24776. forceDepthWrite: boolean;
  24777. /**
  24778. * Specifies the depth function that should be used. 0 means the default engine function
  24779. */
  24780. depthFunction: number;
  24781. /**
  24782. * Specifies if there should be a separate pass for culling
  24783. */
  24784. separateCullingPass: boolean;
  24785. /**
  24786. * Stores the state specifing if fog should be enabled
  24787. */
  24788. private _fogEnabled;
  24789. /**
  24790. * Sets the state for enabling fog
  24791. */
  24792. set fogEnabled(value: boolean);
  24793. /**
  24794. * Gets the value of the fog enabled state
  24795. */
  24796. get fogEnabled(): boolean;
  24797. /**
  24798. * Stores the size of points
  24799. */
  24800. pointSize: number;
  24801. /**
  24802. * Stores the z offset value
  24803. */
  24804. zOffset: number;
  24805. get wireframe(): boolean;
  24806. /**
  24807. * Sets the state of wireframe mode
  24808. */
  24809. set wireframe(value: boolean);
  24810. /**
  24811. * Gets the value specifying if point clouds are enabled
  24812. */
  24813. get pointsCloud(): boolean;
  24814. /**
  24815. * Sets the state of point cloud mode
  24816. */
  24817. set pointsCloud(value: boolean);
  24818. /**
  24819. * Gets the material fill mode
  24820. */
  24821. get fillMode(): number;
  24822. /**
  24823. * Sets the material fill mode
  24824. */
  24825. set fillMode(value: number);
  24826. /**
  24827. * @hidden
  24828. * Stores the effects for the material
  24829. */
  24830. _effect: Nullable<Effect>;
  24831. /**
  24832. * Specifies if uniform buffers should be used
  24833. */
  24834. private _useUBO;
  24835. /**
  24836. * Stores a reference to the scene
  24837. */
  24838. private _scene;
  24839. /**
  24840. * Stores the fill mode state
  24841. */
  24842. private _fillMode;
  24843. /**
  24844. * Specifies if the depth write state should be cached
  24845. */
  24846. private _cachedDepthWriteState;
  24847. /**
  24848. * Specifies if the color write state should be cached
  24849. */
  24850. private _cachedColorWriteState;
  24851. /**
  24852. * Specifies if the depth function state should be cached
  24853. */
  24854. private _cachedDepthFunctionState;
  24855. /**
  24856. * Stores the uniform buffer
  24857. */
  24858. protected _uniformBuffer: UniformBuffer;
  24859. /** @hidden */
  24860. _indexInSceneMaterialArray: number;
  24861. /** @hidden */
  24862. meshMap: Nullable<{
  24863. [id: string]: AbstractMesh | undefined;
  24864. }>;
  24865. /**
  24866. * Creates a material instance
  24867. * @param name defines the name of the material
  24868. * @param scene defines the scene to reference
  24869. * @param doNotAdd specifies if the material should be added to the scene
  24870. */
  24871. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24872. /**
  24873. * Returns a string representation of the current material
  24874. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24875. * @returns a string with material information
  24876. */
  24877. toString(fullDetails?: boolean): string;
  24878. /**
  24879. * Gets the class name of the material
  24880. * @returns a string with the class name of the material
  24881. */
  24882. getClassName(): string;
  24883. /**
  24884. * Specifies if updates for the material been locked
  24885. */
  24886. get isFrozen(): boolean;
  24887. /**
  24888. * Locks updates for the material
  24889. */
  24890. freeze(): void;
  24891. /**
  24892. * Unlocks updates for the material
  24893. */
  24894. unfreeze(): void;
  24895. /**
  24896. * Specifies if the material is ready to be used
  24897. * @param mesh defines the mesh to check
  24898. * @param useInstances specifies if instances should be used
  24899. * @returns a boolean indicating if the material is ready to be used
  24900. */
  24901. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24902. /**
  24903. * Specifies that the submesh is ready to be used
  24904. * @param mesh defines the mesh to check
  24905. * @param subMesh defines which submesh to check
  24906. * @param useInstances specifies that instances should be used
  24907. * @returns a boolean indicating that the submesh is ready or not
  24908. */
  24909. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24910. /**
  24911. * Returns the material effect
  24912. * @returns the effect associated with the material
  24913. */
  24914. getEffect(): Nullable<Effect>;
  24915. /**
  24916. * Returns the current scene
  24917. * @returns a Scene
  24918. */
  24919. getScene(): Scene;
  24920. /**
  24921. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24922. */
  24923. protected _forceAlphaTest: boolean;
  24924. /**
  24925. * The transparency mode of the material.
  24926. */
  24927. protected _transparencyMode: Nullable<number>;
  24928. /**
  24929. * Gets the current transparency mode.
  24930. */
  24931. get transparencyMode(): Nullable<number>;
  24932. /**
  24933. * Sets the transparency mode of the material.
  24934. *
  24935. * | Value | Type | Description |
  24936. * | ----- | ----------------------------------- | ----------- |
  24937. * | 0 | OPAQUE | |
  24938. * | 1 | ALPHATEST | |
  24939. * | 2 | ALPHABLEND | |
  24940. * | 3 | ALPHATESTANDBLEND | |
  24941. *
  24942. */
  24943. set transparencyMode(value: Nullable<number>);
  24944. /**
  24945. * Returns true if alpha blending should be disabled.
  24946. */
  24947. protected get _disableAlphaBlending(): boolean;
  24948. /**
  24949. * Specifies whether or not this material should be rendered in alpha blend mode.
  24950. * @returns a boolean specifying if alpha blending is needed
  24951. */
  24952. needAlphaBlending(): boolean;
  24953. /**
  24954. * Specifies if the mesh will require alpha blending
  24955. * @param mesh defines the mesh to check
  24956. * @returns a boolean specifying if alpha blending is needed for the mesh
  24957. */
  24958. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24959. /**
  24960. * Specifies whether or not this material should be rendered in alpha test mode.
  24961. * @returns a boolean specifying if an alpha test is needed.
  24962. */
  24963. needAlphaTesting(): boolean;
  24964. /**
  24965. * Specifies if material alpha testing should be turned on for the mesh
  24966. * @param mesh defines the mesh to check
  24967. */
  24968. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24969. /**
  24970. * Gets the texture used for the alpha test
  24971. * @returns the texture to use for alpha testing
  24972. */
  24973. getAlphaTestTexture(): Nullable<BaseTexture>;
  24974. /**
  24975. * Marks the material to indicate that it needs to be re-calculated
  24976. */
  24977. markDirty(): void;
  24978. /** @hidden */
  24979. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24980. /**
  24981. * Binds the material to the mesh
  24982. * @param world defines the world transformation matrix
  24983. * @param mesh defines the mesh to bind the material to
  24984. */
  24985. bind(world: Matrix, mesh?: Mesh): void;
  24986. /**
  24987. * Binds the submesh to the material
  24988. * @param world defines the world transformation matrix
  24989. * @param mesh defines the mesh containing the submesh
  24990. * @param subMesh defines the submesh to bind the material to
  24991. */
  24992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24993. /**
  24994. * Binds the world matrix to the material
  24995. * @param world defines the world transformation matrix
  24996. */
  24997. bindOnlyWorldMatrix(world: Matrix): void;
  24998. /**
  24999. * Binds the scene's uniform buffer to the effect.
  25000. * @param effect defines the effect to bind to the scene uniform buffer
  25001. * @param sceneUbo defines the uniform buffer storing scene data
  25002. */
  25003. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25004. /**
  25005. * Binds the view matrix to the effect
  25006. * @param effect defines the effect to bind the view matrix to
  25007. */
  25008. bindView(effect: Effect): void;
  25009. /**
  25010. * Binds the view projection matrix to the effect
  25011. * @param effect defines the effect to bind the view projection matrix to
  25012. */
  25013. bindViewProjection(effect: Effect): void;
  25014. /**
  25015. * Processes to execute after binding the material to a mesh
  25016. * @param mesh defines the rendered mesh
  25017. */
  25018. protected _afterBind(mesh?: Mesh): void;
  25019. /**
  25020. * Unbinds the material from the mesh
  25021. */
  25022. unbind(): void;
  25023. /**
  25024. * Gets the active textures from the material
  25025. * @returns an array of textures
  25026. */
  25027. getActiveTextures(): BaseTexture[];
  25028. /**
  25029. * Specifies if the material uses a texture
  25030. * @param texture defines the texture to check against the material
  25031. * @returns a boolean specifying if the material uses the texture
  25032. */
  25033. hasTexture(texture: BaseTexture): boolean;
  25034. /**
  25035. * Makes a duplicate of the material, and gives it a new name
  25036. * @param name defines the new name for the duplicated material
  25037. * @returns the cloned material
  25038. */
  25039. clone(name: string): Nullable<Material>;
  25040. /**
  25041. * Gets the meshes bound to the material
  25042. * @returns an array of meshes bound to the material
  25043. */
  25044. getBindedMeshes(): AbstractMesh[];
  25045. /**
  25046. * Force shader compilation
  25047. * @param mesh defines the mesh associated with this material
  25048. * @param onCompiled defines a function to execute once the material is compiled
  25049. * @param options defines the options to configure the compilation
  25050. * @param onError defines a function to execute if the material fails compiling
  25051. */
  25052. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25053. /**
  25054. * Force shader compilation
  25055. * @param mesh defines the mesh that will use this material
  25056. * @param options defines additional options for compiling the shaders
  25057. * @returns a promise that resolves when the compilation completes
  25058. */
  25059. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25060. private static readonly _AllDirtyCallBack;
  25061. private static readonly _ImageProcessingDirtyCallBack;
  25062. private static readonly _TextureDirtyCallBack;
  25063. private static readonly _FresnelDirtyCallBack;
  25064. private static readonly _MiscDirtyCallBack;
  25065. private static readonly _LightsDirtyCallBack;
  25066. private static readonly _AttributeDirtyCallBack;
  25067. private static _FresnelAndMiscDirtyCallBack;
  25068. private static _TextureAndMiscDirtyCallBack;
  25069. private static readonly _DirtyCallbackArray;
  25070. private static readonly _RunDirtyCallBacks;
  25071. /**
  25072. * Marks a define in the material to indicate that it needs to be re-computed
  25073. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25074. */
  25075. markAsDirty(flag: number): void;
  25076. /**
  25077. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25078. * @param func defines a function which checks material defines against the submeshes
  25079. */
  25080. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25081. /**
  25082. * Indicates that we need to re-calculated for all submeshes
  25083. */
  25084. protected _markAllSubMeshesAsAllDirty(): void;
  25085. /**
  25086. * Indicates that image processing needs to be re-calculated for all submeshes
  25087. */
  25088. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25089. /**
  25090. * Indicates that textures need to be re-calculated for all submeshes
  25091. */
  25092. protected _markAllSubMeshesAsTexturesDirty(): void;
  25093. /**
  25094. * Indicates that fresnel needs to be re-calculated for all submeshes
  25095. */
  25096. protected _markAllSubMeshesAsFresnelDirty(): void;
  25097. /**
  25098. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25099. */
  25100. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25101. /**
  25102. * Indicates that lights need to be re-calculated for all submeshes
  25103. */
  25104. protected _markAllSubMeshesAsLightsDirty(): void;
  25105. /**
  25106. * Indicates that attributes need to be re-calculated for all submeshes
  25107. */
  25108. protected _markAllSubMeshesAsAttributesDirty(): void;
  25109. /**
  25110. * Indicates that misc needs to be re-calculated for all submeshes
  25111. */
  25112. protected _markAllSubMeshesAsMiscDirty(): void;
  25113. /**
  25114. * Indicates that textures and misc need to be re-calculated for all submeshes
  25115. */
  25116. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25117. /**
  25118. * Disposes the material
  25119. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25120. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25121. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25122. */
  25123. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25124. /** @hidden */
  25125. private releaseVertexArrayObject;
  25126. /**
  25127. * Serializes this material
  25128. * @returns the serialized material object
  25129. */
  25130. serialize(): any;
  25131. /**
  25132. * Creates a material from parsed material data
  25133. * @param parsedMaterial defines parsed material data
  25134. * @param scene defines the hosting scene
  25135. * @param rootUrl defines the root URL to use to load textures
  25136. * @returns a new material
  25137. */
  25138. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25139. }
  25140. }
  25141. declare module "babylonjs/Materials/multiMaterial" {
  25142. import { Nullable } from "babylonjs/types";
  25143. import { Scene } from "babylonjs/scene";
  25144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25145. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  25146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25147. import { Material } from "babylonjs/Materials/material";
  25148. /**
  25149. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25150. * separate meshes. This can be use to improve performances.
  25151. * @see http://doc.babylonjs.com/how_to/multi_materials
  25152. */
  25153. export class MultiMaterial extends Material {
  25154. private _subMaterials;
  25155. /**
  25156. * Gets or Sets the list of Materials used within the multi material.
  25157. * They need to be ordered according to the submeshes order in the associated mesh
  25158. */
  25159. get subMaterials(): Nullable<Material>[];
  25160. set subMaterials(value: Nullable<Material>[]);
  25161. /**
  25162. * Function used to align with Node.getChildren()
  25163. * @returns the list of Materials used within the multi material
  25164. */
  25165. getChildren(): Nullable<Material>[];
  25166. /**
  25167. * Instantiates a new Multi Material
  25168. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25169. * separate meshes. This can be use to improve performances.
  25170. * @see http://doc.babylonjs.com/how_to/multi_materials
  25171. * @param name Define the name in the scene
  25172. * @param scene Define the scene the material belongs to
  25173. */
  25174. constructor(name: string, scene: Scene);
  25175. private _hookArray;
  25176. /**
  25177. * Get one of the submaterial by its index in the submaterials array
  25178. * @param index The index to look the sub material at
  25179. * @returns The Material if the index has been defined
  25180. */
  25181. getSubMaterial(index: number): Nullable<Material>;
  25182. /**
  25183. * Get the list of active textures for the whole sub materials list.
  25184. * @returns All the textures that will be used during the rendering
  25185. */
  25186. getActiveTextures(): BaseTexture[];
  25187. /**
  25188. * Gets the current class name of the material e.g. "MultiMaterial"
  25189. * Mainly use in serialization.
  25190. * @returns the class name
  25191. */
  25192. getClassName(): string;
  25193. /**
  25194. * Checks if the material is ready to render the requested sub mesh
  25195. * @param mesh Define the mesh the submesh belongs to
  25196. * @param subMesh Define the sub mesh to look readyness for
  25197. * @param useInstances Define whether or not the material is used with instances
  25198. * @returns true if ready, otherwise false
  25199. */
  25200. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  25201. /**
  25202. * Clones the current material and its related sub materials
  25203. * @param name Define the name of the newly cloned material
  25204. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25205. * @returns the cloned material
  25206. */
  25207. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25208. /**
  25209. * Serializes the materials into a JSON representation.
  25210. * @returns the JSON representation
  25211. */
  25212. serialize(): any;
  25213. /**
  25214. * Dispose the material and release its associated resources
  25215. * @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)
  25216. * @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)
  25217. * @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)
  25218. */
  25219. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25220. /**
  25221. * Creates a MultiMaterial from parsed MultiMaterial data.
  25222. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25223. * @param scene defines the hosting scene
  25224. * @returns a new MultiMaterial
  25225. */
  25226. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25227. }
  25228. }
  25229. declare module "babylonjs/Meshes/subMesh" {
  25230. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25231. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25232. import { Engine } from "babylonjs/Engines/engine";
  25233. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25234. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25235. import { Effect } from "babylonjs/Materials/effect";
  25236. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25237. import { Plane } from "babylonjs/Maths/math.plane";
  25238. import { Collider } from "babylonjs/Collisions/collider";
  25239. import { Material } from "babylonjs/Materials/material";
  25240. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25242. import { Mesh } from "babylonjs/Meshes/mesh";
  25243. import { Ray } from "babylonjs/Culling/ray";
  25244. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25245. /**
  25246. * Base class for submeshes
  25247. */
  25248. export class BaseSubMesh {
  25249. /** @hidden */
  25250. _materialDefines: Nullable<MaterialDefines>;
  25251. /** @hidden */
  25252. _materialEffect: Nullable<Effect>;
  25253. /** @hidden */
  25254. _effectOverride: Nullable<Effect>;
  25255. /**
  25256. * Gets material defines used by the effect associated to the sub mesh
  25257. */
  25258. get materialDefines(): Nullable<MaterialDefines>;
  25259. /**
  25260. * Sets material defines used by the effect associated to the sub mesh
  25261. */
  25262. set materialDefines(defines: Nullable<MaterialDefines>);
  25263. /**
  25264. * Gets associated effect
  25265. */
  25266. get effect(): Nullable<Effect>;
  25267. /**
  25268. * Sets associated effect (effect used to render this submesh)
  25269. * @param effect defines the effect to associate with
  25270. * @param defines defines the set of defines used to compile this effect
  25271. */
  25272. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25273. }
  25274. /**
  25275. * Defines a subdivision inside a mesh
  25276. */
  25277. export class SubMesh extends BaseSubMesh implements ICullable {
  25278. /** the material index to use */
  25279. materialIndex: number;
  25280. /** vertex index start */
  25281. verticesStart: number;
  25282. /** vertices count */
  25283. verticesCount: number;
  25284. /** index start */
  25285. indexStart: number;
  25286. /** indices count */
  25287. indexCount: number;
  25288. /** @hidden */
  25289. _linesIndexCount: number;
  25290. private _mesh;
  25291. private _renderingMesh;
  25292. private _boundingInfo;
  25293. private _linesIndexBuffer;
  25294. /** @hidden */
  25295. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25296. /** @hidden */
  25297. _trianglePlanes: Plane[];
  25298. /** @hidden */
  25299. _lastColliderTransformMatrix: Nullable<Matrix>;
  25300. /** @hidden */
  25301. _renderId: number;
  25302. /** @hidden */
  25303. _alphaIndex: number;
  25304. /** @hidden */
  25305. _distanceToCamera: number;
  25306. /** @hidden */
  25307. _id: number;
  25308. private _currentMaterial;
  25309. /**
  25310. * Add a new submesh to a mesh
  25311. * @param materialIndex defines the material index to use
  25312. * @param verticesStart defines vertex index start
  25313. * @param verticesCount defines vertices count
  25314. * @param indexStart defines index start
  25315. * @param indexCount defines indices count
  25316. * @param mesh defines the parent mesh
  25317. * @param renderingMesh defines an optional rendering mesh
  25318. * @param createBoundingBox defines if bounding box should be created for this submesh
  25319. * @returns the new submesh
  25320. */
  25321. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25322. /**
  25323. * Creates a new submesh
  25324. * @param materialIndex defines the material index to use
  25325. * @param verticesStart defines vertex index start
  25326. * @param verticesCount defines vertices count
  25327. * @param indexStart defines index start
  25328. * @param indexCount defines indices count
  25329. * @param mesh defines the parent mesh
  25330. * @param renderingMesh defines an optional rendering mesh
  25331. * @param createBoundingBox defines if bounding box should be created for this submesh
  25332. */
  25333. constructor(
  25334. /** the material index to use */
  25335. materialIndex: number,
  25336. /** vertex index start */
  25337. verticesStart: number,
  25338. /** vertices count */
  25339. verticesCount: number,
  25340. /** index start */
  25341. indexStart: number,
  25342. /** indices count */
  25343. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  25344. /**
  25345. * Returns true if this submesh covers the entire parent mesh
  25346. * @ignorenaming
  25347. */
  25348. get IsGlobal(): boolean;
  25349. /**
  25350. * Returns the submesh BoudingInfo object
  25351. * @returns current bounding info (or mesh's one if the submesh is global)
  25352. */
  25353. getBoundingInfo(): BoundingInfo;
  25354. /**
  25355. * Sets the submesh BoundingInfo
  25356. * @param boundingInfo defines the new bounding info to use
  25357. * @returns the SubMesh
  25358. */
  25359. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25360. /**
  25361. * Returns the mesh of the current submesh
  25362. * @return the parent mesh
  25363. */
  25364. getMesh(): AbstractMesh;
  25365. /**
  25366. * Returns the rendering mesh of the submesh
  25367. * @returns the rendering mesh (could be different from parent mesh)
  25368. */
  25369. getRenderingMesh(): Mesh;
  25370. /**
  25371. * Returns the replacement mesh of the submesh
  25372. * @returns the replacement mesh (could be different from parent mesh)
  25373. */
  25374. getReplacementMesh(): Nullable<AbstractMesh>;
  25375. /**
  25376. * Returns the effective mesh of the submesh
  25377. * @returns the effective mesh (could be different from parent mesh)
  25378. */
  25379. getEffectiveMesh(): AbstractMesh;
  25380. /**
  25381. * Returns the submesh material
  25382. * @returns null or the current material
  25383. */
  25384. getMaterial(): Nullable<Material>;
  25385. /**
  25386. * Sets a new updated BoundingInfo object to the submesh
  25387. * @param data defines an optional position array to use to determine the bounding info
  25388. * @returns the SubMesh
  25389. */
  25390. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25391. /** @hidden */
  25392. _checkCollision(collider: Collider): boolean;
  25393. /**
  25394. * Updates the submesh BoundingInfo
  25395. * @param world defines the world matrix to use to update the bounding info
  25396. * @returns the submesh
  25397. */
  25398. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25399. /**
  25400. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25401. * @param frustumPlanes defines the frustum planes
  25402. * @returns true if the submesh is intersecting with the frustum
  25403. */
  25404. isInFrustum(frustumPlanes: Plane[]): boolean;
  25405. /**
  25406. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25407. * @param frustumPlanes defines the frustum planes
  25408. * @returns true if the submesh is inside the frustum
  25409. */
  25410. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25411. /**
  25412. * Renders the submesh
  25413. * @param enableAlphaMode defines if alpha needs to be used
  25414. * @returns the submesh
  25415. */
  25416. render(enableAlphaMode: boolean): SubMesh;
  25417. /**
  25418. * @hidden
  25419. */
  25420. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25421. /**
  25422. * Checks if the submesh intersects with a ray
  25423. * @param ray defines the ray to test
  25424. * @returns true is the passed ray intersects the submesh bounding box
  25425. */
  25426. canIntersects(ray: Ray): boolean;
  25427. /**
  25428. * Intersects current submesh with a ray
  25429. * @param ray defines the ray to test
  25430. * @param positions defines mesh's positions array
  25431. * @param indices defines mesh's indices array
  25432. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25433. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25434. * @returns intersection info or null if no intersection
  25435. */
  25436. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25437. /** @hidden */
  25438. private _intersectLines;
  25439. /** @hidden */
  25440. private _intersectUnIndexedLines;
  25441. /** @hidden */
  25442. private _intersectTriangles;
  25443. /** @hidden */
  25444. private _intersectUnIndexedTriangles;
  25445. /** @hidden */
  25446. _rebuild(): void;
  25447. /**
  25448. * Creates a new submesh from the passed mesh
  25449. * @param newMesh defines the new hosting mesh
  25450. * @param newRenderingMesh defines an optional rendering mesh
  25451. * @returns the new submesh
  25452. */
  25453. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25454. /**
  25455. * Release associated resources
  25456. */
  25457. dispose(): void;
  25458. /**
  25459. * Gets the class name
  25460. * @returns the string "SubMesh".
  25461. */
  25462. getClassName(): string;
  25463. /**
  25464. * Creates a new submesh from indices data
  25465. * @param materialIndex the index of the main mesh material
  25466. * @param startIndex the index where to start the copy in the mesh indices array
  25467. * @param indexCount the number of indices to copy then from the startIndex
  25468. * @param mesh the main mesh to create the submesh from
  25469. * @param renderingMesh the optional rendering mesh
  25470. * @returns a new submesh
  25471. */
  25472. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25473. }
  25474. }
  25475. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25476. /**
  25477. * Class used to represent data loading progression
  25478. */
  25479. export class SceneLoaderFlags {
  25480. private static _ForceFullSceneLoadingForIncremental;
  25481. private static _ShowLoadingScreen;
  25482. private static _CleanBoneMatrixWeights;
  25483. private static _loggingLevel;
  25484. /**
  25485. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25486. */
  25487. static get ForceFullSceneLoadingForIncremental(): boolean;
  25488. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25489. /**
  25490. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25491. */
  25492. static get ShowLoadingScreen(): boolean;
  25493. static set ShowLoadingScreen(value: boolean);
  25494. /**
  25495. * Defines the current logging level (while loading the scene)
  25496. * @ignorenaming
  25497. */
  25498. static get loggingLevel(): number;
  25499. static set loggingLevel(value: number);
  25500. /**
  25501. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25502. */
  25503. static get CleanBoneMatrixWeights(): boolean;
  25504. static set CleanBoneMatrixWeights(value: boolean);
  25505. }
  25506. }
  25507. declare module "babylonjs/Meshes/geometry" {
  25508. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25509. import { Scene } from "babylonjs/scene";
  25510. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25511. import { Engine } from "babylonjs/Engines/engine";
  25512. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25513. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25514. import { Effect } from "babylonjs/Materials/effect";
  25515. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25516. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25517. import { Mesh } from "babylonjs/Meshes/mesh";
  25518. /**
  25519. * Class used to store geometry data (vertex buffers + index buffer)
  25520. */
  25521. export class Geometry implements IGetSetVerticesData {
  25522. /**
  25523. * Gets or sets the ID of the geometry
  25524. */
  25525. id: string;
  25526. /**
  25527. * Gets or sets the unique ID of the geometry
  25528. */
  25529. uniqueId: number;
  25530. /**
  25531. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25532. */
  25533. delayLoadState: number;
  25534. /**
  25535. * Gets the file containing the data to load when running in delay load state
  25536. */
  25537. delayLoadingFile: Nullable<string>;
  25538. /**
  25539. * Callback called when the geometry is updated
  25540. */
  25541. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25542. private _scene;
  25543. private _engine;
  25544. private _meshes;
  25545. private _totalVertices;
  25546. /** @hidden */
  25547. _indices: IndicesArray;
  25548. /** @hidden */
  25549. _vertexBuffers: {
  25550. [key: string]: VertexBuffer;
  25551. };
  25552. private _isDisposed;
  25553. private _extend;
  25554. private _boundingBias;
  25555. /** @hidden */
  25556. _delayInfo: Array<string>;
  25557. private _indexBuffer;
  25558. private _indexBufferIsUpdatable;
  25559. /** @hidden */
  25560. _boundingInfo: Nullable<BoundingInfo>;
  25561. /** @hidden */
  25562. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25563. /** @hidden */
  25564. _softwareSkinningFrameId: number;
  25565. private _vertexArrayObjects;
  25566. private _updatable;
  25567. /** @hidden */
  25568. _positions: Nullable<Vector3[]>;
  25569. /**
  25570. * 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
  25571. */
  25572. get boundingBias(): Vector2;
  25573. /**
  25574. * 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
  25575. */
  25576. set boundingBias(value: Vector2);
  25577. /**
  25578. * Static function used to attach a new empty geometry to a mesh
  25579. * @param mesh defines the mesh to attach the geometry to
  25580. * @returns the new Geometry
  25581. */
  25582. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25583. /** Get the list of meshes using this geometry */
  25584. get meshes(): Mesh[];
  25585. /**
  25586. * Creates a new geometry
  25587. * @param id defines the unique ID
  25588. * @param scene defines the hosting scene
  25589. * @param vertexData defines the VertexData used to get geometry data
  25590. * @param updatable defines if geometry must be updatable (false by default)
  25591. * @param mesh defines the mesh that will be associated with the geometry
  25592. */
  25593. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25594. /**
  25595. * Gets the current extend of the geometry
  25596. */
  25597. get extend(): {
  25598. minimum: Vector3;
  25599. maximum: Vector3;
  25600. };
  25601. /**
  25602. * Gets the hosting scene
  25603. * @returns the hosting Scene
  25604. */
  25605. getScene(): Scene;
  25606. /**
  25607. * Gets the hosting engine
  25608. * @returns the hosting Engine
  25609. */
  25610. getEngine(): Engine;
  25611. /**
  25612. * Defines if the geometry is ready to use
  25613. * @returns true if the geometry is ready to be used
  25614. */
  25615. isReady(): boolean;
  25616. /**
  25617. * Gets a value indicating that the geometry should not be serialized
  25618. */
  25619. get doNotSerialize(): boolean;
  25620. /** @hidden */
  25621. _rebuild(): void;
  25622. /**
  25623. * Affects all geometry data in one call
  25624. * @param vertexData defines the geometry data
  25625. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25626. */
  25627. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25628. /**
  25629. * Set specific vertex data
  25630. * @param kind defines the data kind (Position, normal, etc...)
  25631. * @param data defines the vertex data to use
  25632. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25633. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25634. */
  25635. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25636. /**
  25637. * Removes a specific vertex data
  25638. * @param kind defines the data kind (Position, normal, etc...)
  25639. */
  25640. removeVerticesData(kind: string): void;
  25641. /**
  25642. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25643. * @param buffer defines the vertex buffer to use
  25644. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25645. */
  25646. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25647. /**
  25648. * Update a specific vertex buffer
  25649. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25650. * It will do nothing if the buffer is not updatable
  25651. * @param kind defines the data kind (Position, normal, etc...)
  25652. * @param data defines the data to use
  25653. * @param offset defines the offset in the target buffer where to store the data
  25654. * @param useBytes set to true if the offset is in bytes
  25655. */
  25656. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25657. /**
  25658. * Update a specific vertex buffer
  25659. * This function will create a new buffer if the current one is not updatable
  25660. * @param kind defines the data kind (Position, normal, etc...)
  25661. * @param data defines the data to use
  25662. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25663. */
  25664. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25665. private _updateBoundingInfo;
  25666. /** @hidden */
  25667. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25668. /**
  25669. * Gets total number of vertices
  25670. * @returns the total number of vertices
  25671. */
  25672. getTotalVertices(): number;
  25673. /**
  25674. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25675. * @param kind defines the data kind (Position, normal, etc...)
  25676. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25677. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25678. * @returns a float array containing vertex data
  25679. */
  25680. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25681. /**
  25682. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25683. * @param kind defines the data kind (Position, normal, etc...)
  25684. * @returns true if the vertex buffer with the specified kind is updatable
  25685. */
  25686. isVertexBufferUpdatable(kind: string): boolean;
  25687. /**
  25688. * Gets a specific vertex buffer
  25689. * @param kind defines the data kind (Position, normal, etc...)
  25690. * @returns a VertexBuffer
  25691. */
  25692. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25693. /**
  25694. * Returns all vertex buffers
  25695. * @return an object holding all vertex buffers indexed by kind
  25696. */
  25697. getVertexBuffers(): Nullable<{
  25698. [key: string]: VertexBuffer;
  25699. }>;
  25700. /**
  25701. * Gets a boolean indicating if specific vertex buffer is present
  25702. * @param kind defines the data kind (Position, normal, etc...)
  25703. * @returns true if data is present
  25704. */
  25705. isVerticesDataPresent(kind: string): boolean;
  25706. /**
  25707. * Gets a list of all attached data kinds (Position, normal, etc...)
  25708. * @returns a list of string containing all kinds
  25709. */
  25710. getVerticesDataKinds(): string[];
  25711. /**
  25712. * Update index buffer
  25713. * @param indices defines the indices to store in the index buffer
  25714. * @param offset defines the offset in the target buffer where to store the data
  25715. * @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)
  25716. */
  25717. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25718. /**
  25719. * Creates a new index buffer
  25720. * @param indices defines the indices to store in the index buffer
  25721. * @param totalVertices defines the total number of vertices (could be null)
  25722. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25723. */
  25724. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25725. /**
  25726. * Return the total number of indices
  25727. * @returns the total number of indices
  25728. */
  25729. getTotalIndices(): number;
  25730. /**
  25731. * Gets the index buffer array
  25732. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25733. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25734. * @returns the index buffer array
  25735. */
  25736. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25737. /**
  25738. * Gets the index buffer
  25739. * @return the index buffer
  25740. */
  25741. getIndexBuffer(): Nullable<DataBuffer>;
  25742. /** @hidden */
  25743. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25744. /**
  25745. * Release the associated resources for a specific mesh
  25746. * @param mesh defines the source mesh
  25747. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25748. */
  25749. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25750. /**
  25751. * Apply current geometry to a given mesh
  25752. * @param mesh defines the mesh to apply geometry to
  25753. */
  25754. applyToMesh(mesh: Mesh): void;
  25755. private _updateExtend;
  25756. private _applyToMesh;
  25757. private notifyUpdate;
  25758. /**
  25759. * Load the geometry if it was flagged as delay loaded
  25760. * @param scene defines the hosting scene
  25761. * @param onLoaded defines a callback called when the geometry is loaded
  25762. */
  25763. load(scene: Scene, onLoaded?: () => void): void;
  25764. private _queueLoad;
  25765. /**
  25766. * Invert the geometry to move from a right handed system to a left handed one.
  25767. */
  25768. toLeftHanded(): void;
  25769. /** @hidden */
  25770. _resetPointsArrayCache(): void;
  25771. /** @hidden */
  25772. _generatePointsArray(): boolean;
  25773. /**
  25774. * Gets a value indicating if the geometry is disposed
  25775. * @returns true if the geometry was disposed
  25776. */
  25777. isDisposed(): boolean;
  25778. private _disposeVertexArrayObjects;
  25779. /**
  25780. * Free all associated resources
  25781. */
  25782. dispose(): void;
  25783. /**
  25784. * Clone the current geometry into a new geometry
  25785. * @param id defines the unique ID of the new geometry
  25786. * @returns a new geometry object
  25787. */
  25788. copy(id: string): Geometry;
  25789. /**
  25790. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25791. * @return a JSON representation of the current geometry data (without the vertices data)
  25792. */
  25793. serialize(): any;
  25794. private toNumberArray;
  25795. /**
  25796. * Serialize all vertices data into a JSON oject
  25797. * @returns a JSON representation of the current geometry data
  25798. */
  25799. serializeVerticeData(): any;
  25800. /**
  25801. * Extracts a clone of a mesh geometry
  25802. * @param mesh defines the source mesh
  25803. * @param id defines the unique ID of the new geometry object
  25804. * @returns the new geometry object
  25805. */
  25806. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25807. /**
  25808. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25809. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25810. * Be aware Math.random() could cause collisions, but:
  25811. * "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"
  25812. * @returns a string containing a new GUID
  25813. */
  25814. static RandomId(): string;
  25815. /** @hidden */
  25816. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25817. private static _CleanMatricesWeights;
  25818. /**
  25819. * Create a new geometry from persisted data (Using .babylon file format)
  25820. * @param parsedVertexData defines the persisted data
  25821. * @param scene defines the hosting scene
  25822. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25823. * @returns the new geometry object
  25824. */
  25825. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25826. }
  25827. }
  25828. declare module "babylonjs/Meshes/mesh.vertexData" {
  25829. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25830. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25831. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25832. import { Geometry } from "babylonjs/Meshes/geometry";
  25833. import { Mesh } from "babylonjs/Meshes/mesh";
  25834. /**
  25835. * Define an interface for all classes that will get and set the data on vertices
  25836. */
  25837. export interface IGetSetVerticesData {
  25838. /**
  25839. * Gets a boolean indicating if specific vertex data is present
  25840. * @param kind defines the vertex data kind to use
  25841. * @returns true is data kind is present
  25842. */
  25843. isVerticesDataPresent(kind: string): boolean;
  25844. /**
  25845. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25846. * @param kind defines the data kind (Position, normal, etc...)
  25847. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25848. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25849. * @returns a float array containing vertex data
  25850. */
  25851. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25852. /**
  25853. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25854. * @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.
  25855. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25856. * @returns the indices array or an empty array if the mesh has no geometry
  25857. */
  25858. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25859. /**
  25860. * Set specific vertex data
  25861. * @param kind defines the data kind (Position, normal, etc...)
  25862. * @param data defines the vertex data to use
  25863. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25864. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25865. */
  25866. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25867. /**
  25868. * Update a specific associated vertex buffer
  25869. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25870. * - VertexBuffer.PositionKind
  25871. * - VertexBuffer.UVKind
  25872. * - VertexBuffer.UV2Kind
  25873. * - VertexBuffer.UV3Kind
  25874. * - VertexBuffer.UV4Kind
  25875. * - VertexBuffer.UV5Kind
  25876. * - VertexBuffer.UV6Kind
  25877. * - VertexBuffer.ColorKind
  25878. * - VertexBuffer.MatricesIndicesKind
  25879. * - VertexBuffer.MatricesIndicesExtraKind
  25880. * - VertexBuffer.MatricesWeightsKind
  25881. * - VertexBuffer.MatricesWeightsExtraKind
  25882. * @param data defines the data source
  25883. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25884. * @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)
  25885. */
  25886. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25887. /**
  25888. * Creates a new index buffer
  25889. * @param indices defines the indices to store in the index buffer
  25890. * @param totalVertices defines the total number of vertices (could be null)
  25891. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25892. */
  25893. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25894. }
  25895. /**
  25896. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25897. */
  25898. export class VertexData {
  25899. /**
  25900. * Mesh side orientation : usually the external or front surface
  25901. */
  25902. static readonly FRONTSIDE: number;
  25903. /**
  25904. * Mesh side orientation : usually the internal or back surface
  25905. */
  25906. static readonly BACKSIDE: number;
  25907. /**
  25908. * Mesh side orientation : both internal and external or front and back surfaces
  25909. */
  25910. static readonly DOUBLESIDE: number;
  25911. /**
  25912. * Mesh side orientation : by default, `FRONTSIDE`
  25913. */
  25914. static readonly DEFAULTSIDE: number;
  25915. /**
  25916. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25917. */
  25918. positions: Nullable<FloatArray>;
  25919. /**
  25920. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25921. */
  25922. normals: Nullable<FloatArray>;
  25923. /**
  25924. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25925. */
  25926. tangents: Nullable<FloatArray>;
  25927. /**
  25928. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25929. */
  25930. uvs: Nullable<FloatArray>;
  25931. /**
  25932. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25933. */
  25934. uvs2: Nullable<FloatArray>;
  25935. /**
  25936. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25937. */
  25938. uvs3: Nullable<FloatArray>;
  25939. /**
  25940. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25941. */
  25942. uvs4: Nullable<FloatArray>;
  25943. /**
  25944. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25945. */
  25946. uvs5: Nullable<FloatArray>;
  25947. /**
  25948. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25949. */
  25950. uvs6: Nullable<FloatArray>;
  25951. /**
  25952. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25953. */
  25954. colors: Nullable<FloatArray>;
  25955. /**
  25956. * 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).
  25957. */
  25958. matricesIndices: Nullable<FloatArray>;
  25959. /**
  25960. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25961. */
  25962. matricesWeights: Nullable<FloatArray>;
  25963. /**
  25964. * An array extending the number of possible indices
  25965. */
  25966. matricesIndicesExtra: Nullable<FloatArray>;
  25967. /**
  25968. * An array extending the number of possible weights when the number of indices is extended
  25969. */
  25970. matricesWeightsExtra: Nullable<FloatArray>;
  25971. /**
  25972. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25973. */
  25974. indices: Nullable<IndicesArray>;
  25975. /**
  25976. * Uses the passed data array to set the set the values for the specified kind of data
  25977. * @param data a linear array of floating numbers
  25978. * @param kind the type of data that is being set, eg positions, colors etc
  25979. */
  25980. set(data: FloatArray, kind: string): void;
  25981. /**
  25982. * Associates the vertexData to the passed Mesh.
  25983. * Sets it as updatable or not (default `false`)
  25984. * @param mesh the mesh the vertexData is applied to
  25985. * @param updatable when used and having the value true allows new data to update the vertexData
  25986. * @returns the VertexData
  25987. */
  25988. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25989. /**
  25990. * Associates the vertexData to the passed Geometry.
  25991. * Sets it as updatable or not (default `false`)
  25992. * @param geometry the geometry the vertexData is applied to
  25993. * @param updatable when used and having the value true allows new data to update the vertexData
  25994. * @returns VertexData
  25995. */
  25996. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25997. /**
  25998. * Updates the associated mesh
  25999. * @param mesh the mesh to be updated
  26000. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26001. * @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
  26002. * @returns VertexData
  26003. */
  26004. updateMesh(mesh: Mesh): VertexData;
  26005. /**
  26006. * Updates the associated geometry
  26007. * @param geometry the geometry to be updated
  26008. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26009. * @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
  26010. * @returns VertexData.
  26011. */
  26012. updateGeometry(geometry: Geometry): VertexData;
  26013. private _applyTo;
  26014. private _update;
  26015. /**
  26016. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26017. * @param matrix the transforming matrix
  26018. * @returns the VertexData
  26019. */
  26020. transform(matrix: Matrix): VertexData;
  26021. /**
  26022. * Merges the passed VertexData into the current one
  26023. * @param other the VertexData to be merged into the current one
  26024. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26025. * @returns the modified VertexData
  26026. */
  26027. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26028. private _mergeElement;
  26029. private _validate;
  26030. /**
  26031. * Serializes the VertexData
  26032. * @returns a serialized object
  26033. */
  26034. serialize(): any;
  26035. /**
  26036. * Extracts the vertexData from a mesh
  26037. * @param mesh the mesh from which to extract the VertexData
  26038. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26039. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26040. * @returns the object VertexData associated to the passed mesh
  26041. */
  26042. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26043. /**
  26044. * Extracts the vertexData from the geometry
  26045. * @param geometry the geometry from which to extract the VertexData
  26046. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26047. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26048. * @returns the object VertexData associated to the passed mesh
  26049. */
  26050. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26051. private static _ExtractFrom;
  26052. /**
  26053. * Creates the VertexData for a Ribbon
  26054. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26055. * * pathArray array of paths, each of which an array of successive Vector3
  26056. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26057. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26058. * * 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
  26059. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26060. * * 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)
  26061. * * 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)
  26062. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26063. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26064. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26065. * @returns the VertexData of the ribbon
  26066. */
  26067. static CreateRibbon(options: {
  26068. pathArray: Vector3[][];
  26069. closeArray?: boolean;
  26070. closePath?: boolean;
  26071. offset?: number;
  26072. sideOrientation?: number;
  26073. frontUVs?: Vector4;
  26074. backUVs?: Vector4;
  26075. invertUV?: boolean;
  26076. uvs?: Vector2[];
  26077. colors?: Color4[];
  26078. }): VertexData;
  26079. /**
  26080. * Creates the VertexData for a box
  26081. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26082. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26083. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26084. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26085. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26086. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26087. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26088. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26089. * * 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)
  26090. * * 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)
  26091. * @returns the VertexData of the box
  26092. */
  26093. static CreateBox(options: {
  26094. size?: number;
  26095. width?: number;
  26096. height?: number;
  26097. depth?: number;
  26098. faceUV?: Vector4[];
  26099. faceColors?: Color4[];
  26100. sideOrientation?: number;
  26101. frontUVs?: Vector4;
  26102. backUVs?: Vector4;
  26103. }): VertexData;
  26104. /**
  26105. * Creates the VertexData for a tiled box
  26106. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26107. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26108. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26109. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26111. * @returns the VertexData of the box
  26112. */
  26113. static CreateTiledBox(options: {
  26114. pattern?: number;
  26115. width?: number;
  26116. height?: number;
  26117. depth?: number;
  26118. tileSize?: number;
  26119. tileWidth?: number;
  26120. tileHeight?: number;
  26121. alignHorizontal?: number;
  26122. alignVertical?: number;
  26123. faceUV?: Vector4[];
  26124. faceColors?: Color4[];
  26125. sideOrientation?: number;
  26126. }): VertexData;
  26127. /**
  26128. * Creates the VertexData for a tiled plane
  26129. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26130. * * pattern a limited pattern arrangement depending on the number
  26131. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26132. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26133. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26134. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26135. * * 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)
  26136. * * 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)
  26137. * @returns the VertexData of the tiled plane
  26138. */
  26139. static CreateTiledPlane(options: {
  26140. pattern?: number;
  26141. tileSize?: number;
  26142. tileWidth?: number;
  26143. tileHeight?: number;
  26144. size?: number;
  26145. width?: number;
  26146. height?: number;
  26147. alignHorizontal?: number;
  26148. alignVertical?: number;
  26149. sideOrientation?: number;
  26150. frontUVs?: Vector4;
  26151. backUVs?: Vector4;
  26152. }): VertexData;
  26153. /**
  26154. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26155. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26156. * * segments sets the number of horizontal strips optional, default 32
  26157. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26158. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26159. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26160. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26161. * * 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
  26162. * * 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
  26163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26164. * * 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)
  26165. * * 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)
  26166. * @returns the VertexData of the ellipsoid
  26167. */
  26168. static CreateSphere(options: {
  26169. segments?: number;
  26170. diameter?: number;
  26171. diameterX?: number;
  26172. diameterY?: number;
  26173. diameterZ?: number;
  26174. arc?: number;
  26175. slice?: number;
  26176. sideOrientation?: number;
  26177. frontUVs?: Vector4;
  26178. backUVs?: Vector4;
  26179. }): VertexData;
  26180. /**
  26181. * Creates the VertexData for a cylinder, cone or prism
  26182. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26183. * * height sets the height (y direction) of the cylinder, optional, default 2
  26184. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26185. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26186. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26187. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26188. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26189. * * 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
  26190. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26191. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26192. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26193. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26194. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26195. * * 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)
  26196. * * 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)
  26197. * @returns the VertexData of the cylinder, cone or prism
  26198. */
  26199. static CreateCylinder(options: {
  26200. height?: number;
  26201. diameterTop?: number;
  26202. diameterBottom?: number;
  26203. diameter?: number;
  26204. tessellation?: number;
  26205. subdivisions?: number;
  26206. arc?: number;
  26207. faceColors?: Color4[];
  26208. faceUV?: Vector4[];
  26209. hasRings?: boolean;
  26210. enclose?: boolean;
  26211. sideOrientation?: number;
  26212. frontUVs?: Vector4;
  26213. backUVs?: Vector4;
  26214. }): VertexData;
  26215. /**
  26216. * Creates the VertexData for a torus
  26217. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26218. * * diameter the diameter of the torus, optional default 1
  26219. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26220. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26221. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26222. * * 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)
  26223. * * 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)
  26224. * @returns the VertexData of the torus
  26225. */
  26226. static CreateTorus(options: {
  26227. diameter?: number;
  26228. thickness?: number;
  26229. tessellation?: number;
  26230. sideOrientation?: number;
  26231. frontUVs?: Vector4;
  26232. backUVs?: Vector4;
  26233. }): VertexData;
  26234. /**
  26235. * Creates the VertexData of the LineSystem
  26236. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26237. * - lines an array of lines, each line being an array of successive Vector3
  26238. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26239. * @returns the VertexData of the LineSystem
  26240. */
  26241. static CreateLineSystem(options: {
  26242. lines: Vector3[][];
  26243. colors?: Nullable<Color4[][]>;
  26244. }): VertexData;
  26245. /**
  26246. * Create the VertexData for a DashedLines
  26247. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26248. * - points an array successive Vector3
  26249. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26250. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26251. * - dashNb the intended total number of dashes, optional, default 200
  26252. * @returns the VertexData for the DashedLines
  26253. */
  26254. static CreateDashedLines(options: {
  26255. points: Vector3[];
  26256. dashSize?: number;
  26257. gapSize?: number;
  26258. dashNb?: number;
  26259. }): VertexData;
  26260. /**
  26261. * Creates the VertexData for a Ground
  26262. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26263. * - width the width (x direction) of the ground, optional, default 1
  26264. * - height the height (z direction) of the ground, optional, default 1
  26265. * - subdivisions the number of subdivisions per side, optional, default 1
  26266. * @returns the VertexData of the Ground
  26267. */
  26268. static CreateGround(options: {
  26269. width?: number;
  26270. height?: number;
  26271. subdivisions?: number;
  26272. subdivisionsX?: number;
  26273. subdivisionsY?: number;
  26274. }): VertexData;
  26275. /**
  26276. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26277. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26278. * * xmin the ground minimum X coordinate, optional, default -1
  26279. * * zmin the ground minimum Z coordinate, optional, default -1
  26280. * * xmax the ground maximum X coordinate, optional, default 1
  26281. * * zmax the ground maximum Z coordinate, optional, default 1
  26282. * * 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}
  26283. * * 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}
  26284. * @returns the VertexData of the TiledGround
  26285. */
  26286. static CreateTiledGround(options: {
  26287. xmin: number;
  26288. zmin: number;
  26289. xmax: number;
  26290. zmax: number;
  26291. subdivisions?: {
  26292. w: number;
  26293. h: number;
  26294. };
  26295. precision?: {
  26296. w: number;
  26297. h: number;
  26298. };
  26299. }): VertexData;
  26300. /**
  26301. * Creates the VertexData of the Ground designed from a heightmap
  26302. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26303. * * width the width (x direction) of the ground
  26304. * * height the height (z direction) of the ground
  26305. * * subdivisions the number of subdivisions per side
  26306. * * minHeight the minimum altitude on the ground, optional, default 0
  26307. * * maxHeight the maximum altitude on the ground, optional default 1
  26308. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26309. * * buffer the array holding the image color data
  26310. * * bufferWidth the width of image
  26311. * * bufferHeight the height of image
  26312. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26313. * @returns the VertexData of the Ground designed from a heightmap
  26314. */
  26315. static CreateGroundFromHeightMap(options: {
  26316. width: number;
  26317. height: number;
  26318. subdivisions: number;
  26319. minHeight: number;
  26320. maxHeight: number;
  26321. colorFilter: Color3;
  26322. buffer: Uint8Array;
  26323. bufferWidth: number;
  26324. bufferHeight: number;
  26325. alphaFilter: number;
  26326. }): VertexData;
  26327. /**
  26328. * Creates the VertexData for a Plane
  26329. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26330. * * size sets the width and height of the plane to the value of size, optional default 1
  26331. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26332. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26333. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26334. * * 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)
  26335. * * 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)
  26336. * @returns the VertexData of the box
  26337. */
  26338. static CreatePlane(options: {
  26339. size?: number;
  26340. width?: number;
  26341. height?: number;
  26342. sideOrientation?: number;
  26343. frontUVs?: Vector4;
  26344. backUVs?: Vector4;
  26345. }): VertexData;
  26346. /**
  26347. * Creates the VertexData of the Disc or regular Polygon
  26348. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26349. * * radius the radius of the disc, optional default 0.5
  26350. * * tessellation the number of polygon sides, optional, default 64
  26351. * * 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
  26352. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26353. * * 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)
  26354. * * 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)
  26355. * @returns the VertexData of the box
  26356. */
  26357. static CreateDisc(options: {
  26358. radius?: number;
  26359. tessellation?: number;
  26360. arc?: number;
  26361. sideOrientation?: number;
  26362. frontUVs?: Vector4;
  26363. backUVs?: Vector4;
  26364. }): VertexData;
  26365. /**
  26366. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26367. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26368. * @param polygon a mesh built from polygonTriangulation.build()
  26369. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26370. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26371. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26372. * @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)
  26373. * @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)
  26374. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26375. * @returns the VertexData of the Polygon
  26376. */
  26377. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26378. /**
  26379. * Creates the VertexData of the IcoSphere
  26380. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26381. * * radius the radius of the IcoSphere, optional default 1
  26382. * * radiusX allows stretching in the x direction, optional, default radius
  26383. * * radiusY allows stretching in the y direction, optional, default radius
  26384. * * radiusZ allows stretching in the z direction, optional, default radius
  26385. * * flat when true creates a flat shaded mesh, optional, default true
  26386. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26387. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26388. * * 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)
  26389. * * 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)
  26390. * @returns the VertexData of the IcoSphere
  26391. */
  26392. static CreateIcoSphere(options: {
  26393. radius?: number;
  26394. radiusX?: number;
  26395. radiusY?: number;
  26396. radiusZ?: number;
  26397. flat?: boolean;
  26398. subdivisions?: number;
  26399. sideOrientation?: number;
  26400. frontUVs?: Vector4;
  26401. backUVs?: Vector4;
  26402. }): VertexData;
  26403. /**
  26404. * Creates the VertexData for a Polyhedron
  26405. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26406. * * type provided types are:
  26407. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26408. * * 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)
  26409. * * size the size of the IcoSphere, optional default 1
  26410. * * sizeX allows stretching in the x direction, optional, default size
  26411. * * sizeY allows stretching in the y direction, optional, default size
  26412. * * sizeZ allows stretching in the z direction, optional, default size
  26413. * * 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
  26414. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26415. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26416. * * flat when true creates a flat shaded mesh, optional, default true
  26417. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26418. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26419. * * 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)
  26420. * * 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)
  26421. * @returns the VertexData of the Polyhedron
  26422. */
  26423. static CreatePolyhedron(options: {
  26424. type?: number;
  26425. size?: number;
  26426. sizeX?: number;
  26427. sizeY?: number;
  26428. sizeZ?: number;
  26429. custom?: any;
  26430. faceUV?: Vector4[];
  26431. faceColors?: Color4[];
  26432. flat?: boolean;
  26433. sideOrientation?: number;
  26434. frontUVs?: Vector4;
  26435. backUVs?: Vector4;
  26436. }): VertexData;
  26437. /**
  26438. * Creates the VertexData for a TorusKnot
  26439. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26440. * * radius the radius of the torus knot, optional, default 2
  26441. * * tube the thickness of the tube, optional, default 0.5
  26442. * * radialSegments the number of sides on each tube segments, optional, default 32
  26443. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26444. * * p the number of windings around the z axis, optional, default 2
  26445. * * q the number of windings around the x axis, optional, default 3
  26446. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26447. * * 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)
  26448. * * 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)
  26449. * @returns the VertexData of the Torus Knot
  26450. */
  26451. static CreateTorusKnot(options: {
  26452. radius?: number;
  26453. tube?: number;
  26454. radialSegments?: number;
  26455. tubularSegments?: number;
  26456. p?: number;
  26457. q?: number;
  26458. sideOrientation?: number;
  26459. frontUVs?: Vector4;
  26460. backUVs?: Vector4;
  26461. }): VertexData;
  26462. /**
  26463. * Compute normals for given positions and indices
  26464. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26465. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26466. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26467. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26468. * * facetNormals : optional array of facet normals (vector3)
  26469. * * facetPositions : optional array of facet positions (vector3)
  26470. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26471. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26472. * * bInfo : optional bounding info, required for facetPartitioning computation
  26473. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26474. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26475. * * useRightHandedSystem: optional boolean to for right handed system computation
  26476. * * depthSort : optional boolean to enable the facet depth sort computation
  26477. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26478. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26479. */
  26480. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26481. facetNormals?: any;
  26482. facetPositions?: any;
  26483. facetPartitioning?: any;
  26484. ratio?: number;
  26485. bInfo?: any;
  26486. bbSize?: Vector3;
  26487. subDiv?: any;
  26488. useRightHandedSystem?: boolean;
  26489. depthSort?: boolean;
  26490. distanceTo?: Vector3;
  26491. depthSortedFacets?: any;
  26492. }): void;
  26493. /** @hidden */
  26494. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26495. /**
  26496. * Applies VertexData created from the imported parameters to the geometry
  26497. * @param parsedVertexData the parsed data from an imported file
  26498. * @param geometry the geometry to apply the VertexData to
  26499. */
  26500. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26501. }
  26502. }
  26503. declare module "babylonjs/Morph/morphTarget" {
  26504. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26505. import { Observable } from "babylonjs/Misc/observable";
  26506. import { Nullable, FloatArray } from "babylonjs/types";
  26507. import { Scene } from "babylonjs/scene";
  26508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26509. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26510. /**
  26511. * Defines a target to use with MorphTargetManager
  26512. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26513. */
  26514. export class MorphTarget implements IAnimatable {
  26515. /** defines the name of the target */
  26516. name: string;
  26517. /**
  26518. * Gets or sets the list of animations
  26519. */
  26520. animations: import("babylonjs/Animations/animation").Animation[];
  26521. private _scene;
  26522. private _positions;
  26523. private _normals;
  26524. private _tangents;
  26525. private _uvs;
  26526. private _influence;
  26527. private _uniqueId;
  26528. /**
  26529. * Observable raised when the influence changes
  26530. */
  26531. onInfluenceChanged: Observable<boolean>;
  26532. /** @hidden */
  26533. _onDataLayoutChanged: Observable<void>;
  26534. /**
  26535. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26536. */
  26537. get influence(): number;
  26538. set influence(influence: number);
  26539. /**
  26540. * Gets or sets the id of the morph Target
  26541. */
  26542. id: string;
  26543. private _animationPropertiesOverride;
  26544. /**
  26545. * Gets or sets the animation properties override
  26546. */
  26547. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26548. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26549. /**
  26550. * Creates a new MorphTarget
  26551. * @param name defines the name of the target
  26552. * @param influence defines the influence to use
  26553. * @param scene defines the scene the morphtarget belongs to
  26554. */
  26555. constructor(
  26556. /** defines the name of the target */
  26557. name: string, influence?: number, scene?: Nullable<Scene>);
  26558. /**
  26559. * Gets the unique ID of this manager
  26560. */
  26561. get uniqueId(): number;
  26562. /**
  26563. * Gets a boolean defining if the target contains position data
  26564. */
  26565. get hasPositions(): boolean;
  26566. /**
  26567. * Gets a boolean defining if the target contains normal data
  26568. */
  26569. get hasNormals(): boolean;
  26570. /**
  26571. * Gets a boolean defining if the target contains tangent data
  26572. */
  26573. get hasTangents(): boolean;
  26574. /**
  26575. * Gets a boolean defining if the target contains texture coordinates data
  26576. */
  26577. get hasUVs(): boolean;
  26578. /**
  26579. * Affects position data to this target
  26580. * @param data defines the position data to use
  26581. */
  26582. setPositions(data: Nullable<FloatArray>): void;
  26583. /**
  26584. * Gets the position data stored in this target
  26585. * @returns a FloatArray containing the position data (or null if not present)
  26586. */
  26587. getPositions(): Nullable<FloatArray>;
  26588. /**
  26589. * Affects normal data to this target
  26590. * @param data defines the normal data to use
  26591. */
  26592. setNormals(data: Nullable<FloatArray>): void;
  26593. /**
  26594. * Gets the normal data stored in this target
  26595. * @returns a FloatArray containing the normal data (or null if not present)
  26596. */
  26597. getNormals(): Nullable<FloatArray>;
  26598. /**
  26599. * Affects tangent data to this target
  26600. * @param data defines the tangent data to use
  26601. */
  26602. setTangents(data: Nullable<FloatArray>): void;
  26603. /**
  26604. * Gets the tangent data stored in this target
  26605. * @returns a FloatArray containing the tangent data (or null if not present)
  26606. */
  26607. getTangents(): Nullable<FloatArray>;
  26608. /**
  26609. * Affects texture coordinates data to this target
  26610. * @param data defines the texture coordinates data to use
  26611. */
  26612. setUVs(data: Nullable<FloatArray>): void;
  26613. /**
  26614. * Gets the texture coordinates data stored in this target
  26615. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26616. */
  26617. getUVs(): Nullable<FloatArray>;
  26618. /**
  26619. * Clone the current target
  26620. * @returns a new MorphTarget
  26621. */
  26622. clone(): MorphTarget;
  26623. /**
  26624. * Serializes the current target into a Serialization object
  26625. * @returns the serialized object
  26626. */
  26627. serialize(): any;
  26628. /**
  26629. * Returns the string "MorphTarget"
  26630. * @returns "MorphTarget"
  26631. */
  26632. getClassName(): string;
  26633. /**
  26634. * Creates a new target from serialized data
  26635. * @param serializationObject defines the serialized data to use
  26636. * @returns a new MorphTarget
  26637. */
  26638. static Parse(serializationObject: any): MorphTarget;
  26639. /**
  26640. * Creates a MorphTarget from mesh data
  26641. * @param mesh defines the source mesh
  26642. * @param name defines the name to use for the new target
  26643. * @param influence defines the influence to attach to the target
  26644. * @returns a new MorphTarget
  26645. */
  26646. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26647. }
  26648. }
  26649. declare module "babylonjs/Morph/morphTargetManager" {
  26650. import { Nullable } from "babylonjs/types";
  26651. import { Scene } from "babylonjs/scene";
  26652. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26653. /**
  26654. * This class is used to deform meshes using morphing between different targets
  26655. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26656. */
  26657. export class MorphTargetManager {
  26658. private _targets;
  26659. private _targetInfluenceChangedObservers;
  26660. private _targetDataLayoutChangedObservers;
  26661. private _activeTargets;
  26662. private _scene;
  26663. private _influences;
  26664. private _supportsNormals;
  26665. private _supportsTangents;
  26666. private _supportsUVs;
  26667. private _vertexCount;
  26668. private _uniqueId;
  26669. private _tempInfluences;
  26670. /**
  26671. * Gets or sets a boolean indicating if normals must be morphed
  26672. */
  26673. enableNormalMorphing: boolean;
  26674. /**
  26675. * Gets or sets a boolean indicating if tangents must be morphed
  26676. */
  26677. enableTangentMorphing: boolean;
  26678. /**
  26679. * Gets or sets a boolean indicating if UV must be morphed
  26680. */
  26681. enableUVMorphing: boolean;
  26682. /**
  26683. * Creates a new MorphTargetManager
  26684. * @param scene defines the current scene
  26685. */
  26686. constructor(scene?: Nullable<Scene>);
  26687. /**
  26688. * Gets the unique ID of this manager
  26689. */
  26690. get uniqueId(): number;
  26691. /**
  26692. * Gets the number of vertices handled by this manager
  26693. */
  26694. get vertexCount(): number;
  26695. /**
  26696. * Gets a boolean indicating if this manager supports morphing of normals
  26697. */
  26698. get supportsNormals(): boolean;
  26699. /**
  26700. * Gets a boolean indicating if this manager supports morphing of tangents
  26701. */
  26702. get supportsTangents(): boolean;
  26703. /**
  26704. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26705. */
  26706. get supportsUVs(): boolean;
  26707. /**
  26708. * Gets the number of targets stored in this manager
  26709. */
  26710. get numTargets(): number;
  26711. /**
  26712. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26713. */
  26714. get numInfluencers(): number;
  26715. /**
  26716. * Gets the list of influences (one per target)
  26717. */
  26718. get influences(): Float32Array;
  26719. /**
  26720. * Gets the active target at specified index. An active target is a target with an influence > 0
  26721. * @param index defines the index to check
  26722. * @returns the requested target
  26723. */
  26724. getActiveTarget(index: number): MorphTarget;
  26725. /**
  26726. * Gets the target at specified index
  26727. * @param index defines the index to check
  26728. * @returns the requested target
  26729. */
  26730. getTarget(index: number): MorphTarget;
  26731. /**
  26732. * Add a new target to this manager
  26733. * @param target defines the target to add
  26734. */
  26735. addTarget(target: MorphTarget): void;
  26736. /**
  26737. * Removes a target from the manager
  26738. * @param target defines the target to remove
  26739. */
  26740. removeTarget(target: MorphTarget): void;
  26741. /**
  26742. * Clone the current manager
  26743. * @returns a new MorphTargetManager
  26744. */
  26745. clone(): MorphTargetManager;
  26746. /**
  26747. * Serializes the current manager into a Serialization object
  26748. * @returns the serialized object
  26749. */
  26750. serialize(): any;
  26751. private _syncActiveTargets;
  26752. /**
  26753. * Syncrhonize the targets with all the meshes using this morph target manager
  26754. */
  26755. synchronize(): void;
  26756. /**
  26757. * Creates a new MorphTargetManager from serialized data
  26758. * @param serializationObject defines the serialized data
  26759. * @param scene defines the hosting scene
  26760. * @returns the new MorphTargetManager
  26761. */
  26762. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26763. }
  26764. }
  26765. declare module "babylonjs/Meshes/meshLODLevel" {
  26766. import { Mesh } from "babylonjs/Meshes/mesh";
  26767. import { Nullable } from "babylonjs/types";
  26768. /**
  26769. * Class used to represent a specific level of detail of a mesh
  26770. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26771. */
  26772. export class MeshLODLevel {
  26773. /** Defines the distance where this level should start being displayed */
  26774. distance: number;
  26775. /** Defines the mesh to use to render this level */
  26776. mesh: Nullable<Mesh>;
  26777. /**
  26778. * Creates a new LOD level
  26779. * @param distance defines the distance where this level should star being displayed
  26780. * @param mesh defines the mesh to use to render this level
  26781. */
  26782. constructor(
  26783. /** Defines the distance where this level should start being displayed */
  26784. distance: number,
  26785. /** Defines the mesh to use to render this level */
  26786. mesh: Nullable<Mesh>);
  26787. }
  26788. }
  26789. declare module "babylonjs/Meshes/groundMesh" {
  26790. import { Scene } from "babylonjs/scene";
  26791. import { Vector3 } from "babylonjs/Maths/math.vector";
  26792. import { Mesh } from "babylonjs/Meshes/mesh";
  26793. /**
  26794. * Mesh representing the gorund
  26795. */
  26796. export class GroundMesh extends Mesh {
  26797. /** If octree should be generated */
  26798. generateOctree: boolean;
  26799. private _heightQuads;
  26800. /** @hidden */
  26801. _subdivisionsX: number;
  26802. /** @hidden */
  26803. _subdivisionsY: number;
  26804. /** @hidden */
  26805. _width: number;
  26806. /** @hidden */
  26807. _height: number;
  26808. /** @hidden */
  26809. _minX: number;
  26810. /** @hidden */
  26811. _maxX: number;
  26812. /** @hidden */
  26813. _minZ: number;
  26814. /** @hidden */
  26815. _maxZ: number;
  26816. constructor(name: string, scene: Scene);
  26817. /**
  26818. * "GroundMesh"
  26819. * @returns "GroundMesh"
  26820. */
  26821. getClassName(): string;
  26822. /**
  26823. * The minimum of x and y subdivisions
  26824. */
  26825. get subdivisions(): number;
  26826. /**
  26827. * X subdivisions
  26828. */
  26829. get subdivisionsX(): number;
  26830. /**
  26831. * Y subdivisions
  26832. */
  26833. get subdivisionsY(): number;
  26834. /**
  26835. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26836. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26837. * @param chunksCount the number of subdivisions for x and y
  26838. * @param octreeBlocksSize (Default: 32)
  26839. */
  26840. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26841. /**
  26842. * Returns a height (y) value in the Worl system :
  26843. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26844. * @param x x coordinate
  26845. * @param z z coordinate
  26846. * @returns the ground y position if (x, z) are outside the ground surface.
  26847. */
  26848. getHeightAtCoordinates(x: number, z: number): number;
  26849. /**
  26850. * Returns a normalized vector (Vector3) orthogonal to the ground
  26851. * at the ground coordinates (x, z) expressed in the World system.
  26852. * @param x x coordinate
  26853. * @param z z coordinate
  26854. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26855. */
  26856. getNormalAtCoordinates(x: number, z: number): Vector3;
  26857. /**
  26858. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26859. * at the ground coordinates (x, z) expressed in the World system.
  26860. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26861. * @param x x coordinate
  26862. * @param z z coordinate
  26863. * @param ref vector to store the result
  26864. * @returns the GroundMesh.
  26865. */
  26866. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26867. /**
  26868. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26869. * if the ground has been updated.
  26870. * This can be used in the render loop.
  26871. * @returns the GroundMesh.
  26872. */
  26873. updateCoordinateHeights(): GroundMesh;
  26874. private _getFacetAt;
  26875. private _initHeightQuads;
  26876. private _computeHeightQuads;
  26877. /**
  26878. * Serializes this ground mesh
  26879. * @param serializationObject object to write serialization to
  26880. */
  26881. serialize(serializationObject: any): void;
  26882. /**
  26883. * Parses a serialized ground mesh
  26884. * @param parsedMesh the serialized mesh
  26885. * @param scene the scene to create the ground mesh in
  26886. * @returns the created ground mesh
  26887. */
  26888. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26889. }
  26890. }
  26891. declare module "babylonjs/Physics/physicsJoint" {
  26892. import { Vector3 } from "babylonjs/Maths/math.vector";
  26893. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26894. /**
  26895. * Interface for Physics-Joint data
  26896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26897. */
  26898. export interface PhysicsJointData {
  26899. /**
  26900. * The main pivot of the joint
  26901. */
  26902. mainPivot?: Vector3;
  26903. /**
  26904. * The connected pivot of the joint
  26905. */
  26906. connectedPivot?: Vector3;
  26907. /**
  26908. * The main axis of the joint
  26909. */
  26910. mainAxis?: Vector3;
  26911. /**
  26912. * The connected axis of the joint
  26913. */
  26914. connectedAxis?: Vector3;
  26915. /**
  26916. * The collision of the joint
  26917. */
  26918. collision?: boolean;
  26919. /**
  26920. * Native Oimo/Cannon/Energy data
  26921. */
  26922. nativeParams?: any;
  26923. }
  26924. /**
  26925. * This is a holder class for the physics joint created by the physics plugin
  26926. * It holds a set of functions to control the underlying joint
  26927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26928. */
  26929. export class PhysicsJoint {
  26930. /**
  26931. * The type of the physics joint
  26932. */
  26933. type: number;
  26934. /**
  26935. * The data for the physics joint
  26936. */
  26937. jointData: PhysicsJointData;
  26938. private _physicsJoint;
  26939. protected _physicsPlugin: IPhysicsEnginePlugin;
  26940. /**
  26941. * Initializes the physics joint
  26942. * @param type The type of the physics joint
  26943. * @param jointData The data for the physics joint
  26944. */
  26945. constructor(
  26946. /**
  26947. * The type of the physics joint
  26948. */
  26949. type: number,
  26950. /**
  26951. * The data for the physics joint
  26952. */
  26953. jointData: PhysicsJointData);
  26954. /**
  26955. * Gets the physics joint
  26956. */
  26957. get physicsJoint(): any;
  26958. /**
  26959. * Sets the physics joint
  26960. */
  26961. set physicsJoint(newJoint: any);
  26962. /**
  26963. * Sets the physics plugin
  26964. */
  26965. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26966. /**
  26967. * Execute a function that is physics-plugin specific.
  26968. * @param {Function} func the function that will be executed.
  26969. * It accepts two parameters: the physics world and the physics joint
  26970. */
  26971. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26972. /**
  26973. * Distance-Joint type
  26974. */
  26975. static DistanceJoint: number;
  26976. /**
  26977. * Hinge-Joint type
  26978. */
  26979. static HingeJoint: number;
  26980. /**
  26981. * Ball-and-Socket joint type
  26982. */
  26983. static BallAndSocketJoint: number;
  26984. /**
  26985. * Wheel-Joint type
  26986. */
  26987. static WheelJoint: number;
  26988. /**
  26989. * Slider-Joint type
  26990. */
  26991. static SliderJoint: number;
  26992. /**
  26993. * Prismatic-Joint type
  26994. */
  26995. static PrismaticJoint: number;
  26996. /**
  26997. * Universal-Joint type
  26998. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26999. */
  27000. static UniversalJoint: number;
  27001. /**
  27002. * Hinge-Joint 2 type
  27003. */
  27004. static Hinge2Joint: number;
  27005. /**
  27006. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27007. */
  27008. static PointToPointJoint: number;
  27009. /**
  27010. * Spring-Joint type
  27011. */
  27012. static SpringJoint: number;
  27013. /**
  27014. * Lock-Joint type
  27015. */
  27016. static LockJoint: number;
  27017. }
  27018. /**
  27019. * A class representing a physics distance joint
  27020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27021. */
  27022. export class DistanceJoint extends PhysicsJoint {
  27023. /**
  27024. *
  27025. * @param jointData The data for the Distance-Joint
  27026. */
  27027. constructor(jointData: DistanceJointData);
  27028. /**
  27029. * Update the predefined distance.
  27030. * @param maxDistance The maximum preferred distance
  27031. * @param minDistance The minimum preferred distance
  27032. */
  27033. updateDistance(maxDistance: number, minDistance?: number): void;
  27034. }
  27035. /**
  27036. * Represents a Motor-Enabled Joint
  27037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27038. */
  27039. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27040. /**
  27041. * Initializes the Motor-Enabled Joint
  27042. * @param type The type of the joint
  27043. * @param jointData The physica joint data for the joint
  27044. */
  27045. constructor(type: number, jointData: PhysicsJointData);
  27046. /**
  27047. * Set the motor values.
  27048. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27049. * @param force the force to apply
  27050. * @param maxForce max force for this motor.
  27051. */
  27052. setMotor(force?: number, maxForce?: number): void;
  27053. /**
  27054. * Set the motor's limits.
  27055. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27056. * @param upperLimit The upper limit of the motor
  27057. * @param lowerLimit The lower limit of the motor
  27058. */
  27059. setLimit(upperLimit: number, lowerLimit?: number): void;
  27060. }
  27061. /**
  27062. * This class represents a single physics Hinge-Joint
  27063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27064. */
  27065. export class HingeJoint extends MotorEnabledJoint {
  27066. /**
  27067. * Initializes the Hinge-Joint
  27068. * @param jointData The joint data for the Hinge-Joint
  27069. */
  27070. constructor(jointData: PhysicsJointData);
  27071. /**
  27072. * Set the motor values.
  27073. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27074. * @param {number} force the force to apply
  27075. * @param {number} maxForce max force for this motor.
  27076. */
  27077. setMotor(force?: number, maxForce?: number): void;
  27078. /**
  27079. * Set the motor's limits.
  27080. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27081. * @param upperLimit The upper limit of the motor
  27082. * @param lowerLimit The lower limit of the motor
  27083. */
  27084. setLimit(upperLimit: number, lowerLimit?: number): void;
  27085. }
  27086. /**
  27087. * This class represents a dual hinge physics joint (same as wheel joint)
  27088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27089. */
  27090. export class Hinge2Joint extends MotorEnabledJoint {
  27091. /**
  27092. * Initializes the Hinge2-Joint
  27093. * @param jointData The joint data for the Hinge2-Joint
  27094. */
  27095. constructor(jointData: PhysicsJointData);
  27096. /**
  27097. * Set the motor values.
  27098. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27099. * @param {number} targetSpeed the speed the motor is to reach
  27100. * @param {number} maxForce max force for this motor.
  27101. * @param {motorIndex} the motor's index, 0 or 1.
  27102. */
  27103. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27104. /**
  27105. * Set the motor limits.
  27106. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27107. * @param {number} upperLimit the upper limit
  27108. * @param {number} lowerLimit lower limit
  27109. * @param {motorIndex} the motor's index, 0 or 1.
  27110. */
  27111. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27112. }
  27113. /**
  27114. * Interface for a motor enabled joint
  27115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27116. */
  27117. export interface IMotorEnabledJoint {
  27118. /**
  27119. * Physics joint
  27120. */
  27121. physicsJoint: any;
  27122. /**
  27123. * Sets the motor of the motor-enabled joint
  27124. * @param force The force of the motor
  27125. * @param maxForce The maximum force of the motor
  27126. * @param motorIndex The index of the motor
  27127. */
  27128. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27129. /**
  27130. * Sets the limit of the motor
  27131. * @param upperLimit The upper limit of the motor
  27132. * @param lowerLimit The lower limit of the motor
  27133. * @param motorIndex The index of the motor
  27134. */
  27135. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27136. }
  27137. /**
  27138. * Joint data for a Distance-Joint
  27139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27140. */
  27141. export interface DistanceJointData extends PhysicsJointData {
  27142. /**
  27143. * Max distance the 2 joint objects can be apart
  27144. */
  27145. maxDistance: number;
  27146. }
  27147. /**
  27148. * Joint data from a spring joint
  27149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27150. */
  27151. export interface SpringJointData extends PhysicsJointData {
  27152. /**
  27153. * Length of the spring
  27154. */
  27155. length: number;
  27156. /**
  27157. * Stiffness of the spring
  27158. */
  27159. stiffness: number;
  27160. /**
  27161. * Damping of the spring
  27162. */
  27163. damping: number;
  27164. /** this callback will be called when applying the force to the impostors. */
  27165. forceApplicationCallback: () => void;
  27166. }
  27167. }
  27168. declare module "babylonjs/Physics/physicsRaycastResult" {
  27169. import { Vector3 } from "babylonjs/Maths/math.vector";
  27170. /**
  27171. * Holds the data for the raycast result
  27172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27173. */
  27174. export class PhysicsRaycastResult {
  27175. private _hasHit;
  27176. private _hitDistance;
  27177. private _hitNormalWorld;
  27178. private _hitPointWorld;
  27179. private _rayFromWorld;
  27180. private _rayToWorld;
  27181. /**
  27182. * Gets if there was a hit
  27183. */
  27184. get hasHit(): boolean;
  27185. /**
  27186. * Gets the distance from the hit
  27187. */
  27188. get hitDistance(): number;
  27189. /**
  27190. * Gets the hit normal/direction in the world
  27191. */
  27192. get hitNormalWorld(): Vector3;
  27193. /**
  27194. * Gets the hit point in the world
  27195. */
  27196. get hitPointWorld(): Vector3;
  27197. /**
  27198. * Gets the ray "start point" of the ray in the world
  27199. */
  27200. get rayFromWorld(): Vector3;
  27201. /**
  27202. * Gets the ray "end point" of the ray in the world
  27203. */
  27204. get rayToWorld(): Vector3;
  27205. /**
  27206. * Sets the hit data (normal & point in world space)
  27207. * @param hitNormalWorld defines the normal in world space
  27208. * @param hitPointWorld defines the point in world space
  27209. */
  27210. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27211. /**
  27212. * Sets the distance from the start point to the hit point
  27213. * @param distance
  27214. */
  27215. setHitDistance(distance: number): void;
  27216. /**
  27217. * Calculates the distance manually
  27218. */
  27219. calculateHitDistance(): void;
  27220. /**
  27221. * Resets all the values to default
  27222. * @param from The from point on world space
  27223. * @param to The to point on world space
  27224. */
  27225. reset(from?: Vector3, to?: Vector3): void;
  27226. }
  27227. /**
  27228. * Interface for the size containing width and height
  27229. */
  27230. interface IXYZ {
  27231. /**
  27232. * X
  27233. */
  27234. x: number;
  27235. /**
  27236. * Y
  27237. */
  27238. y: number;
  27239. /**
  27240. * Z
  27241. */
  27242. z: number;
  27243. }
  27244. }
  27245. declare module "babylonjs/Physics/IPhysicsEngine" {
  27246. import { Nullable } from "babylonjs/types";
  27247. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27249. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27250. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27251. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27252. /**
  27253. * Interface used to describe a physics joint
  27254. */
  27255. export interface PhysicsImpostorJoint {
  27256. /** Defines the main impostor to which the joint is linked */
  27257. mainImpostor: PhysicsImpostor;
  27258. /** Defines the impostor that is connected to the main impostor using this joint */
  27259. connectedImpostor: PhysicsImpostor;
  27260. /** Defines the joint itself */
  27261. joint: PhysicsJoint;
  27262. }
  27263. /** @hidden */
  27264. export interface IPhysicsEnginePlugin {
  27265. world: any;
  27266. name: string;
  27267. setGravity(gravity: Vector3): void;
  27268. setTimeStep(timeStep: number): void;
  27269. getTimeStep(): number;
  27270. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27271. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27272. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27273. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27274. removePhysicsBody(impostor: PhysicsImpostor): void;
  27275. generateJoint(joint: PhysicsImpostorJoint): void;
  27276. removeJoint(joint: PhysicsImpostorJoint): void;
  27277. isSupported(): boolean;
  27278. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27279. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27280. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27281. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27282. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27283. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27284. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27285. getBodyMass(impostor: PhysicsImpostor): number;
  27286. getBodyFriction(impostor: PhysicsImpostor): number;
  27287. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27288. getBodyRestitution(impostor: PhysicsImpostor): number;
  27289. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27290. getBodyPressure?(impostor: PhysicsImpostor): number;
  27291. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27292. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27293. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27294. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27295. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27296. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27297. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27298. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27299. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27300. sleepBody(impostor: PhysicsImpostor): void;
  27301. wakeUpBody(impostor: PhysicsImpostor): void;
  27302. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27303. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27304. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27305. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27306. getRadius(impostor: PhysicsImpostor): number;
  27307. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27308. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27309. dispose(): void;
  27310. }
  27311. /**
  27312. * Interface used to define a physics engine
  27313. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27314. */
  27315. export interface IPhysicsEngine {
  27316. /**
  27317. * Gets the gravity vector used by the simulation
  27318. */
  27319. gravity: Vector3;
  27320. /**
  27321. * Sets the gravity vector used by the simulation
  27322. * @param gravity defines the gravity vector to use
  27323. */
  27324. setGravity(gravity: Vector3): void;
  27325. /**
  27326. * Set the time step of the physics engine.
  27327. * Default is 1/60.
  27328. * To slow it down, enter 1/600 for example.
  27329. * To speed it up, 1/30
  27330. * @param newTimeStep the new timestep to apply to this world.
  27331. */
  27332. setTimeStep(newTimeStep: number): void;
  27333. /**
  27334. * Get the time step of the physics engine.
  27335. * @returns the current time step
  27336. */
  27337. getTimeStep(): number;
  27338. /**
  27339. * Set the sub time step of the physics engine.
  27340. * Default is 0 meaning there is no sub steps
  27341. * To increase physics resolution precision, set a small value (like 1 ms)
  27342. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27343. */
  27344. setSubTimeStep(subTimeStep: number): void;
  27345. /**
  27346. * Get the sub time step of the physics engine.
  27347. * @returns the current sub time step
  27348. */
  27349. getSubTimeStep(): number;
  27350. /**
  27351. * Release all resources
  27352. */
  27353. dispose(): void;
  27354. /**
  27355. * Gets the name of the current physics plugin
  27356. * @returns the name of the plugin
  27357. */
  27358. getPhysicsPluginName(): string;
  27359. /**
  27360. * Adding a new impostor for the impostor tracking.
  27361. * This will be done by the impostor itself.
  27362. * @param impostor the impostor to add
  27363. */
  27364. addImpostor(impostor: PhysicsImpostor): void;
  27365. /**
  27366. * Remove an impostor from the engine.
  27367. * This impostor and its mesh will not longer be updated by the physics engine.
  27368. * @param impostor the impostor to remove
  27369. */
  27370. removeImpostor(impostor: PhysicsImpostor): void;
  27371. /**
  27372. * Add a joint to the physics engine
  27373. * @param mainImpostor defines the main impostor to which the joint is added.
  27374. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27375. * @param joint defines the joint that will connect both impostors.
  27376. */
  27377. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27378. /**
  27379. * Removes a joint from the simulation
  27380. * @param mainImpostor defines the impostor used with the joint
  27381. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27382. * @param joint defines the joint to remove
  27383. */
  27384. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27385. /**
  27386. * Gets the current plugin used to run the simulation
  27387. * @returns current plugin
  27388. */
  27389. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27390. /**
  27391. * Gets the list of physic impostors
  27392. * @returns an array of PhysicsImpostor
  27393. */
  27394. getImpostors(): Array<PhysicsImpostor>;
  27395. /**
  27396. * Gets the impostor for a physics enabled object
  27397. * @param object defines the object impersonated by the impostor
  27398. * @returns the PhysicsImpostor or null if not found
  27399. */
  27400. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27401. /**
  27402. * Gets the impostor for a physics body object
  27403. * @param body defines physics body used by the impostor
  27404. * @returns the PhysicsImpostor or null if not found
  27405. */
  27406. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27407. /**
  27408. * Does a raycast in the physics world
  27409. * @param from when should the ray start?
  27410. * @param to when should the ray end?
  27411. * @returns PhysicsRaycastResult
  27412. */
  27413. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27414. /**
  27415. * Called by the scene. No need to call it.
  27416. * @param delta defines the timespam between frames
  27417. */
  27418. _step(delta: number): void;
  27419. }
  27420. }
  27421. declare module "babylonjs/Physics/physicsImpostor" {
  27422. import { Nullable, IndicesArray } from "babylonjs/types";
  27423. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27424. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27426. import { Scene } from "babylonjs/scene";
  27427. import { Bone } from "babylonjs/Bones/bone";
  27428. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27429. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27430. import { Space } from "babylonjs/Maths/math.axis";
  27431. /**
  27432. * The interface for the physics imposter parameters
  27433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27434. */
  27435. export interface PhysicsImpostorParameters {
  27436. /**
  27437. * The mass of the physics imposter
  27438. */
  27439. mass: number;
  27440. /**
  27441. * The friction of the physics imposter
  27442. */
  27443. friction?: number;
  27444. /**
  27445. * The coefficient of restitution of the physics imposter
  27446. */
  27447. restitution?: number;
  27448. /**
  27449. * The native options of the physics imposter
  27450. */
  27451. nativeOptions?: any;
  27452. /**
  27453. * Specifies if the parent should be ignored
  27454. */
  27455. ignoreParent?: boolean;
  27456. /**
  27457. * Specifies if bi-directional transformations should be disabled
  27458. */
  27459. disableBidirectionalTransformation?: boolean;
  27460. /**
  27461. * The pressure inside the physics imposter, soft object only
  27462. */
  27463. pressure?: number;
  27464. /**
  27465. * The stiffness the physics imposter, soft object only
  27466. */
  27467. stiffness?: number;
  27468. /**
  27469. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27470. */
  27471. velocityIterations?: number;
  27472. /**
  27473. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27474. */
  27475. positionIterations?: number;
  27476. /**
  27477. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27478. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27479. * Add to fix multiple points
  27480. */
  27481. fixedPoints?: number;
  27482. /**
  27483. * The collision margin around a soft object
  27484. */
  27485. margin?: number;
  27486. /**
  27487. * The collision margin around a soft object
  27488. */
  27489. damping?: number;
  27490. /**
  27491. * The path for a rope based on an extrusion
  27492. */
  27493. path?: any;
  27494. /**
  27495. * The shape of an extrusion used for a rope based on an extrusion
  27496. */
  27497. shape?: any;
  27498. }
  27499. /**
  27500. * Interface for a physics-enabled object
  27501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27502. */
  27503. export interface IPhysicsEnabledObject {
  27504. /**
  27505. * The position of the physics-enabled object
  27506. */
  27507. position: Vector3;
  27508. /**
  27509. * The rotation of the physics-enabled object
  27510. */
  27511. rotationQuaternion: Nullable<Quaternion>;
  27512. /**
  27513. * The scale of the physics-enabled object
  27514. */
  27515. scaling: Vector3;
  27516. /**
  27517. * The rotation of the physics-enabled object
  27518. */
  27519. rotation?: Vector3;
  27520. /**
  27521. * The parent of the physics-enabled object
  27522. */
  27523. parent?: any;
  27524. /**
  27525. * The bounding info of the physics-enabled object
  27526. * @returns The bounding info of the physics-enabled object
  27527. */
  27528. getBoundingInfo(): BoundingInfo;
  27529. /**
  27530. * Computes the world matrix
  27531. * @param force Specifies if the world matrix should be computed by force
  27532. * @returns A world matrix
  27533. */
  27534. computeWorldMatrix(force: boolean): Matrix;
  27535. /**
  27536. * Gets the world matrix
  27537. * @returns A world matrix
  27538. */
  27539. getWorldMatrix?(): Matrix;
  27540. /**
  27541. * Gets the child meshes
  27542. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27543. * @returns An array of abstract meshes
  27544. */
  27545. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27546. /**
  27547. * Gets the vertex data
  27548. * @param kind The type of vertex data
  27549. * @returns A nullable array of numbers, or a float32 array
  27550. */
  27551. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27552. /**
  27553. * Gets the indices from the mesh
  27554. * @returns A nullable array of index arrays
  27555. */
  27556. getIndices?(): Nullable<IndicesArray>;
  27557. /**
  27558. * Gets the scene from the mesh
  27559. * @returns the indices array or null
  27560. */
  27561. getScene?(): Scene;
  27562. /**
  27563. * Gets the absolute position from the mesh
  27564. * @returns the absolute position
  27565. */
  27566. getAbsolutePosition(): Vector3;
  27567. /**
  27568. * Gets the absolute pivot point from the mesh
  27569. * @returns the absolute pivot point
  27570. */
  27571. getAbsolutePivotPoint(): Vector3;
  27572. /**
  27573. * Rotates the mesh
  27574. * @param axis The axis of rotation
  27575. * @param amount The amount of rotation
  27576. * @param space The space of the rotation
  27577. * @returns The rotation transform node
  27578. */
  27579. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27580. /**
  27581. * Translates the mesh
  27582. * @param axis The axis of translation
  27583. * @param distance The distance of translation
  27584. * @param space The space of the translation
  27585. * @returns The transform node
  27586. */
  27587. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27588. /**
  27589. * Sets the absolute position of the mesh
  27590. * @param absolutePosition The absolute position of the mesh
  27591. * @returns The transform node
  27592. */
  27593. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27594. /**
  27595. * Gets the class name of the mesh
  27596. * @returns The class name
  27597. */
  27598. getClassName(): string;
  27599. }
  27600. /**
  27601. * Represents a physics imposter
  27602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27603. */
  27604. export class PhysicsImpostor {
  27605. /**
  27606. * The physics-enabled object used as the physics imposter
  27607. */
  27608. object: IPhysicsEnabledObject;
  27609. /**
  27610. * The type of the physics imposter
  27611. */
  27612. type: number;
  27613. private _options;
  27614. private _scene?;
  27615. /**
  27616. * The default object size of the imposter
  27617. */
  27618. static DEFAULT_OBJECT_SIZE: Vector3;
  27619. /**
  27620. * The identity quaternion of the imposter
  27621. */
  27622. static IDENTITY_QUATERNION: Quaternion;
  27623. /** @hidden */
  27624. _pluginData: any;
  27625. private _physicsEngine;
  27626. private _physicsBody;
  27627. private _bodyUpdateRequired;
  27628. private _onBeforePhysicsStepCallbacks;
  27629. private _onAfterPhysicsStepCallbacks;
  27630. /** @hidden */
  27631. _onPhysicsCollideCallbacks: Array<{
  27632. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27633. otherImpostors: Array<PhysicsImpostor>;
  27634. }>;
  27635. private _deltaPosition;
  27636. private _deltaRotation;
  27637. private _deltaRotationConjugated;
  27638. /** @hidden */
  27639. _isFromLine: boolean;
  27640. private _parent;
  27641. private _isDisposed;
  27642. private static _tmpVecs;
  27643. private static _tmpQuat;
  27644. /**
  27645. * Specifies if the physics imposter is disposed
  27646. */
  27647. get isDisposed(): boolean;
  27648. /**
  27649. * Gets the mass of the physics imposter
  27650. */
  27651. get mass(): number;
  27652. set mass(value: number);
  27653. /**
  27654. * Gets the coefficient of friction
  27655. */
  27656. get friction(): number;
  27657. /**
  27658. * Sets the coefficient of friction
  27659. */
  27660. set friction(value: number);
  27661. /**
  27662. * Gets the coefficient of restitution
  27663. */
  27664. get restitution(): number;
  27665. /**
  27666. * Sets the coefficient of restitution
  27667. */
  27668. set restitution(value: number);
  27669. /**
  27670. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27671. */
  27672. get pressure(): number;
  27673. /**
  27674. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27675. */
  27676. set pressure(value: number);
  27677. /**
  27678. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27679. */
  27680. get stiffness(): number;
  27681. /**
  27682. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27683. */
  27684. set stiffness(value: number);
  27685. /**
  27686. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27687. */
  27688. get velocityIterations(): number;
  27689. /**
  27690. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27691. */
  27692. set velocityIterations(value: number);
  27693. /**
  27694. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27695. */
  27696. get positionIterations(): number;
  27697. /**
  27698. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27699. */
  27700. set positionIterations(value: number);
  27701. /**
  27702. * The unique id of the physics imposter
  27703. * set by the physics engine when adding this impostor to the array
  27704. */
  27705. uniqueId: number;
  27706. /**
  27707. * @hidden
  27708. */
  27709. soft: boolean;
  27710. /**
  27711. * @hidden
  27712. */
  27713. segments: number;
  27714. private _joints;
  27715. /**
  27716. * Initializes the physics imposter
  27717. * @param object The physics-enabled object used as the physics imposter
  27718. * @param type The type of the physics imposter
  27719. * @param _options The options for the physics imposter
  27720. * @param _scene The Babylon scene
  27721. */
  27722. constructor(
  27723. /**
  27724. * The physics-enabled object used as the physics imposter
  27725. */
  27726. object: IPhysicsEnabledObject,
  27727. /**
  27728. * The type of the physics imposter
  27729. */
  27730. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27731. /**
  27732. * This function will completly initialize this impostor.
  27733. * It will create a new body - but only if this mesh has no parent.
  27734. * If it has, this impostor will not be used other than to define the impostor
  27735. * of the child mesh.
  27736. * @hidden
  27737. */
  27738. _init(): void;
  27739. private _getPhysicsParent;
  27740. /**
  27741. * Should a new body be generated.
  27742. * @returns boolean specifying if body initialization is required
  27743. */
  27744. isBodyInitRequired(): boolean;
  27745. /**
  27746. * Sets the updated scaling
  27747. * @param updated Specifies if the scaling is updated
  27748. */
  27749. setScalingUpdated(): void;
  27750. /**
  27751. * Force a regeneration of this or the parent's impostor's body.
  27752. * Use under cautious - This will remove all joints already implemented.
  27753. */
  27754. forceUpdate(): void;
  27755. /**
  27756. * Gets the body that holds this impostor. Either its own, or its parent.
  27757. */
  27758. get physicsBody(): any;
  27759. /**
  27760. * Get the parent of the physics imposter
  27761. * @returns Physics imposter or null
  27762. */
  27763. get parent(): Nullable<PhysicsImpostor>;
  27764. /**
  27765. * Sets the parent of the physics imposter
  27766. */
  27767. set parent(value: Nullable<PhysicsImpostor>);
  27768. /**
  27769. * Set the physics body. Used mainly by the physics engine/plugin
  27770. */
  27771. set physicsBody(physicsBody: any);
  27772. /**
  27773. * Resets the update flags
  27774. */
  27775. resetUpdateFlags(): void;
  27776. /**
  27777. * Gets the object extend size
  27778. * @returns the object extend size
  27779. */
  27780. getObjectExtendSize(): Vector3;
  27781. /**
  27782. * Gets the object center
  27783. * @returns The object center
  27784. */
  27785. getObjectCenter(): Vector3;
  27786. /**
  27787. * Get a specific parameter from the options parameters
  27788. * @param paramName The object parameter name
  27789. * @returns The object parameter
  27790. */
  27791. getParam(paramName: string): any;
  27792. /**
  27793. * Sets a specific parameter in the options given to the physics plugin
  27794. * @param paramName The parameter name
  27795. * @param value The value of the parameter
  27796. */
  27797. setParam(paramName: string, value: number): void;
  27798. /**
  27799. * Specifically change the body's mass option. Won't recreate the physics body object
  27800. * @param mass The mass of the physics imposter
  27801. */
  27802. setMass(mass: number): void;
  27803. /**
  27804. * Gets the linear velocity
  27805. * @returns linear velocity or null
  27806. */
  27807. getLinearVelocity(): Nullable<Vector3>;
  27808. /**
  27809. * Sets the linear velocity
  27810. * @param velocity linear velocity or null
  27811. */
  27812. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27813. /**
  27814. * Gets the angular velocity
  27815. * @returns angular velocity or null
  27816. */
  27817. getAngularVelocity(): Nullable<Vector3>;
  27818. /**
  27819. * Sets the angular velocity
  27820. * @param velocity The velocity or null
  27821. */
  27822. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27823. /**
  27824. * Execute a function with the physics plugin native code
  27825. * Provide a function the will have two variables - the world object and the physics body object
  27826. * @param func The function to execute with the physics plugin native code
  27827. */
  27828. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27829. /**
  27830. * Register a function that will be executed before the physics world is stepping forward
  27831. * @param func The function to execute before the physics world is stepped forward
  27832. */
  27833. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27834. /**
  27835. * Unregister a function that will be executed before the physics world is stepping forward
  27836. * @param func The function to execute before the physics world is stepped forward
  27837. */
  27838. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27839. /**
  27840. * Register a function that will be executed after the physics step
  27841. * @param func The function to execute after physics step
  27842. */
  27843. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27844. /**
  27845. * Unregisters a function that will be executed after the physics step
  27846. * @param func The function to execute after physics step
  27847. */
  27848. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27849. /**
  27850. * register a function that will be executed when this impostor collides against a different body
  27851. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27852. * @param func Callback that is executed on collision
  27853. */
  27854. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27855. /**
  27856. * Unregisters the physics imposter on contact
  27857. * @param collideAgainst The physics object to collide against
  27858. * @param func Callback to execute on collision
  27859. */
  27860. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27861. private _tmpQuat;
  27862. private _tmpQuat2;
  27863. /**
  27864. * Get the parent rotation
  27865. * @returns The parent rotation
  27866. */
  27867. getParentsRotation(): Quaternion;
  27868. /**
  27869. * this function is executed by the physics engine.
  27870. */
  27871. beforeStep: () => void;
  27872. /**
  27873. * this function is executed by the physics engine
  27874. */
  27875. afterStep: () => void;
  27876. /**
  27877. * Legacy collision detection event support
  27878. */
  27879. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27880. /**
  27881. * event and body object due to cannon's event-based architecture.
  27882. */
  27883. onCollide: (e: {
  27884. body: any;
  27885. }) => void;
  27886. /**
  27887. * Apply a force
  27888. * @param force The force to apply
  27889. * @param contactPoint The contact point for the force
  27890. * @returns The physics imposter
  27891. */
  27892. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27893. /**
  27894. * Apply an impulse
  27895. * @param force The impulse force
  27896. * @param contactPoint The contact point for the impulse force
  27897. * @returns The physics imposter
  27898. */
  27899. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27900. /**
  27901. * A help function to create a joint
  27902. * @param otherImpostor A physics imposter used to create a joint
  27903. * @param jointType The type of joint
  27904. * @param jointData The data for the joint
  27905. * @returns The physics imposter
  27906. */
  27907. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27908. /**
  27909. * Add a joint to this impostor with a different impostor
  27910. * @param otherImpostor A physics imposter used to add a joint
  27911. * @param joint The joint to add
  27912. * @returns The physics imposter
  27913. */
  27914. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27915. /**
  27916. * Add an anchor to a cloth impostor
  27917. * @param otherImpostor rigid impostor to anchor to
  27918. * @param width ratio across width from 0 to 1
  27919. * @param height ratio up height from 0 to 1
  27920. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27921. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27922. * @returns impostor the soft imposter
  27923. */
  27924. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27925. /**
  27926. * Add a hook to a rope impostor
  27927. * @param otherImpostor rigid impostor to anchor to
  27928. * @param length ratio across rope from 0 to 1
  27929. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27930. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27931. * @returns impostor the rope imposter
  27932. */
  27933. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27934. /**
  27935. * Will keep this body still, in a sleep mode.
  27936. * @returns the physics imposter
  27937. */
  27938. sleep(): PhysicsImpostor;
  27939. /**
  27940. * Wake the body up.
  27941. * @returns The physics imposter
  27942. */
  27943. wakeUp(): PhysicsImpostor;
  27944. /**
  27945. * Clones the physics imposter
  27946. * @param newObject The physics imposter clones to this physics-enabled object
  27947. * @returns A nullable physics imposter
  27948. */
  27949. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27950. /**
  27951. * Disposes the physics imposter
  27952. */
  27953. dispose(): void;
  27954. /**
  27955. * Sets the delta position
  27956. * @param position The delta position amount
  27957. */
  27958. setDeltaPosition(position: Vector3): void;
  27959. /**
  27960. * Sets the delta rotation
  27961. * @param rotation The delta rotation amount
  27962. */
  27963. setDeltaRotation(rotation: Quaternion): void;
  27964. /**
  27965. * Gets the box size of the physics imposter and stores the result in the input parameter
  27966. * @param result Stores the box size
  27967. * @returns The physics imposter
  27968. */
  27969. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27970. /**
  27971. * Gets the radius of the physics imposter
  27972. * @returns Radius of the physics imposter
  27973. */
  27974. getRadius(): number;
  27975. /**
  27976. * Sync a bone with this impostor
  27977. * @param bone The bone to sync to the impostor.
  27978. * @param boneMesh The mesh that the bone is influencing.
  27979. * @param jointPivot The pivot of the joint / bone in local space.
  27980. * @param distToJoint Optional distance from the impostor to the joint.
  27981. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27982. */
  27983. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27984. /**
  27985. * Sync impostor to a bone
  27986. * @param bone The bone that the impostor will be synced to.
  27987. * @param boneMesh The mesh that the bone is influencing.
  27988. * @param jointPivot The pivot of the joint / bone in local space.
  27989. * @param distToJoint Optional distance from the impostor to the joint.
  27990. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27991. * @param boneAxis Optional vector3 axis the bone is aligned with
  27992. */
  27993. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27994. /**
  27995. * No-Imposter type
  27996. */
  27997. static NoImpostor: number;
  27998. /**
  27999. * Sphere-Imposter type
  28000. */
  28001. static SphereImpostor: number;
  28002. /**
  28003. * Box-Imposter type
  28004. */
  28005. static BoxImpostor: number;
  28006. /**
  28007. * Plane-Imposter type
  28008. */
  28009. static PlaneImpostor: number;
  28010. /**
  28011. * Mesh-imposter type
  28012. */
  28013. static MeshImpostor: number;
  28014. /**
  28015. * Capsule-Impostor type (Ammo.js plugin only)
  28016. */
  28017. static CapsuleImpostor: number;
  28018. /**
  28019. * Cylinder-Imposter type
  28020. */
  28021. static CylinderImpostor: number;
  28022. /**
  28023. * Particle-Imposter type
  28024. */
  28025. static ParticleImpostor: number;
  28026. /**
  28027. * Heightmap-Imposter type
  28028. */
  28029. static HeightmapImpostor: number;
  28030. /**
  28031. * ConvexHull-Impostor type (Ammo.js plugin only)
  28032. */
  28033. static ConvexHullImpostor: number;
  28034. /**
  28035. * Custom-Imposter type (Ammo.js plugin only)
  28036. */
  28037. static CustomImpostor: number;
  28038. /**
  28039. * Rope-Imposter type
  28040. */
  28041. static RopeImpostor: number;
  28042. /**
  28043. * Cloth-Imposter type
  28044. */
  28045. static ClothImpostor: number;
  28046. /**
  28047. * Softbody-Imposter type
  28048. */
  28049. static SoftbodyImpostor: number;
  28050. }
  28051. }
  28052. declare module "babylonjs/Meshes/mesh" {
  28053. import { Observable } from "babylonjs/Misc/observable";
  28054. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28055. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28056. import { Camera } from "babylonjs/Cameras/camera";
  28057. import { Scene } from "babylonjs/scene";
  28058. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28059. import { Color4 } from "babylonjs/Maths/math.color";
  28060. import { Engine } from "babylonjs/Engines/engine";
  28061. import { Node } from "babylonjs/node";
  28062. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28063. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28064. import { Buffer } from "babylonjs/Meshes/buffer";
  28065. import { Geometry } from "babylonjs/Meshes/geometry";
  28066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28067. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28068. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28069. import { Effect } from "babylonjs/Materials/effect";
  28070. import { Material } from "babylonjs/Materials/material";
  28071. import { Skeleton } from "babylonjs/Bones/skeleton";
  28072. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28073. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28074. import { Path3D } from "babylonjs/Maths/math.path";
  28075. import { Plane } from "babylonjs/Maths/math.plane";
  28076. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28077. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28078. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28079. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28080. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28081. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28082. /**
  28083. * @hidden
  28084. **/
  28085. export class _CreationDataStorage {
  28086. closePath?: boolean;
  28087. closeArray?: boolean;
  28088. idx: number[];
  28089. dashSize: number;
  28090. gapSize: number;
  28091. path3D: Path3D;
  28092. pathArray: Vector3[][];
  28093. arc: number;
  28094. radius: number;
  28095. cap: number;
  28096. tessellation: number;
  28097. }
  28098. /**
  28099. * @hidden
  28100. **/
  28101. class _InstanceDataStorage {
  28102. visibleInstances: any;
  28103. batchCache: _InstancesBatch;
  28104. instancesBufferSize: number;
  28105. instancesBuffer: Nullable<Buffer>;
  28106. instancesData: Float32Array;
  28107. overridenInstanceCount: number;
  28108. isFrozen: boolean;
  28109. previousBatch: Nullable<_InstancesBatch>;
  28110. hardwareInstancedRendering: boolean;
  28111. sideOrientation: number;
  28112. manualUpdate: boolean;
  28113. }
  28114. /**
  28115. * @hidden
  28116. **/
  28117. export class _InstancesBatch {
  28118. mustReturn: boolean;
  28119. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28120. renderSelf: boolean[];
  28121. hardwareInstancedRendering: boolean[];
  28122. }
  28123. /**
  28124. * @hidden
  28125. **/
  28126. class _ThinInstanceDataStorage {
  28127. instancesCount: number;
  28128. matrixBuffer: Nullable<Buffer>;
  28129. matrixBufferSize: number;
  28130. matrixData: Nullable<Float32Array>;
  28131. boundingVectors: Array<Vector3>;
  28132. }
  28133. /**
  28134. * Class used to represent renderable models
  28135. */
  28136. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28137. /**
  28138. * Mesh side orientation : usually the external or front surface
  28139. */
  28140. static readonly FRONTSIDE: number;
  28141. /**
  28142. * Mesh side orientation : usually the internal or back surface
  28143. */
  28144. static readonly BACKSIDE: number;
  28145. /**
  28146. * Mesh side orientation : both internal and external or front and back surfaces
  28147. */
  28148. static readonly DOUBLESIDE: number;
  28149. /**
  28150. * Mesh side orientation : by default, `FRONTSIDE`
  28151. */
  28152. static readonly DEFAULTSIDE: number;
  28153. /**
  28154. * Mesh cap setting : no cap
  28155. */
  28156. static readonly NO_CAP: number;
  28157. /**
  28158. * Mesh cap setting : one cap at the beginning of the mesh
  28159. */
  28160. static readonly CAP_START: number;
  28161. /**
  28162. * Mesh cap setting : one cap at the end of the mesh
  28163. */
  28164. static readonly CAP_END: number;
  28165. /**
  28166. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28167. */
  28168. static readonly CAP_ALL: number;
  28169. /**
  28170. * Mesh pattern setting : no flip or rotate
  28171. */
  28172. static readonly NO_FLIP: number;
  28173. /**
  28174. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28175. */
  28176. static readonly FLIP_TILE: number;
  28177. /**
  28178. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28179. */
  28180. static readonly ROTATE_TILE: number;
  28181. /**
  28182. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28183. */
  28184. static readonly FLIP_ROW: number;
  28185. /**
  28186. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28187. */
  28188. static readonly ROTATE_ROW: number;
  28189. /**
  28190. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28191. */
  28192. static readonly FLIP_N_ROTATE_TILE: number;
  28193. /**
  28194. * Mesh pattern setting : rotate pattern and rotate
  28195. */
  28196. static readonly FLIP_N_ROTATE_ROW: number;
  28197. /**
  28198. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28199. */
  28200. static readonly CENTER: number;
  28201. /**
  28202. * Mesh tile positioning : part tiles on left
  28203. */
  28204. static readonly LEFT: number;
  28205. /**
  28206. * Mesh tile positioning : part tiles on right
  28207. */
  28208. static readonly RIGHT: number;
  28209. /**
  28210. * Mesh tile positioning : part tiles on top
  28211. */
  28212. static readonly TOP: number;
  28213. /**
  28214. * Mesh tile positioning : part tiles on bottom
  28215. */
  28216. static readonly BOTTOM: number;
  28217. /**
  28218. * Gets the default side orientation.
  28219. * @param orientation the orientation to value to attempt to get
  28220. * @returns the default orientation
  28221. * @hidden
  28222. */
  28223. static _GetDefaultSideOrientation(orientation?: number): number;
  28224. private _internalMeshDataInfo;
  28225. /**
  28226. * An event triggered before rendering the mesh
  28227. */
  28228. get onBeforeRenderObservable(): Observable<Mesh>;
  28229. /**
  28230. * An event triggered before binding the mesh
  28231. */
  28232. get onBeforeBindObservable(): Observable<Mesh>;
  28233. /**
  28234. * An event triggered after rendering the mesh
  28235. */
  28236. get onAfterRenderObservable(): Observable<Mesh>;
  28237. /**
  28238. * An event triggered before drawing the mesh
  28239. */
  28240. get onBeforeDrawObservable(): Observable<Mesh>;
  28241. private _onBeforeDrawObserver;
  28242. /**
  28243. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28244. */
  28245. set onBeforeDraw(callback: () => void);
  28246. get hasInstances(): boolean;
  28247. get hasThinInstances(): boolean;
  28248. /**
  28249. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28250. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28251. */
  28252. delayLoadState: number;
  28253. /**
  28254. * Gets the list of instances created from this mesh
  28255. * it is not supposed to be modified manually.
  28256. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28257. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28258. */
  28259. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28260. /**
  28261. * Gets the file containing delay loading data for this mesh
  28262. */
  28263. delayLoadingFile: string;
  28264. /** @hidden */
  28265. _binaryInfo: any;
  28266. /**
  28267. * User defined function used to change how LOD level selection is done
  28268. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28269. */
  28270. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28271. /**
  28272. * Gets or sets the morph target manager
  28273. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28274. */
  28275. get morphTargetManager(): Nullable<MorphTargetManager>;
  28276. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28277. /** @hidden */
  28278. _creationDataStorage: Nullable<_CreationDataStorage>;
  28279. /** @hidden */
  28280. _geometry: Nullable<Geometry>;
  28281. /** @hidden */
  28282. _delayInfo: Array<string>;
  28283. /** @hidden */
  28284. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28285. /** @hidden */
  28286. _instanceDataStorage: _InstanceDataStorage;
  28287. /** @hidden */
  28288. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28289. private _effectiveMaterial;
  28290. /** @hidden */
  28291. _shouldGenerateFlatShading: boolean;
  28292. /** @hidden */
  28293. _originalBuilderSideOrientation: number;
  28294. /**
  28295. * Use this property to change the original side orientation defined at construction time
  28296. */
  28297. overrideMaterialSideOrientation: Nullable<number>;
  28298. /**
  28299. * Gets the source mesh (the one used to clone this one from)
  28300. */
  28301. get source(): Nullable<Mesh>;
  28302. /**
  28303. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28304. */
  28305. get isUnIndexed(): boolean;
  28306. set isUnIndexed(value: boolean);
  28307. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28308. get worldMatrixInstancedBuffer(): Float32Array;
  28309. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28310. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28311. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28312. /**
  28313. * @constructor
  28314. * @param name The value used by scene.getMeshByName() to do a lookup.
  28315. * @param scene The scene to add this mesh to.
  28316. * @param parent The parent of this mesh, if it has one
  28317. * @param source An optional Mesh from which geometry is shared, cloned.
  28318. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28319. * When false, achieved by calling a clone(), also passing False.
  28320. * This will make creation of children, recursive.
  28321. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28322. */
  28323. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28324. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28325. doNotInstantiate: boolean;
  28326. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28327. /**
  28328. * Gets the class name
  28329. * @returns the string "Mesh".
  28330. */
  28331. getClassName(): string;
  28332. /** @hidden */
  28333. get _isMesh(): boolean;
  28334. /**
  28335. * Returns a description of this mesh
  28336. * @param fullDetails define if full details about this mesh must be used
  28337. * @returns a descriptive string representing this mesh
  28338. */
  28339. toString(fullDetails?: boolean): string;
  28340. /** @hidden */
  28341. _unBindEffect(): void;
  28342. /**
  28343. * Gets a boolean indicating if this mesh has LOD
  28344. */
  28345. get hasLODLevels(): boolean;
  28346. /**
  28347. * Gets the list of MeshLODLevel associated with the current mesh
  28348. * @returns an array of MeshLODLevel
  28349. */
  28350. getLODLevels(): MeshLODLevel[];
  28351. private _sortLODLevels;
  28352. /**
  28353. * Add a mesh as LOD level triggered at the given distance.
  28354. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28355. * @param distance The distance from the center of the object to show this level
  28356. * @param mesh The mesh to be added as LOD level (can be null)
  28357. * @return This mesh (for chaining)
  28358. */
  28359. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28360. /**
  28361. * Returns the LOD level mesh at the passed distance or null if not found.
  28362. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28363. * @param distance The distance from the center of the object to show this level
  28364. * @returns a Mesh or `null`
  28365. */
  28366. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28367. /**
  28368. * Remove a mesh from the LOD array
  28369. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28370. * @param mesh defines the mesh to be removed
  28371. * @return This mesh (for chaining)
  28372. */
  28373. removeLODLevel(mesh: Mesh): Mesh;
  28374. /**
  28375. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28376. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28377. * @param camera defines the camera to use to compute distance
  28378. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28379. * @return This mesh (for chaining)
  28380. */
  28381. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28382. /**
  28383. * Gets the mesh internal Geometry object
  28384. */
  28385. get geometry(): Nullable<Geometry>;
  28386. /**
  28387. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28388. * @returns the total number of vertices
  28389. */
  28390. getTotalVertices(): number;
  28391. /**
  28392. * Returns the content of an associated vertex buffer
  28393. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28394. * - VertexBuffer.PositionKind
  28395. * - VertexBuffer.UVKind
  28396. * - VertexBuffer.UV2Kind
  28397. * - VertexBuffer.UV3Kind
  28398. * - VertexBuffer.UV4Kind
  28399. * - VertexBuffer.UV5Kind
  28400. * - VertexBuffer.UV6Kind
  28401. * - VertexBuffer.ColorKind
  28402. * - VertexBuffer.MatricesIndicesKind
  28403. * - VertexBuffer.MatricesIndicesExtraKind
  28404. * - VertexBuffer.MatricesWeightsKind
  28405. * - VertexBuffer.MatricesWeightsExtraKind
  28406. * @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
  28407. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28408. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28409. */
  28410. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28411. /**
  28412. * Returns the mesh VertexBuffer object from the requested `kind`
  28413. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28414. * - VertexBuffer.PositionKind
  28415. * - VertexBuffer.NormalKind
  28416. * - VertexBuffer.UVKind
  28417. * - VertexBuffer.UV2Kind
  28418. * - VertexBuffer.UV3Kind
  28419. * - VertexBuffer.UV4Kind
  28420. * - VertexBuffer.UV5Kind
  28421. * - VertexBuffer.UV6Kind
  28422. * - VertexBuffer.ColorKind
  28423. * - VertexBuffer.MatricesIndicesKind
  28424. * - VertexBuffer.MatricesIndicesExtraKind
  28425. * - VertexBuffer.MatricesWeightsKind
  28426. * - VertexBuffer.MatricesWeightsExtraKind
  28427. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28428. */
  28429. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28430. /**
  28431. * Tests if a specific vertex buffer is associated with this mesh
  28432. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28433. * - VertexBuffer.PositionKind
  28434. * - VertexBuffer.NormalKind
  28435. * - VertexBuffer.UVKind
  28436. * - VertexBuffer.UV2Kind
  28437. * - VertexBuffer.UV3Kind
  28438. * - VertexBuffer.UV4Kind
  28439. * - VertexBuffer.UV5Kind
  28440. * - VertexBuffer.UV6Kind
  28441. * - VertexBuffer.ColorKind
  28442. * - VertexBuffer.MatricesIndicesKind
  28443. * - VertexBuffer.MatricesIndicesExtraKind
  28444. * - VertexBuffer.MatricesWeightsKind
  28445. * - VertexBuffer.MatricesWeightsExtraKind
  28446. * @returns a boolean
  28447. */
  28448. isVerticesDataPresent(kind: string): boolean;
  28449. /**
  28450. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28451. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28452. * - VertexBuffer.PositionKind
  28453. * - VertexBuffer.UVKind
  28454. * - VertexBuffer.UV2Kind
  28455. * - VertexBuffer.UV3Kind
  28456. * - VertexBuffer.UV4Kind
  28457. * - VertexBuffer.UV5Kind
  28458. * - VertexBuffer.UV6Kind
  28459. * - VertexBuffer.ColorKind
  28460. * - VertexBuffer.MatricesIndicesKind
  28461. * - VertexBuffer.MatricesIndicesExtraKind
  28462. * - VertexBuffer.MatricesWeightsKind
  28463. * - VertexBuffer.MatricesWeightsExtraKind
  28464. * @returns a boolean
  28465. */
  28466. isVertexBufferUpdatable(kind: string): boolean;
  28467. /**
  28468. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28469. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28470. * - VertexBuffer.PositionKind
  28471. * - VertexBuffer.NormalKind
  28472. * - VertexBuffer.UVKind
  28473. * - VertexBuffer.UV2Kind
  28474. * - VertexBuffer.UV3Kind
  28475. * - VertexBuffer.UV4Kind
  28476. * - VertexBuffer.UV5Kind
  28477. * - VertexBuffer.UV6Kind
  28478. * - VertexBuffer.ColorKind
  28479. * - VertexBuffer.MatricesIndicesKind
  28480. * - VertexBuffer.MatricesIndicesExtraKind
  28481. * - VertexBuffer.MatricesWeightsKind
  28482. * - VertexBuffer.MatricesWeightsExtraKind
  28483. * @returns an array of strings
  28484. */
  28485. getVerticesDataKinds(): string[];
  28486. /**
  28487. * Returns a positive integer : the total number of indices in this mesh geometry.
  28488. * @returns the numner of indices or zero if the mesh has no geometry.
  28489. */
  28490. getTotalIndices(): number;
  28491. /**
  28492. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28493. * @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.
  28494. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28495. * @returns the indices array or an empty array if the mesh has no geometry
  28496. */
  28497. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28498. get isBlocked(): boolean;
  28499. /**
  28500. * Determine if the current mesh is ready to be rendered
  28501. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28502. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28503. * @returns true if all associated assets are ready (material, textures, shaders)
  28504. */
  28505. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28506. /**
  28507. * 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.
  28508. */
  28509. get areNormalsFrozen(): boolean;
  28510. /**
  28511. * 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.
  28512. * @returns the current mesh
  28513. */
  28514. freezeNormals(): Mesh;
  28515. /**
  28516. * 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
  28517. * @returns the current mesh
  28518. */
  28519. unfreezeNormals(): Mesh;
  28520. /**
  28521. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28522. */
  28523. set overridenInstanceCount(count: number);
  28524. /** @hidden */
  28525. _preActivate(): Mesh;
  28526. /** @hidden */
  28527. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28528. /** @hidden */
  28529. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28530. protected _afterComputeWorldMatrix(): void;
  28531. /**
  28532. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28533. * This means the mesh underlying bounding box and sphere are recomputed.
  28534. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28535. * @returns the current mesh
  28536. */
  28537. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28538. /** @hidden */
  28539. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28540. /**
  28541. * This function will subdivide the mesh into multiple submeshes
  28542. * @param count defines the expected number of submeshes
  28543. */
  28544. subdivide(count: number): void;
  28545. /**
  28546. * Copy a FloatArray into a specific associated vertex buffer
  28547. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28548. * - VertexBuffer.PositionKind
  28549. * - VertexBuffer.UVKind
  28550. * - VertexBuffer.UV2Kind
  28551. * - VertexBuffer.UV3Kind
  28552. * - VertexBuffer.UV4Kind
  28553. * - VertexBuffer.UV5Kind
  28554. * - VertexBuffer.UV6Kind
  28555. * - VertexBuffer.ColorKind
  28556. * - VertexBuffer.MatricesIndicesKind
  28557. * - VertexBuffer.MatricesIndicesExtraKind
  28558. * - VertexBuffer.MatricesWeightsKind
  28559. * - VertexBuffer.MatricesWeightsExtraKind
  28560. * @param data defines the data source
  28561. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28562. * @param stride defines the data stride size (can be null)
  28563. * @returns the current mesh
  28564. */
  28565. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28566. /**
  28567. * Delete a vertex buffer associated with this mesh
  28568. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28569. * - VertexBuffer.PositionKind
  28570. * - VertexBuffer.UVKind
  28571. * - VertexBuffer.UV2Kind
  28572. * - VertexBuffer.UV3Kind
  28573. * - VertexBuffer.UV4Kind
  28574. * - VertexBuffer.UV5Kind
  28575. * - VertexBuffer.UV6Kind
  28576. * - VertexBuffer.ColorKind
  28577. * - VertexBuffer.MatricesIndicesKind
  28578. * - VertexBuffer.MatricesIndicesExtraKind
  28579. * - VertexBuffer.MatricesWeightsKind
  28580. * - VertexBuffer.MatricesWeightsExtraKind
  28581. */
  28582. removeVerticesData(kind: string): void;
  28583. /**
  28584. * Flags an associated vertex buffer as updatable
  28585. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28586. * - VertexBuffer.PositionKind
  28587. * - VertexBuffer.UVKind
  28588. * - VertexBuffer.UV2Kind
  28589. * - VertexBuffer.UV3Kind
  28590. * - VertexBuffer.UV4Kind
  28591. * - VertexBuffer.UV5Kind
  28592. * - VertexBuffer.UV6Kind
  28593. * - VertexBuffer.ColorKind
  28594. * - VertexBuffer.MatricesIndicesKind
  28595. * - VertexBuffer.MatricesIndicesExtraKind
  28596. * - VertexBuffer.MatricesWeightsKind
  28597. * - VertexBuffer.MatricesWeightsExtraKind
  28598. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28599. */
  28600. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28601. /**
  28602. * Sets the mesh global Vertex Buffer
  28603. * @param buffer defines the buffer to use
  28604. * @returns the current mesh
  28605. */
  28606. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28607. /**
  28608. * Update a specific associated vertex buffer
  28609. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28610. * - VertexBuffer.PositionKind
  28611. * - VertexBuffer.UVKind
  28612. * - VertexBuffer.UV2Kind
  28613. * - VertexBuffer.UV3Kind
  28614. * - VertexBuffer.UV4Kind
  28615. * - VertexBuffer.UV5Kind
  28616. * - VertexBuffer.UV6Kind
  28617. * - VertexBuffer.ColorKind
  28618. * - VertexBuffer.MatricesIndicesKind
  28619. * - VertexBuffer.MatricesIndicesExtraKind
  28620. * - VertexBuffer.MatricesWeightsKind
  28621. * - VertexBuffer.MatricesWeightsExtraKind
  28622. * @param data defines the data source
  28623. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28624. * @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)
  28625. * @returns the current mesh
  28626. */
  28627. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28628. /**
  28629. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28630. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28631. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28632. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28633. * @returns the current mesh
  28634. */
  28635. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28636. /**
  28637. * Creates a un-shared specific occurence of the geometry for the mesh.
  28638. * @returns the current mesh
  28639. */
  28640. makeGeometryUnique(): Mesh;
  28641. /**
  28642. * Set the index buffer of this mesh
  28643. * @param indices defines the source data
  28644. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28645. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28646. * @returns the current mesh
  28647. */
  28648. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28649. /**
  28650. * Update the current index buffer
  28651. * @param indices defines the source data
  28652. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28653. * @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)
  28654. * @returns the current mesh
  28655. */
  28656. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28657. /**
  28658. * Invert the geometry to move from a right handed system to a left handed one.
  28659. * @returns the current mesh
  28660. */
  28661. toLeftHanded(): Mesh;
  28662. /** @hidden */
  28663. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28664. /** @hidden */
  28665. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28666. /**
  28667. * Registers for this mesh a javascript function called just before the rendering process
  28668. * @param func defines the function to call before rendering this mesh
  28669. * @returns the current mesh
  28670. */
  28671. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28672. /**
  28673. * Disposes a previously registered javascript function called before the rendering
  28674. * @param func defines the function to remove
  28675. * @returns the current mesh
  28676. */
  28677. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28678. /**
  28679. * Registers for this mesh a javascript function called just after the rendering is complete
  28680. * @param func defines the function to call after rendering this mesh
  28681. * @returns the current mesh
  28682. */
  28683. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28684. /**
  28685. * Disposes a previously registered javascript function called after the rendering.
  28686. * @param func defines the function to remove
  28687. * @returns the current mesh
  28688. */
  28689. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28690. /** @hidden */
  28691. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28692. /** @hidden */
  28693. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28694. /** @hidden */
  28695. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28696. /** @hidden */
  28697. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28698. /** @hidden */
  28699. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28700. /** @hidden */
  28701. _rebuild(): void;
  28702. /** @hidden */
  28703. _freeze(): void;
  28704. /** @hidden */
  28705. _unFreeze(): void;
  28706. /**
  28707. * 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
  28708. * @param subMesh defines the subMesh to render
  28709. * @param enableAlphaMode defines if alpha mode can be changed
  28710. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28711. * @returns the current mesh
  28712. */
  28713. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28714. private _onBeforeDraw;
  28715. /**
  28716. * Renormalize the mesh and patch it up if there are no weights
  28717. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28718. * However in the case of zero weights then we set just a single influence to 1.
  28719. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28720. */
  28721. cleanMatrixWeights(): void;
  28722. private normalizeSkinFourWeights;
  28723. private normalizeSkinWeightsAndExtra;
  28724. /**
  28725. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28726. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28727. * the user know there was an issue with importing the mesh
  28728. * @returns a validation object with skinned, valid and report string
  28729. */
  28730. validateSkinning(): {
  28731. skinned: boolean;
  28732. valid: boolean;
  28733. report: string;
  28734. };
  28735. /** @hidden */
  28736. _checkDelayState(): Mesh;
  28737. private _queueLoad;
  28738. /**
  28739. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28740. * A mesh is in the frustum if its bounding box intersects the frustum
  28741. * @param frustumPlanes defines the frustum to test
  28742. * @returns true if the mesh is in the frustum planes
  28743. */
  28744. isInFrustum(frustumPlanes: Plane[]): boolean;
  28745. /**
  28746. * Sets the mesh material by the material or multiMaterial `id` property
  28747. * @param id is a string identifying the material or the multiMaterial
  28748. * @returns the current mesh
  28749. */
  28750. setMaterialByID(id: string): Mesh;
  28751. /**
  28752. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28753. * @returns an array of IAnimatable
  28754. */
  28755. getAnimatables(): IAnimatable[];
  28756. /**
  28757. * Modifies the mesh geometry according to the passed transformation matrix.
  28758. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28759. * The mesh normals are modified using the same transformation.
  28760. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28761. * @param transform defines the transform matrix to use
  28762. * @see http://doc.babylonjs.com/resources/baking_transformations
  28763. * @returns the current mesh
  28764. */
  28765. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28766. /**
  28767. * Modifies the mesh geometry according to its own current World Matrix.
  28768. * The mesh World Matrix is then reset.
  28769. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28770. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28771. * @see http://doc.babylonjs.com/resources/baking_transformations
  28772. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28773. * @returns the current mesh
  28774. */
  28775. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28776. /** @hidden */
  28777. get _positions(): Nullable<Vector3[]>;
  28778. /** @hidden */
  28779. _resetPointsArrayCache(): Mesh;
  28780. /** @hidden */
  28781. _generatePointsArray(): boolean;
  28782. /**
  28783. * Returns a new Mesh object generated from the current mesh properties.
  28784. * This method must not get confused with createInstance()
  28785. * @param name is a string, the name given to the new mesh
  28786. * @param newParent can be any Node object (default `null`)
  28787. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28788. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28789. * @returns a new mesh
  28790. */
  28791. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28792. /**
  28793. * Releases resources associated with this mesh.
  28794. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28795. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28796. */
  28797. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28798. /** @hidden */
  28799. _disposeInstanceSpecificData(): void;
  28800. /** @hidden */
  28801. _disposeThinInstanceSpecificData(): void;
  28802. /**
  28803. * Modifies the mesh geometry according to a displacement map.
  28804. * 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.
  28805. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28806. * @param url is a string, the URL from the image file is to be downloaded.
  28807. * @param minHeight is the lower limit of the displacement.
  28808. * @param maxHeight is the upper limit of the displacement.
  28809. * @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.
  28810. * @param uvOffset is an optional vector2 used to offset UV.
  28811. * @param uvScale is an optional vector2 used to scale UV.
  28812. * @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.
  28813. * @returns the Mesh.
  28814. */
  28815. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28816. /**
  28817. * Modifies the mesh geometry according to a displacementMap buffer.
  28818. * 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.
  28819. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28820. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28821. * @param heightMapWidth is the width of the buffer image.
  28822. * @param heightMapHeight is the height of the buffer image.
  28823. * @param minHeight is the lower limit of the displacement.
  28824. * @param maxHeight is the upper limit of the displacement.
  28825. * @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.
  28826. * @param uvOffset is an optional vector2 used to offset UV.
  28827. * @param uvScale is an optional vector2 used to scale UV.
  28828. * @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.
  28829. * @returns the Mesh.
  28830. */
  28831. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28832. /**
  28833. * Modify the mesh to get a flat shading rendering.
  28834. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28835. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28836. * @returns current mesh
  28837. */
  28838. convertToFlatShadedMesh(): Mesh;
  28839. /**
  28840. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28841. * In other words, more vertices, no more indices and a single bigger VBO.
  28842. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28843. * @returns current mesh
  28844. */
  28845. convertToUnIndexedMesh(): Mesh;
  28846. /**
  28847. * Inverses facet orientations.
  28848. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28849. * @param flipNormals will also inverts the normals
  28850. * @returns current mesh
  28851. */
  28852. flipFaces(flipNormals?: boolean): Mesh;
  28853. /**
  28854. * Increase the number of facets and hence vertices in a mesh
  28855. * Vertex normals are interpolated from existing vertex normals
  28856. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28857. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28858. */
  28859. increaseVertices(numberPerEdge: number): void;
  28860. /**
  28861. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28862. * This will undo any application of covertToFlatShadedMesh
  28863. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28864. */
  28865. forceSharedVertices(): void;
  28866. /** @hidden */
  28867. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28868. /** @hidden */
  28869. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28870. /**
  28871. * Creates a new InstancedMesh object from the mesh model.
  28872. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28873. * @param name defines the name of the new instance
  28874. * @returns a new InstancedMesh
  28875. */
  28876. createInstance(name: string): InstancedMesh;
  28877. /**
  28878. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28879. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28880. * @returns the current mesh
  28881. */
  28882. synchronizeInstances(): Mesh;
  28883. /**
  28884. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28885. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28886. * This should be used together with the simplification to avoid disappearing triangles.
  28887. * @param successCallback an optional success callback to be called after the optimization finished.
  28888. * @returns the current mesh
  28889. */
  28890. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28891. /**
  28892. * Serialize current mesh
  28893. * @param serializationObject defines the object which will receive the serialization data
  28894. */
  28895. serialize(serializationObject: any): void;
  28896. /** @hidden */
  28897. _syncGeometryWithMorphTargetManager(): void;
  28898. /** @hidden */
  28899. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28900. /**
  28901. * Returns a new Mesh object parsed from the source provided.
  28902. * @param parsedMesh is the source
  28903. * @param scene defines the hosting scene
  28904. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28905. * @returns a new Mesh
  28906. */
  28907. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28908. /**
  28909. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28910. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28911. * @param name defines the name of the mesh to create
  28912. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28913. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28914. * @param closePath creates a seam between the first and the last points of each path of the path array
  28915. * @param offset is taken in account only if the `pathArray` is containing a single path
  28916. * @param scene defines the hosting scene
  28917. * @param updatable defines if the mesh must be flagged as updatable
  28918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28919. * @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)
  28920. * @returns a new Mesh
  28921. */
  28922. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28923. /**
  28924. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28925. * @param name defines the name of the mesh to create
  28926. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28927. * @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
  28928. * @param scene defines the hosting scene
  28929. * @param updatable defines if the mesh must be flagged as updatable
  28930. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28931. * @returns a new Mesh
  28932. */
  28933. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28934. /**
  28935. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28936. * @param name defines the name of the mesh to create
  28937. * @param size sets the size (float) of each box side (default 1)
  28938. * @param scene defines the hosting scene
  28939. * @param updatable defines if the mesh must be flagged as updatable
  28940. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28941. * @returns a new Mesh
  28942. */
  28943. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28944. /**
  28945. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28946. * @param name defines the name of the mesh to create
  28947. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28948. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28949. * @param scene defines the hosting scene
  28950. * @param updatable defines if the mesh must be flagged as updatable
  28951. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28952. * @returns a new Mesh
  28953. */
  28954. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28955. /**
  28956. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28957. * @param name defines the name of the mesh to create
  28958. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28959. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28960. * @param scene defines the hosting scene
  28961. * @returns a new Mesh
  28962. */
  28963. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28964. /**
  28965. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28966. * @param name defines the name of the mesh to create
  28967. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28968. * @param diameterTop set the top cap diameter (floats, default 1)
  28969. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28970. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28971. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28972. * @param scene defines the hosting scene
  28973. * @param updatable defines if the mesh must be flagged as updatable
  28974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28975. * @returns a new Mesh
  28976. */
  28977. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28978. /**
  28979. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28980. * @param name defines the name of the mesh to create
  28981. * @param diameter sets the diameter size (float) of the torus (default 1)
  28982. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28983. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28984. * @param scene defines the hosting scene
  28985. * @param updatable defines if the mesh must be flagged as updatable
  28986. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28987. * @returns a new Mesh
  28988. */
  28989. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28990. /**
  28991. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28992. * @param name defines the name of the mesh to create
  28993. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28994. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28995. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28996. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28997. * @param p the number of windings on X axis (positive integers, default 2)
  28998. * @param q the number of windings on Y axis (positive integers, default 3)
  28999. * @param scene defines the hosting scene
  29000. * @param updatable defines if the mesh must be flagged as updatable
  29001. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29002. * @returns a new Mesh
  29003. */
  29004. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29005. /**
  29006. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29007. * @param name defines the name of the mesh to create
  29008. * @param points is an array successive Vector3
  29009. * @param scene defines the hosting scene
  29010. * @param updatable defines if the mesh must be flagged as updatable
  29011. * @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).
  29012. * @returns a new Mesh
  29013. */
  29014. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29015. /**
  29016. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29017. * @param name defines the name of the mesh to create
  29018. * @param points is an array successive Vector3
  29019. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29020. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29021. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29022. * @param scene defines the hosting scene
  29023. * @param updatable defines if the mesh must be flagged as updatable
  29024. * @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)
  29025. * @returns a new Mesh
  29026. */
  29027. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29028. /**
  29029. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29030. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29031. * 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.
  29032. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29033. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29034. * Remember you can only change the shape positions, not their number when updating a polygon.
  29035. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29036. * @param name defines the name of the mesh to create
  29037. * @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
  29038. * @param scene defines the hosting scene
  29039. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29040. * @param updatable defines if the mesh must be flagged as updatable
  29041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29042. * @param earcutInjection can be used to inject your own earcut reference
  29043. * @returns a new Mesh
  29044. */
  29045. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29046. /**
  29047. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29048. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29049. * @param name defines the name of the mesh to create
  29050. * @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
  29051. * @param depth defines the height of extrusion
  29052. * @param scene defines the hosting scene
  29053. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29054. * @param updatable defines if the mesh must be flagged as updatable
  29055. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29056. * @param earcutInjection can be used to inject your own earcut reference
  29057. * @returns a new Mesh
  29058. */
  29059. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29060. /**
  29061. * Creates an extruded shape mesh.
  29062. * 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
  29063. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29064. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29065. * @param name defines the name of the mesh to create
  29066. * @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
  29067. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29068. * @param scale is the value to scale the shape
  29069. * @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
  29070. * @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
  29071. * @param scene defines the hosting scene
  29072. * @param updatable defines if the mesh must be flagged as updatable
  29073. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29074. * @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)
  29075. * @returns a new Mesh
  29076. */
  29077. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29078. /**
  29079. * Creates an custom extruded shape mesh.
  29080. * The custom extrusion is a parametric shape.
  29081. * It has no predefined shape. Its final shape will depend on the input parameters.
  29082. * Please consider using the same method from the MeshBuilder class instead
  29083. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29084. * @param name defines the name of the mesh to create
  29085. * @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
  29086. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29087. * @param scaleFunction is a custom Javascript function called on each path point
  29088. * @param rotationFunction is a custom Javascript function called on each path point
  29089. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29090. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  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 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)
  29096. * @returns a new Mesh
  29097. */
  29098. 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;
  29099. /**
  29100. * Creates lathe mesh.
  29101. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29102. * Please consider using the same method from the MeshBuilder class instead
  29103. * @param name defines the name of the mesh to create
  29104. * @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
  29105. * @param radius is the radius value of the lathe
  29106. * @param tessellation is the side number of the lathe.
  29107. * @param scene defines the hosting scene
  29108. * @param updatable defines if the mesh must be flagged as updatable
  29109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29110. * @returns a new Mesh
  29111. */
  29112. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29113. /**
  29114. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29115. * @param name defines the name of the mesh to create
  29116. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29117. * @param scene defines the hosting scene
  29118. * @param updatable defines if the mesh must be flagged as updatable
  29119. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29120. * @returns a new Mesh
  29121. */
  29122. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29123. /**
  29124. * Creates a ground mesh.
  29125. * Please consider using the same method from the MeshBuilder class instead
  29126. * @param name defines the name of the mesh to create
  29127. * @param width set the width of the ground
  29128. * @param height set the height of the ground
  29129. * @param subdivisions sets the number of subdivisions per side
  29130. * @param scene defines the hosting scene
  29131. * @param updatable defines if the mesh must be flagged as updatable
  29132. * @returns a new Mesh
  29133. */
  29134. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29135. /**
  29136. * Creates a tiled ground mesh.
  29137. * Please consider using the same method from the MeshBuilder class instead
  29138. * @param name defines the name of the mesh to create
  29139. * @param xmin set the ground minimum X coordinate
  29140. * @param zmin set the ground minimum Y coordinate
  29141. * @param xmax set the ground maximum X coordinate
  29142. * @param zmax set the ground maximum Z coordinate
  29143. * @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
  29144. * @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
  29145. * @param scene defines the hosting scene
  29146. * @param updatable defines if the mesh must be flagged as updatable
  29147. * @returns a new Mesh
  29148. */
  29149. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29150. w: number;
  29151. h: number;
  29152. }, precision: {
  29153. w: number;
  29154. h: number;
  29155. }, scene: Scene, updatable?: boolean): Mesh;
  29156. /**
  29157. * Creates a ground mesh from a height map.
  29158. * Please consider using the same method from the MeshBuilder class instead
  29159. * @see http://doc.babylonjs.com/babylon101/height_map
  29160. * @param name defines the name of the mesh to create
  29161. * @param url sets the URL of the height map image resource
  29162. * @param width set the ground width size
  29163. * @param height set the ground height size
  29164. * @param subdivisions sets the number of subdivision per side
  29165. * @param minHeight is the minimum altitude on the ground
  29166. * @param maxHeight is the maximum altitude on the ground
  29167. * @param scene defines the hosting scene
  29168. * @param updatable defines if the mesh must be flagged as updatable
  29169. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29170. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29171. * @returns a new Mesh
  29172. */
  29173. 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;
  29174. /**
  29175. * Creates a tube mesh.
  29176. * The tube is a parametric shape.
  29177. * It has no predefined shape. Its final shape will depend on the input parameters.
  29178. * Please consider using the same method from the MeshBuilder class instead
  29179. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29180. * @param name defines the name of the mesh to create
  29181. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29182. * @param radius sets the tube radius size
  29183. * @param tessellation is the number of sides on the tubular surface
  29184. * @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
  29185. * @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
  29186. * @param scene defines the hosting scene
  29187. * @param updatable defines if the mesh must be flagged as updatable
  29188. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29189. * @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)
  29190. * @returns a new Mesh
  29191. */
  29192. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29193. (i: number, distance: number): number;
  29194. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29195. /**
  29196. * Creates a polyhedron mesh.
  29197. * Please consider using the same method from the MeshBuilder class instead.
  29198. * * 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
  29199. * * The parameter `size` (positive float, default 1) sets the polygon size
  29200. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29201. * * 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`
  29202. * * 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
  29203. * * 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)`)
  29204. * * 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
  29205. * * 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
  29206. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29207. * * If you create a double-sided mesh, you can choose what parts of 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
  29208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29209. * @param name defines the name of the mesh to create
  29210. * @param options defines the options used to create the mesh
  29211. * @param scene defines the hosting scene
  29212. * @returns a new Mesh
  29213. */
  29214. static CreatePolyhedron(name: string, options: {
  29215. type?: number;
  29216. size?: number;
  29217. sizeX?: number;
  29218. sizeY?: number;
  29219. sizeZ?: number;
  29220. custom?: any;
  29221. faceUV?: Vector4[];
  29222. faceColors?: Color4[];
  29223. updatable?: boolean;
  29224. sideOrientation?: number;
  29225. }, scene: Scene): Mesh;
  29226. /**
  29227. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29228. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29229. * * 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`)
  29230. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29231. * * 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
  29232. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29233. * * If you create a double-sided mesh, you can choose what parts of 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
  29234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29235. * @param name defines the name of the mesh
  29236. * @param options defines the options used to create the mesh
  29237. * @param scene defines the hosting scene
  29238. * @returns a new Mesh
  29239. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29240. */
  29241. static CreateIcoSphere(name: string, options: {
  29242. radius?: number;
  29243. flat?: boolean;
  29244. subdivisions?: number;
  29245. sideOrientation?: number;
  29246. updatable?: boolean;
  29247. }, scene: Scene): Mesh;
  29248. /**
  29249. * Creates a decal mesh.
  29250. * Please consider using the same method from the MeshBuilder class instead.
  29251. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29252. * @param name defines the name of the mesh
  29253. * @param sourceMesh defines the mesh receiving the decal
  29254. * @param position sets the position of the decal in world coordinates
  29255. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29256. * @param size sets the decal scaling
  29257. * @param angle sets the angle to rotate the decal
  29258. * @returns a new Mesh
  29259. */
  29260. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29261. /**
  29262. * Prepare internal position array for software CPU skinning
  29263. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29264. */
  29265. setPositionsForCPUSkinning(): Float32Array;
  29266. /**
  29267. * Prepare internal normal array for software CPU skinning
  29268. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29269. */
  29270. setNormalsForCPUSkinning(): Float32Array;
  29271. /**
  29272. * Updates the vertex buffer by applying transformation from the bones
  29273. * @param skeleton defines the skeleton to apply to current mesh
  29274. * @returns the current mesh
  29275. */
  29276. applySkeleton(skeleton: Skeleton): Mesh;
  29277. /**
  29278. * 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
  29279. * @param meshes defines the list of meshes to scan
  29280. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29281. */
  29282. static MinMax(meshes: AbstractMesh[]): {
  29283. min: Vector3;
  29284. max: Vector3;
  29285. };
  29286. /**
  29287. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29288. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29289. * @returns a vector3
  29290. */
  29291. static Center(meshesOrMinMaxVector: {
  29292. min: Vector3;
  29293. max: Vector3;
  29294. } | AbstractMesh[]): Vector3;
  29295. /**
  29296. * Merge the array of meshes into a single mesh for performance reasons.
  29297. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29298. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29299. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29300. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29301. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29302. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29303. * @returns a new mesh
  29304. */
  29305. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29306. /** @hidden */
  29307. addInstance(instance: InstancedMesh): void;
  29308. /** @hidden */
  29309. removeInstance(instance: InstancedMesh): void;
  29310. }
  29311. }
  29312. declare module "babylonjs/Cameras/camera" {
  29313. import { SmartArray } from "babylonjs/Misc/smartArray";
  29314. import { Observable } from "babylonjs/Misc/observable";
  29315. import { Nullable } from "babylonjs/types";
  29316. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29317. import { Scene } from "babylonjs/scene";
  29318. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29319. import { Node } from "babylonjs/node";
  29320. import { Mesh } from "babylonjs/Meshes/mesh";
  29321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29322. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29323. import { Viewport } from "babylonjs/Maths/math.viewport";
  29324. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29325. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29326. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29327. import { Ray } from "babylonjs/Culling/ray";
  29328. /**
  29329. * This is the base class of all the camera used in the application.
  29330. * @see http://doc.babylonjs.com/features/cameras
  29331. */
  29332. export class Camera extends Node {
  29333. /** @hidden */
  29334. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29335. /**
  29336. * This is the default projection mode used by the cameras.
  29337. * It helps recreating a feeling of perspective and better appreciate depth.
  29338. * This is the best way to simulate real life cameras.
  29339. */
  29340. static readonly PERSPECTIVE_CAMERA: number;
  29341. /**
  29342. * This helps creating camera with an orthographic mode.
  29343. * 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.
  29344. */
  29345. static readonly ORTHOGRAPHIC_CAMERA: number;
  29346. /**
  29347. * This is the default FOV mode for perspective cameras.
  29348. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29349. */
  29350. static readonly FOVMODE_VERTICAL_FIXED: number;
  29351. /**
  29352. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29353. */
  29354. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29355. /**
  29356. * This specifies ther is no need for a camera rig.
  29357. * Basically only one eye is rendered corresponding to the camera.
  29358. */
  29359. static readonly RIG_MODE_NONE: number;
  29360. /**
  29361. * Simulates a camera Rig with one blue eye and one red eye.
  29362. * This can be use with 3d blue and red glasses.
  29363. */
  29364. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29365. /**
  29366. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29367. */
  29368. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29369. /**
  29370. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29371. */
  29372. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29373. /**
  29374. * Defines that both eyes of the camera will be rendered over under each other.
  29375. */
  29376. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29377. /**
  29378. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29379. */
  29380. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29381. /**
  29382. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29383. */
  29384. static readonly RIG_MODE_VR: number;
  29385. /**
  29386. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29387. */
  29388. static readonly RIG_MODE_WEBVR: number;
  29389. /**
  29390. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29391. */
  29392. static readonly RIG_MODE_CUSTOM: number;
  29393. /**
  29394. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29395. */
  29396. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29397. /**
  29398. * Define the input manager associated with the camera.
  29399. */
  29400. inputs: CameraInputsManager<Camera>;
  29401. /** @hidden */
  29402. _position: Vector3;
  29403. /**
  29404. * Define the current local position of the camera in the scene
  29405. */
  29406. get position(): Vector3;
  29407. set position(newPosition: Vector3);
  29408. /**
  29409. * The vector the camera should consider as up.
  29410. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29411. */
  29412. upVector: Vector3;
  29413. /**
  29414. * Define the current limit on the left side for an orthographic camera
  29415. * In scene unit
  29416. */
  29417. orthoLeft: Nullable<number>;
  29418. /**
  29419. * Define the current limit on the right side for an orthographic camera
  29420. * In scene unit
  29421. */
  29422. orthoRight: Nullable<number>;
  29423. /**
  29424. * Define the current limit on the bottom side for an orthographic camera
  29425. * In scene unit
  29426. */
  29427. orthoBottom: Nullable<number>;
  29428. /**
  29429. * Define the current limit on the top side for an orthographic camera
  29430. * In scene unit
  29431. */
  29432. orthoTop: Nullable<number>;
  29433. /**
  29434. * Field Of View is set in Radians. (default is 0.8)
  29435. */
  29436. fov: number;
  29437. /**
  29438. * Define the minimum distance the camera can see from.
  29439. * This is important to note that the depth buffer are not infinite and the closer it starts
  29440. * the more your scene might encounter depth fighting issue.
  29441. */
  29442. minZ: number;
  29443. /**
  29444. * Define the maximum distance the camera can see to.
  29445. * This is important to note that the depth buffer are not infinite and the further it end
  29446. * the more your scene might encounter depth fighting issue.
  29447. */
  29448. maxZ: number;
  29449. /**
  29450. * Define the default inertia of the camera.
  29451. * This helps giving a smooth feeling to the camera movement.
  29452. */
  29453. inertia: number;
  29454. /**
  29455. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29456. */
  29457. mode: number;
  29458. /**
  29459. * Define whether the camera is intermediate.
  29460. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29461. */
  29462. isIntermediate: boolean;
  29463. /**
  29464. * Define the viewport of the camera.
  29465. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29466. */
  29467. viewport: Viewport;
  29468. /**
  29469. * Restricts the camera to viewing objects with the same layerMask.
  29470. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29471. */
  29472. layerMask: number;
  29473. /**
  29474. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29475. */
  29476. fovMode: number;
  29477. /**
  29478. * Rig mode of the camera.
  29479. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29480. * This is normally controlled byt the camera themselves as internal use.
  29481. */
  29482. cameraRigMode: number;
  29483. /**
  29484. * Defines the distance between both "eyes" in case of a RIG
  29485. */
  29486. interaxialDistance: number;
  29487. /**
  29488. * Defines if stereoscopic rendering is done side by side or over under.
  29489. */
  29490. isStereoscopicSideBySide: boolean;
  29491. /**
  29492. * 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
  29493. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29494. * else in the scene. (Eg. security camera)
  29495. *
  29496. * 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)
  29497. */
  29498. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29499. /**
  29500. * When set, the camera will render to this render target instead of the default canvas
  29501. *
  29502. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29503. */
  29504. outputRenderTarget: Nullable<RenderTargetTexture>;
  29505. /**
  29506. * Observable triggered when the camera view matrix has changed.
  29507. */
  29508. onViewMatrixChangedObservable: Observable<Camera>;
  29509. /**
  29510. * Observable triggered when the camera Projection matrix has changed.
  29511. */
  29512. onProjectionMatrixChangedObservable: Observable<Camera>;
  29513. /**
  29514. * Observable triggered when the inputs have been processed.
  29515. */
  29516. onAfterCheckInputsObservable: Observable<Camera>;
  29517. /**
  29518. * Observable triggered when reset has been called and applied to the camera.
  29519. */
  29520. onRestoreStateObservable: Observable<Camera>;
  29521. /**
  29522. * Is this camera a part of a rig system?
  29523. */
  29524. isRigCamera: boolean;
  29525. /**
  29526. * If isRigCamera set to true this will be set with the parent camera.
  29527. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29528. */
  29529. rigParent?: Camera;
  29530. /** @hidden */
  29531. _cameraRigParams: any;
  29532. /** @hidden */
  29533. _rigCameras: Camera[];
  29534. /** @hidden */
  29535. _rigPostProcess: Nullable<PostProcess>;
  29536. protected _webvrViewMatrix: Matrix;
  29537. /** @hidden */
  29538. _skipRendering: boolean;
  29539. /** @hidden */
  29540. _projectionMatrix: Matrix;
  29541. /** @hidden */
  29542. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29543. /** @hidden */
  29544. _activeMeshes: SmartArray<AbstractMesh>;
  29545. protected _globalPosition: Vector3;
  29546. /** @hidden */
  29547. _computedViewMatrix: Matrix;
  29548. private _doNotComputeProjectionMatrix;
  29549. private _transformMatrix;
  29550. private _frustumPlanes;
  29551. private _refreshFrustumPlanes;
  29552. private _storedFov;
  29553. private _stateStored;
  29554. /**
  29555. * Instantiates a new camera object.
  29556. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29557. * @see http://doc.babylonjs.com/features/cameras
  29558. * @param name Defines the name of the camera in the scene
  29559. * @param position Defines the position of the camera
  29560. * @param scene Defines the scene the camera belongs too
  29561. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29562. */
  29563. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29564. /**
  29565. * Store current camera state (fov, position, etc..)
  29566. * @returns the camera
  29567. */
  29568. storeState(): Camera;
  29569. /**
  29570. * Restores the camera state values if it has been stored. You must call storeState() first
  29571. */
  29572. protected _restoreStateValues(): boolean;
  29573. /**
  29574. * Restored camera state. You must call storeState() first.
  29575. * @returns true if restored and false otherwise
  29576. */
  29577. restoreState(): boolean;
  29578. /**
  29579. * Gets the class name of the camera.
  29580. * @returns the class name
  29581. */
  29582. getClassName(): string;
  29583. /** @hidden */
  29584. readonly _isCamera: boolean;
  29585. /**
  29586. * Gets a string representation of the camera useful for debug purpose.
  29587. * @param fullDetails Defines that a more verboe level of logging is required
  29588. * @returns the string representation
  29589. */
  29590. toString(fullDetails?: boolean): string;
  29591. /**
  29592. * Gets the current world space position of the camera.
  29593. */
  29594. get globalPosition(): Vector3;
  29595. /**
  29596. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29597. * @returns the active meshe list
  29598. */
  29599. getActiveMeshes(): SmartArray<AbstractMesh>;
  29600. /**
  29601. * Check whether a mesh is part of the current active mesh list of the camera
  29602. * @param mesh Defines the mesh to check
  29603. * @returns true if active, false otherwise
  29604. */
  29605. isActiveMesh(mesh: Mesh): boolean;
  29606. /**
  29607. * Is this camera ready to be used/rendered
  29608. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29609. * @return true if the camera is ready
  29610. */
  29611. isReady(completeCheck?: boolean): boolean;
  29612. /** @hidden */
  29613. _initCache(): void;
  29614. /** @hidden */
  29615. _updateCache(ignoreParentClass?: boolean): void;
  29616. /** @hidden */
  29617. _isSynchronized(): boolean;
  29618. /** @hidden */
  29619. _isSynchronizedViewMatrix(): boolean;
  29620. /** @hidden */
  29621. _isSynchronizedProjectionMatrix(): boolean;
  29622. /**
  29623. * Attach the input controls to a specific dom element to get the input from.
  29624. * @param element Defines the element the controls should be listened from
  29625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29626. */
  29627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29628. /**
  29629. * Detach the current controls from the specified dom element.
  29630. * @param element Defines the element to stop listening the inputs from
  29631. */
  29632. detachControl(element: HTMLElement): void;
  29633. /**
  29634. * Update the camera state according to the different inputs gathered during the frame.
  29635. */
  29636. update(): void;
  29637. /** @hidden */
  29638. _checkInputs(): void;
  29639. /** @hidden */
  29640. get rigCameras(): Camera[];
  29641. /**
  29642. * Gets the post process used by the rig cameras
  29643. */
  29644. get rigPostProcess(): Nullable<PostProcess>;
  29645. /**
  29646. * Internal, gets the first post proces.
  29647. * @returns the first post process to be run on this camera.
  29648. */
  29649. _getFirstPostProcess(): Nullable<PostProcess>;
  29650. private _cascadePostProcessesToRigCams;
  29651. /**
  29652. * Attach a post process to the camera.
  29653. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29654. * @param postProcess The post process to attach to the camera
  29655. * @param insertAt The position of the post process in case several of them are in use in the scene
  29656. * @returns the position the post process has been inserted at
  29657. */
  29658. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29659. /**
  29660. * Detach a post process to the camera.
  29661. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29662. * @param postProcess The post process to detach from the camera
  29663. */
  29664. detachPostProcess(postProcess: PostProcess): void;
  29665. /**
  29666. * Gets the current world matrix of the camera
  29667. */
  29668. getWorldMatrix(): Matrix;
  29669. /** @hidden */
  29670. _getViewMatrix(): Matrix;
  29671. /**
  29672. * Gets the current view matrix of the camera.
  29673. * @param force forces the camera to recompute the matrix without looking at the cached state
  29674. * @returns the view matrix
  29675. */
  29676. getViewMatrix(force?: boolean): Matrix;
  29677. /**
  29678. * Freeze the projection matrix.
  29679. * It will prevent the cache check of the camera projection compute and can speed up perf
  29680. * if no parameter of the camera are meant to change
  29681. * @param projection Defines manually a projection if necessary
  29682. */
  29683. freezeProjectionMatrix(projection?: Matrix): void;
  29684. /**
  29685. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29686. */
  29687. unfreezeProjectionMatrix(): void;
  29688. /**
  29689. * Gets the current projection matrix of the camera.
  29690. * @param force forces the camera to recompute the matrix without looking at the cached state
  29691. * @returns the projection matrix
  29692. */
  29693. getProjectionMatrix(force?: boolean): Matrix;
  29694. /**
  29695. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29696. * @returns a Matrix
  29697. */
  29698. getTransformationMatrix(): Matrix;
  29699. private _updateFrustumPlanes;
  29700. /**
  29701. * Checks if a cullable object (mesh...) is in the camera frustum
  29702. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29703. * @param target The object to check
  29704. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29705. * @returns true if the object is in frustum otherwise false
  29706. */
  29707. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29708. /**
  29709. * Checks if a cullable object (mesh...) is in the camera frustum
  29710. * Unlike isInFrustum this cheks the full bounding box
  29711. * @param target The object to check
  29712. * @returns true if the object is in frustum otherwise false
  29713. */
  29714. isCompletelyInFrustum(target: ICullable): boolean;
  29715. /**
  29716. * Gets a ray in the forward direction from the camera.
  29717. * @param length Defines the length of the ray to create
  29718. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29719. * @param origin Defines the start point of the ray which defaults to the camera position
  29720. * @returns the forward ray
  29721. */
  29722. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29723. /**
  29724. * Releases resources associated with this node.
  29725. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29726. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29727. */
  29728. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29729. /** @hidden */
  29730. _isLeftCamera: boolean;
  29731. /**
  29732. * Gets the left camera of a rig setup in case of Rigged Camera
  29733. */
  29734. get isLeftCamera(): boolean;
  29735. /** @hidden */
  29736. _isRightCamera: boolean;
  29737. /**
  29738. * Gets the right camera of a rig setup in case of Rigged Camera
  29739. */
  29740. get isRightCamera(): boolean;
  29741. /**
  29742. * Gets the left camera of a rig setup in case of Rigged Camera
  29743. */
  29744. get leftCamera(): Nullable<FreeCamera>;
  29745. /**
  29746. * Gets the right camera of a rig setup in case of Rigged Camera
  29747. */
  29748. get rightCamera(): Nullable<FreeCamera>;
  29749. /**
  29750. * Gets the left camera target of a rig setup in case of Rigged Camera
  29751. * @returns the target position
  29752. */
  29753. getLeftTarget(): Nullable<Vector3>;
  29754. /**
  29755. * Gets the right camera target of a rig setup in case of Rigged Camera
  29756. * @returns the target position
  29757. */
  29758. getRightTarget(): Nullable<Vector3>;
  29759. /**
  29760. * @hidden
  29761. */
  29762. setCameraRigMode(mode: number, rigParams: any): void;
  29763. /** @hidden */
  29764. static _setStereoscopicRigMode(camera: Camera): void;
  29765. /** @hidden */
  29766. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29767. /** @hidden */
  29768. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29769. /** @hidden */
  29770. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29771. /** @hidden */
  29772. _getVRProjectionMatrix(): Matrix;
  29773. protected _updateCameraRotationMatrix(): void;
  29774. protected _updateWebVRCameraRotationMatrix(): void;
  29775. /**
  29776. * This function MUST be overwritten by the different WebVR cameras available.
  29777. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29778. * @hidden
  29779. */
  29780. _getWebVRProjectionMatrix(): Matrix;
  29781. /**
  29782. * This function MUST be overwritten by the different WebVR cameras available.
  29783. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29784. * @hidden
  29785. */
  29786. _getWebVRViewMatrix(): Matrix;
  29787. /** @hidden */
  29788. setCameraRigParameter(name: string, value: any): void;
  29789. /**
  29790. * needs to be overridden by children so sub has required properties to be copied
  29791. * @hidden
  29792. */
  29793. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29794. /**
  29795. * May need to be overridden by children
  29796. * @hidden
  29797. */
  29798. _updateRigCameras(): void;
  29799. /** @hidden */
  29800. _setupInputs(): void;
  29801. /**
  29802. * Serialiaze the camera setup to a json represention
  29803. * @returns the JSON representation
  29804. */
  29805. serialize(): any;
  29806. /**
  29807. * Clones the current camera.
  29808. * @param name The cloned camera name
  29809. * @returns the cloned camera
  29810. */
  29811. clone(name: string): Camera;
  29812. /**
  29813. * Gets the direction of the camera relative to a given local axis.
  29814. * @param localAxis Defines the reference axis to provide a relative direction.
  29815. * @return the direction
  29816. */
  29817. getDirection(localAxis: Vector3): Vector3;
  29818. /**
  29819. * Returns the current camera absolute rotation
  29820. */
  29821. get absoluteRotation(): Quaternion;
  29822. /**
  29823. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29824. * @param localAxis Defines the reference axis to provide a relative direction.
  29825. * @param result Defines the vector to store the result in
  29826. */
  29827. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29828. /**
  29829. * Gets a camera constructor for a given camera type
  29830. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29831. * @param name The name of the camera the result will be able to instantiate
  29832. * @param scene The scene the result will construct the camera in
  29833. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29834. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29835. * @returns a factory method to construc the camera
  29836. */
  29837. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29838. /**
  29839. * Compute the world matrix of the camera.
  29840. * @returns the camera world matrix
  29841. */
  29842. computeWorldMatrix(): Matrix;
  29843. /**
  29844. * Parse a JSON and creates the camera from the parsed information
  29845. * @param parsedCamera The JSON to parse
  29846. * @param scene The scene to instantiate the camera in
  29847. * @returns the newly constructed camera
  29848. */
  29849. static Parse(parsedCamera: any, scene: Scene): Camera;
  29850. }
  29851. }
  29852. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29853. import { Nullable } from "babylonjs/types";
  29854. import { Scene } from "babylonjs/scene";
  29855. import { Vector4 } from "babylonjs/Maths/math.vector";
  29856. import { Mesh } from "babylonjs/Meshes/mesh";
  29857. /**
  29858. * Class containing static functions to help procedurally build meshes
  29859. */
  29860. export class DiscBuilder {
  29861. /**
  29862. * Creates a plane polygonal mesh. By default, this is a disc
  29863. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29864. * * 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
  29865. * * 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
  29866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29867. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29869. * @param name defines the name of the mesh
  29870. * @param options defines the options used to create the mesh
  29871. * @param scene defines the hosting scene
  29872. * @returns the plane polygonal mesh
  29873. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29874. */
  29875. static CreateDisc(name: string, options: {
  29876. radius?: number;
  29877. tessellation?: number;
  29878. arc?: number;
  29879. updatable?: boolean;
  29880. sideOrientation?: number;
  29881. frontUVs?: Vector4;
  29882. backUVs?: Vector4;
  29883. }, scene?: Nullable<Scene>): Mesh;
  29884. }
  29885. }
  29886. declare module "babylonjs/Materials/fresnelParameters" {
  29887. import { DeepImmutable } from "babylonjs/types";
  29888. import { Color3 } from "babylonjs/Maths/math.color";
  29889. /**
  29890. * Options to be used when creating a FresnelParameters.
  29891. */
  29892. export type IFresnelParametersCreationOptions = {
  29893. /**
  29894. * Define the color used on edges (grazing angle)
  29895. */
  29896. leftColor?: Color3;
  29897. /**
  29898. * Define the color used on center
  29899. */
  29900. rightColor?: Color3;
  29901. /**
  29902. * Define bias applied to computed fresnel term
  29903. */
  29904. bias?: number;
  29905. /**
  29906. * Defined the power exponent applied to fresnel term
  29907. */
  29908. power?: number;
  29909. /**
  29910. * Define if the fresnel effect is enable or not.
  29911. */
  29912. isEnabled?: boolean;
  29913. };
  29914. /**
  29915. * Serialized format for FresnelParameters.
  29916. */
  29917. export type IFresnelParametersSerialized = {
  29918. /**
  29919. * Define the color used on edges (grazing angle) [as an array]
  29920. */
  29921. leftColor: number[];
  29922. /**
  29923. * Define the color used on center [as an array]
  29924. */
  29925. rightColor: number[];
  29926. /**
  29927. * Define bias applied to computed fresnel term
  29928. */
  29929. bias: number;
  29930. /**
  29931. * Defined the power exponent applied to fresnel term
  29932. */
  29933. power?: number;
  29934. /**
  29935. * Define if the fresnel effect is enable or not.
  29936. */
  29937. isEnabled: boolean;
  29938. };
  29939. /**
  29940. * This represents all the required information to add a fresnel effect on a material:
  29941. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29942. */
  29943. export class FresnelParameters {
  29944. private _isEnabled;
  29945. /**
  29946. * Define if the fresnel effect is enable or not.
  29947. */
  29948. get isEnabled(): boolean;
  29949. set isEnabled(value: boolean);
  29950. /**
  29951. * Define the color used on edges (grazing angle)
  29952. */
  29953. leftColor: Color3;
  29954. /**
  29955. * Define the color used on center
  29956. */
  29957. rightColor: Color3;
  29958. /**
  29959. * Define bias applied to computed fresnel term
  29960. */
  29961. bias: number;
  29962. /**
  29963. * Defined the power exponent applied to fresnel term
  29964. */
  29965. power: number;
  29966. /**
  29967. * Creates a new FresnelParameters object.
  29968. *
  29969. * @param options provide your own settings to optionally to override defaults
  29970. */
  29971. constructor(options?: IFresnelParametersCreationOptions);
  29972. /**
  29973. * Clones the current fresnel and its valuues
  29974. * @returns a clone fresnel configuration
  29975. */
  29976. clone(): FresnelParameters;
  29977. /**
  29978. * Determines equality between FresnelParameters objects
  29979. * @param otherFresnelParameters defines the second operand
  29980. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29981. */
  29982. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29983. /**
  29984. * Serializes the current fresnel parameters to a JSON representation.
  29985. * @return the JSON serialization
  29986. */
  29987. serialize(): IFresnelParametersSerialized;
  29988. /**
  29989. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29990. * @param parsedFresnelParameters Define the JSON representation
  29991. * @returns the parsed parameters
  29992. */
  29993. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29994. }
  29995. }
  29996. declare module "babylonjs/Materials/materialFlags" {
  29997. /**
  29998. * This groups all the flags used to control the materials channel.
  29999. */
  30000. export class MaterialFlags {
  30001. private static _DiffuseTextureEnabled;
  30002. /**
  30003. * Are diffuse textures enabled in the application.
  30004. */
  30005. static get DiffuseTextureEnabled(): boolean;
  30006. static set DiffuseTextureEnabled(value: boolean);
  30007. private static _AmbientTextureEnabled;
  30008. /**
  30009. * Are ambient textures enabled in the application.
  30010. */
  30011. static get AmbientTextureEnabled(): boolean;
  30012. static set AmbientTextureEnabled(value: boolean);
  30013. private static _OpacityTextureEnabled;
  30014. /**
  30015. * Are opacity textures enabled in the application.
  30016. */
  30017. static get OpacityTextureEnabled(): boolean;
  30018. static set OpacityTextureEnabled(value: boolean);
  30019. private static _ReflectionTextureEnabled;
  30020. /**
  30021. * Are reflection textures enabled in the application.
  30022. */
  30023. static get ReflectionTextureEnabled(): boolean;
  30024. static set ReflectionTextureEnabled(value: boolean);
  30025. private static _EmissiveTextureEnabled;
  30026. /**
  30027. * Are emissive textures enabled in the application.
  30028. */
  30029. static get EmissiveTextureEnabled(): boolean;
  30030. static set EmissiveTextureEnabled(value: boolean);
  30031. private static _SpecularTextureEnabled;
  30032. /**
  30033. * Are specular textures enabled in the application.
  30034. */
  30035. static get SpecularTextureEnabled(): boolean;
  30036. static set SpecularTextureEnabled(value: boolean);
  30037. private static _BumpTextureEnabled;
  30038. /**
  30039. * Are bump textures enabled in the application.
  30040. */
  30041. static get BumpTextureEnabled(): boolean;
  30042. static set BumpTextureEnabled(value: boolean);
  30043. private static _LightmapTextureEnabled;
  30044. /**
  30045. * Are lightmap textures enabled in the application.
  30046. */
  30047. static get LightmapTextureEnabled(): boolean;
  30048. static set LightmapTextureEnabled(value: boolean);
  30049. private static _RefractionTextureEnabled;
  30050. /**
  30051. * Are refraction textures enabled in the application.
  30052. */
  30053. static get RefractionTextureEnabled(): boolean;
  30054. static set RefractionTextureEnabled(value: boolean);
  30055. private static _ColorGradingTextureEnabled;
  30056. /**
  30057. * Are color grading textures enabled in the application.
  30058. */
  30059. static get ColorGradingTextureEnabled(): boolean;
  30060. static set ColorGradingTextureEnabled(value: boolean);
  30061. private static _FresnelEnabled;
  30062. /**
  30063. * Are fresnels enabled in the application.
  30064. */
  30065. static get FresnelEnabled(): boolean;
  30066. static set FresnelEnabled(value: boolean);
  30067. private static _ClearCoatTextureEnabled;
  30068. /**
  30069. * Are clear coat textures enabled in the application.
  30070. */
  30071. static get ClearCoatTextureEnabled(): boolean;
  30072. static set ClearCoatTextureEnabled(value: boolean);
  30073. private static _ClearCoatBumpTextureEnabled;
  30074. /**
  30075. * Are clear coat bump textures enabled in the application.
  30076. */
  30077. static get ClearCoatBumpTextureEnabled(): boolean;
  30078. static set ClearCoatBumpTextureEnabled(value: boolean);
  30079. private static _ClearCoatTintTextureEnabled;
  30080. /**
  30081. * Are clear coat tint textures enabled in the application.
  30082. */
  30083. static get ClearCoatTintTextureEnabled(): boolean;
  30084. static set ClearCoatTintTextureEnabled(value: boolean);
  30085. private static _SheenTextureEnabled;
  30086. /**
  30087. * Are sheen textures enabled in the application.
  30088. */
  30089. static get SheenTextureEnabled(): boolean;
  30090. static set SheenTextureEnabled(value: boolean);
  30091. private static _AnisotropicTextureEnabled;
  30092. /**
  30093. * Are anisotropic textures enabled in the application.
  30094. */
  30095. static get AnisotropicTextureEnabled(): boolean;
  30096. static set AnisotropicTextureEnabled(value: boolean);
  30097. private static _ThicknessTextureEnabled;
  30098. /**
  30099. * Are thickness textures enabled in the application.
  30100. */
  30101. static get ThicknessTextureEnabled(): boolean;
  30102. static set ThicknessTextureEnabled(value: boolean);
  30103. }
  30104. }
  30105. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30106. /** @hidden */
  30107. export var defaultFragmentDeclaration: {
  30108. name: string;
  30109. shader: string;
  30110. };
  30111. }
  30112. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30113. /** @hidden */
  30114. export var defaultUboDeclaration: {
  30115. name: string;
  30116. shader: string;
  30117. };
  30118. }
  30119. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30120. /** @hidden */
  30121. export var lightFragmentDeclaration: {
  30122. name: string;
  30123. shader: string;
  30124. };
  30125. }
  30126. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30127. /** @hidden */
  30128. export var lightUboDeclaration: {
  30129. name: string;
  30130. shader: string;
  30131. };
  30132. }
  30133. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30134. /** @hidden */
  30135. export var lightsFragmentFunctions: {
  30136. name: string;
  30137. shader: string;
  30138. };
  30139. }
  30140. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30141. /** @hidden */
  30142. export var shadowsFragmentFunctions: {
  30143. name: string;
  30144. shader: string;
  30145. };
  30146. }
  30147. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30148. /** @hidden */
  30149. export var fresnelFunction: {
  30150. name: string;
  30151. shader: string;
  30152. };
  30153. }
  30154. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30155. /** @hidden */
  30156. export var bumpFragmentMainFunctions: {
  30157. name: string;
  30158. shader: string;
  30159. };
  30160. }
  30161. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30162. /** @hidden */
  30163. export var bumpFragmentFunctions: {
  30164. name: string;
  30165. shader: string;
  30166. };
  30167. }
  30168. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30169. /** @hidden */
  30170. export var logDepthDeclaration: {
  30171. name: string;
  30172. shader: string;
  30173. };
  30174. }
  30175. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30176. /** @hidden */
  30177. export var bumpFragment: {
  30178. name: string;
  30179. shader: string;
  30180. };
  30181. }
  30182. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30183. /** @hidden */
  30184. export var depthPrePass: {
  30185. name: string;
  30186. shader: string;
  30187. };
  30188. }
  30189. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30190. /** @hidden */
  30191. export var lightFragment: {
  30192. name: string;
  30193. shader: string;
  30194. };
  30195. }
  30196. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30197. /** @hidden */
  30198. export var logDepthFragment: {
  30199. name: string;
  30200. shader: string;
  30201. };
  30202. }
  30203. declare module "babylonjs/Shaders/default.fragment" {
  30204. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30205. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30206. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30207. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30208. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30209. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30210. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30211. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30212. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30213. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30214. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30215. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30216. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30217. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30218. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30219. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30220. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30221. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30222. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30223. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30224. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30225. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30226. /** @hidden */
  30227. export var defaultPixelShader: {
  30228. name: string;
  30229. shader: string;
  30230. };
  30231. }
  30232. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30233. /** @hidden */
  30234. export var defaultVertexDeclaration: {
  30235. name: string;
  30236. shader: string;
  30237. };
  30238. }
  30239. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30240. /** @hidden */
  30241. export var bumpVertexDeclaration: {
  30242. name: string;
  30243. shader: string;
  30244. };
  30245. }
  30246. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30247. /** @hidden */
  30248. export var bumpVertex: {
  30249. name: string;
  30250. shader: string;
  30251. };
  30252. }
  30253. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30254. /** @hidden */
  30255. export var fogVertex: {
  30256. name: string;
  30257. shader: string;
  30258. };
  30259. }
  30260. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30261. /** @hidden */
  30262. export var shadowsVertex: {
  30263. name: string;
  30264. shader: string;
  30265. };
  30266. }
  30267. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30268. /** @hidden */
  30269. export var pointCloudVertex: {
  30270. name: string;
  30271. shader: string;
  30272. };
  30273. }
  30274. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30275. /** @hidden */
  30276. export var logDepthVertex: {
  30277. name: string;
  30278. shader: string;
  30279. };
  30280. }
  30281. declare module "babylonjs/Shaders/default.vertex" {
  30282. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30283. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30285. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30286. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30287. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30288. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30289. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30290. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30291. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30292. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30293. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30294. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30295. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30296. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30297. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30298. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30299. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30300. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30301. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30302. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30303. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30304. /** @hidden */
  30305. export var defaultVertexShader: {
  30306. name: string;
  30307. shader: string;
  30308. };
  30309. }
  30310. declare module "babylonjs/Materials/standardMaterial" {
  30311. import { SmartArray } from "babylonjs/Misc/smartArray";
  30312. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30313. import { Nullable } from "babylonjs/types";
  30314. import { Scene } from "babylonjs/scene";
  30315. import { Matrix } from "babylonjs/Maths/math.vector";
  30316. import { Color3 } from "babylonjs/Maths/math.color";
  30317. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30319. import { Mesh } from "babylonjs/Meshes/mesh";
  30320. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30321. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30322. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30323. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30324. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30325. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30326. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30327. import "babylonjs/Shaders/default.fragment";
  30328. import "babylonjs/Shaders/default.vertex";
  30329. /** @hidden */
  30330. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30331. MAINUV1: boolean;
  30332. MAINUV2: boolean;
  30333. DIFFUSE: boolean;
  30334. DIFFUSEDIRECTUV: number;
  30335. AMBIENT: boolean;
  30336. AMBIENTDIRECTUV: number;
  30337. OPACITY: boolean;
  30338. OPACITYDIRECTUV: number;
  30339. OPACITYRGB: boolean;
  30340. REFLECTION: boolean;
  30341. EMISSIVE: boolean;
  30342. EMISSIVEDIRECTUV: number;
  30343. SPECULAR: boolean;
  30344. SPECULARDIRECTUV: number;
  30345. BUMP: boolean;
  30346. BUMPDIRECTUV: number;
  30347. PARALLAX: boolean;
  30348. PARALLAXOCCLUSION: boolean;
  30349. SPECULAROVERALPHA: boolean;
  30350. CLIPPLANE: boolean;
  30351. CLIPPLANE2: boolean;
  30352. CLIPPLANE3: boolean;
  30353. CLIPPLANE4: boolean;
  30354. CLIPPLANE5: boolean;
  30355. CLIPPLANE6: boolean;
  30356. ALPHATEST: boolean;
  30357. DEPTHPREPASS: boolean;
  30358. ALPHAFROMDIFFUSE: boolean;
  30359. POINTSIZE: boolean;
  30360. FOG: boolean;
  30361. SPECULARTERM: boolean;
  30362. DIFFUSEFRESNEL: boolean;
  30363. OPACITYFRESNEL: boolean;
  30364. REFLECTIONFRESNEL: boolean;
  30365. REFRACTIONFRESNEL: boolean;
  30366. EMISSIVEFRESNEL: boolean;
  30367. FRESNEL: boolean;
  30368. NORMAL: boolean;
  30369. UV1: boolean;
  30370. UV2: boolean;
  30371. VERTEXCOLOR: boolean;
  30372. VERTEXALPHA: boolean;
  30373. NUM_BONE_INFLUENCERS: number;
  30374. BonesPerMesh: number;
  30375. BONETEXTURE: boolean;
  30376. INSTANCES: boolean;
  30377. THIN_INSTANCES: boolean;
  30378. GLOSSINESS: boolean;
  30379. ROUGHNESS: boolean;
  30380. EMISSIVEASILLUMINATION: boolean;
  30381. LINKEMISSIVEWITHDIFFUSE: boolean;
  30382. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30383. LIGHTMAP: boolean;
  30384. LIGHTMAPDIRECTUV: number;
  30385. OBJECTSPACE_NORMALMAP: boolean;
  30386. USELIGHTMAPASSHADOWMAP: boolean;
  30387. REFLECTIONMAP_3D: boolean;
  30388. REFLECTIONMAP_SPHERICAL: boolean;
  30389. REFLECTIONMAP_PLANAR: boolean;
  30390. REFLECTIONMAP_CUBIC: boolean;
  30391. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30392. REFLECTIONMAP_PROJECTION: boolean;
  30393. REFLECTIONMAP_SKYBOX: boolean;
  30394. REFLECTIONMAP_EXPLICIT: boolean;
  30395. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30396. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30397. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30398. INVERTCUBICMAP: boolean;
  30399. LOGARITHMICDEPTH: boolean;
  30400. REFRACTION: boolean;
  30401. REFRACTIONMAP_3D: boolean;
  30402. REFLECTIONOVERALPHA: boolean;
  30403. TWOSIDEDLIGHTING: boolean;
  30404. SHADOWFLOAT: boolean;
  30405. MORPHTARGETS: boolean;
  30406. MORPHTARGETS_NORMAL: boolean;
  30407. MORPHTARGETS_TANGENT: boolean;
  30408. MORPHTARGETS_UV: boolean;
  30409. NUM_MORPH_INFLUENCERS: number;
  30410. NONUNIFORMSCALING: boolean;
  30411. PREMULTIPLYALPHA: boolean;
  30412. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30413. ALPHABLEND: boolean;
  30414. RGBDLIGHTMAP: boolean;
  30415. RGBDREFLECTION: boolean;
  30416. RGBDREFRACTION: boolean;
  30417. IMAGEPROCESSING: boolean;
  30418. VIGNETTE: boolean;
  30419. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30420. VIGNETTEBLENDMODEOPAQUE: boolean;
  30421. TONEMAPPING: boolean;
  30422. TONEMAPPING_ACES: boolean;
  30423. CONTRAST: boolean;
  30424. COLORCURVES: boolean;
  30425. COLORGRADING: boolean;
  30426. COLORGRADING3D: boolean;
  30427. SAMPLER3DGREENDEPTH: boolean;
  30428. SAMPLER3DBGRMAP: boolean;
  30429. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30430. MULTIVIEW: boolean;
  30431. /**
  30432. * If the reflection texture on this material is in linear color space
  30433. * @hidden
  30434. */
  30435. IS_REFLECTION_LINEAR: boolean;
  30436. /**
  30437. * If the refraction texture on this material is in linear color space
  30438. * @hidden
  30439. */
  30440. IS_REFRACTION_LINEAR: boolean;
  30441. EXPOSURE: boolean;
  30442. constructor();
  30443. setReflectionMode(modeToEnable: string): void;
  30444. }
  30445. /**
  30446. * This is the default material used in Babylon. It is the best trade off between quality
  30447. * and performances.
  30448. * @see http://doc.babylonjs.com/babylon101/materials
  30449. */
  30450. export class StandardMaterial extends PushMaterial {
  30451. private _diffuseTexture;
  30452. /**
  30453. * The basic texture of the material as viewed under a light.
  30454. */
  30455. diffuseTexture: Nullable<BaseTexture>;
  30456. private _ambientTexture;
  30457. /**
  30458. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30459. */
  30460. ambientTexture: Nullable<BaseTexture>;
  30461. private _opacityTexture;
  30462. /**
  30463. * Define the transparency of the material from a texture.
  30464. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30465. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30466. */
  30467. opacityTexture: Nullable<BaseTexture>;
  30468. private _reflectionTexture;
  30469. /**
  30470. * Define the texture used to display the reflection.
  30471. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30472. */
  30473. reflectionTexture: Nullable<BaseTexture>;
  30474. private _emissiveTexture;
  30475. /**
  30476. * Define texture of the material as if self lit.
  30477. * This will be mixed in the final result even in the absence of light.
  30478. */
  30479. emissiveTexture: Nullable<BaseTexture>;
  30480. private _specularTexture;
  30481. /**
  30482. * Define how the color and intensity of the highlight given by the light in the material.
  30483. */
  30484. specularTexture: Nullable<BaseTexture>;
  30485. private _bumpTexture;
  30486. /**
  30487. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30488. * 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.
  30489. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30490. */
  30491. bumpTexture: Nullable<BaseTexture>;
  30492. private _lightmapTexture;
  30493. /**
  30494. * Complex lighting can be computationally expensive to compute at runtime.
  30495. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30496. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30497. */
  30498. lightmapTexture: Nullable<BaseTexture>;
  30499. private _refractionTexture;
  30500. /**
  30501. * Define the texture used to display the refraction.
  30502. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30503. */
  30504. refractionTexture: Nullable<BaseTexture>;
  30505. /**
  30506. * The color of the material lit by the environmental background lighting.
  30507. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30508. */
  30509. ambientColor: Color3;
  30510. /**
  30511. * The basic color of the material as viewed under a light.
  30512. */
  30513. diffuseColor: Color3;
  30514. /**
  30515. * Define how the color and intensity of the highlight given by the light in the material.
  30516. */
  30517. specularColor: Color3;
  30518. /**
  30519. * Define the color of the material as if self lit.
  30520. * This will be mixed in the final result even in the absence of light.
  30521. */
  30522. emissiveColor: Color3;
  30523. /**
  30524. * Defines how sharp are the highlights in the material.
  30525. * The bigger the value the sharper giving a more glossy feeling to the result.
  30526. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30527. */
  30528. specularPower: number;
  30529. private _useAlphaFromDiffuseTexture;
  30530. /**
  30531. * Does the transparency come from the diffuse texture alpha channel.
  30532. */
  30533. useAlphaFromDiffuseTexture: boolean;
  30534. private _useEmissiveAsIllumination;
  30535. /**
  30536. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30537. */
  30538. useEmissiveAsIllumination: boolean;
  30539. private _linkEmissiveWithDiffuse;
  30540. /**
  30541. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30542. * the emissive level when the final color is close to one.
  30543. */
  30544. linkEmissiveWithDiffuse: boolean;
  30545. private _useSpecularOverAlpha;
  30546. /**
  30547. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30548. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30549. */
  30550. useSpecularOverAlpha: boolean;
  30551. private _useReflectionOverAlpha;
  30552. /**
  30553. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30554. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30555. */
  30556. useReflectionOverAlpha: boolean;
  30557. private _disableLighting;
  30558. /**
  30559. * Does lights from the scene impacts this material.
  30560. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30561. */
  30562. disableLighting: boolean;
  30563. private _useObjectSpaceNormalMap;
  30564. /**
  30565. * Allows using an object space normal map (instead of tangent space).
  30566. */
  30567. useObjectSpaceNormalMap: boolean;
  30568. private _useParallax;
  30569. /**
  30570. * Is parallax enabled or not.
  30571. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30572. */
  30573. useParallax: boolean;
  30574. private _useParallaxOcclusion;
  30575. /**
  30576. * Is parallax occlusion enabled or not.
  30577. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30578. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30579. */
  30580. useParallaxOcclusion: boolean;
  30581. /**
  30582. * 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.
  30583. */
  30584. parallaxScaleBias: number;
  30585. private _roughness;
  30586. /**
  30587. * Helps to define how blurry the reflections should appears in the material.
  30588. */
  30589. roughness: number;
  30590. /**
  30591. * In case of refraction, define the value of the index of refraction.
  30592. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30593. */
  30594. indexOfRefraction: number;
  30595. /**
  30596. * Invert the refraction texture alongside the y axis.
  30597. * It can be useful with procedural textures or probe for instance.
  30598. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30599. */
  30600. invertRefractionY: boolean;
  30601. /**
  30602. * Defines the alpha limits in alpha test mode.
  30603. */
  30604. alphaCutOff: number;
  30605. private _useLightmapAsShadowmap;
  30606. /**
  30607. * In case of light mapping, define whether the map contains light or shadow informations.
  30608. */
  30609. useLightmapAsShadowmap: boolean;
  30610. private _diffuseFresnelParameters;
  30611. /**
  30612. * Define the diffuse fresnel parameters of the material.
  30613. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30614. */
  30615. diffuseFresnelParameters: FresnelParameters;
  30616. private _opacityFresnelParameters;
  30617. /**
  30618. * Define the opacity fresnel parameters of the material.
  30619. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30620. */
  30621. opacityFresnelParameters: FresnelParameters;
  30622. private _reflectionFresnelParameters;
  30623. /**
  30624. * Define the reflection fresnel parameters of the material.
  30625. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30626. */
  30627. reflectionFresnelParameters: FresnelParameters;
  30628. private _refractionFresnelParameters;
  30629. /**
  30630. * Define the refraction fresnel parameters of the material.
  30631. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30632. */
  30633. refractionFresnelParameters: FresnelParameters;
  30634. private _emissiveFresnelParameters;
  30635. /**
  30636. * Define the emissive fresnel parameters of the material.
  30637. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30638. */
  30639. emissiveFresnelParameters: FresnelParameters;
  30640. private _useReflectionFresnelFromSpecular;
  30641. /**
  30642. * If true automatically deducts the fresnels values from the material specularity.
  30643. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30644. */
  30645. useReflectionFresnelFromSpecular: boolean;
  30646. private _useGlossinessFromSpecularMapAlpha;
  30647. /**
  30648. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30649. */
  30650. useGlossinessFromSpecularMapAlpha: boolean;
  30651. private _maxSimultaneousLights;
  30652. /**
  30653. * Defines the maximum number of lights that can be used in the material
  30654. */
  30655. maxSimultaneousLights: number;
  30656. private _invertNormalMapX;
  30657. /**
  30658. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30659. */
  30660. invertNormalMapX: boolean;
  30661. private _invertNormalMapY;
  30662. /**
  30663. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30664. */
  30665. invertNormalMapY: boolean;
  30666. private _twoSidedLighting;
  30667. /**
  30668. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30669. */
  30670. twoSidedLighting: boolean;
  30671. /**
  30672. * Default configuration related to image processing available in the standard Material.
  30673. */
  30674. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30675. /**
  30676. * Gets the image processing configuration used either in this material.
  30677. */
  30678. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30679. /**
  30680. * Sets the Default image processing configuration used either in the this material.
  30681. *
  30682. * If sets to null, the scene one is in use.
  30683. */
  30684. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30685. /**
  30686. * Keep track of the image processing observer to allow dispose and replace.
  30687. */
  30688. private _imageProcessingObserver;
  30689. /**
  30690. * Attaches a new image processing configuration to the Standard Material.
  30691. * @param configuration
  30692. */
  30693. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30694. /**
  30695. * Gets wether the color curves effect is enabled.
  30696. */
  30697. get cameraColorCurvesEnabled(): boolean;
  30698. /**
  30699. * Sets wether the color curves effect is enabled.
  30700. */
  30701. set cameraColorCurvesEnabled(value: boolean);
  30702. /**
  30703. * Gets wether the color grading effect is enabled.
  30704. */
  30705. get cameraColorGradingEnabled(): boolean;
  30706. /**
  30707. * Gets wether the color grading effect is enabled.
  30708. */
  30709. set cameraColorGradingEnabled(value: boolean);
  30710. /**
  30711. * Gets wether tonemapping is enabled or not.
  30712. */
  30713. get cameraToneMappingEnabled(): boolean;
  30714. /**
  30715. * Sets wether tonemapping is enabled or not
  30716. */
  30717. set cameraToneMappingEnabled(value: boolean);
  30718. /**
  30719. * The camera exposure used on this material.
  30720. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30721. * This corresponds to a photographic exposure.
  30722. */
  30723. get cameraExposure(): number;
  30724. /**
  30725. * The camera exposure used on this material.
  30726. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30727. * This corresponds to a photographic exposure.
  30728. */
  30729. set cameraExposure(value: number);
  30730. /**
  30731. * Gets The camera contrast used on this material.
  30732. */
  30733. get cameraContrast(): number;
  30734. /**
  30735. * Sets The camera contrast used on this material.
  30736. */
  30737. set cameraContrast(value: number);
  30738. /**
  30739. * Gets the Color Grading 2D Lookup Texture.
  30740. */
  30741. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30742. /**
  30743. * Sets the Color Grading 2D Lookup Texture.
  30744. */
  30745. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30746. /**
  30747. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30748. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30749. * 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;
  30750. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30751. */
  30752. get cameraColorCurves(): Nullable<ColorCurves>;
  30753. /**
  30754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30756. * 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;
  30757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30758. */
  30759. set cameraColorCurves(value: Nullable<ColorCurves>);
  30760. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30761. protected _worldViewProjectionMatrix: Matrix;
  30762. protected _globalAmbientColor: Color3;
  30763. protected _useLogarithmicDepth: boolean;
  30764. protected _rebuildInParallel: boolean;
  30765. /**
  30766. * Instantiates a new standard material.
  30767. * This is the default material used in Babylon. It is the best trade off between quality
  30768. * and performances.
  30769. * @see http://doc.babylonjs.com/babylon101/materials
  30770. * @param name Define the name of the material in the scene
  30771. * @param scene Define the scene the material belong to
  30772. */
  30773. constructor(name: string, scene: Scene);
  30774. /**
  30775. * Gets a boolean indicating that current material needs to register RTT
  30776. */
  30777. get hasRenderTargetTextures(): boolean;
  30778. /**
  30779. * Gets the current class name of the material e.g. "StandardMaterial"
  30780. * Mainly use in serialization.
  30781. * @returns the class name
  30782. */
  30783. getClassName(): string;
  30784. /**
  30785. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30786. * You can try switching to logarithmic depth.
  30787. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30788. */
  30789. get useLogarithmicDepth(): boolean;
  30790. set useLogarithmicDepth(value: boolean);
  30791. /**
  30792. * Specifies if the material will require alpha blending
  30793. * @returns a boolean specifying if alpha blending is needed
  30794. */
  30795. needAlphaBlending(): boolean;
  30796. /**
  30797. * Specifies if this material should be rendered in alpha test mode
  30798. * @returns a boolean specifying if an alpha test is needed.
  30799. */
  30800. needAlphaTesting(): boolean;
  30801. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30802. /**
  30803. * Get the texture used for alpha test purpose.
  30804. * @returns the diffuse texture in case of the standard material.
  30805. */
  30806. getAlphaTestTexture(): Nullable<BaseTexture>;
  30807. /**
  30808. * Get if the submesh is ready to be used and all its information available.
  30809. * Child classes can use it to update shaders
  30810. * @param mesh defines the mesh to check
  30811. * @param subMesh defines which submesh to check
  30812. * @param useInstances specifies that instances should be used
  30813. * @returns a boolean indicating that the submesh is ready or not
  30814. */
  30815. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30816. /**
  30817. * Builds the material UBO layouts.
  30818. * Used internally during the effect preparation.
  30819. */
  30820. buildUniformLayout(): void;
  30821. /**
  30822. * Unbinds the material from the mesh
  30823. */
  30824. unbind(): void;
  30825. /**
  30826. * Binds the submesh to this material by preparing the effect and shader to draw
  30827. * @param world defines the world transformation matrix
  30828. * @param mesh defines the mesh containing the submesh
  30829. * @param subMesh defines the submesh to bind the material to
  30830. */
  30831. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30832. /**
  30833. * Get the list of animatables in the material.
  30834. * @returns the list of animatables object used in the material
  30835. */
  30836. getAnimatables(): IAnimatable[];
  30837. /**
  30838. * Gets the active textures from the material
  30839. * @returns an array of textures
  30840. */
  30841. getActiveTextures(): BaseTexture[];
  30842. /**
  30843. * Specifies if the material uses a texture
  30844. * @param texture defines the texture to check against the material
  30845. * @returns a boolean specifying if the material uses the texture
  30846. */
  30847. hasTexture(texture: BaseTexture): boolean;
  30848. /**
  30849. * Disposes the material
  30850. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30851. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30852. */
  30853. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30854. /**
  30855. * Makes a duplicate of the material, and gives it a new name
  30856. * @param name defines the new name for the duplicated material
  30857. * @returns the cloned material
  30858. */
  30859. clone(name: string): StandardMaterial;
  30860. /**
  30861. * Serializes this material in a JSON representation
  30862. * @returns the serialized material object
  30863. */
  30864. serialize(): any;
  30865. /**
  30866. * Creates a standard material from parsed material data
  30867. * @param source defines the JSON representation of the material
  30868. * @param scene defines the hosting scene
  30869. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30870. * @returns a new standard material
  30871. */
  30872. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30873. /**
  30874. * Are diffuse textures enabled in the application.
  30875. */
  30876. static get DiffuseTextureEnabled(): boolean;
  30877. static set DiffuseTextureEnabled(value: boolean);
  30878. /**
  30879. * Are ambient textures enabled in the application.
  30880. */
  30881. static get AmbientTextureEnabled(): boolean;
  30882. static set AmbientTextureEnabled(value: boolean);
  30883. /**
  30884. * Are opacity textures enabled in the application.
  30885. */
  30886. static get OpacityTextureEnabled(): boolean;
  30887. static set OpacityTextureEnabled(value: boolean);
  30888. /**
  30889. * Are reflection textures enabled in the application.
  30890. */
  30891. static get ReflectionTextureEnabled(): boolean;
  30892. static set ReflectionTextureEnabled(value: boolean);
  30893. /**
  30894. * Are emissive textures enabled in the application.
  30895. */
  30896. static get EmissiveTextureEnabled(): boolean;
  30897. static set EmissiveTextureEnabled(value: boolean);
  30898. /**
  30899. * Are specular textures enabled in the application.
  30900. */
  30901. static get SpecularTextureEnabled(): boolean;
  30902. static set SpecularTextureEnabled(value: boolean);
  30903. /**
  30904. * Are bump textures enabled in the application.
  30905. */
  30906. static get BumpTextureEnabled(): boolean;
  30907. static set BumpTextureEnabled(value: boolean);
  30908. /**
  30909. * Are lightmap textures enabled in the application.
  30910. */
  30911. static get LightmapTextureEnabled(): boolean;
  30912. static set LightmapTextureEnabled(value: boolean);
  30913. /**
  30914. * Are refraction textures enabled in the application.
  30915. */
  30916. static get RefractionTextureEnabled(): boolean;
  30917. static set RefractionTextureEnabled(value: boolean);
  30918. /**
  30919. * Are color grading textures enabled in the application.
  30920. */
  30921. static get ColorGradingTextureEnabled(): boolean;
  30922. static set ColorGradingTextureEnabled(value: boolean);
  30923. /**
  30924. * Are fresnels enabled in the application.
  30925. */
  30926. static get FresnelEnabled(): boolean;
  30927. static set FresnelEnabled(value: boolean);
  30928. }
  30929. }
  30930. declare module "babylonjs/Particles/solidParticleSystem" {
  30931. import { Nullable } from "babylonjs/types";
  30932. import { Mesh } from "babylonjs/Meshes/mesh";
  30933. import { Scene, IDisposable } from "babylonjs/scene";
  30934. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  30935. import { Material } from "babylonjs/Materials/material";
  30936. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  30937. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  30938. /**
  30939. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30940. *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.
  30941. * The SPS is also a particle system. It provides some methods to manage the particles.
  30942. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30943. *
  30944. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30945. */
  30946. export class SolidParticleSystem implements IDisposable {
  30947. /**
  30948. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30949. * Example : var p = SPS.particles[i];
  30950. */
  30951. particles: SolidParticle[];
  30952. /**
  30953. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30954. */
  30955. nbParticles: number;
  30956. /**
  30957. * If the particles must ever face the camera (default false). Useful for planar particles.
  30958. */
  30959. billboard: boolean;
  30960. /**
  30961. * Recompute normals when adding a shape
  30962. */
  30963. recomputeNormals: boolean;
  30964. /**
  30965. * This a counter ofr your own usage. It's not set by any SPS functions.
  30966. */
  30967. counter: number;
  30968. /**
  30969. * The SPS name. This name is also given to the underlying mesh.
  30970. */
  30971. name: string;
  30972. /**
  30973. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30974. */
  30975. mesh: Mesh;
  30976. /**
  30977. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30978. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30979. */
  30980. vars: any;
  30981. /**
  30982. * This array is populated when the SPS is set as 'pickable'.
  30983. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30984. * Each element of this array is an object `{idx: int, faceId: int}`.
  30985. * `idx` is the picked particle index in the `SPS.particles` array
  30986. * `faceId` is the picked face index counted within this particle.
  30987. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30988. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30989. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30990. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30991. */
  30992. pickedParticles: {
  30993. idx: number;
  30994. faceId: number;
  30995. }[];
  30996. /**
  30997. * This array is populated when the SPS is set as 'pickable'
  30998. * Each key of this array is a submesh index.
  30999. * Each element of this array is a second array defined like this :
  31000. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31001. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31002. * `idx` is the picked particle index in the `SPS.particles` array
  31003. * `faceId` is the picked face index counted within this particle.
  31004. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31005. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31006. */
  31007. pickedBySubMesh: {
  31008. idx: number;
  31009. faceId: number;
  31010. }[][];
  31011. /**
  31012. * This array is populated when `enableDepthSort` is set to true.
  31013. * Each element of this array is an instance of the class DepthSortedParticle.
  31014. */
  31015. depthSortedParticles: DepthSortedParticle[];
  31016. /**
  31017. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31018. * @hidden
  31019. */
  31020. _bSphereOnly: boolean;
  31021. /**
  31022. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31023. * @hidden
  31024. */
  31025. _bSphereRadiusFactor: number;
  31026. private _scene;
  31027. private _positions;
  31028. private _indices;
  31029. private _normals;
  31030. private _colors;
  31031. private _uvs;
  31032. private _indices32;
  31033. private _positions32;
  31034. private _normals32;
  31035. private _fixedNormal32;
  31036. private _colors32;
  31037. private _uvs32;
  31038. private _index;
  31039. private _updatable;
  31040. private _pickable;
  31041. private _isVisibilityBoxLocked;
  31042. private _alwaysVisible;
  31043. private _depthSort;
  31044. private _expandable;
  31045. private _shapeCounter;
  31046. private _copy;
  31047. private _color;
  31048. private _computeParticleColor;
  31049. private _computeParticleTexture;
  31050. private _computeParticleRotation;
  31051. private _computeParticleVertex;
  31052. private _computeBoundingBox;
  31053. private _depthSortParticles;
  31054. private _camera;
  31055. private _mustUnrotateFixedNormals;
  31056. private _particlesIntersect;
  31057. private _needs32Bits;
  31058. private _isNotBuilt;
  31059. private _lastParticleId;
  31060. private _idxOfId;
  31061. private _multimaterialEnabled;
  31062. private _useModelMaterial;
  31063. private _indicesByMaterial;
  31064. private _materialIndexes;
  31065. private _depthSortFunction;
  31066. private _materialSortFunction;
  31067. private _materials;
  31068. private _multimaterial;
  31069. private _materialIndexesById;
  31070. private _defaultMaterial;
  31071. private _autoUpdateSubMeshes;
  31072. private _tmpVertex;
  31073. /**
  31074. * Creates a SPS (Solid Particle System) object.
  31075. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31076. * @param scene (Scene) is the scene in which the SPS is added.
  31077. * @param options defines the options of the sps e.g.
  31078. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31079. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31080. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31081. * * 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.
  31082. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31083. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31084. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31085. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31086. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31087. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31088. */
  31089. constructor(name: string, scene: Scene, options?: {
  31090. updatable?: boolean;
  31091. isPickable?: boolean;
  31092. enableDepthSort?: boolean;
  31093. particleIntersection?: boolean;
  31094. boundingSphereOnly?: boolean;
  31095. bSphereRadiusFactor?: number;
  31096. expandable?: boolean;
  31097. useModelMaterial?: boolean;
  31098. enableMultiMaterial?: boolean;
  31099. });
  31100. /**
  31101. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31102. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31103. * @returns the created mesh
  31104. */
  31105. buildMesh(): Mesh;
  31106. /**
  31107. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31108. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31109. * Thus the particles generated from `digest()` have their property `position` set yet.
  31110. * @param mesh ( Mesh ) is the mesh to be digested
  31111. * @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
  31112. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31113. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31114. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31115. * @returns the current SPS
  31116. */
  31117. digest(mesh: Mesh, options?: {
  31118. facetNb?: number;
  31119. number?: number;
  31120. delta?: number;
  31121. storage?: [];
  31122. }): SolidParticleSystem;
  31123. /**
  31124. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31125. * @hidden
  31126. */
  31127. private _unrotateFixedNormals;
  31128. /**
  31129. * Resets the temporary working copy particle
  31130. * @hidden
  31131. */
  31132. private _resetCopy;
  31133. /**
  31134. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31135. * @param p the current index in the positions array to be updated
  31136. * @param ind the current index in the indices array
  31137. * @param shape a Vector3 array, the shape geometry
  31138. * @param positions the positions array to be updated
  31139. * @param meshInd the shape indices array
  31140. * @param indices the indices array to be updated
  31141. * @param meshUV the shape uv array
  31142. * @param uvs the uv array to be updated
  31143. * @param meshCol the shape color array
  31144. * @param colors the color array to be updated
  31145. * @param meshNor the shape normals array
  31146. * @param normals the normals array to be updated
  31147. * @param idx the particle index
  31148. * @param idxInShape the particle index in its shape
  31149. * @param options the addShape() method passed options
  31150. * @model the particle model
  31151. * @hidden
  31152. */
  31153. private _meshBuilder;
  31154. /**
  31155. * Returns a shape Vector3 array from positions float array
  31156. * @param positions float array
  31157. * @returns a vector3 array
  31158. * @hidden
  31159. */
  31160. private _posToShape;
  31161. /**
  31162. * Returns a shapeUV array from a float uvs (array deep copy)
  31163. * @param uvs as a float array
  31164. * @returns a shapeUV array
  31165. * @hidden
  31166. */
  31167. private _uvsToShapeUV;
  31168. /**
  31169. * Adds a new particle object in the particles array
  31170. * @param idx particle index in particles array
  31171. * @param id particle id
  31172. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31173. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31174. * @param model particle ModelShape object
  31175. * @param shapeId model shape identifier
  31176. * @param idxInShape index of the particle in the current model
  31177. * @param bInfo model bounding info object
  31178. * @param storage target storage array, if any
  31179. * @hidden
  31180. */
  31181. private _addParticle;
  31182. /**
  31183. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31184. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31185. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31186. * @param nb (positive integer) the number of particles to be created from this model
  31187. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31188. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31189. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31190. * @returns the number of shapes in the system
  31191. */
  31192. addShape(mesh: Mesh, nb: number, options?: {
  31193. positionFunction?: any;
  31194. vertexFunction?: any;
  31195. storage?: [];
  31196. }): number;
  31197. /**
  31198. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31199. * @hidden
  31200. */
  31201. private _rebuildParticle;
  31202. /**
  31203. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31204. * @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.
  31205. * @returns the SPS.
  31206. */
  31207. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31208. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31209. * Returns an array with the removed particles.
  31210. * 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.
  31211. * The SPS can't be empty so at least one particle needs to remain in place.
  31212. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31213. * @param start index of the first particle to remove
  31214. * @param end index of the last particle to remove (included)
  31215. * @returns an array populated with the removed particles
  31216. */
  31217. removeParticles(start: number, end: number): SolidParticle[];
  31218. /**
  31219. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31220. * @param solidParticleArray an array populated with Solid Particles objects
  31221. * @returns the SPS
  31222. */
  31223. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31224. /**
  31225. * Creates a new particle and modifies the SPS mesh geometry :
  31226. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31227. * - calls _addParticle() to populate the particle array
  31228. * factorized code from addShape() and insertParticlesFromArray()
  31229. * @param idx particle index in the particles array
  31230. * @param i particle index in its shape
  31231. * @param modelShape particle ModelShape object
  31232. * @param shape shape vertex array
  31233. * @param meshInd shape indices array
  31234. * @param meshUV shape uv array
  31235. * @param meshCol shape color array
  31236. * @param meshNor shape normals array
  31237. * @param bbInfo shape bounding info
  31238. * @param storage target particle storage
  31239. * @options addShape() passed options
  31240. * @hidden
  31241. */
  31242. private _insertNewParticle;
  31243. /**
  31244. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31245. * This method calls `updateParticle()` for each particle of the SPS.
  31246. * For an animated SPS, it is usually called within the render loop.
  31247. * 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.
  31248. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31249. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31250. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31251. * @returns the SPS.
  31252. */
  31253. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31254. /**
  31255. * Disposes the SPS.
  31256. */
  31257. dispose(): void;
  31258. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31259. * idx is the particle index in the SPS
  31260. * faceId is the picked face index counted within this particle.
  31261. * Returns null if the pickInfo can't identify a picked particle.
  31262. * @param pickingInfo (PickingInfo object)
  31263. * @returns {idx: number, faceId: number} or null
  31264. */
  31265. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31266. idx: number;
  31267. faceId: number;
  31268. }>;
  31269. /**
  31270. * Returns a SolidParticle object from its identifier : particle.id
  31271. * @param id (integer) the particle Id
  31272. * @returns the searched particle or null if not found in the SPS.
  31273. */
  31274. getParticleById(id: number): Nullable<SolidParticle>;
  31275. /**
  31276. * Returns a new array populated with the particles having the passed shapeId.
  31277. * @param shapeId (integer) the shape identifier
  31278. * @returns a new solid particle array
  31279. */
  31280. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31281. /**
  31282. * Populates the passed array "ref" with the particles having the passed shapeId.
  31283. * @param shapeId the shape identifier
  31284. * @returns the SPS
  31285. * @param ref
  31286. */
  31287. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31288. /**
  31289. * Computes the required SubMeshes according the materials assigned to the particles.
  31290. * @returns the solid particle system.
  31291. * Does nothing if called before the SPS mesh is built.
  31292. */
  31293. computeSubMeshes(): SolidParticleSystem;
  31294. /**
  31295. * Sorts the solid particles by material when MultiMaterial is enabled.
  31296. * Updates the indices32 array.
  31297. * Updates the indicesByMaterial array.
  31298. * Updates the mesh indices array.
  31299. * @returns the SPS
  31300. * @hidden
  31301. */
  31302. private _sortParticlesByMaterial;
  31303. /**
  31304. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31305. * @hidden
  31306. */
  31307. private _setMaterialIndexesById;
  31308. /**
  31309. * Returns an array with unique values of Materials from the passed array
  31310. * @param array the material array to be checked and filtered
  31311. * @hidden
  31312. */
  31313. private _filterUniqueMaterialId;
  31314. /**
  31315. * Sets a new Standard Material as _defaultMaterial if not already set.
  31316. * @hidden
  31317. */
  31318. private _setDefaultMaterial;
  31319. /**
  31320. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31321. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31322. * @returns the SPS.
  31323. */
  31324. refreshVisibleSize(): SolidParticleSystem;
  31325. /**
  31326. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31327. * @param size the size (float) of the visibility box
  31328. * note : this doesn't lock the SPS mesh bounding box.
  31329. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31330. */
  31331. setVisibilityBox(size: number): void;
  31332. /**
  31333. * Gets whether the SPS as always visible or not
  31334. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31335. */
  31336. get isAlwaysVisible(): boolean;
  31337. /**
  31338. * Sets the SPS as always visible or not
  31339. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31340. */
  31341. set isAlwaysVisible(val: boolean);
  31342. /**
  31343. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31344. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31345. */
  31346. set isVisibilityBoxLocked(val: boolean);
  31347. /**
  31348. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31349. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31350. */
  31351. get isVisibilityBoxLocked(): boolean;
  31352. /**
  31353. * Tells to `setParticles()` to compute the particle rotations or not.
  31354. * Default value : true. The SPS is faster when it's set to false.
  31355. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31356. */
  31357. set computeParticleRotation(val: boolean);
  31358. /**
  31359. * Tells to `setParticles()` to compute the particle colors or not.
  31360. * Default value : true. The SPS is faster when it's set to false.
  31361. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31362. */
  31363. set computeParticleColor(val: boolean);
  31364. set computeParticleTexture(val: boolean);
  31365. /**
  31366. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31367. * Default value : false. The SPS is faster when it's set to false.
  31368. * Note : the particle custom vertex positions aren't stored values.
  31369. */
  31370. set computeParticleVertex(val: boolean);
  31371. /**
  31372. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31373. */
  31374. set computeBoundingBox(val: boolean);
  31375. /**
  31376. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31377. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31378. * Default : `true`
  31379. */
  31380. set depthSortParticles(val: boolean);
  31381. /**
  31382. * Gets if `setParticles()` computes the particle rotations or not.
  31383. * Default value : true. The SPS is faster when it's set to false.
  31384. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31385. */
  31386. get computeParticleRotation(): boolean;
  31387. /**
  31388. * Gets if `setParticles()` computes the particle colors or not.
  31389. * Default value : true. The SPS is faster when it's set to false.
  31390. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31391. */
  31392. get computeParticleColor(): boolean;
  31393. /**
  31394. * Gets if `setParticles()` computes the particle textures or not.
  31395. * Default value : true. The SPS is faster when it's set to false.
  31396. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31397. */
  31398. get computeParticleTexture(): boolean;
  31399. /**
  31400. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31401. * Default value : false. The SPS is faster when it's set to false.
  31402. * Note : the particle custom vertex positions aren't stored values.
  31403. */
  31404. get computeParticleVertex(): boolean;
  31405. /**
  31406. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31407. */
  31408. get computeBoundingBox(): boolean;
  31409. /**
  31410. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31411. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31412. * Default : `true`
  31413. */
  31414. get depthSortParticles(): boolean;
  31415. /**
  31416. * Gets if the SPS is created as expandable at construction time.
  31417. * Default : `false`
  31418. */
  31419. get expandable(): boolean;
  31420. /**
  31421. * Gets if the SPS supports the Multi Materials
  31422. */
  31423. get multimaterialEnabled(): boolean;
  31424. /**
  31425. * Gets if the SPS uses the model materials for its own multimaterial.
  31426. */
  31427. get useModelMaterial(): boolean;
  31428. /**
  31429. * The SPS used material array.
  31430. */
  31431. get materials(): Material[];
  31432. /**
  31433. * Sets the SPS MultiMaterial from the passed materials.
  31434. * Note : the passed array is internally copied and not used then by reference.
  31435. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31436. */
  31437. setMultiMaterial(materials: Material[]): void;
  31438. /**
  31439. * The SPS computed multimaterial object
  31440. */
  31441. get multimaterial(): MultiMaterial;
  31442. set multimaterial(mm: MultiMaterial);
  31443. /**
  31444. * If the subMeshes must be updated on the next call to setParticles()
  31445. */
  31446. get autoUpdateSubMeshes(): boolean;
  31447. set autoUpdateSubMeshes(val: boolean);
  31448. /**
  31449. * This function does nothing. It may be overwritten to set all the particle first values.
  31450. * The SPS doesn't call this function, you may have to call it by your own.
  31451. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31452. */
  31453. initParticles(): void;
  31454. /**
  31455. * This function does nothing. It may be overwritten to recycle a particle.
  31456. * The SPS doesn't call this function, you may have to call it by your own.
  31457. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31458. * @param particle The particle to recycle
  31459. * @returns the recycled particle
  31460. */
  31461. recycleParticle(particle: SolidParticle): SolidParticle;
  31462. /**
  31463. * Updates a particle : this function should be overwritten by the user.
  31464. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31465. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31466. * @example : just set a particle position or velocity and recycle conditions
  31467. * @param particle The particle to update
  31468. * @returns the updated particle
  31469. */
  31470. updateParticle(particle: SolidParticle): SolidParticle;
  31471. /**
  31472. * Updates a vertex of a particle : it can be overwritten by the user.
  31473. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31474. * @param particle the current particle
  31475. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31476. * @param pt the index of the current vertex in the particle shape
  31477. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31478. * @example : just set a vertex particle position or color
  31479. * @returns the sps
  31480. */
  31481. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31482. /**
  31483. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31484. * This does nothing and may be overwritten by the user.
  31485. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31486. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31487. * @param update the boolean update value actually passed to setParticles()
  31488. */
  31489. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31490. /**
  31491. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31492. * This will be passed three parameters.
  31493. * This does nothing and may be overwritten by the user.
  31494. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31495. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31496. * @param update the boolean update value actually passed to setParticles()
  31497. */
  31498. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31499. }
  31500. }
  31501. declare module "babylonjs/Particles/solidParticle" {
  31502. import { Nullable } from "babylonjs/types";
  31503. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31504. import { Color4 } from "babylonjs/Maths/math.color";
  31505. import { Mesh } from "babylonjs/Meshes/mesh";
  31506. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31507. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31508. import { Plane } from "babylonjs/Maths/math.plane";
  31509. import { Material } from "babylonjs/Materials/material";
  31510. /**
  31511. * Represents one particle of a solid particle system.
  31512. */
  31513. export class SolidParticle {
  31514. /**
  31515. * particle global index
  31516. */
  31517. idx: number;
  31518. /**
  31519. * particle identifier
  31520. */
  31521. id: number;
  31522. /**
  31523. * The color of the particle
  31524. */
  31525. color: Nullable<Color4>;
  31526. /**
  31527. * The world space position of the particle.
  31528. */
  31529. position: Vector3;
  31530. /**
  31531. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31532. */
  31533. rotation: Vector3;
  31534. /**
  31535. * The world space rotation quaternion of the particle.
  31536. */
  31537. rotationQuaternion: Nullable<Quaternion>;
  31538. /**
  31539. * The scaling of the particle.
  31540. */
  31541. scaling: Vector3;
  31542. /**
  31543. * The uvs of the particle.
  31544. */
  31545. uvs: Vector4;
  31546. /**
  31547. * The current speed of the particle.
  31548. */
  31549. velocity: Vector3;
  31550. /**
  31551. * The pivot point in the particle local space.
  31552. */
  31553. pivot: Vector3;
  31554. /**
  31555. * Must the particle be translated from its pivot point in its local space ?
  31556. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31557. * Default : false
  31558. */
  31559. translateFromPivot: boolean;
  31560. /**
  31561. * Is the particle active or not ?
  31562. */
  31563. alive: boolean;
  31564. /**
  31565. * Is the particle visible or not ?
  31566. */
  31567. isVisible: boolean;
  31568. /**
  31569. * Index of this particle in the global "positions" array (Internal use)
  31570. * @hidden
  31571. */
  31572. _pos: number;
  31573. /**
  31574. * @hidden Index of this particle in the global "indices" array (Internal use)
  31575. */
  31576. _ind: number;
  31577. /**
  31578. * @hidden ModelShape of this particle (Internal use)
  31579. */
  31580. _model: ModelShape;
  31581. /**
  31582. * ModelShape id of this particle
  31583. */
  31584. shapeId: number;
  31585. /**
  31586. * Index of the particle in its shape id
  31587. */
  31588. idxInShape: number;
  31589. /**
  31590. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31591. */
  31592. _modelBoundingInfo: BoundingInfo;
  31593. /**
  31594. * @hidden Particle BoundingInfo object (Internal use)
  31595. */
  31596. _boundingInfo: BoundingInfo;
  31597. /**
  31598. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31599. */
  31600. _sps: SolidParticleSystem;
  31601. /**
  31602. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31603. */
  31604. _stillInvisible: boolean;
  31605. /**
  31606. * @hidden Last computed particle rotation matrix
  31607. */
  31608. _rotationMatrix: number[];
  31609. /**
  31610. * Parent particle Id, if any.
  31611. * Default null.
  31612. */
  31613. parentId: Nullable<number>;
  31614. /**
  31615. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31616. */
  31617. materialIndex: Nullable<number>;
  31618. /**
  31619. * Custom object or properties.
  31620. */
  31621. props: Nullable<any>;
  31622. /**
  31623. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31624. * The possible values are :
  31625. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31626. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31627. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31628. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31629. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31630. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31631. * */
  31632. cullingStrategy: number;
  31633. /**
  31634. * @hidden Internal global position in the SPS.
  31635. */
  31636. _globalPosition: Vector3;
  31637. /**
  31638. * Creates a Solid Particle object.
  31639. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31640. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31641. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31642. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31643. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31644. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31645. * @param shapeId (integer) is the model shape identifier in the SPS.
  31646. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31647. * @param sps defines the sps it is associated to
  31648. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31649. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31650. */
  31651. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31652. /**
  31653. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31654. * @param target the particle target
  31655. * @returns the current particle
  31656. */
  31657. copyToRef(target: SolidParticle): SolidParticle;
  31658. /**
  31659. * Legacy support, changed scale to scaling
  31660. */
  31661. get scale(): Vector3;
  31662. /**
  31663. * Legacy support, changed scale to scaling
  31664. */
  31665. set scale(scale: Vector3);
  31666. /**
  31667. * Legacy support, changed quaternion to rotationQuaternion
  31668. */
  31669. get quaternion(): Nullable<Quaternion>;
  31670. /**
  31671. * Legacy support, changed quaternion to rotationQuaternion
  31672. */
  31673. set quaternion(q: Nullable<Quaternion>);
  31674. /**
  31675. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31676. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31677. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31678. * @returns true if it intersects
  31679. */
  31680. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31681. /**
  31682. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31683. * A particle is in the frustum if its bounding box intersects the frustum
  31684. * @param frustumPlanes defines the frustum to test
  31685. * @returns true if the particle is in the frustum planes
  31686. */
  31687. isInFrustum(frustumPlanes: Plane[]): boolean;
  31688. /**
  31689. * get the rotation matrix of the particle
  31690. * @hidden
  31691. */
  31692. getRotationMatrix(m: Matrix): void;
  31693. }
  31694. /**
  31695. * Represents the shape of the model used by one particle of a solid particle system.
  31696. * SPS internal tool, don't use it manually.
  31697. */
  31698. export class ModelShape {
  31699. /**
  31700. * The shape id
  31701. * @hidden
  31702. */
  31703. shapeID: number;
  31704. /**
  31705. * flat array of model positions (internal use)
  31706. * @hidden
  31707. */
  31708. _shape: Vector3[];
  31709. /**
  31710. * flat array of model UVs (internal use)
  31711. * @hidden
  31712. */
  31713. _shapeUV: number[];
  31714. /**
  31715. * color array of the model
  31716. * @hidden
  31717. */
  31718. _shapeColors: number[];
  31719. /**
  31720. * indices array of the model
  31721. * @hidden
  31722. */
  31723. _indices: number[];
  31724. /**
  31725. * normals array of the model
  31726. * @hidden
  31727. */
  31728. _normals: number[];
  31729. /**
  31730. * length of the shape in the model indices array (internal use)
  31731. * @hidden
  31732. */
  31733. _indicesLength: number;
  31734. /**
  31735. * Custom position function (internal use)
  31736. * @hidden
  31737. */
  31738. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31739. /**
  31740. * Custom vertex function (internal use)
  31741. * @hidden
  31742. */
  31743. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31744. /**
  31745. * Model material (internal use)
  31746. * @hidden
  31747. */
  31748. _material: Nullable<Material>;
  31749. /**
  31750. * 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.
  31751. * SPS internal tool, don't use it manually.
  31752. * @hidden
  31753. */
  31754. 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>);
  31755. }
  31756. /**
  31757. * Represents a Depth Sorted Particle in the solid particle system.
  31758. * @hidden
  31759. */
  31760. export class DepthSortedParticle {
  31761. /**
  31762. * Particle index
  31763. */
  31764. idx: number;
  31765. /**
  31766. * Index of the particle in the "indices" array
  31767. */
  31768. ind: number;
  31769. /**
  31770. * Length of the particle shape in the "indices" array
  31771. */
  31772. indicesLength: number;
  31773. /**
  31774. * Squared distance from the particle to the camera
  31775. */
  31776. sqDistance: number;
  31777. /**
  31778. * Material index when used with MultiMaterials
  31779. */
  31780. materialIndex: number;
  31781. /**
  31782. * Creates a new sorted particle
  31783. * @param materialIndex
  31784. */
  31785. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31786. }
  31787. /**
  31788. * Represents a solid particle vertex
  31789. */
  31790. export class SolidParticleVertex {
  31791. /**
  31792. * Vertex position
  31793. */
  31794. position: Vector3;
  31795. /**
  31796. * Vertex color
  31797. */
  31798. color: Color4;
  31799. /**
  31800. * Vertex UV
  31801. */
  31802. uv: Vector2;
  31803. /**
  31804. * Creates a new solid particle vertex
  31805. */
  31806. constructor();
  31807. /** Vertex x coordinate */
  31808. get x(): number;
  31809. set x(val: number);
  31810. /** Vertex y coordinate */
  31811. get y(): number;
  31812. set y(val: number);
  31813. /** Vertex z coordinate */
  31814. get z(): number;
  31815. set z(val: number);
  31816. }
  31817. }
  31818. declare module "babylonjs/Collisions/meshCollisionData" {
  31819. import { Collider } from "babylonjs/Collisions/collider";
  31820. import { Vector3 } from "babylonjs/Maths/math.vector";
  31821. import { Nullable } from "babylonjs/types";
  31822. import { Observer } from "babylonjs/Misc/observable";
  31823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31824. /**
  31825. * @hidden
  31826. */
  31827. export class _MeshCollisionData {
  31828. _checkCollisions: boolean;
  31829. _collisionMask: number;
  31830. _collisionGroup: number;
  31831. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31832. _collider: Nullable<Collider>;
  31833. _oldPositionForCollisions: Vector3;
  31834. _diffPositionForCollisions: Vector3;
  31835. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31836. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31837. }
  31838. }
  31839. declare module "babylonjs/Meshes/abstractMesh" {
  31840. import { Observable } from "babylonjs/Misc/observable";
  31841. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  31842. import { Camera } from "babylonjs/Cameras/camera";
  31843. import { Scene, IDisposable } from "babylonjs/scene";
  31844. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31845. import { Node } from "babylonjs/node";
  31846. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  31847. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31848. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31849. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31850. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31851. import { Material } from "babylonjs/Materials/material";
  31852. import { Light } from "babylonjs/Lights/light";
  31853. import { Skeleton } from "babylonjs/Bones/skeleton";
  31854. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  31855. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  31856. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31857. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  31858. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  31859. import { Plane } from "babylonjs/Maths/math.plane";
  31860. import { Ray } from "babylonjs/Culling/ray";
  31861. import { Collider } from "babylonjs/Collisions/collider";
  31862. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31863. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  31864. /** @hidden */
  31865. class _FacetDataStorage {
  31866. facetPositions: Vector3[];
  31867. facetNormals: Vector3[];
  31868. facetPartitioning: number[][];
  31869. facetNb: number;
  31870. partitioningSubdivisions: number;
  31871. partitioningBBoxRatio: number;
  31872. facetDataEnabled: boolean;
  31873. facetParameters: any;
  31874. bbSize: Vector3;
  31875. subDiv: {
  31876. max: number;
  31877. X: number;
  31878. Y: number;
  31879. Z: number;
  31880. };
  31881. facetDepthSort: boolean;
  31882. facetDepthSortEnabled: boolean;
  31883. depthSortedIndices: IndicesArray;
  31884. depthSortedFacets: {
  31885. ind: number;
  31886. sqDistance: number;
  31887. }[];
  31888. facetDepthSortFunction: (f1: {
  31889. ind: number;
  31890. sqDistance: number;
  31891. }, f2: {
  31892. ind: number;
  31893. sqDistance: number;
  31894. }) => number;
  31895. facetDepthSortFrom: Vector3;
  31896. facetDepthSortOrigin: Vector3;
  31897. invertedMatrix: Matrix;
  31898. }
  31899. /**
  31900. * @hidden
  31901. **/
  31902. class _InternalAbstractMeshDataInfo {
  31903. _hasVertexAlpha: boolean;
  31904. _useVertexColors: boolean;
  31905. _numBoneInfluencers: number;
  31906. _applyFog: boolean;
  31907. _receiveShadows: boolean;
  31908. _facetData: _FacetDataStorage;
  31909. _visibility: number;
  31910. _skeleton: Nullable<Skeleton>;
  31911. _layerMask: number;
  31912. _computeBonesUsingShaders: boolean;
  31913. _isActive: boolean;
  31914. _onlyForInstances: boolean;
  31915. _isActiveIntermediate: boolean;
  31916. _onlyForInstancesIntermediate: boolean;
  31917. _actAsRegularMesh: boolean;
  31918. }
  31919. /**
  31920. * Class used to store all common mesh properties
  31921. */
  31922. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31923. /** No occlusion */
  31924. static OCCLUSION_TYPE_NONE: number;
  31925. /** Occlusion set to optimisitic */
  31926. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31927. /** Occlusion set to strict */
  31928. static OCCLUSION_TYPE_STRICT: number;
  31929. /** Use an accurante occlusion algorithm */
  31930. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31931. /** Use a conservative occlusion algorithm */
  31932. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31933. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31934. * Test order :
  31935. * Is the bounding sphere outside the frustum ?
  31936. * If not, are the bounding box vertices outside the frustum ?
  31937. * It not, then the cullable object is in the frustum.
  31938. */
  31939. static readonly CULLINGSTRATEGY_STANDARD: number;
  31940. /** Culling strategy : Bounding Sphere Only.
  31941. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31942. * It's also less accurate than the standard because some not visible objects can still be selected.
  31943. * Test : is the bounding sphere outside the frustum ?
  31944. * If not, then the cullable object is in the frustum.
  31945. */
  31946. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31947. /** Culling strategy : Optimistic Inclusion.
  31948. * This in an inclusion test first, then the standard exclusion test.
  31949. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31950. * 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.
  31951. * Anyway, it's as accurate as the standard strategy.
  31952. * Test :
  31953. * Is the cullable object bounding sphere center in the frustum ?
  31954. * If not, apply the default culling strategy.
  31955. */
  31956. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31957. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31958. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31959. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31960. * 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.
  31961. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31962. * Test :
  31963. * Is the cullable object bounding sphere center in the frustum ?
  31964. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31965. */
  31966. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31967. /**
  31968. * No billboard
  31969. */
  31970. static get BILLBOARDMODE_NONE(): number;
  31971. /** Billboard on X axis */
  31972. static get BILLBOARDMODE_X(): number;
  31973. /** Billboard on Y axis */
  31974. static get BILLBOARDMODE_Y(): number;
  31975. /** Billboard on Z axis */
  31976. static get BILLBOARDMODE_Z(): number;
  31977. /** Billboard on all axes */
  31978. static get BILLBOARDMODE_ALL(): number;
  31979. /** Billboard on using position instead of orientation */
  31980. static get BILLBOARDMODE_USE_POSITION(): number;
  31981. /** @hidden */
  31982. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31983. /**
  31984. * The culling strategy to use to check whether the mesh must be rendered or not.
  31985. * This value can be changed at any time and will be used on the next render mesh selection.
  31986. * The possible values are :
  31987. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31988. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31989. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31990. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31991. * Please read each static variable documentation to get details about the culling process.
  31992. * */
  31993. cullingStrategy: number;
  31994. /**
  31995. * Gets the number of facets in the mesh
  31996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31997. */
  31998. get facetNb(): number;
  31999. /**
  32000. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32002. */
  32003. get partitioningSubdivisions(): number;
  32004. set partitioningSubdivisions(nb: number);
  32005. /**
  32006. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32007. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32008. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32009. */
  32010. get partitioningBBoxRatio(): number;
  32011. set partitioningBBoxRatio(ratio: number);
  32012. /**
  32013. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32014. * Works only for updatable meshes.
  32015. * Doesn't work with multi-materials
  32016. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32017. */
  32018. get mustDepthSortFacets(): boolean;
  32019. set mustDepthSortFacets(sort: boolean);
  32020. /**
  32021. * The location (Vector3) where the facet depth sort must be computed from.
  32022. * By default, the active camera position.
  32023. * Used only when facet depth sort is enabled
  32024. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32025. */
  32026. get facetDepthSortFrom(): Vector3;
  32027. set facetDepthSortFrom(location: Vector3);
  32028. /**
  32029. * gets a boolean indicating if facetData is enabled
  32030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32031. */
  32032. get isFacetDataEnabled(): boolean;
  32033. /** @hidden */
  32034. _updateNonUniformScalingState(value: boolean): boolean;
  32035. /**
  32036. * An event triggered when this mesh collides with another one
  32037. */
  32038. onCollideObservable: Observable<AbstractMesh>;
  32039. /** Set a function to call when this mesh collides with another one */
  32040. set onCollide(callback: () => void);
  32041. /**
  32042. * An event triggered when the collision's position changes
  32043. */
  32044. onCollisionPositionChangeObservable: Observable<Vector3>;
  32045. /** Set a function to call when the collision's position changes */
  32046. set onCollisionPositionChange(callback: () => void);
  32047. /**
  32048. * An event triggered when material is changed
  32049. */
  32050. onMaterialChangedObservable: Observable<AbstractMesh>;
  32051. /**
  32052. * Gets or sets the orientation for POV movement & rotation
  32053. */
  32054. definedFacingForward: boolean;
  32055. /** @hidden */
  32056. _occlusionQuery: Nullable<WebGLQuery>;
  32057. /** @hidden */
  32058. _renderingGroup: Nullable<RenderingGroup>;
  32059. /**
  32060. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32061. */
  32062. get visibility(): number;
  32063. /**
  32064. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32065. */
  32066. set visibility(value: number);
  32067. /** Gets or sets the alpha index used to sort transparent meshes
  32068. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32069. */
  32070. alphaIndex: number;
  32071. /**
  32072. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32073. */
  32074. isVisible: boolean;
  32075. /**
  32076. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32077. */
  32078. isPickable: boolean;
  32079. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32080. showSubMeshesBoundingBox: boolean;
  32081. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32082. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32083. */
  32084. isBlocker: boolean;
  32085. /**
  32086. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32087. */
  32088. enablePointerMoveEvents: boolean;
  32089. /**
  32090. * Specifies the rendering group id for this mesh (0 by default)
  32091. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32092. */
  32093. renderingGroupId: number;
  32094. private _material;
  32095. /** Gets or sets current material */
  32096. get material(): Nullable<Material>;
  32097. set material(value: Nullable<Material>);
  32098. /**
  32099. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32100. * @see http://doc.babylonjs.com/babylon101/shadows
  32101. */
  32102. get receiveShadows(): boolean;
  32103. set receiveShadows(value: boolean);
  32104. /** Defines color to use when rendering outline */
  32105. outlineColor: Color3;
  32106. /** Define width to use when rendering outline */
  32107. outlineWidth: number;
  32108. /** Defines color to use when rendering overlay */
  32109. overlayColor: Color3;
  32110. /** Defines alpha to use when rendering overlay */
  32111. overlayAlpha: number;
  32112. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32113. get hasVertexAlpha(): boolean;
  32114. set hasVertexAlpha(value: boolean);
  32115. /** 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) */
  32116. get useVertexColors(): boolean;
  32117. set useVertexColors(value: boolean);
  32118. /**
  32119. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32120. */
  32121. get computeBonesUsingShaders(): boolean;
  32122. set computeBonesUsingShaders(value: boolean);
  32123. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32124. get numBoneInfluencers(): number;
  32125. set numBoneInfluencers(value: number);
  32126. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32127. get applyFog(): boolean;
  32128. set applyFog(value: boolean);
  32129. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32130. useOctreeForRenderingSelection: boolean;
  32131. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32132. useOctreeForPicking: boolean;
  32133. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32134. useOctreeForCollisions: boolean;
  32135. /**
  32136. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32137. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32138. */
  32139. get layerMask(): number;
  32140. set layerMask(value: number);
  32141. /**
  32142. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32143. */
  32144. alwaysSelectAsActiveMesh: boolean;
  32145. /**
  32146. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32147. */
  32148. doNotSyncBoundingInfo: boolean;
  32149. /**
  32150. * Gets or sets the current action manager
  32151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32152. */
  32153. actionManager: Nullable<AbstractActionManager>;
  32154. private _meshCollisionData;
  32155. /**
  32156. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32157. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32158. */
  32159. ellipsoid: Vector3;
  32160. /**
  32161. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32162. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32163. */
  32164. ellipsoidOffset: Vector3;
  32165. /**
  32166. * Gets or sets a collision mask used to mask collisions (default is -1).
  32167. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32168. */
  32169. get collisionMask(): number;
  32170. set collisionMask(mask: number);
  32171. /**
  32172. * Gets or sets the current collision group mask (-1 by default).
  32173. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32174. */
  32175. get collisionGroup(): number;
  32176. set collisionGroup(mask: number);
  32177. /**
  32178. * Gets or sets current surrounding meshes (null by default).
  32179. *
  32180. * By default collision detection is tested against every mesh in the scene.
  32181. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32182. * meshes will be tested for the collision.
  32183. *
  32184. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32185. */
  32186. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32187. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32188. /**
  32189. * Defines edge width used when edgesRenderer is enabled
  32190. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32191. */
  32192. edgesWidth: number;
  32193. /**
  32194. * Defines edge color used when edgesRenderer is enabled
  32195. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32196. */
  32197. edgesColor: Color4;
  32198. /** @hidden */
  32199. _edgesRenderer: Nullable<IEdgesRenderer>;
  32200. /** @hidden */
  32201. _masterMesh: Nullable<AbstractMesh>;
  32202. /** @hidden */
  32203. _boundingInfo: Nullable<BoundingInfo>;
  32204. /** @hidden */
  32205. _renderId: number;
  32206. /**
  32207. * Gets or sets the list of subMeshes
  32208. * @see http://doc.babylonjs.com/how_to/multi_materials
  32209. */
  32210. subMeshes: SubMesh[];
  32211. /** @hidden */
  32212. _intersectionsInProgress: AbstractMesh[];
  32213. /** @hidden */
  32214. _unIndexed: boolean;
  32215. /** @hidden */
  32216. _lightSources: Light[];
  32217. /** Gets the list of lights affecting that mesh */
  32218. get lightSources(): Light[];
  32219. /** @hidden */
  32220. get _positions(): Nullable<Vector3[]>;
  32221. /** @hidden */
  32222. _waitingData: {
  32223. lods: Nullable<any>;
  32224. actions: Nullable<any>;
  32225. freezeWorldMatrix: Nullable<boolean>;
  32226. };
  32227. /** @hidden */
  32228. _bonesTransformMatrices: Nullable<Float32Array>;
  32229. /** @hidden */
  32230. _transformMatrixTexture: Nullable<RawTexture>;
  32231. /**
  32232. * Gets or sets a skeleton to apply skining transformations
  32233. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32234. */
  32235. set skeleton(value: Nullable<Skeleton>);
  32236. get skeleton(): Nullable<Skeleton>;
  32237. /**
  32238. * An event triggered when the mesh is rebuilt.
  32239. */
  32240. onRebuildObservable: Observable<AbstractMesh>;
  32241. /**
  32242. * Creates a new AbstractMesh
  32243. * @param name defines the name of the mesh
  32244. * @param scene defines the hosting scene
  32245. */
  32246. constructor(name: string, scene?: Nullable<Scene>);
  32247. /**
  32248. * Returns the string "AbstractMesh"
  32249. * @returns "AbstractMesh"
  32250. */
  32251. getClassName(): string;
  32252. /**
  32253. * Gets a string representation of the current mesh
  32254. * @param fullDetails defines a boolean indicating if full details must be included
  32255. * @returns a string representation of the current mesh
  32256. */
  32257. toString(fullDetails?: boolean): string;
  32258. /**
  32259. * @hidden
  32260. */
  32261. protected _getEffectiveParent(): Nullable<Node>;
  32262. /** @hidden */
  32263. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32264. /** @hidden */
  32265. _rebuild(): void;
  32266. /** @hidden */
  32267. _resyncLightSources(): void;
  32268. /** @hidden */
  32269. _resyncLightSource(light: Light): void;
  32270. /** @hidden */
  32271. _unBindEffect(): void;
  32272. /** @hidden */
  32273. _removeLightSource(light: Light, dispose: boolean): void;
  32274. private _markSubMeshesAsDirty;
  32275. /** @hidden */
  32276. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32277. /** @hidden */
  32278. _markSubMeshesAsAttributesDirty(): void;
  32279. /** @hidden */
  32280. _markSubMeshesAsMiscDirty(): void;
  32281. /**
  32282. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32283. */
  32284. get scaling(): Vector3;
  32285. set scaling(newScaling: Vector3);
  32286. /**
  32287. * Returns true if the mesh is blocked. Implemented by child classes
  32288. */
  32289. get isBlocked(): boolean;
  32290. /**
  32291. * Returns the mesh itself by default. Implemented by child classes
  32292. * @param camera defines the camera to use to pick the right LOD level
  32293. * @returns the currentAbstractMesh
  32294. */
  32295. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32296. /**
  32297. * Returns 0 by default. Implemented by child classes
  32298. * @returns an integer
  32299. */
  32300. getTotalVertices(): number;
  32301. /**
  32302. * Returns a positive integer : the total number of indices in this mesh geometry.
  32303. * @returns the numner of indices or zero if the mesh has no geometry.
  32304. */
  32305. getTotalIndices(): number;
  32306. /**
  32307. * Returns null by default. Implemented by child classes
  32308. * @returns null
  32309. */
  32310. getIndices(): Nullable<IndicesArray>;
  32311. /**
  32312. * Returns the array of the requested vertex data kind. Implemented by child classes
  32313. * @param kind defines the vertex data kind to use
  32314. * @returns null
  32315. */
  32316. getVerticesData(kind: string): Nullable<FloatArray>;
  32317. /**
  32318. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32319. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32320. * Note that a new underlying VertexBuffer object is created each call.
  32321. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32322. * @param kind defines vertex data kind:
  32323. * * VertexBuffer.PositionKind
  32324. * * VertexBuffer.UVKind
  32325. * * VertexBuffer.UV2Kind
  32326. * * VertexBuffer.UV3Kind
  32327. * * VertexBuffer.UV4Kind
  32328. * * VertexBuffer.UV5Kind
  32329. * * VertexBuffer.UV6Kind
  32330. * * VertexBuffer.ColorKind
  32331. * * VertexBuffer.MatricesIndicesKind
  32332. * * VertexBuffer.MatricesIndicesExtraKind
  32333. * * VertexBuffer.MatricesWeightsKind
  32334. * * VertexBuffer.MatricesWeightsExtraKind
  32335. * @param data defines the data source
  32336. * @param updatable defines if the data must be flagged as updatable (or static)
  32337. * @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
  32338. * @returns the current mesh
  32339. */
  32340. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32341. /**
  32342. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32343. * If the mesh has no geometry, it is simply returned as it is.
  32344. * @param kind defines vertex data kind:
  32345. * * VertexBuffer.PositionKind
  32346. * * VertexBuffer.UVKind
  32347. * * VertexBuffer.UV2Kind
  32348. * * VertexBuffer.UV3Kind
  32349. * * VertexBuffer.UV4Kind
  32350. * * VertexBuffer.UV5Kind
  32351. * * VertexBuffer.UV6Kind
  32352. * * VertexBuffer.ColorKind
  32353. * * VertexBuffer.MatricesIndicesKind
  32354. * * VertexBuffer.MatricesIndicesExtraKind
  32355. * * VertexBuffer.MatricesWeightsKind
  32356. * * VertexBuffer.MatricesWeightsExtraKind
  32357. * @param data defines the data source
  32358. * @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
  32359. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32360. * @returns the current mesh
  32361. */
  32362. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32363. /**
  32364. * Sets the mesh indices,
  32365. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32366. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32367. * @param totalVertices Defines the total number of vertices
  32368. * @returns the current mesh
  32369. */
  32370. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32371. /**
  32372. * Gets a boolean indicating if specific vertex data is present
  32373. * @param kind defines the vertex data kind to use
  32374. * @returns true is data kind is present
  32375. */
  32376. isVerticesDataPresent(kind: string): boolean;
  32377. /**
  32378. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32379. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32380. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32381. * @returns a BoundingInfo
  32382. */
  32383. getBoundingInfo(): BoundingInfo;
  32384. /**
  32385. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32386. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32387. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32388. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32389. * @returns the current mesh
  32390. */
  32391. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32392. /**
  32393. * Overwrite the current bounding info
  32394. * @param boundingInfo defines the new bounding info
  32395. * @returns the current mesh
  32396. */
  32397. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32398. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32399. get useBones(): boolean;
  32400. /** @hidden */
  32401. _preActivate(): void;
  32402. /** @hidden */
  32403. _preActivateForIntermediateRendering(renderId: number): void;
  32404. /** @hidden */
  32405. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32406. /** @hidden */
  32407. _postActivate(): void;
  32408. /** @hidden */
  32409. _freeze(): void;
  32410. /** @hidden */
  32411. _unFreeze(): void;
  32412. /**
  32413. * Gets the current world matrix
  32414. * @returns a Matrix
  32415. */
  32416. getWorldMatrix(): Matrix;
  32417. /** @hidden */
  32418. _getWorldMatrixDeterminant(): number;
  32419. /**
  32420. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32421. */
  32422. get isAnInstance(): boolean;
  32423. /**
  32424. * Gets a boolean indicating if this mesh has instances
  32425. */
  32426. get hasInstances(): boolean;
  32427. /**
  32428. * Gets a boolean indicating if this mesh has thin instances
  32429. */
  32430. get hasThinInstances(): boolean;
  32431. /**
  32432. * Perform relative position change from the point of view of behind the front of the mesh.
  32433. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32434. * Supports definition of mesh facing forward or backward
  32435. * @param amountRight defines the distance on the right axis
  32436. * @param amountUp defines the distance on the up axis
  32437. * @param amountForward defines the distance on the forward axis
  32438. * @returns the current mesh
  32439. */
  32440. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32441. /**
  32442. * Calculate relative position change from the point of view of behind the front of the mesh.
  32443. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32444. * Supports definition of mesh facing forward or backward
  32445. * @param amountRight defines the distance on the right axis
  32446. * @param amountUp defines the distance on the up axis
  32447. * @param amountForward defines the distance on the forward axis
  32448. * @returns the new displacement vector
  32449. */
  32450. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32451. /**
  32452. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32453. * Supports definition of mesh facing forward or backward
  32454. * @param flipBack defines the flip
  32455. * @param twirlClockwise defines the twirl
  32456. * @param tiltRight defines the tilt
  32457. * @returns the current mesh
  32458. */
  32459. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32460. /**
  32461. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32462. * Supports definition of mesh facing forward or backward.
  32463. * @param flipBack defines the flip
  32464. * @param twirlClockwise defines the twirl
  32465. * @param tiltRight defines the tilt
  32466. * @returns the new rotation vector
  32467. */
  32468. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32469. /**
  32470. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32471. * This means the mesh underlying bounding box and sphere are recomputed.
  32472. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32473. * @returns the current mesh
  32474. */
  32475. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32476. /** @hidden */
  32477. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32478. /** @hidden */
  32479. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32480. /** @hidden */
  32481. _updateBoundingInfo(): AbstractMesh;
  32482. /** @hidden */
  32483. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32484. /** @hidden */
  32485. protected _afterComputeWorldMatrix(): void;
  32486. /** @hidden */
  32487. get _effectiveMesh(): AbstractMesh;
  32488. /**
  32489. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32490. * A mesh is in the frustum if its bounding box intersects the frustum
  32491. * @param frustumPlanes defines the frustum to test
  32492. * @returns true if the mesh is in the frustum planes
  32493. */
  32494. isInFrustum(frustumPlanes: Plane[]): boolean;
  32495. /**
  32496. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32497. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32498. * @param frustumPlanes defines the frustum to test
  32499. * @returns true if the mesh is completely in the frustum planes
  32500. */
  32501. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32502. /**
  32503. * True if the mesh intersects another mesh or a SolidParticle object
  32504. * @param mesh defines a target mesh or SolidParticle to test
  32505. * @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)
  32506. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32507. * @returns true if there is an intersection
  32508. */
  32509. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32510. /**
  32511. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32512. * @param point defines the point to test
  32513. * @returns true if there is an intersection
  32514. */
  32515. intersectsPoint(point: Vector3): boolean;
  32516. /**
  32517. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32518. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32519. */
  32520. get checkCollisions(): boolean;
  32521. set checkCollisions(collisionEnabled: boolean);
  32522. /**
  32523. * Gets Collider object used to compute collisions (not physics)
  32524. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32525. */
  32526. get collider(): Nullable<Collider>;
  32527. /**
  32528. * Move the mesh using collision engine
  32529. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32530. * @param displacement defines the requested displacement vector
  32531. * @returns the current mesh
  32532. */
  32533. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32534. private _onCollisionPositionChange;
  32535. /** @hidden */
  32536. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32537. /** @hidden */
  32538. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32539. /** @hidden */
  32540. _checkCollision(collider: Collider): AbstractMesh;
  32541. /** @hidden */
  32542. _generatePointsArray(): boolean;
  32543. /**
  32544. * Checks if the passed Ray intersects with the mesh
  32545. * @param ray defines the ray to use
  32546. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32547. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32548. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32549. * @returns the picking info
  32550. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32551. */
  32552. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32553. /**
  32554. * Clones the current mesh
  32555. * @param name defines the mesh name
  32556. * @param newParent defines the new mesh parent
  32557. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32558. * @returns the new mesh
  32559. */
  32560. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32561. /**
  32562. * Disposes all the submeshes of the current meshnp
  32563. * @returns the current mesh
  32564. */
  32565. releaseSubMeshes(): AbstractMesh;
  32566. /**
  32567. * Releases resources associated with this abstract mesh.
  32568. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32569. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32570. */
  32571. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32572. /**
  32573. * Adds the passed mesh as a child to the current mesh
  32574. * @param mesh defines the child mesh
  32575. * @returns the current mesh
  32576. */
  32577. addChild(mesh: AbstractMesh): AbstractMesh;
  32578. /**
  32579. * Removes the passed mesh from the current mesh children list
  32580. * @param mesh defines the child mesh
  32581. * @returns the current mesh
  32582. */
  32583. removeChild(mesh: AbstractMesh): AbstractMesh;
  32584. /** @hidden */
  32585. private _initFacetData;
  32586. /**
  32587. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32588. * This method can be called within the render loop.
  32589. * 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
  32590. * @returns the current mesh
  32591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32592. */
  32593. updateFacetData(): AbstractMesh;
  32594. /**
  32595. * Returns the facetLocalNormals array.
  32596. * The normals are expressed in the mesh local spac
  32597. * @returns an array of Vector3
  32598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32599. */
  32600. getFacetLocalNormals(): Vector3[];
  32601. /**
  32602. * Returns the facetLocalPositions array.
  32603. * The facet positions are expressed in the mesh local space
  32604. * @returns an array of Vector3
  32605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32606. */
  32607. getFacetLocalPositions(): Vector3[];
  32608. /**
  32609. * Returns the facetLocalPartioning array
  32610. * @returns an array of array of numbers
  32611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32612. */
  32613. getFacetLocalPartitioning(): number[][];
  32614. /**
  32615. * Returns the i-th facet position in the world system.
  32616. * This method allocates a new Vector3 per call
  32617. * @param i defines the facet index
  32618. * @returns a new Vector3
  32619. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32620. */
  32621. getFacetPosition(i: number): Vector3;
  32622. /**
  32623. * Sets the reference Vector3 with the i-th facet position in the world system
  32624. * @param i defines the facet index
  32625. * @param ref defines the target vector
  32626. * @returns the current mesh
  32627. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32628. */
  32629. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32630. /**
  32631. * Returns the i-th facet normal in the world system.
  32632. * This method allocates a new Vector3 per call
  32633. * @param i defines the facet index
  32634. * @returns a new Vector3
  32635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32636. */
  32637. getFacetNormal(i: number): Vector3;
  32638. /**
  32639. * Sets the reference Vector3 with the i-th facet normal in the world system
  32640. * @param i defines the facet index
  32641. * @param ref defines the target vector
  32642. * @returns the current mesh
  32643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32644. */
  32645. getFacetNormalToRef(i: number, ref: Vector3): this;
  32646. /**
  32647. * 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)
  32648. * @param x defines x coordinate
  32649. * @param y defines y coordinate
  32650. * @param z defines z coordinate
  32651. * @returns the array of facet indexes
  32652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32653. */
  32654. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32655. /**
  32656. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32657. * @param projected sets as the (x,y,z) world projection on the facet
  32658. * @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
  32659. * @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
  32660. * @param x defines x coordinate
  32661. * @param y defines y coordinate
  32662. * @param z defines z coordinate
  32663. * @returns the face index if found (or null instead)
  32664. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32665. */
  32666. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32667. /**
  32668. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32669. * @param projected sets as the (x,y,z) local projection on the facet
  32670. * @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
  32671. * @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
  32672. * @param x defines x coordinate
  32673. * @param y defines y coordinate
  32674. * @param z defines z coordinate
  32675. * @returns the face index if found (or null instead)
  32676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32677. */
  32678. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32679. /**
  32680. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32681. * @returns the parameters
  32682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32683. */
  32684. getFacetDataParameters(): any;
  32685. /**
  32686. * Disables the feature FacetData and frees the related memory
  32687. * @returns the current mesh
  32688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32689. */
  32690. disableFacetData(): AbstractMesh;
  32691. /**
  32692. * Updates the AbstractMesh indices array
  32693. * @param indices defines the data source
  32694. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32695. * @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)
  32696. * @returns the current mesh
  32697. */
  32698. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32699. /**
  32700. * Creates new normals data for the mesh
  32701. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32702. * @returns the current mesh
  32703. */
  32704. createNormals(updatable: boolean): AbstractMesh;
  32705. /**
  32706. * Align the mesh with a normal
  32707. * @param normal defines the normal to use
  32708. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32709. * @returns the current mesh
  32710. */
  32711. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32712. /** @hidden */
  32713. _checkOcclusionQuery(): boolean;
  32714. /**
  32715. * Disables the mesh edge rendering mode
  32716. * @returns the currentAbstractMesh
  32717. */
  32718. disableEdgesRendering(): AbstractMesh;
  32719. /**
  32720. * Enables the edge rendering mode on the mesh.
  32721. * This mode makes the mesh edges visible
  32722. * @param epsilon defines the maximal distance between two angles to detect a face
  32723. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32724. * @returns the currentAbstractMesh
  32725. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32726. */
  32727. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32728. }
  32729. }
  32730. declare module "babylonjs/Actions/actionEvent" {
  32731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32732. import { Nullable } from "babylonjs/types";
  32733. import { Sprite } from "babylonjs/Sprites/sprite";
  32734. import { Scene } from "babylonjs/scene";
  32735. import { Vector2 } from "babylonjs/Maths/math.vector";
  32736. /**
  32737. * Interface used to define ActionEvent
  32738. */
  32739. export interface IActionEvent {
  32740. /** The mesh or sprite that triggered the action */
  32741. source: any;
  32742. /** The X mouse cursor position at the time of the event */
  32743. pointerX: number;
  32744. /** The Y mouse cursor position at the time of the event */
  32745. pointerY: number;
  32746. /** The mesh that is currently pointed at (can be null) */
  32747. meshUnderPointer: Nullable<AbstractMesh>;
  32748. /** the original (browser) event that triggered the ActionEvent */
  32749. sourceEvent?: any;
  32750. /** additional data for the event */
  32751. additionalData?: any;
  32752. }
  32753. /**
  32754. * ActionEvent is the event being sent when an action is triggered.
  32755. */
  32756. export class ActionEvent implements IActionEvent {
  32757. /** The mesh or sprite that triggered the action */
  32758. source: any;
  32759. /** The X mouse cursor position at the time of the event */
  32760. pointerX: number;
  32761. /** The Y mouse cursor position at the time of the event */
  32762. pointerY: number;
  32763. /** The mesh that is currently pointed at (can be null) */
  32764. meshUnderPointer: Nullable<AbstractMesh>;
  32765. /** the original (browser) event that triggered the ActionEvent */
  32766. sourceEvent?: any;
  32767. /** additional data for the event */
  32768. additionalData?: any;
  32769. /**
  32770. * Creates a new ActionEvent
  32771. * @param source The mesh or sprite that triggered the action
  32772. * @param pointerX The X mouse cursor position at the time of the event
  32773. * @param pointerY The Y mouse cursor position at the time of the event
  32774. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32775. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32776. * @param additionalData additional data for the event
  32777. */
  32778. constructor(
  32779. /** The mesh or sprite that triggered the action */
  32780. source: any,
  32781. /** The X mouse cursor position at the time of the event */
  32782. pointerX: number,
  32783. /** The Y mouse cursor position at the time of the event */
  32784. pointerY: number,
  32785. /** The mesh that is currently pointed at (can be null) */
  32786. meshUnderPointer: Nullable<AbstractMesh>,
  32787. /** the original (browser) event that triggered the ActionEvent */
  32788. sourceEvent?: any,
  32789. /** additional data for the event */
  32790. additionalData?: any);
  32791. /**
  32792. * Helper function to auto-create an ActionEvent from a source mesh.
  32793. * @param source The source mesh that triggered the event
  32794. * @param evt The original (browser) event
  32795. * @param additionalData additional data for the event
  32796. * @returns the new ActionEvent
  32797. */
  32798. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32799. /**
  32800. * Helper function to auto-create an ActionEvent from a source sprite
  32801. * @param source The source sprite that triggered the event
  32802. * @param scene Scene associated with the sprite
  32803. * @param evt The original (browser) event
  32804. * @param additionalData additional data for the event
  32805. * @returns the new ActionEvent
  32806. */
  32807. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32808. /**
  32809. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32810. * @param scene the scene where the event occurred
  32811. * @param evt The original (browser) event
  32812. * @returns the new ActionEvent
  32813. */
  32814. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32815. /**
  32816. * Helper function to auto-create an ActionEvent from a primitive
  32817. * @param prim defines the target primitive
  32818. * @param pointerPos defines the pointer position
  32819. * @param evt The original (browser) event
  32820. * @param additionalData additional data for the event
  32821. * @returns the new ActionEvent
  32822. */
  32823. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32824. }
  32825. }
  32826. declare module "babylonjs/Actions/abstractActionManager" {
  32827. import { IDisposable } from "babylonjs/scene";
  32828. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32829. import { IAction } from "babylonjs/Actions/action";
  32830. import { Nullable } from "babylonjs/types";
  32831. /**
  32832. * Abstract class used to decouple action Manager from scene and meshes.
  32833. * Do not instantiate.
  32834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32835. */
  32836. export abstract class AbstractActionManager implements IDisposable {
  32837. /** Gets the list of active triggers */
  32838. static Triggers: {
  32839. [key: string]: number;
  32840. };
  32841. /** Gets the cursor to use when hovering items */
  32842. hoverCursor: string;
  32843. /** Gets the list of actions */
  32844. actions: IAction[];
  32845. /**
  32846. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32847. */
  32848. isRecursive: boolean;
  32849. /**
  32850. * Releases all associated resources
  32851. */
  32852. abstract dispose(): void;
  32853. /**
  32854. * Does this action manager has pointer triggers
  32855. */
  32856. abstract get hasPointerTriggers(): boolean;
  32857. /**
  32858. * Does this action manager has pick triggers
  32859. */
  32860. abstract get hasPickTriggers(): boolean;
  32861. /**
  32862. * Process a specific trigger
  32863. * @param trigger defines the trigger to process
  32864. * @param evt defines the event details to be processed
  32865. */
  32866. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32867. /**
  32868. * Does this action manager handles actions of any of the given triggers
  32869. * @param triggers defines the triggers to be tested
  32870. * @return a boolean indicating whether one (or more) of the triggers is handled
  32871. */
  32872. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32873. /**
  32874. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32875. * speed.
  32876. * @param triggerA defines the trigger to be tested
  32877. * @param triggerB defines the trigger to be tested
  32878. * @return a boolean indicating whether one (or more) of the triggers is handled
  32879. */
  32880. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32881. /**
  32882. * Does this action manager handles actions of a given trigger
  32883. * @param trigger defines the trigger to be tested
  32884. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32885. * @return whether the trigger is handled
  32886. */
  32887. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32888. /**
  32889. * Serialize this manager to a JSON object
  32890. * @param name defines the property name to store this manager
  32891. * @returns a JSON representation of this manager
  32892. */
  32893. abstract serialize(name: string): any;
  32894. /**
  32895. * Registers an action to this action manager
  32896. * @param action defines the action to be registered
  32897. * @return the action amended (prepared) after registration
  32898. */
  32899. abstract registerAction(action: IAction): Nullable<IAction>;
  32900. /**
  32901. * Unregisters an action to this action manager
  32902. * @param action defines the action to be unregistered
  32903. * @return a boolean indicating whether the action has been unregistered
  32904. */
  32905. abstract unregisterAction(action: IAction): Boolean;
  32906. /**
  32907. * Does exist one action manager with at least one trigger
  32908. **/
  32909. static get HasTriggers(): boolean;
  32910. /**
  32911. * Does exist one action manager with at least one pick trigger
  32912. **/
  32913. static get HasPickTriggers(): boolean;
  32914. /**
  32915. * Does exist one action manager that handles actions of a given trigger
  32916. * @param trigger defines the trigger to be tested
  32917. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32918. **/
  32919. static HasSpecificTrigger(trigger: number): boolean;
  32920. }
  32921. }
  32922. declare module "babylonjs/node" {
  32923. import { Scene } from "babylonjs/scene";
  32924. import { Nullable } from "babylonjs/types";
  32925. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32926. import { Engine } from "babylonjs/Engines/engine";
  32927. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  32928. import { Observable } from "babylonjs/Misc/observable";
  32929. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32930. import { IInspectable } from "babylonjs/Misc/iInspectable";
  32931. import { Animatable } from "babylonjs/Animations/animatable";
  32932. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32933. import { Animation } from "babylonjs/Animations/animation";
  32934. import { AnimationRange } from "babylonjs/Animations/animationRange";
  32935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32936. /**
  32937. * Defines how a node can be built from a string name.
  32938. */
  32939. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32940. /**
  32941. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32942. */
  32943. export class Node implements IBehaviorAware<Node> {
  32944. /** @hidden */
  32945. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  32946. private static _NodeConstructors;
  32947. /**
  32948. * Add a new node constructor
  32949. * @param type defines the type name of the node to construct
  32950. * @param constructorFunc defines the constructor function
  32951. */
  32952. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32953. /**
  32954. * Returns a node constructor based on type name
  32955. * @param type defines the type name
  32956. * @param name defines the new node name
  32957. * @param scene defines the hosting scene
  32958. * @param options defines optional options to transmit to constructors
  32959. * @returns the new constructor or null
  32960. */
  32961. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32962. /**
  32963. * Gets or sets the name of the node
  32964. */
  32965. name: string;
  32966. /**
  32967. * Gets or sets the id of the node
  32968. */
  32969. id: string;
  32970. /**
  32971. * Gets or sets the unique id of the node
  32972. */
  32973. uniqueId: number;
  32974. /**
  32975. * Gets or sets a string used to store user defined state for the node
  32976. */
  32977. state: string;
  32978. /**
  32979. * Gets or sets an object used to store user defined information for the node
  32980. */
  32981. metadata: any;
  32982. /**
  32983. * For internal use only. Please do not use.
  32984. */
  32985. reservedDataStore: any;
  32986. /**
  32987. * List of inspectable custom properties (used by the Inspector)
  32988. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32989. */
  32990. inspectableCustomProperties: IInspectable[];
  32991. private _doNotSerialize;
  32992. /**
  32993. * Gets or sets a boolean used to define if the node must be serialized
  32994. */
  32995. get doNotSerialize(): boolean;
  32996. set doNotSerialize(value: boolean);
  32997. /** @hidden */
  32998. _isDisposed: boolean;
  32999. /**
  33000. * Gets a list of Animations associated with the node
  33001. */
  33002. animations: import("babylonjs/Animations/animation").Animation[];
  33003. protected _ranges: {
  33004. [name: string]: Nullable<AnimationRange>;
  33005. };
  33006. /**
  33007. * Callback raised when the node is ready to be used
  33008. */
  33009. onReady: Nullable<(node: Node) => void>;
  33010. private _isEnabled;
  33011. private _isParentEnabled;
  33012. private _isReady;
  33013. /** @hidden */
  33014. _currentRenderId: number;
  33015. private _parentUpdateId;
  33016. /** @hidden */
  33017. _childUpdateId: number;
  33018. /** @hidden */
  33019. _waitingParentId: Nullable<string>;
  33020. /** @hidden */
  33021. _scene: Scene;
  33022. /** @hidden */
  33023. _cache: any;
  33024. private _parentNode;
  33025. private _children;
  33026. /** @hidden */
  33027. _worldMatrix: Matrix;
  33028. /** @hidden */
  33029. _worldMatrixDeterminant: number;
  33030. /** @hidden */
  33031. _worldMatrixDeterminantIsDirty: boolean;
  33032. /** @hidden */
  33033. private _sceneRootNodesIndex;
  33034. /**
  33035. * Gets a boolean indicating if the node has been disposed
  33036. * @returns true if the node was disposed
  33037. */
  33038. isDisposed(): boolean;
  33039. /**
  33040. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33041. * @see https://doc.babylonjs.com/how_to/parenting
  33042. */
  33043. set parent(parent: Nullable<Node>);
  33044. get parent(): Nullable<Node>;
  33045. /** @hidden */
  33046. _addToSceneRootNodes(): void;
  33047. /** @hidden */
  33048. _removeFromSceneRootNodes(): void;
  33049. private _animationPropertiesOverride;
  33050. /**
  33051. * Gets or sets the animation properties override
  33052. */
  33053. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33054. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33055. /**
  33056. * Gets a string idenfifying the name of the class
  33057. * @returns "Node" string
  33058. */
  33059. getClassName(): string;
  33060. /** @hidden */
  33061. readonly _isNode: boolean;
  33062. /**
  33063. * An event triggered when the mesh is disposed
  33064. */
  33065. onDisposeObservable: Observable<Node>;
  33066. private _onDisposeObserver;
  33067. /**
  33068. * Sets a callback that will be raised when the node will be disposed
  33069. */
  33070. set onDispose(callback: () => void);
  33071. /**
  33072. * Creates a new Node
  33073. * @param name the name and id to be given to this node
  33074. * @param scene the scene this node will be added to
  33075. */
  33076. constructor(name: string, scene?: Nullable<Scene>);
  33077. /**
  33078. * Gets the scene of the node
  33079. * @returns a scene
  33080. */
  33081. getScene(): Scene;
  33082. /**
  33083. * Gets the engine of the node
  33084. * @returns a Engine
  33085. */
  33086. getEngine(): Engine;
  33087. private _behaviors;
  33088. /**
  33089. * Attach a behavior to the node
  33090. * @see http://doc.babylonjs.com/features/behaviour
  33091. * @param behavior defines the behavior to attach
  33092. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33093. * @returns the current Node
  33094. */
  33095. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33096. /**
  33097. * Remove an attached behavior
  33098. * @see http://doc.babylonjs.com/features/behaviour
  33099. * @param behavior defines the behavior to attach
  33100. * @returns the current Node
  33101. */
  33102. removeBehavior(behavior: Behavior<Node>): Node;
  33103. /**
  33104. * Gets the list of attached behaviors
  33105. * @see http://doc.babylonjs.com/features/behaviour
  33106. */
  33107. get behaviors(): Behavior<Node>[];
  33108. /**
  33109. * Gets an attached behavior by name
  33110. * @param name defines the name of the behavior to look for
  33111. * @see http://doc.babylonjs.com/features/behaviour
  33112. * @returns null if behavior was not found else the requested behavior
  33113. */
  33114. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33115. /**
  33116. * Returns the latest update of the World matrix
  33117. * @returns a Matrix
  33118. */
  33119. getWorldMatrix(): Matrix;
  33120. /** @hidden */
  33121. _getWorldMatrixDeterminant(): number;
  33122. /**
  33123. * Returns directly the latest state of the mesh World matrix.
  33124. * A Matrix is returned.
  33125. */
  33126. get worldMatrixFromCache(): Matrix;
  33127. /** @hidden */
  33128. _initCache(): void;
  33129. /** @hidden */
  33130. updateCache(force?: boolean): void;
  33131. /** @hidden */
  33132. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33133. /** @hidden */
  33134. _updateCache(ignoreParentClass?: boolean): void;
  33135. /** @hidden */
  33136. _isSynchronized(): boolean;
  33137. /** @hidden */
  33138. _markSyncedWithParent(): void;
  33139. /** @hidden */
  33140. isSynchronizedWithParent(): boolean;
  33141. /** @hidden */
  33142. isSynchronized(): boolean;
  33143. /**
  33144. * Is this node ready to be used/rendered
  33145. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33146. * @return true if the node is ready
  33147. */
  33148. isReady(completeCheck?: boolean): boolean;
  33149. /**
  33150. * Is this node enabled?
  33151. * 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
  33152. * @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
  33153. * @return whether this node (and its parent) is enabled
  33154. */
  33155. isEnabled(checkAncestors?: boolean): boolean;
  33156. /** @hidden */
  33157. protected _syncParentEnabledState(): void;
  33158. /**
  33159. * Set the enabled state of this node
  33160. * @param value defines the new enabled state
  33161. */
  33162. setEnabled(value: boolean): void;
  33163. /**
  33164. * Is this node a descendant of the given node?
  33165. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33166. * @param ancestor defines the parent node to inspect
  33167. * @returns a boolean indicating if this node is a descendant of the given node
  33168. */
  33169. isDescendantOf(ancestor: Node): boolean;
  33170. /** @hidden */
  33171. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33172. /**
  33173. * Will return all nodes that have this node as ascendant
  33174. * @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
  33175. * @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
  33176. * @return all children nodes of all types
  33177. */
  33178. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33179. /**
  33180. * Get all child-meshes of this node
  33181. * @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)
  33182. * @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
  33183. * @returns an array of AbstractMesh
  33184. */
  33185. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33186. /**
  33187. * Get all direct children of this node
  33188. * @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
  33189. * @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)
  33190. * @returns an array of Node
  33191. */
  33192. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33193. /** @hidden */
  33194. _setReady(state: boolean): void;
  33195. /**
  33196. * Get an animation by name
  33197. * @param name defines the name of the animation to look for
  33198. * @returns null if not found else the requested animation
  33199. */
  33200. getAnimationByName(name: string): Nullable<Animation>;
  33201. /**
  33202. * Creates an animation range for this node
  33203. * @param name defines the name of the range
  33204. * @param from defines the starting key
  33205. * @param to defines the end key
  33206. */
  33207. createAnimationRange(name: string, from: number, to: number): void;
  33208. /**
  33209. * Delete a specific animation range
  33210. * @param name defines the name of the range to delete
  33211. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33212. */
  33213. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33214. /**
  33215. * Get an animation range by name
  33216. * @param name defines the name of the animation range to look for
  33217. * @returns null if not found else the requested animation range
  33218. */
  33219. getAnimationRange(name: string): Nullable<AnimationRange>;
  33220. /**
  33221. * Gets the list of all animation ranges defined on this node
  33222. * @returns an array
  33223. */
  33224. getAnimationRanges(): Nullable<AnimationRange>[];
  33225. /**
  33226. * Will start the animation sequence
  33227. * @param name defines the range frames for animation sequence
  33228. * @param loop defines if the animation should loop (false by default)
  33229. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33230. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33231. * @returns the object created for this animation. If range does not exist, it will return null
  33232. */
  33233. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33234. /**
  33235. * Serialize animation ranges into a JSON compatible object
  33236. * @returns serialization object
  33237. */
  33238. serializeAnimationRanges(): any;
  33239. /**
  33240. * Computes the world matrix of the node
  33241. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33242. * @returns the world matrix
  33243. */
  33244. computeWorldMatrix(force?: boolean): Matrix;
  33245. /**
  33246. * Releases resources associated with this node.
  33247. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33248. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33249. */
  33250. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33251. /**
  33252. * Parse animation range data from a serialization object and store them into a given node
  33253. * @param node defines where to store the animation ranges
  33254. * @param parsedNode defines the serialization object to read data from
  33255. * @param scene defines the hosting scene
  33256. */
  33257. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33258. /**
  33259. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33260. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33261. * @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
  33262. * @returns the new bounding vectors
  33263. */
  33264. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33265. min: Vector3;
  33266. max: Vector3;
  33267. };
  33268. }
  33269. }
  33270. declare module "babylonjs/Animations/animation" {
  33271. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33272. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33273. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33274. import { Nullable } from "babylonjs/types";
  33275. import { Scene } from "babylonjs/scene";
  33276. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33277. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33278. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33279. import { Node } from "babylonjs/node";
  33280. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33281. import { Size } from "babylonjs/Maths/math.size";
  33282. import { Animatable } from "babylonjs/Animations/animatable";
  33283. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33284. /**
  33285. * @hidden
  33286. */
  33287. export class _IAnimationState {
  33288. key: number;
  33289. repeatCount: number;
  33290. workValue?: any;
  33291. loopMode?: number;
  33292. offsetValue?: any;
  33293. highLimitValue?: any;
  33294. }
  33295. /**
  33296. * Class used to store any kind of animation
  33297. */
  33298. export class Animation {
  33299. /**Name of the animation */
  33300. name: string;
  33301. /**Property to animate */
  33302. targetProperty: string;
  33303. /**The frames per second of the animation */
  33304. framePerSecond: number;
  33305. /**The data type of the animation */
  33306. dataType: number;
  33307. /**The loop mode of the animation */
  33308. loopMode?: number | undefined;
  33309. /**Specifies if blending should be enabled */
  33310. enableBlending?: boolean | undefined;
  33311. /**
  33312. * Use matrix interpolation instead of using direct key value when animating matrices
  33313. */
  33314. static AllowMatricesInterpolation: boolean;
  33315. /**
  33316. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33317. */
  33318. static AllowMatrixDecomposeForInterpolation: boolean;
  33319. /**
  33320. * Stores the key frames of the animation
  33321. */
  33322. private _keys;
  33323. /**
  33324. * Stores the easing function of the animation
  33325. */
  33326. private _easingFunction;
  33327. /**
  33328. * @hidden Internal use only
  33329. */
  33330. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33331. /**
  33332. * The set of event that will be linked to this animation
  33333. */
  33334. private _events;
  33335. /**
  33336. * Stores an array of target property paths
  33337. */
  33338. targetPropertyPath: string[];
  33339. /**
  33340. * Stores the blending speed of the animation
  33341. */
  33342. blendingSpeed: number;
  33343. /**
  33344. * Stores the animation ranges for the animation
  33345. */
  33346. private _ranges;
  33347. /**
  33348. * @hidden Internal use
  33349. */
  33350. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33351. /**
  33352. * Sets up an animation
  33353. * @param property The property to animate
  33354. * @param animationType The animation type to apply
  33355. * @param framePerSecond The frames per second of the animation
  33356. * @param easingFunction The easing function used in the animation
  33357. * @returns The created animation
  33358. */
  33359. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33360. /**
  33361. * Create and start an animation on a node
  33362. * @param name defines the name of the global animation that will be run on all nodes
  33363. * @param node defines the root node where the animation will take place
  33364. * @param targetProperty defines property to animate
  33365. * @param framePerSecond defines the number of frame per second yo use
  33366. * @param totalFrame defines the number of frames in total
  33367. * @param from defines the initial value
  33368. * @param to defines the final value
  33369. * @param loopMode defines which loop mode you want to use (off by default)
  33370. * @param easingFunction defines the easing function to use (linear by default)
  33371. * @param onAnimationEnd defines the callback to call when animation end
  33372. * @returns the animatable created for this animation
  33373. */
  33374. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33375. /**
  33376. * Create and start an animation on a node and its descendants
  33377. * @param name defines the name of the global animation that will be run on all nodes
  33378. * @param node defines the root node where the animation will take place
  33379. * @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
  33380. * @param targetProperty defines property to animate
  33381. * @param framePerSecond defines the number of frame per second to use
  33382. * @param totalFrame defines the number of frames in total
  33383. * @param from defines the initial value
  33384. * @param to defines the final value
  33385. * @param loopMode defines which loop mode you want to use (off by default)
  33386. * @param easingFunction defines the easing function to use (linear by default)
  33387. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33388. * @returns the list of animatables created for all nodes
  33389. * @example https://www.babylonjs-playground.com/#MH0VLI
  33390. */
  33391. 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[]>;
  33392. /**
  33393. * Creates a new animation, merges it with the existing animations and starts it
  33394. * @param name Name of the animation
  33395. * @param node Node which contains the scene that begins the animations
  33396. * @param targetProperty Specifies which property to animate
  33397. * @param framePerSecond The frames per second of the animation
  33398. * @param totalFrame The total number of frames
  33399. * @param from The frame at the beginning of the animation
  33400. * @param to The frame at the end of the animation
  33401. * @param loopMode Specifies the loop mode of the animation
  33402. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33403. * @param onAnimationEnd Callback to run once the animation is complete
  33404. * @returns Nullable animation
  33405. */
  33406. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33407. /**
  33408. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33409. * @param sourceAnimation defines the Animation containing keyframes to convert
  33410. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33411. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33412. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33413. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33414. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33415. */
  33416. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33417. /**
  33418. * Transition property of an host to the target Value
  33419. * @param property The property to transition
  33420. * @param targetValue The target Value of the property
  33421. * @param host The object where the property to animate belongs
  33422. * @param scene Scene used to run the animation
  33423. * @param frameRate Framerate (in frame/s) to use
  33424. * @param transition The transition type we want to use
  33425. * @param duration The duration of the animation, in milliseconds
  33426. * @param onAnimationEnd Callback trigger at the end of the animation
  33427. * @returns Nullable animation
  33428. */
  33429. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33430. /**
  33431. * Return the array of runtime animations currently using this animation
  33432. */
  33433. get runtimeAnimations(): RuntimeAnimation[];
  33434. /**
  33435. * Specifies if any of the runtime animations are currently running
  33436. */
  33437. get hasRunningRuntimeAnimations(): boolean;
  33438. /**
  33439. * Initializes the animation
  33440. * @param name Name of the animation
  33441. * @param targetProperty Property to animate
  33442. * @param framePerSecond The frames per second of the animation
  33443. * @param dataType The data type of the animation
  33444. * @param loopMode The loop mode of the animation
  33445. * @param enableBlending Specifies if blending should be enabled
  33446. */
  33447. constructor(
  33448. /**Name of the animation */
  33449. name: string,
  33450. /**Property to animate */
  33451. targetProperty: string,
  33452. /**The frames per second of the animation */
  33453. framePerSecond: number,
  33454. /**The data type of the animation */
  33455. dataType: number,
  33456. /**The loop mode of the animation */
  33457. loopMode?: number | undefined,
  33458. /**Specifies if blending should be enabled */
  33459. enableBlending?: boolean | undefined);
  33460. /**
  33461. * Converts the animation to a string
  33462. * @param fullDetails support for multiple levels of logging within scene loading
  33463. * @returns String form of the animation
  33464. */
  33465. toString(fullDetails?: boolean): string;
  33466. /**
  33467. * Add an event to this animation
  33468. * @param event Event to add
  33469. */
  33470. addEvent(event: AnimationEvent): void;
  33471. /**
  33472. * Remove all events found at the given frame
  33473. * @param frame The frame to remove events from
  33474. */
  33475. removeEvents(frame: number): void;
  33476. /**
  33477. * Retrieves all the events from the animation
  33478. * @returns Events from the animation
  33479. */
  33480. getEvents(): AnimationEvent[];
  33481. /**
  33482. * Creates an animation range
  33483. * @param name Name of the animation range
  33484. * @param from Starting frame of the animation range
  33485. * @param to Ending frame of the animation
  33486. */
  33487. createRange(name: string, from: number, to: number): void;
  33488. /**
  33489. * Deletes an animation range by name
  33490. * @param name Name of the animation range to delete
  33491. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33492. */
  33493. deleteRange(name: string, deleteFrames?: boolean): void;
  33494. /**
  33495. * Gets the animation range by name, or null if not defined
  33496. * @param name Name of the animation range
  33497. * @returns Nullable animation range
  33498. */
  33499. getRange(name: string): Nullable<AnimationRange>;
  33500. /**
  33501. * Gets the key frames from the animation
  33502. * @returns The key frames of the animation
  33503. */
  33504. getKeys(): Array<IAnimationKey>;
  33505. /**
  33506. * Gets the highest frame rate of the animation
  33507. * @returns Highest frame rate of the animation
  33508. */
  33509. getHighestFrame(): number;
  33510. /**
  33511. * Gets the easing function of the animation
  33512. * @returns Easing function of the animation
  33513. */
  33514. getEasingFunction(): IEasingFunction;
  33515. /**
  33516. * Sets the easing function of the animation
  33517. * @param easingFunction A custom mathematical formula for animation
  33518. */
  33519. setEasingFunction(easingFunction: EasingFunction): void;
  33520. /**
  33521. * Interpolates a scalar linearly
  33522. * @param startValue Start value of the animation curve
  33523. * @param endValue End value of the animation curve
  33524. * @param gradient Scalar amount to interpolate
  33525. * @returns Interpolated scalar value
  33526. */
  33527. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33528. /**
  33529. * Interpolates a scalar cubically
  33530. * @param startValue Start value of the animation curve
  33531. * @param outTangent End tangent of the animation
  33532. * @param endValue End value of the animation curve
  33533. * @param inTangent Start tangent of the animation curve
  33534. * @param gradient Scalar amount to interpolate
  33535. * @returns Interpolated scalar value
  33536. */
  33537. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33538. /**
  33539. * Interpolates a quaternion using a spherical linear interpolation
  33540. * @param startValue Start value of the animation curve
  33541. * @param endValue End value of the animation curve
  33542. * @param gradient Scalar amount to interpolate
  33543. * @returns Interpolated quaternion value
  33544. */
  33545. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33546. /**
  33547. * Interpolates a quaternion cubically
  33548. * @param startValue Start value of the animation curve
  33549. * @param outTangent End tangent of the animation curve
  33550. * @param endValue End value of the animation curve
  33551. * @param inTangent Start tangent of the animation curve
  33552. * @param gradient Scalar amount to interpolate
  33553. * @returns Interpolated quaternion value
  33554. */
  33555. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33556. /**
  33557. * Interpolates a Vector3 linearl
  33558. * @param startValue Start value of the animation curve
  33559. * @param endValue End value of the animation curve
  33560. * @param gradient Scalar amount to interpolate
  33561. * @returns Interpolated scalar value
  33562. */
  33563. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33564. /**
  33565. * Interpolates a Vector3 cubically
  33566. * @param startValue Start value of the animation curve
  33567. * @param outTangent End tangent of the animation
  33568. * @param endValue End value of the animation curve
  33569. * @param inTangent Start tangent of the animation curve
  33570. * @param gradient Scalar amount to interpolate
  33571. * @returns InterpolatedVector3 value
  33572. */
  33573. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33574. /**
  33575. * Interpolates a Vector2 linearly
  33576. * @param startValue Start value of the animation curve
  33577. * @param endValue End value of the animation curve
  33578. * @param gradient Scalar amount to interpolate
  33579. * @returns Interpolated Vector2 value
  33580. */
  33581. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33582. /**
  33583. * Interpolates a Vector2 cubically
  33584. * @param startValue Start value of the animation curve
  33585. * @param outTangent End tangent of the animation
  33586. * @param endValue End value of the animation curve
  33587. * @param inTangent Start tangent of the animation curve
  33588. * @param gradient Scalar amount to interpolate
  33589. * @returns Interpolated Vector2 value
  33590. */
  33591. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33592. /**
  33593. * Interpolates a size linearly
  33594. * @param startValue Start value of the animation curve
  33595. * @param endValue End value of the animation curve
  33596. * @param gradient Scalar amount to interpolate
  33597. * @returns Interpolated Size value
  33598. */
  33599. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33600. /**
  33601. * Interpolates a Color3 linearly
  33602. * @param startValue Start value of the animation curve
  33603. * @param endValue End value of the animation curve
  33604. * @param gradient Scalar amount to interpolate
  33605. * @returns Interpolated Color3 value
  33606. */
  33607. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33608. /**
  33609. * Interpolates a Color4 linearly
  33610. * @param startValue Start value of the animation curve
  33611. * @param endValue End value of the animation curve
  33612. * @param gradient Scalar amount to interpolate
  33613. * @returns Interpolated Color3 value
  33614. */
  33615. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33616. /**
  33617. * @hidden Internal use only
  33618. */
  33619. _getKeyValue(value: any): any;
  33620. /**
  33621. * @hidden Internal use only
  33622. */
  33623. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33624. /**
  33625. * Defines the function to use to interpolate matrices
  33626. * @param startValue defines the start matrix
  33627. * @param endValue defines the end matrix
  33628. * @param gradient defines the gradient between both matrices
  33629. * @param result defines an optional target matrix where to store the interpolation
  33630. * @returns the interpolated matrix
  33631. */
  33632. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33633. /**
  33634. * Makes a copy of the animation
  33635. * @returns Cloned animation
  33636. */
  33637. clone(): Animation;
  33638. /**
  33639. * Sets the key frames of the animation
  33640. * @param values The animation key frames to set
  33641. */
  33642. setKeys(values: Array<IAnimationKey>): void;
  33643. /**
  33644. * Serializes the animation to an object
  33645. * @returns Serialized object
  33646. */
  33647. serialize(): any;
  33648. /**
  33649. * Float animation type
  33650. */
  33651. static readonly ANIMATIONTYPE_FLOAT: number;
  33652. /**
  33653. * Vector3 animation type
  33654. */
  33655. static readonly ANIMATIONTYPE_VECTOR3: number;
  33656. /**
  33657. * Quaternion animation type
  33658. */
  33659. static readonly ANIMATIONTYPE_QUATERNION: number;
  33660. /**
  33661. * Matrix animation type
  33662. */
  33663. static readonly ANIMATIONTYPE_MATRIX: number;
  33664. /**
  33665. * Color3 animation type
  33666. */
  33667. static readonly ANIMATIONTYPE_COLOR3: number;
  33668. /**
  33669. * Color3 animation type
  33670. */
  33671. static readonly ANIMATIONTYPE_COLOR4: number;
  33672. /**
  33673. * Vector2 animation type
  33674. */
  33675. static readonly ANIMATIONTYPE_VECTOR2: number;
  33676. /**
  33677. * Size animation type
  33678. */
  33679. static readonly ANIMATIONTYPE_SIZE: number;
  33680. /**
  33681. * Relative Loop Mode
  33682. */
  33683. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33684. /**
  33685. * Cycle Loop Mode
  33686. */
  33687. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33688. /**
  33689. * Constant Loop Mode
  33690. */
  33691. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33692. /** @hidden */
  33693. static _UniversalLerp(left: any, right: any, amount: number): any;
  33694. /**
  33695. * Parses an animation object and creates an animation
  33696. * @param parsedAnimation Parsed animation object
  33697. * @returns Animation object
  33698. */
  33699. static Parse(parsedAnimation: any): Animation;
  33700. /**
  33701. * Appends the serialized animations from the source animations
  33702. * @param source Source containing the animations
  33703. * @param destination Target to store the animations
  33704. */
  33705. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33706. }
  33707. }
  33708. declare module "babylonjs/Animations/animatable.interface" {
  33709. import { Nullable } from "babylonjs/types";
  33710. import { Animation } from "babylonjs/Animations/animation";
  33711. /**
  33712. * Interface containing an array of animations
  33713. */
  33714. export interface IAnimatable {
  33715. /**
  33716. * Array of animations
  33717. */
  33718. animations: Nullable<Array<Animation>>;
  33719. }
  33720. }
  33721. declare module "babylonjs/Misc/decorators" {
  33722. import { Nullable } from "babylonjs/types";
  33723. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33724. import { Scene } from "babylonjs/scene";
  33725. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33726. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33727. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33728. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33729. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33730. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33731. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33732. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33733. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33734. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33735. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33736. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33737. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33738. /**
  33739. * Decorator used to define property that can be serialized as reference to a camera
  33740. * @param sourceName defines the name of the property to decorate
  33741. */
  33742. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33743. /**
  33744. * Class used to help serialization objects
  33745. */
  33746. export class SerializationHelper {
  33747. /** @hidden */
  33748. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  33749. /** @hidden */
  33750. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  33751. /** @hidden */
  33752. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  33753. /** @hidden */
  33754. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  33755. /**
  33756. * Appends the serialized animations from the source animations
  33757. * @param source Source containing the animations
  33758. * @param destination Target to store the animations
  33759. */
  33760. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33761. /**
  33762. * Static function used to serialized a specific entity
  33763. * @param entity defines the entity to serialize
  33764. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33765. * @returns a JSON compatible object representing the serialization of the entity
  33766. */
  33767. static Serialize<T>(entity: T, serializationObject?: any): any;
  33768. /**
  33769. * Creates a new entity from a serialization data object
  33770. * @param creationFunction defines a function used to instanciated the new entity
  33771. * @param source defines the source serialization data
  33772. * @param scene defines the hosting scene
  33773. * @param rootUrl defines the root url for resources
  33774. * @returns a new entity
  33775. */
  33776. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33777. /**
  33778. * Clones an object
  33779. * @param creationFunction defines the function used to instanciate the new object
  33780. * @param source defines the source object
  33781. * @returns the cloned object
  33782. */
  33783. static Clone<T>(creationFunction: () => T, source: T): T;
  33784. /**
  33785. * Instanciates a new object based on a source one (some data will be shared between both object)
  33786. * @param creationFunction defines the function used to instanciate the new object
  33787. * @param source defines the source object
  33788. * @returns the new object
  33789. */
  33790. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33791. }
  33792. }
  33793. declare module "babylonjs/Materials/Textures/baseTexture" {
  33794. import { Observable } from "babylonjs/Misc/observable";
  33795. import { Nullable } from "babylonjs/types";
  33796. import { Scene } from "babylonjs/scene";
  33797. import { Matrix } from "babylonjs/Maths/math.vector";
  33798. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33799. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33800. import { ISize } from "babylonjs/Maths/math.size";
  33801. import "babylonjs/Misc/fileTools";
  33802. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33803. /**
  33804. * Base class of all the textures in babylon.
  33805. * It groups all the common properties the materials, post process, lights... might need
  33806. * in order to make a correct use of the texture.
  33807. */
  33808. export class BaseTexture implements IAnimatable {
  33809. /**
  33810. * Default anisotropic filtering level for the application.
  33811. * It is set to 4 as a good tradeoff between perf and quality.
  33812. */
  33813. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33814. /**
  33815. * Gets or sets the unique id of the texture
  33816. */
  33817. uniqueId: number;
  33818. /**
  33819. * Define the name of the texture.
  33820. */
  33821. name: string;
  33822. /**
  33823. * Gets or sets an object used to store user defined information.
  33824. */
  33825. metadata: any;
  33826. /**
  33827. * For internal use only. Please do not use.
  33828. */
  33829. reservedDataStore: any;
  33830. private _hasAlpha;
  33831. /**
  33832. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33833. */
  33834. set hasAlpha(value: boolean);
  33835. get hasAlpha(): boolean;
  33836. /**
  33837. * Defines if the alpha value should be determined via the rgb values.
  33838. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33839. */
  33840. getAlphaFromRGB: boolean;
  33841. /**
  33842. * Intensity or strength of the texture.
  33843. * It is commonly used by materials to fine tune the intensity of the texture
  33844. */
  33845. level: number;
  33846. /**
  33847. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33848. * This is part of the texture as textures usually maps to one uv set.
  33849. */
  33850. coordinatesIndex: number;
  33851. private _coordinatesMode;
  33852. /**
  33853. * How a texture is mapped.
  33854. *
  33855. * | Value | Type | Description |
  33856. * | ----- | ----------------------------------- | ----------- |
  33857. * | 0 | EXPLICIT_MODE | |
  33858. * | 1 | SPHERICAL_MODE | |
  33859. * | 2 | PLANAR_MODE | |
  33860. * | 3 | CUBIC_MODE | |
  33861. * | 4 | PROJECTION_MODE | |
  33862. * | 5 | SKYBOX_MODE | |
  33863. * | 6 | INVCUBIC_MODE | |
  33864. * | 7 | EQUIRECTANGULAR_MODE | |
  33865. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33866. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33867. */
  33868. set coordinatesMode(value: number);
  33869. get coordinatesMode(): number;
  33870. /**
  33871. * | Value | Type | Description |
  33872. * | ----- | ------------------ | ----------- |
  33873. * | 0 | CLAMP_ADDRESSMODE | |
  33874. * | 1 | WRAP_ADDRESSMODE | |
  33875. * | 2 | MIRROR_ADDRESSMODE | |
  33876. */
  33877. wrapU: number;
  33878. /**
  33879. * | Value | Type | Description |
  33880. * | ----- | ------------------ | ----------- |
  33881. * | 0 | CLAMP_ADDRESSMODE | |
  33882. * | 1 | WRAP_ADDRESSMODE | |
  33883. * | 2 | MIRROR_ADDRESSMODE | |
  33884. */
  33885. wrapV: number;
  33886. /**
  33887. * | Value | Type | Description |
  33888. * | ----- | ------------------ | ----------- |
  33889. * | 0 | CLAMP_ADDRESSMODE | |
  33890. * | 1 | WRAP_ADDRESSMODE | |
  33891. * | 2 | MIRROR_ADDRESSMODE | |
  33892. */
  33893. wrapR: number;
  33894. /**
  33895. * With compliant hardware and browser (supporting anisotropic filtering)
  33896. * this defines the level of anisotropic filtering in the texture.
  33897. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33898. */
  33899. anisotropicFilteringLevel: number;
  33900. /**
  33901. * Define if the texture is a cube texture or if false a 2d texture.
  33902. */
  33903. get isCube(): boolean;
  33904. set isCube(value: boolean);
  33905. /**
  33906. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33907. */
  33908. get is3D(): boolean;
  33909. set is3D(value: boolean);
  33910. /**
  33911. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33912. */
  33913. get is2DArray(): boolean;
  33914. set is2DArray(value: boolean);
  33915. /**
  33916. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33917. * HDR texture are usually stored in linear space.
  33918. * This only impacts the PBR and Background materials
  33919. */
  33920. gammaSpace: boolean;
  33921. /**
  33922. * Gets or sets whether or not the texture contains RGBD data.
  33923. */
  33924. get isRGBD(): boolean;
  33925. set isRGBD(value: boolean);
  33926. /**
  33927. * Is Z inverted in the texture (useful in a cube texture).
  33928. */
  33929. invertZ: boolean;
  33930. /**
  33931. * Are mip maps generated for this texture or not.
  33932. */
  33933. get noMipmap(): boolean;
  33934. /**
  33935. * @hidden
  33936. */
  33937. lodLevelInAlpha: boolean;
  33938. /**
  33939. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33940. */
  33941. get lodGenerationOffset(): number;
  33942. set lodGenerationOffset(value: number);
  33943. /**
  33944. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33945. */
  33946. get lodGenerationScale(): number;
  33947. set lodGenerationScale(value: number);
  33948. /**
  33949. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33950. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33951. * average roughness values.
  33952. */
  33953. get linearSpecularLOD(): boolean;
  33954. set linearSpecularLOD(value: boolean);
  33955. /**
  33956. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33957. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33958. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33959. */
  33960. get irradianceTexture(): Nullable<BaseTexture>;
  33961. set irradianceTexture(value: Nullable<BaseTexture>);
  33962. /**
  33963. * Define if the texture is a render target.
  33964. */
  33965. isRenderTarget: boolean;
  33966. /**
  33967. * Define the unique id of the texture in the scene.
  33968. */
  33969. get uid(): string;
  33970. /** @hidden */
  33971. _prefiltered: boolean;
  33972. /**
  33973. * Return a string representation of the texture.
  33974. * @returns the texture as a string
  33975. */
  33976. toString(): string;
  33977. /**
  33978. * Get the class name of the texture.
  33979. * @returns "BaseTexture"
  33980. */
  33981. getClassName(): string;
  33982. /**
  33983. * Define the list of animation attached to the texture.
  33984. */
  33985. animations: import("babylonjs/Animations/animation").Animation[];
  33986. /**
  33987. * An event triggered when the texture is disposed.
  33988. */
  33989. onDisposeObservable: Observable<BaseTexture>;
  33990. private _onDisposeObserver;
  33991. /**
  33992. * Callback triggered when the texture has been disposed.
  33993. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33994. */
  33995. set onDispose(callback: () => void);
  33996. /**
  33997. * Define the current state of the loading sequence when in delayed load mode.
  33998. */
  33999. delayLoadState: number;
  34000. private _scene;
  34001. private _engine;
  34002. /** @hidden */
  34003. _texture: Nullable<InternalTexture>;
  34004. private _uid;
  34005. /**
  34006. * Define if the texture is preventinga material to render or not.
  34007. * If not and the texture is not ready, the engine will use a default black texture instead.
  34008. */
  34009. get isBlocking(): boolean;
  34010. /**
  34011. * Instantiates a new BaseTexture.
  34012. * Base class of all the textures in babylon.
  34013. * It groups all the common properties the materials, post process, lights... might need
  34014. * in order to make a correct use of the texture.
  34015. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34016. */
  34017. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34018. /**
  34019. * Get the scene the texture belongs to.
  34020. * @returns the scene or null if undefined
  34021. */
  34022. getScene(): Nullable<Scene>;
  34023. /** @hidden */
  34024. protected _getEngine(): Nullable<ThinEngine>;
  34025. /**
  34026. * Get the texture transform matrix used to offset tile the texture for istance.
  34027. * @returns the transformation matrix
  34028. */
  34029. getTextureMatrix(): Matrix;
  34030. /**
  34031. * Get the texture reflection matrix used to rotate/transform the reflection.
  34032. * @returns the reflection matrix
  34033. */
  34034. getReflectionTextureMatrix(): Matrix;
  34035. /**
  34036. * Get the underlying lower level texture from Babylon.
  34037. * @returns the insternal texture
  34038. */
  34039. getInternalTexture(): Nullable<InternalTexture>;
  34040. /**
  34041. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34042. * @returns true if ready or not blocking
  34043. */
  34044. isReadyOrNotBlocking(): boolean;
  34045. /**
  34046. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34047. * @returns true if fully ready
  34048. */
  34049. isReady(): boolean;
  34050. private _cachedSize;
  34051. /**
  34052. * Get the size of the texture.
  34053. * @returns the texture size.
  34054. */
  34055. getSize(): ISize;
  34056. /**
  34057. * Get the base size of the texture.
  34058. * It can be different from the size if the texture has been resized for POT for instance
  34059. * @returns the base size
  34060. */
  34061. getBaseSize(): ISize;
  34062. /**
  34063. * Update the sampling mode of the texture.
  34064. * Default is Trilinear mode.
  34065. *
  34066. * | Value | Type | Description |
  34067. * | ----- | ------------------ | ----------- |
  34068. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34069. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34070. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34071. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34072. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34073. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34074. * | 7 | NEAREST_LINEAR | |
  34075. * | 8 | NEAREST_NEAREST | |
  34076. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34077. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34078. * | 11 | LINEAR_LINEAR | |
  34079. * | 12 | LINEAR_NEAREST | |
  34080. *
  34081. * > _mag_: magnification filter (close to the viewer)
  34082. * > _min_: minification filter (far from the viewer)
  34083. * > _mip_: filter used between mip map levels
  34084. *@param samplingMode Define the new sampling mode of the texture
  34085. */
  34086. updateSamplingMode(samplingMode: number): void;
  34087. /**
  34088. * Scales the texture if is `canRescale()`
  34089. * @param ratio the resize factor we want to use to rescale
  34090. */
  34091. scale(ratio: number): void;
  34092. /**
  34093. * Get if the texture can rescale.
  34094. */
  34095. get canRescale(): boolean;
  34096. /** @hidden */
  34097. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34098. /** @hidden */
  34099. _rebuild(): void;
  34100. /**
  34101. * Triggers the load sequence in delayed load mode.
  34102. */
  34103. delayLoad(): void;
  34104. /**
  34105. * Clones the texture.
  34106. * @returns the cloned texture
  34107. */
  34108. clone(): Nullable<BaseTexture>;
  34109. /**
  34110. * Get the texture underlying type (INT, FLOAT...)
  34111. */
  34112. get textureType(): number;
  34113. /**
  34114. * Get the texture underlying format (RGB, RGBA...)
  34115. */
  34116. get textureFormat(): number;
  34117. /**
  34118. * Indicates that textures need to be re-calculated for all materials
  34119. */
  34120. protected _markAllSubMeshesAsTexturesDirty(): void;
  34121. /**
  34122. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34123. * This will returns an RGBA array buffer containing either in values (0-255) or
  34124. * float values (0-1) depending of the underlying buffer type.
  34125. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34126. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34127. * @param buffer defines a user defined buffer to fill with data (can be null)
  34128. * @returns The Array buffer containing the pixels data.
  34129. */
  34130. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34131. /**
  34132. * Release and destroy the underlying lower level texture aka internalTexture.
  34133. */
  34134. releaseInternalTexture(): void;
  34135. /** @hidden */
  34136. get _lodTextureHigh(): Nullable<BaseTexture>;
  34137. /** @hidden */
  34138. get _lodTextureMid(): Nullable<BaseTexture>;
  34139. /** @hidden */
  34140. get _lodTextureLow(): Nullable<BaseTexture>;
  34141. /**
  34142. * Dispose the texture and release its associated resources.
  34143. */
  34144. dispose(): void;
  34145. /**
  34146. * Serialize the texture into a JSON representation that can be parsed later on.
  34147. * @returns the JSON representation of the texture
  34148. */
  34149. serialize(): any;
  34150. /**
  34151. * Helper function to be called back once a list of texture contains only ready textures.
  34152. * @param textures Define the list of textures to wait for
  34153. * @param callback Define the callback triggered once the entire list will be ready
  34154. */
  34155. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34156. private static _isScene;
  34157. }
  34158. }
  34159. declare module "babylonjs/Materials/effect" {
  34160. import { Observable } from "babylonjs/Misc/observable";
  34161. import { Nullable } from "babylonjs/types";
  34162. import { IDisposable } from "babylonjs/scene";
  34163. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34164. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34165. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34166. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34167. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34168. import { Engine } from "babylonjs/Engines/engine";
  34169. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34170. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34171. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34172. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34173. /**
  34174. * Options to be used when creating an effect.
  34175. */
  34176. export interface IEffectCreationOptions {
  34177. /**
  34178. * Atrributes that will be used in the shader.
  34179. */
  34180. attributes: string[];
  34181. /**
  34182. * Uniform varible names that will be set in the shader.
  34183. */
  34184. uniformsNames: string[];
  34185. /**
  34186. * Uniform buffer variable names that will be set in the shader.
  34187. */
  34188. uniformBuffersNames: string[];
  34189. /**
  34190. * Sampler texture variable names that will be set in the shader.
  34191. */
  34192. samplers: string[];
  34193. /**
  34194. * Define statements that will be set in the shader.
  34195. */
  34196. defines: any;
  34197. /**
  34198. * Possible fallbacks for this effect to improve performance when needed.
  34199. */
  34200. fallbacks: Nullable<IEffectFallbacks>;
  34201. /**
  34202. * Callback that will be called when the shader is compiled.
  34203. */
  34204. onCompiled: Nullable<(effect: Effect) => void>;
  34205. /**
  34206. * Callback that will be called if an error occurs during shader compilation.
  34207. */
  34208. onError: Nullable<(effect: Effect, errors: string) => void>;
  34209. /**
  34210. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34211. */
  34212. indexParameters?: any;
  34213. /**
  34214. * Max number of lights that can be used in the shader.
  34215. */
  34216. maxSimultaneousLights?: number;
  34217. /**
  34218. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34219. */
  34220. transformFeedbackVaryings?: Nullable<string[]>;
  34221. /**
  34222. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  34223. */
  34224. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34225. }
  34226. /**
  34227. * Effect containing vertex and fragment shader that can be executed on an object.
  34228. */
  34229. export class Effect implements IDisposable {
  34230. /**
  34231. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34232. */
  34233. static ShadersRepository: string;
  34234. /**
  34235. * Enable logging of the shader code when a compilation error occurs
  34236. */
  34237. static LogShaderCodeOnCompilationError: boolean;
  34238. /**
  34239. * Name of the effect.
  34240. */
  34241. name: any;
  34242. /**
  34243. * String container all the define statements that should be set on the shader.
  34244. */
  34245. defines: string;
  34246. /**
  34247. * Callback that will be called when the shader is compiled.
  34248. */
  34249. onCompiled: Nullable<(effect: Effect) => void>;
  34250. /**
  34251. * Callback that will be called if an error occurs during shader compilation.
  34252. */
  34253. onError: Nullable<(effect: Effect, errors: string) => void>;
  34254. /**
  34255. * Callback that will be called when effect is bound.
  34256. */
  34257. onBind: Nullable<(effect: Effect) => void>;
  34258. /**
  34259. * Unique ID of the effect.
  34260. */
  34261. uniqueId: number;
  34262. /**
  34263. * Observable that will be called when the shader is compiled.
  34264. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34265. */
  34266. onCompileObservable: Observable<Effect>;
  34267. /**
  34268. * Observable that will be called if an error occurs during shader compilation.
  34269. */
  34270. onErrorObservable: Observable<Effect>;
  34271. /** @hidden */
  34272. _onBindObservable: Nullable<Observable<Effect>>;
  34273. /**
  34274. * @hidden
  34275. * Specifies if the effect was previously ready
  34276. */
  34277. _wasPreviouslyReady: boolean;
  34278. /**
  34279. * Observable that will be called when effect is bound.
  34280. */
  34281. get onBindObservable(): Observable<Effect>;
  34282. /** @hidden */
  34283. _bonesComputationForcedToCPU: boolean;
  34284. private static _uniqueIdSeed;
  34285. private _engine;
  34286. private _uniformBuffersNames;
  34287. private _uniformBuffersNamesList;
  34288. private _uniformsNames;
  34289. private _samplerList;
  34290. private _samplers;
  34291. private _isReady;
  34292. private _compilationError;
  34293. private _allFallbacksProcessed;
  34294. private _attributesNames;
  34295. private _attributes;
  34296. private _attributeLocationByName;
  34297. private _uniforms;
  34298. /**
  34299. * Key for the effect.
  34300. * @hidden
  34301. */
  34302. _key: string;
  34303. private _indexParameters;
  34304. private _fallbacks;
  34305. private _vertexSourceCode;
  34306. private _fragmentSourceCode;
  34307. private _vertexSourceCodeOverride;
  34308. private _fragmentSourceCodeOverride;
  34309. private _transformFeedbackVaryings;
  34310. /**
  34311. * Compiled shader to webGL program.
  34312. * @hidden
  34313. */
  34314. _pipelineContext: Nullable<IPipelineContext>;
  34315. private _valueCache;
  34316. private static _baseCache;
  34317. /**
  34318. * Instantiates an effect.
  34319. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34320. * @param baseName Name of the effect.
  34321. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34322. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34323. * @param samplers List of sampler variables that will be passed to the shader.
  34324. * @param engine Engine to be used to render the effect
  34325. * @param defines Define statements to be added to the shader.
  34326. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34327. * @param onCompiled Callback that will be called when the shader is compiled.
  34328. * @param onError Callback that will be called if an error occurs during shader compilation.
  34329. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34330. */
  34331. 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);
  34332. private _useFinalCode;
  34333. /**
  34334. * Unique key for this effect
  34335. */
  34336. get key(): string;
  34337. /**
  34338. * If the effect has been compiled and prepared.
  34339. * @returns if the effect is compiled and prepared.
  34340. */
  34341. isReady(): boolean;
  34342. private _isReadyInternal;
  34343. /**
  34344. * The engine the effect was initialized with.
  34345. * @returns the engine.
  34346. */
  34347. getEngine(): Engine;
  34348. /**
  34349. * The pipeline context for this effect
  34350. * @returns the associated pipeline context
  34351. */
  34352. getPipelineContext(): Nullable<IPipelineContext>;
  34353. /**
  34354. * The set of names of attribute variables for the shader.
  34355. * @returns An array of attribute names.
  34356. */
  34357. getAttributesNames(): string[];
  34358. /**
  34359. * Returns the attribute at the given index.
  34360. * @param index The index of the attribute.
  34361. * @returns The location of the attribute.
  34362. */
  34363. getAttributeLocation(index: number): number;
  34364. /**
  34365. * Returns the attribute based on the name of the variable.
  34366. * @param name of the attribute to look up.
  34367. * @returns the attribute location.
  34368. */
  34369. getAttributeLocationByName(name: string): number;
  34370. /**
  34371. * The number of attributes.
  34372. * @returns the numnber of attributes.
  34373. */
  34374. getAttributesCount(): number;
  34375. /**
  34376. * Gets the index of a uniform variable.
  34377. * @param uniformName of the uniform to look up.
  34378. * @returns the index.
  34379. */
  34380. getUniformIndex(uniformName: string): number;
  34381. /**
  34382. * Returns the attribute based on the name of the variable.
  34383. * @param uniformName of the uniform to look up.
  34384. * @returns the location of the uniform.
  34385. */
  34386. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34387. /**
  34388. * Returns an array of sampler variable names
  34389. * @returns The array of sampler variable names.
  34390. */
  34391. getSamplers(): string[];
  34392. /**
  34393. * Returns an array of uniform variable names
  34394. * @returns The array of uniform variable names.
  34395. */
  34396. getUniformNames(): string[];
  34397. /**
  34398. * Returns an array of uniform buffer variable names
  34399. * @returns The array of uniform buffer variable names.
  34400. */
  34401. getUniformBuffersNames(): string[];
  34402. /**
  34403. * Returns the index parameters used to create the effect
  34404. * @returns The index parameters object
  34405. */
  34406. getIndexParameters(): any;
  34407. /**
  34408. * The error from the last compilation.
  34409. * @returns the error string.
  34410. */
  34411. getCompilationError(): string;
  34412. /**
  34413. * Gets a boolean indicating that all fallbacks were used during compilation
  34414. * @returns true if all fallbacks were used
  34415. */
  34416. allFallbacksProcessed(): boolean;
  34417. /**
  34418. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34419. * @param func The callback to be used.
  34420. */
  34421. executeWhenCompiled(func: (effect: Effect) => void): void;
  34422. private _checkIsReady;
  34423. private _loadShader;
  34424. /**
  34425. * Gets the vertex shader source code of this effect
  34426. */
  34427. get vertexSourceCode(): string;
  34428. /**
  34429. * Gets the fragment shader source code of this effect
  34430. */
  34431. get fragmentSourceCode(): string;
  34432. /**
  34433. * Recompiles the webGL program
  34434. * @param vertexSourceCode The source code for the vertex shader.
  34435. * @param fragmentSourceCode The source code for the fragment shader.
  34436. * @param onCompiled Callback called when completed.
  34437. * @param onError Callback called on error.
  34438. * @hidden
  34439. */
  34440. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34441. /**
  34442. * Prepares the effect
  34443. * @hidden
  34444. */
  34445. _prepareEffect(): void;
  34446. private _getShaderCodeAndErrorLine;
  34447. private _processCompilationErrors;
  34448. /**
  34449. * Checks if the effect is supported. (Must be called after compilation)
  34450. */
  34451. get isSupported(): boolean;
  34452. /**
  34453. * Binds a texture to the engine to be used as output of the shader.
  34454. * @param channel Name of the output variable.
  34455. * @param texture Texture to bind.
  34456. * @hidden
  34457. */
  34458. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34459. /**
  34460. * Sets a texture on the engine to be used in the shader.
  34461. * @param channel Name of the sampler variable.
  34462. * @param texture Texture to set.
  34463. */
  34464. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34465. /**
  34466. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34467. * @param channel Name of the sampler variable.
  34468. * @param texture Texture to set.
  34469. */
  34470. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34471. /**
  34472. * Sets an array of textures on the engine to be used in the shader.
  34473. * @param channel Name of the variable.
  34474. * @param textures Textures to set.
  34475. */
  34476. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34477. /**
  34478. * 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)
  34479. * @param channel Name of the sampler variable.
  34480. * @param postProcess Post process to get the input texture from.
  34481. */
  34482. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34483. /**
  34484. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34485. * 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)
  34486. * @param channel Name of the sampler variable.
  34487. * @param postProcess Post process to get the output texture from.
  34488. */
  34489. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34490. /** @hidden */
  34491. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34492. /** @hidden */
  34493. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34494. /** @hidden */
  34495. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34496. /** @hidden */
  34497. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34498. /**
  34499. * Binds a buffer to a uniform.
  34500. * @param buffer Buffer to bind.
  34501. * @param name Name of the uniform variable to bind to.
  34502. */
  34503. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34504. /**
  34505. * Binds block to a uniform.
  34506. * @param blockName Name of the block to bind.
  34507. * @param index Index to bind.
  34508. */
  34509. bindUniformBlock(blockName: string, index: number): void;
  34510. /**
  34511. * Sets an interger value on a uniform variable.
  34512. * @param uniformName Name of the variable.
  34513. * @param value Value to be set.
  34514. * @returns this effect.
  34515. */
  34516. setInt(uniformName: string, value: number): Effect;
  34517. /**
  34518. * Sets an int array on a uniform variable.
  34519. * @param uniformName Name of the variable.
  34520. * @param array array to be set.
  34521. * @returns this effect.
  34522. */
  34523. setIntArray(uniformName: string, array: Int32Array): Effect;
  34524. /**
  34525. * 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)
  34526. * @param uniformName Name of the variable.
  34527. * @param array array to be set.
  34528. * @returns this effect.
  34529. */
  34530. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34531. /**
  34532. * 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)
  34533. * @param uniformName Name of the variable.
  34534. * @param array array to be set.
  34535. * @returns this effect.
  34536. */
  34537. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34538. /**
  34539. * 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)
  34540. * @param uniformName Name of the variable.
  34541. * @param array array to be set.
  34542. * @returns this effect.
  34543. */
  34544. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34545. /**
  34546. * Sets an float array on a uniform variable.
  34547. * @param uniformName Name of the variable.
  34548. * @param array array to be set.
  34549. * @returns this effect.
  34550. */
  34551. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34552. /**
  34553. * 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)
  34554. * @param uniformName Name of the variable.
  34555. * @param array array to be set.
  34556. * @returns this effect.
  34557. */
  34558. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34559. /**
  34560. * 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)
  34561. * @param uniformName Name of the variable.
  34562. * @param array array to be set.
  34563. * @returns this effect.
  34564. */
  34565. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34566. /**
  34567. * 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)
  34568. * @param uniformName Name of the variable.
  34569. * @param array array to be set.
  34570. * @returns this effect.
  34571. */
  34572. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34573. /**
  34574. * Sets an array on a uniform variable.
  34575. * @param uniformName Name of the variable.
  34576. * @param array array to be set.
  34577. * @returns this effect.
  34578. */
  34579. setArray(uniformName: string, array: number[]): Effect;
  34580. /**
  34581. * 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)
  34582. * @param uniformName Name of the variable.
  34583. * @param array array to be set.
  34584. * @returns this effect.
  34585. */
  34586. setArray2(uniformName: string, array: number[]): Effect;
  34587. /**
  34588. * 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)
  34589. * @param uniformName Name of the variable.
  34590. * @param array array to be set.
  34591. * @returns this effect.
  34592. */
  34593. setArray3(uniformName: string, array: number[]): Effect;
  34594. /**
  34595. * 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)
  34596. * @param uniformName Name of the variable.
  34597. * @param array array to be set.
  34598. * @returns this effect.
  34599. */
  34600. setArray4(uniformName: string, array: number[]): Effect;
  34601. /**
  34602. * Sets matrices on a uniform variable.
  34603. * @param uniformName Name of the variable.
  34604. * @param matrices matrices to be set.
  34605. * @returns this effect.
  34606. */
  34607. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34608. /**
  34609. * Sets matrix on a uniform variable.
  34610. * @param uniformName Name of the variable.
  34611. * @param matrix matrix to be set.
  34612. * @returns this effect.
  34613. */
  34614. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34615. /**
  34616. * 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)
  34617. * @param uniformName Name of the variable.
  34618. * @param matrix matrix to be set.
  34619. * @returns this effect.
  34620. */
  34621. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34622. /**
  34623. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34624. * @param uniformName Name of the variable.
  34625. * @param matrix matrix to be set.
  34626. * @returns this effect.
  34627. */
  34628. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34629. /**
  34630. * Sets a float on a uniform variable.
  34631. * @param uniformName Name of the variable.
  34632. * @param value value to be set.
  34633. * @returns this effect.
  34634. */
  34635. setFloat(uniformName: string, value: number): Effect;
  34636. /**
  34637. * Sets a boolean on a uniform variable.
  34638. * @param uniformName Name of the variable.
  34639. * @param bool value to be set.
  34640. * @returns this effect.
  34641. */
  34642. setBool(uniformName: string, bool: boolean): Effect;
  34643. /**
  34644. * Sets a Vector2 on a uniform variable.
  34645. * @param uniformName Name of the variable.
  34646. * @param vector2 vector2 to be set.
  34647. * @returns this effect.
  34648. */
  34649. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34650. /**
  34651. * Sets a float2 on a uniform variable.
  34652. * @param uniformName Name of the variable.
  34653. * @param x First float in float2.
  34654. * @param y Second float in float2.
  34655. * @returns this effect.
  34656. */
  34657. setFloat2(uniformName: string, x: number, y: number): Effect;
  34658. /**
  34659. * Sets a Vector3 on a uniform variable.
  34660. * @param uniformName Name of the variable.
  34661. * @param vector3 Value to be set.
  34662. * @returns this effect.
  34663. */
  34664. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34665. /**
  34666. * Sets a float3 on a uniform variable.
  34667. * @param uniformName Name of the variable.
  34668. * @param x First float in float3.
  34669. * @param y Second float in float3.
  34670. * @param z Third float in float3.
  34671. * @returns this effect.
  34672. */
  34673. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34674. /**
  34675. * Sets a Vector4 on a uniform variable.
  34676. * @param uniformName Name of the variable.
  34677. * @param vector4 Value to be set.
  34678. * @returns this effect.
  34679. */
  34680. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34681. /**
  34682. * Sets a float4 on a uniform variable.
  34683. * @param uniformName Name of the variable.
  34684. * @param x First float in float4.
  34685. * @param y Second float in float4.
  34686. * @param z Third float in float4.
  34687. * @param w Fourth float in float4.
  34688. * @returns this effect.
  34689. */
  34690. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34691. /**
  34692. * Sets a Color3 on a uniform variable.
  34693. * @param uniformName Name of the variable.
  34694. * @param color3 Value to be set.
  34695. * @returns this effect.
  34696. */
  34697. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34698. /**
  34699. * Sets a Color4 on a uniform variable.
  34700. * @param uniformName Name of the variable.
  34701. * @param color3 Value to be set.
  34702. * @param alpha Alpha value to be set.
  34703. * @returns this effect.
  34704. */
  34705. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34706. /**
  34707. * Sets a Color4 on a uniform variable
  34708. * @param uniformName defines the name of the variable
  34709. * @param color4 defines the value to be set
  34710. * @returns this effect.
  34711. */
  34712. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34713. /** Release all associated resources */
  34714. dispose(): void;
  34715. /**
  34716. * This function will add a new shader to the shader store
  34717. * @param name the name of the shader
  34718. * @param pixelShader optional pixel shader content
  34719. * @param vertexShader optional vertex shader content
  34720. */
  34721. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34722. /**
  34723. * Store of each shader (The can be looked up using effect.key)
  34724. */
  34725. static ShadersStore: {
  34726. [key: string]: string;
  34727. };
  34728. /**
  34729. * Store of each included file for a shader (The can be looked up using effect.key)
  34730. */
  34731. static IncludesShadersStore: {
  34732. [key: string]: string;
  34733. };
  34734. /**
  34735. * Resets the cache of effects.
  34736. */
  34737. static ResetCache(): void;
  34738. }
  34739. }
  34740. declare module "babylonjs/Engines/engineCapabilities" {
  34741. /**
  34742. * Interface used to describe the capabilities of the engine relatively to the current browser
  34743. */
  34744. export interface EngineCapabilities {
  34745. /** Maximum textures units per fragment shader */
  34746. maxTexturesImageUnits: number;
  34747. /** Maximum texture units per vertex shader */
  34748. maxVertexTextureImageUnits: number;
  34749. /** Maximum textures units in the entire pipeline */
  34750. maxCombinedTexturesImageUnits: number;
  34751. /** Maximum texture size */
  34752. maxTextureSize: number;
  34753. /** Maximum texture samples */
  34754. maxSamples?: number;
  34755. /** Maximum cube texture size */
  34756. maxCubemapTextureSize: number;
  34757. /** Maximum render texture size */
  34758. maxRenderTextureSize: number;
  34759. /** Maximum number of vertex attributes */
  34760. maxVertexAttribs: number;
  34761. /** Maximum number of varyings */
  34762. maxVaryingVectors: number;
  34763. /** Maximum number of uniforms per vertex shader */
  34764. maxVertexUniformVectors: number;
  34765. /** Maximum number of uniforms per fragment shader */
  34766. maxFragmentUniformVectors: number;
  34767. /** Defines if standard derivates (dx/dy) are supported */
  34768. standardDerivatives: boolean;
  34769. /** Defines if s3tc texture compression is supported */
  34770. s3tc?: WEBGL_compressed_texture_s3tc;
  34771. /** Defines if pvrtc texture compression is supported */
  34772. pvrtc: any;
  34773. /** Defines if etc1 texture compression is supported */
  34774. etc1: any;
  34775. /** Defines if etc2 texture compression is supported */
  34776. etc2: any;
  34777. /** Defines if astc texture compression is supported */
  34778. astc: any;
  34779. /** Defines if float textures are supported */
  34780. textureFloat: boolean;
  34781. /** Defines if vertex array objects are supported */
  34782. vertexArrayObject: boolean;
  34783. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34784. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34785. /** Gets the maximum level of anisotropy supported */
  34786. maxAnisotropy: number;
  34787. /** Defines if instancing is supported */
  34788. instancedArrays: boolean;
  34789. /** Defines if 32 bits indices are supported */
  34790. uintIndices: boolean;
  34791. /** Defines if high precision shaders are supported */
  34792. highPrecisionShaderSupported: boolean;
  34793. /** Defines if depth reading in the fragment shader is supported */
  34794. fragmentDepthSupported: boolean;
  34795. /** Defines if float texture linear filtering is supported*/
  34796. textureFloatLinearFiltering: boolean;
  34797. /** Defines if rendering to float textures is supported */
  34798. textureFloatRender: boolean;
  34799. /** Defines if half float textures are supported*/
  34800. textureHalfFloat: boolean;
  34801. /** Defines if half float texture linear filtering is supported*/
  34802. textureHalfFloatLinearFiltering: boolean;
  34803. /** Defines if rendering to half float textures is supported */
  34804. textureHalfFloatRender: boolean;
  34805. /** Defines if textureLOD shader command is supported */
  34806. textureLOD: boolean;
  34807. /** Defines if draw buffers extension is supported */
  34808. drawBuffersExtension: boolean;
  34809. /** Defines if depth textures are supported */
  34810. depthTextureExtension: boolean;
  34811. /** Defines if float color buffer are supported */
  34812. colorBufferFloat: boolean;
  34813. /** Gets disjoint timer query extension (null if not supported) */
  34814. timerQuery?: EXT_disjoint_timer_query;
  34815. /** Defines if timestamp can be used with timer query */
  34816. canUseTimestampForTimerQuery: boolean;
  34817. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34818. multiview?: any;
  34819. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34820. oculusMultiview?: any;
  34821. /** Function used to let the system compiles shaders in background */
  34822. parallelShaderCompile?: {
  34823. COMPLETION_STATUS_KHR: number;
  34824. };
  34825. /** Max number of texture samples for MSAA */
  34826. maxMSAASamples: number;
  34827. /** Defines if the blend min max extension is supported */
  34828. blendMinMax: boolean;
  34829. }
  34830. }
  34831. declare module "babylonjs/States/depthCullingState" {
  34832. import { Nullable } from "babylonjs/types";
  34833. /**
  34834. * @hidden
  34835. **/
  34836. export class DepthCullingState {
  34837. private _isDepthTestDirty;
  34838. private _isDepthMaskDirty;
  34839. private _isDepthFuncDirty;
  34840. private _isCullFaceDirty;
  34841. private _isCullDirty;
  34842. private _isZOffsetDirty;
  34843. private _isFrontFaceDirty;
  34844. private _depthTest;
  34845. private _depthMask;
  34846. private _depthFunc;
  34847. private _cull;
  34848. private _cullFace;
  34849. private _zOffset;
  34850. private _frontFace;
  34851. /**
  34852. * Initializes the state.
  34853. */
  34854. constructor();
  34855. get isDirty(): boolean;
  34856. get zOffset(): number;
  34857. set zOffset(value: number);
  34858. get cullFace(): Nullable<number>;
  34859. set cullFace(value: Nullable<number>);
  34860. get cull(): Nullable<boolean>;
  34861. set cull(value: Nullable<boolean>);
  34862. get depthFunc(): Nullable<number>;
  34863. set depthFunc(value: Nullable<number>);
  34864. get depthMask(): boolean;
  34865. set depthMask(value: boolean);
  34866. get depthTest(): boolean;
  34867. set depthTest(value: boolean);
  34868. get frontFace(): Nullable<number>;
  34869. set frontFace(value: Nullable<number>);
  34870. reset(): void;
  34871. apply(gl: WebGLRenderingContext): void;
  34872. }
  34873. }
  34874. declare module "babylonjs/States/stencilState" {
  34875. /**
  34876. * @hidden
  34877. **/
  34878. export class StencilState {
  34879. /** 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 */
  34880. static readonly ALWAYS: number;
  34881. /** Passed to stencilOperation to specify that stencil value must be kept */
  34882. static readonly KEEP: number;
  34883. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34884. static readonly REPLACE: number;
  34885. private _isStencilTestDirty;
  34886. private _isStencilMaskDirty;
  34887. private _isStencilFuncDirty;
  34888. private _isStencilOpDirty;
  34889. private _stencilTest;
  34890. private _stencilMask;
  34891. private _stencilFunc;
  34892. private _stencilFuncRef;
  34893. private _stencilFuncMask;
  34894. private _stencilOpStencilFail;
  34895. private _stencilOpDepthFail;
  34896. private _stencilOpStencilDepthPass;
  34897. get isDirty(): boolean;
  34898. get stencilFunc(): number;
  34899. set stencilFunc(value: number);
  34900. get stencilFuncRef(): number;
  34901. set stencilFuncRef(value: number);
  34902. get stencilFuncMask(): number;
  34903. set stencilFuncMask(value: number);
  34904. get stencilOpStencilFail(): number;
  34905. set stencilOpStencilFail(value: number);
  34906. get stencilOpDepthFail(): number;
  34907. set stencilOpDepthFail(value: number);
  34908. get stencilOpStencilDepthPass(): number;
  34909. set stencilOpStencilDepthPass(value: number);
  34910. get stencilMask(): number;
  34911. set stencilMask(value: number);
  34912. get stencilTest(): boolean;
  34913. set stencilTest(value: boolean);
  34914. constructor();
  34915. reset(): void;
  34916. apply(gl: WebGLRenderingContext): void;
  34917. }
  34918. }
  34919. declare module "babylonjs/States/alphaCullingState" {
  34920. /**
  34921. * @hidden
  34922. **/
  34923. export class AlphaState {
  34924. private _isAlphaBlendDirty;
  34925. private _isBlendFunctionParametersDirty;
  34926. private _isBlendEquationParametersDirty;
  34927. private _isBlendConstantsDirty;
  34928. private _alphaBlend;
  34929. private _blendFunctionParameters;
  34930. private _blendEquationParameters;
  34931. private _blendConstants;
  34932. /**
  34933. * Initializes the state.
  34934. */
  34935. constructor();
  34936. get isDirty(): boolean;
  34937. get alphaBlend(): boolean;
  34938. set alphaBlend(value: boolean);
  34939. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34940. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34941. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34942. reset(): void;
  34943. apply(gl: WebGLRenderingContext): void;
  34944. }
  34945. }
  34946. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  34947. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  34948. /** @hidden */
  34949. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34950. attributeProcessor(attribute: string): string;
  34951. varyingProcessor(varying: string, isFragment: boolean): string;
  34952. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34953. }
  34954. }
  34955. declare module "babylonjs/Engines/instancingAttributeInfo" {
  34956. /**
  34957. * Interface for attribute information associated with buffer instanciation
  34958. */
  34959. export interface InstancingAttributeInfo {
  34960. /**
  34961. * Name of the GLSL attribute
  34962. * if attribute index is not specified, this is used to retrieve the index from the effect
  34963. */
  34964. attributeName: string;
  34965. /**
  34966. * Index/offset of the attribute in the vertex shader
  34967. * if not specified, this will be computes from the name.
  34968. */
  34969. index?: number;
  34970. /**
  34971. * size of the attribute, 1, 2, 3 or 4
  34972. */
  34973. attributeSize: number;
  34974. /**
  34975. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34976. */
  34977. offset: number;
  34978. /**
  34979. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34980. * default to 1
  34981. */
  34982. divisor?: number;
  34983. /**
  34984. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34985. * default is FLOAT
  34986. */
  34987. attributeType?: number;
  34988. /**
  34989. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34990. */
  34991. normalized?: boolean;
  34992. }
  34993. }
  34994. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  34995. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34996. import { Nullable } from "babylonjs/types";
  34997. module "babylonjs/Engines/thinEngine" {
  34998. interface ThinEngine {
  34999. /**
  35000. * Update a video texture
  35001. * @param texture defines the texture to update
  35002. * @param video defines the video element to use
  35003. * @param invertY defines if data must be stored with Y axis inverted
  35004. */
  35005. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35006. }
  35007. }
  35008. }
  35009. declare module "babylonjs/Materials/Textures/videoTexture" {
  35010. import { Observable } from "babylonjs/Misc/observable";
  35011. import { Nullable } from "babylonjs/types";
  35012. import { Scene } from "babylonjs/scene";
  35013. import { Texture } from "babylonjs/Materials/Textures/texture";
  35014. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35015. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35016. /**
  35017. * Settings for finer control over video usage
  35018. */
  35019. export interface VideoTextureSettings {
  35020. /**
  35021. * Applies `autoplay` to video, if specified
  35022. */
  35023. autoPlay?: boolean;
  35024. /**
  35025. * Applies `loop` to video, if specified
  35026. */
  35027. loop?: boolean;
  35028. /**
  35029. * Automatically updates internal texture from video at every frame in the render loop
  35030. */
  35031. autoUpdateTexture: boolean;
  35032. /**
  35033. * Image src displayed during the video loading or until the user interacts with the video.
  35034. */
  35035. poster?: string;
  35036. }
  35037. /**
  35038. * If you want to display a video in your scene, this is the special texture for that.
  35039. * This special texture works similar to other textures, with the exception of a few parameters.
  35040. * @see https://doc.babylonjs.com/how_to/video_texture
  35041. */
  35042. export class VideoTexture extends Texture {
  35043. /**
  35044. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35045. */
  35046. readonly autoUpdateTexture: boolean;
  35047. /**
  35048. * The video instance used by the texture internally
  35049. */
  35050. readonly video: HTMLVideoElement;
  35051. private _onUserActionRequestedObservable;
  35052. /**
  35053. * Event triggerd when a dom action is required by the user to play the video.
  35054. * This happens due to recent changes in browser policies preventing video to auto start.
  35055. */
  35056. get onUserActionRequestedObservable(): Observable<Texture>;
  35057. private _generateMipMaps;
  35058. private _stillImageCaptured;
  35059. private _displayingPosterTexture;
  35060. private _settings;
  35061. private _createInternalTextureOnEvent;
  35062. private _frameId;
  35063. private _currentSrc;
  35064. /**
  35065. * Creates a video texture.
  35066. * If you want to display a video in your scene, this is the special texture for that.
  35067. * This special texture works similar to other textures, with the exception of a few parameters.
  35068. * @see https://doc.babylonjs.com/how_to/video_texture
  35069. * @param name optional name, will detect from video source, if not defined
  35070. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35071. * @param scene is obviously the current scene.
  35072. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35073. * @param invertY is false by default but can be used to invert video on Y axis
  35074. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35075. * @param settings allows finer control over video usage
  35076. */
  35077. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35078. private _getName;
  35079. private _getVideo;
  35080. private _createInternalTexture;
  35081. private reset;
  35082. /**
  35083. * @hidden Internal method to initiate `update`.
  35084. */
  35085. _rebuild(): void;
  35086. /**
  35087. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35088. */
  35089. update(): void;
  35090. /**
  35091. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35092. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35093. */
  35094. updateTexture(isVisible: boolean): void;
  35095. protected _updateInternalTexture: () => void;
  35096. /**
  35097. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35098. * @param url New url.
  35099. */
  35100. updateURL(url: string): void;
  35101. /**
  35102. * Clones the texture.
  35103. * @returns the cloned texture
  35104. */
  35105. clone(): VideoTexture;
  35106. /**
  35107. * Dispose the texture and release its associated resources.
  35108. */
  35109. dispose(): void;
  35110. /**
  35111. * Creates a video texture straight from a stream.
  35112. * @param scene Define the scene the texture should be created in
  35113. * @param stream Define the stream the texture should be created from
  35114. * @returns The created video texture as a promise
  35115. */
  35116. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35117. /**
  35118. * Creates a video texture straight from your WebCam video feed.
  35119. * @param scene Define the scene the texture should be created in
  35120. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35121. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35122. * @returns The created video texture as a promise
  35123. */
  35124. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35125. minWidth: number;
  35126. maxWidth: number;
  35127. minHeight: number;
  35128. maxHeight: number;
  35129. deviceId: string;
  35130. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35131. /**
  35132. * Creates a video texture straight from your WebCam video feed.
  35133. * @param scene Define the scene the texture should be created in
  35134. * @param onReady Define a callback to triggered once the texture will be ready
  35135. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35136. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35137. */
  35138. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35139. minWidth: number;
  35140. maxWidth: number;
  35141. minHeight: number;
  35142. maxHeight: number;
  35143. deviceId: string;
  35144. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35145. }
  35146. }
  35147. declare module "babylonjs/Engines/thinEngine" {
  35148. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35149. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35150. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35151. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35152. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35153. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35154. import { Observable } from "babylonjs/Misc/observable";
  35155. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35156. import { StencilState } from "babylonjs/States/stencilState";
  35157. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35159. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35160. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35161. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35162. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35163. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35164. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35165. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35166. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35167. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35168. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35169. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35170. import { WebRequest } from "babylonjs/Misc/webRequest";
  35171. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35172. /**
  35173. * Defines the interface used by objects working like Scene
  35174. * @hidden
  35175. */
  35176. export interface ISceneLike {
  35177. _addPendingData(data: any): void;
  35178. _removePendingData(data: any): void;
  35179. offlineProvider: IOfflineProvider;
  35180. }
  35181. /** Interface defining initialization parameters for Engine class */
  35182. export interface EngineOptions extends WebGLContextAttributes {
  35183. /**
  35184. * Defines if the engine should no exceed a specified device ratio
  35185. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35186. */
  35187. limitDeviceRatio?: number;
  35188. /**
  35189. * Defines if webvr should be enabled automatically
  35190. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35191. */
  35192. autoEnableWebVR?: boolean;
  35193. /**
  35194. * Defines if webgl2 should be turned off even if supported
  35195. * @see http://doc.babylonjs.com/features/webgl2
  35196. */
  35197. disableWebGL2Support?: boolean;
  35198. /**
  35199. * Defines if webaudio should be initialized as well
  35200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35201. */
  35202. audioEngine?: boolean;
  35203. /**
  35204. * Defines if animations should run using a deterministic lock step
  35205. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35206. */
  35207. deterministicLockstep?: boolean;
  35208. /** Defines the maximum steps to use with deterministic lock step mode */
  35209. lockstepMaxSteps?: number;
  35210. /** Defines the seconds between each deterministic lock step */
  35211. timeStep?: number;
  35212. /**
  35213. * Defines that engine should ignore context lost events
  35214. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35215. */
  35216. doNotHandleContextLost?: boolean;
  35217. /**
  35218. * Defines that engine should ignore modifying touch action attribute and style
  35219. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35220. */
  35221. doNotHandleTouchAction?: boolean;
  35222. /**
  35223. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35224. */
  35225. useHighPrecisionFloats?: boolean;
  35226. }
  35227. /**
  35228. * The base engine class (root of all engines)
  35229. */
  35230. export class ThinEngine {
  35231. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35232. static ExceptionList: ({
  35233. key: string;
  35234. capture: string;
  35235. captureConstraint: number;
  35236. targets: string[];
  35237. } | {
  35238. key: string;
  35239. capture: null;
  35240. captureConstraint: null;
  35241. targets: string[];
  35242. })[];
  35243. /** @hidden */
  35244. static _TextureLoaders: IInternalTextureLoader[];
  35245. /**
  35246. * Returns the current npm package of the sdk
  35247. */
  35248. static get NpmPackage(): string;
  35249. /**
  35250. * Returns the current version of the framework
  35251. */
  35252. static get Version(): string;
  35253. /**
  35254. * Returns a string describing the current engine
  35255. */
  35256. get description(): string;
  35257. /**
  35258. * Gets or sets the epsilon value used by collision engine
  35259. */
  35260. static CollisionsEpsilon: number;
  35261. /**
  35262. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35263. */
  35264. static get ShadersRepository(): string;
  35265. static set ShadersRepository(value: string);
  35266. /** @hidden */
  35267. _shaderProcessor: IShaderProcessor;
  35268. /**
  35269. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35270. */
  35271. forcePOTTextures: boolean;
  35272. /**
  35273. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35274. */
  35275. isFullscreen: boolean;
  35276. /**
  35277. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35278. */
  35279. cullBackFaces: boolean;
  35280. /**
  35281. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35282. */
  35283. renderEvenInBackground: boolean;
  35284. /**
  35285. * Gets or sets a boolean indicating that cache can be kept between frames
  35286. */
  35287. preventCacheWipeBetweenFrames: boolean;
  35288. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35289. validateShaderPrograms: boolean;
  35290. /**
  35291. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35292. * This can provide greater z depth for distant objects.
  35293. */
  35294. useReverseDepthBuffer: boolean;
  35295. /**
  35296. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35297. */
  35298. disableUniformBuffers: boolean;
  35299. /** @hidden */
  35300. _uniformBuffers: UniformBuffer[];
  35301. /**
  35302. * Gets a boolean indicating that the engine supports uniform buffers
  35303. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35304. */
  35305. get supportsUniformBuffers(): boolean;
  35306. /** @hidden */
  35307. _gl: WebGLRenderingContext;
  35308. /** @hidden */
  35309. _webGLVersion: number;
  35310. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35311. protected _windowIsBackground: boolean;
  35312. protected _creationOptions: EngineOptions;
  35313. protected _highPrecisionShadersAllowed: boolean;
  35314. /** @hidden */
  35315. get _shouldUseHighPrecisionShader(): boolean;
  35316. /**
  35317. * Gets a boolean indicating that only power of 2 textures are supported
  35318. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35319. */
  35320. get needPOTTextures(): boolean;
  35321. /** @hidden */
  35322. _badOS: boolean;
  35323. /** @hidden */
  35324. _badDesktopOS: boolean;
  35325. private _hardwareScalingLevel;
  35326. /** @hidden */
  35327. _caps: EngineCapabilities;
  35328. private _isStencilEnable;
  35329. private _glVersion;
  35330. private _glRenderer;
  35331. private _glVendor;
  35332. /** @hidden */
  35333. _videoTextureSupported: boolean;
  35334. protected _renderingQueueLaunched: boolean;
  35335. protected _activeRenderLoops: (() => void)[];
  35336. /**
  35337. * Observable signaled when a context lost event is raised
  35338. */
  35339. onContextLostObservable: Observable<ThinEngine>;
  35340. /**
  35341. * Observable signaled when a context restored event is raised
  35342. */
  35343. onContextRestoredObservable: Observable<ThinEngine>;
  35344. private _onContextLost;
  35345. private _onContextRestored;
  35346. protected _contextWasLost: boolean;
  35347. /** @hidden */
  35348. _doNotHandleContextLost: boolean;
  35349. /**
  35350. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35351. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35352. */
  35353. get doNotHandleContextLost(): boolean;
  35354. set doNotHandleContextLost(value: boolean);
  35355. /**
  35356. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35357. */
  35358. disableVertexArrayObjects: boolean;
  35359. /** @hidden */
  35360. protected _colorWrite: boolean;
  35361. /** @hidden */
  35362. protected _colorWriteChanged: boolean;
  35363. /** @hidden */
  35364. protected _depthCullingState: DepthCullingState;
  35365. /** @hidden */
  35366. protected _stencilState: StencilState;
  35367. /** @hidden */
  35368. _alphaState: AlphaState;
  35369. /** @hidden */
  35370. _alphaMode: number;
  35371. /** @hidden */
  35372. _alphaEquation: number;
  35373. /** @hidden */
  35374. _internalTexturesCache: InternalTexture[];
  35375. /** @hidden */
  35376. protected _activeChannel: number;
  35377. private _currentTextureChannel;
  35378. /** @hidden */
  35379. protected _boundTexturesCache: {
  35380. [key: string]: Nullable<InternalTexture>;
  35381. };
  35382. /** @hidden */
  35383. protected _currentEffect: Nullable<Effect>;
  35384. /** @hidden */
  35385. protected _currentProgram: Nullable<WebGLProgram>;
  35386. private _compiledEffects;
  35387. private _vertexAttribArraysEnabled;
  35388. /** @hidden */
  35389. protected _cachedViewport: Nullable<IViewportLike>;
  35390. private _cachedVertexArrayObject;
  35391. /** @hidden */
  35392. protected _cachedVertexBuffers: any;
  35393. /** @hidden */
  35394. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35395. /** @hidden */
  35396. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35397. /** @hidden */
  35398. _currentRenderTarget: Nullable<InternalTexture>;
  35399. private _uintIndicesCurrentlySet;
  35400. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35401. /** @hidden */
  35402. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35403. /** @hidden */
  35404. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35405. private _currentBufferPointers;
  35406. private _currentInstanceLocations;
  35407. private _currentInstanceBuffers;
  35408. private _textureUnits;
  35409. /** @hidden */
  35410. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35411. /** @hidden */
  35412. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35413. /** @hidden */
  35414. _boundRenderFunction: any;
  35415. private _vaoRecordInProgress;
  35416. private _mustWipeVertexAttributes;
  35417. private _emptyTexture;
  35418. private _emptyCubeTexture;
  35419. private _emptyTexture3D;
  35420. private _emptyTexture2DArray;
  35421. /** @hidden */
  35422. _frameHandler: number;
  35423. private _nextFreeTextureSlots;
  35424. private _maxSimultaneousTextures;
  35425. private _activeRequests;
  35426. /** @hidden */
  35427. _transformTextureUrl: Nullable<(url: string) => string>;
  35428. protected get _supportsHardwareTextureRescaling(): boolean;
  35429. private _framebufferDimensionsObject;
  35430. /**
  35431. * sets the object from which width and height will be taken from when getting render width and height
  35432. * Will fallback to the gl object
  35433. * @param dimensions the framebuffer width and height that will be used.
  35434. */
  35435. set framebufferDimensionsObject(dimensions: Nullable<{
  35436. framebufferWidth: number;
  35437. framebufferHeight: number;
  35438. }>);
  35439. /**
  35440. * Gets the current viewport
  35441. */
  35442. get currentViewport(): Nullable<IViewportLike>;
  35443. /**
  35444. * Gets the default empty texture
  35445. */
  35446. get emptyTexture(): InternalTexture;
  35447. /**
  35448. * Gets the default empty 3D texture
  35449. */
  35450. get emptyTexture3D(): InternalTexture;
  35451. /**
  35452. * Gets the default empty 2D array texture
  35453. */
  35454. get emptyTexture2DArray(): InternalTexture;
  35455. /**
  35456. * Gets the default empty cube texture
  35457. */
  35458. get emptyCubeTexture(): InternalTexture;
  35459. /**
  35460. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35461. */
  35462. readonly premultipliedAlpha: boolean;
  35463. /**
  35464. * Observable event triggered before each texture is initialized
  35465. */
  35466. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35467. /**
  35468. * Creates a new engine
  35469. * @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
  35470. * @param antialias defines enable antialiasing (default: false)
  35471. * @param options defines further options to be sent to the getContext() function
  35472. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35473. */
  35474. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35475. private _rebuildInternalTextures;
  35476. private _rebuildEffects;
  35477. /**
  35478. * Gets a boolean indicating if all created effects are ready
  35479. * @returns true if all effects are ready
  35480. */
  35481. areAllEffectsReady(): boolean;
  35482. protected _rebuildBuffers(): void;
  35483. protected _initGLContext(): void;
  35484. /**
  35485. * Gets version of the current webGL context
  35486. */
  35487. get webGLVersion(): number;
  35488. /**
  35489. * Gets a string idenfifying the name of the class
  35490. * @returns "Engine" string
  35491. */
  35492. getClassName(): string;
  35493. /**
  35494. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35495. */
  35496. get isStencilEnable(): boolean;
  35497. /** @hidden */
  35498. _prepareWorkingCanvas(): void;
  35499. /**
  35500. * Reset the texture cache to empty state
  35501. */
  35502. resetTextureCache(): void;
  35503. /**
  35504. * Gets an object containing information about the current webGL context
  35505. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35506. */
  35507. getGlInfo(): {
  35508. vendor: string;
  35509. renderer: string;
  35510. version: string;
  35511. };
  35512. /**
  35513. * Defines the hardware scaling level.
  35514. * By default the hardware scaling level is computed from the window device ratio.
  35515. * 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.
  35516. * @param level defines the level to use
  35517. */
  35518. setHardwareScalingLevel(level: number): void;
  35519. /**
  35520. * Gets the current hardware scaling level.
  35521. * By default the hardware scaling level is computed from the window device ratio.
  35522. * 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.
  35523. * @returns a number indicating the current hardware scaling level
  35524. */
  35525. getHardwareScalingLevel(): number;
  35526. /**
  35527. * Gets the list of loaded textures
  35528. * @returns an array containing all loaded textures
  35529. */
  35530. getLoadedTexturesCache(): InternalTexture[];
  35531. /**
  35532. * Gets the object containing all engine capabilities
  35533. * @returns the EngineCapabilities object
  35534. */
  35535. getCaps(): EngineCapabilities;
  35536. /**
  35537. * stop executing a render loop function and remove it from the execution array
  35538. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35539. */
  35540. stopRenderLoop(renderFunction?: () => void): void;
  35541. /** @hidden */
  35542. _renderLoop(): void;
  35543. /**
  35544. * Gets the HTML canvas attached with the current webGL context
  35545. * @returns a HTML canvas
  35546. */
  35547. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35548. /**
  35549. * Gets host window
  35550. * @returns the host window object
  35551. */
  35552. getHostWindow(): Nullable<Window>;
  35553. /**
  35554. * Gets the current render width
  35555. * @param useScreen defines if screen size must be used (or the current render target if any)
  35556. * @returns a number defining the current render width
  35557. */
  35558. getRenderWidth(useScreen?: boolean): number;
  35559. /**
  35560. * Gets the current render height
  35561. * @param useScreen defines if screen size must be used (or the current render target if any)
  35562. * @returns a number defining the current render height
  35563. */
  35564. getRenderHeight(useScreen?: boolean): number;
  35565. /**
  35566. * Can be used to override the current requestAnimationFrame requester.
  35567. * @hidden
  35568. */
  35569. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35570. /**
  35571. * Register and execute a render loop. The engine can have more than one render function
  35572. * @param renderFunction defines the function to continuously execute
  35573. */
  35574. runRenderLoop(renderFunction: () => void): void;
  35575. /**
  35576. * Clear the current render buffer or the current render target (if any is set up)
  35577. * @param color defines the color to use
  35578. * @param backBuffer defines if the back buffer must be cleared
  35579. * @param depth defines if the depth buffer must be cleared
  35580. * @param stencil defines if the stencil buffer must be cleared
  35581. */
  35582. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35583. private _viewportCached;
  35584. /** @hidden */
  35585. _viewport(x: number, y: number, width: number, height: number): void;
  35586. /**
  35587. * Set the WebGL's viewport
  35588. * @param viewport defines the viewport element to be used
  35589. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35590. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35591. */
  35592. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35593. /**
  35594. * Begin a new frame
  35595. */
  35596. beginFrame(): void;
  35597. /**
  35598. * Enf the current frame
  35599. */
  35600. endFrame(): void;
  35601. /**
  35602. * Resize the view according to the canvas' size
  35603. */
  35604. resize(): void;
  35605. /**
  35606. * Force a specific size of the canvas
  35607. * @param width defines the new canvas' width
  35608. * @param height defines the new canvas' height
  35609. */
  35610. setSize(width: number, height: number): void;
  35611. /**
  35612. * Binds the frame buffer to the specified texture.
  35613. * @param texture The texture to render to or null for the default canvas
  35614. * @param faceIndex The face of the texture to render to in case of cube texture
  35615. * @param requiredWidth The width of the target to render to
  35616. * @param requiredHeight The height of the target to render to
  35617. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35618. * @param lodLevel defines the lod level to bind to the frame buffer
  35619. * @param layer defines the 2d array index to bind to frame buffer to
  35620. */
  35621. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35622. /** @hidden */
  35623. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35624. /**
  35625. * Unbind the current render target texture from the webGL context
  35626. * @param texture defines the render target texture to unbind
  35627. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35628. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35629. */
  35630. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35631. /**
  35632. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35633. */
  35634. flushFramebuffer(): void;
  35635. /**
  35636. * Unbind the current render target and bind the default framebuffer
  35637. */
  35638. restoreDefaultFramebuffer(): void;
  35639. /** @hidden */
  35640. protected _resetVertexBufferBinding(): void;
  35641. /**
  35642. * Creates a vertex buffer
  35643. * @param data the data for the vertex buffer
  35644. * @returns the new WebGL static buffer
  35645. */
  35646. createVertexBuffer(data: DataArray): DataBuffer;
  35647. private _createVertexBuffer;
  35648. /**
  35649. * Creates a dynamic vertex buffer
  35650. * @param data the data for the dynamic vertex buffer
  35651. * @returns the new WebGL dynamic buffer
  35652. */
  35653. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35654. protected _resetIndexBufferBinding(): void;
  35655. /**
  35656. * Creates a new index buffer
  35657. * @param indices defines the content of the index buffer
  35658. * @param updatable defines if the index buffer must be updatable
  35659. * @returns a new webGL buffer
  35660. */
  35661. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35662. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35663. /**
  35664. * Bind a webGL buffer to the webGL context
  35665. * @param buffer defines the buffer to bind
  35666. */
  35667. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35668. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35669. private bindBuffer;
  35670. /**
  35671. * update the bound buffer with the given data
  35672. * @param data defines the data to update
  35673. */
  35674. updateArrayBuffer(data: Float32Array): void;
  35675. private _vertexAttribPointer;
  35676. /** @hidden */
  35677. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35678. private _bindVertexBuffersAttributes;
  35679. /**
  35680. * Records a vertex array object
  35681. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35682. * @param vertexBuffers defines the list of vertex buffers to store
  35683. * @param indexBuffer defines the index buffer to store
  35684. * @param effect defines the effect to store
  35685. * @returns the new vertex array object
  35686. */
  35687. recordVertexArrayObject(vertexBuffers: {
  35688. [key: string]: VertexBuffer;
  35689. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35690. /**
  35691. * Bind a specific vertex array object
  35692. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35693. * @param vertexArrayObject defines the vertex array object to bind
  35694. * @param indexBuffer defines the index buffer to bind
  35695. */
  35696. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35697. /**
  35698. * Bind webGl buffers directly to the webGL context
  35699. * @param vertexBuffer defines the vertex buffer to bind
  35700. * @param indexBuffer defines the index buffer to bind
  35701. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35702. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35703. * @param effect defines the effect associated with the vertex buffer
  35704. */
  35705. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35706. private _unbindVertexArrayObject;
  35707. /**
  35708. * Bind a list of vertex buffers to the webGL context
  35709. * @param vertexBuffers defines the list of vertex buffers to bind
  35710. * @param indexBuffer defines the index buffer to bind
  35711. * @param effect defines the effect associated with the vertex buffers
  35712. */
  35713. bindBuffers(vertexBuffers: {
  35714. [key: string]: Nullable<VertexBuffer>;
  35715. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35716. /**
  35717. * Unbind all instance attributes
  35718. */
  35719. unbindInstanceAttributes(): void;
  35720. /**
  35721. * Release and free the memory of a vertex array object
  35722. * @param vao defines the vertex array object to delete
  35723. */
  35724. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35725. /** @hidden */
  35726. _releaseBuffer(buffer: DataBuffer): boolean;
  35727. protected _deleteBuffer(buffer: DataBuffer): void;
  35728. /**
  35729. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35730. * @param instancesBuffer defines the webGL buffer to update and bind
  35731. * @param data defines the data to store in the buffer
  35732. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35733. */
  35734. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35735. /**
  35736. * Bind the content of a webGL buffer used with instantiation
  35737. * @param instancesBuffer defines the webGL buffer to bind
  35738. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35739. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35740. */
  35741. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35742. /**
  35743. * Disable the instance attribute corresponding to the name in parameter
  35744. * @param name defines the name of the attribute to disable
  35745. */
  35746. disableInstanceAttributeByName(name: string): void;
  35747. /**
  35748. * Disable the instance attribute corresponding to the location in parameter
  35749. * @param attributeLocation defines the attribute location of the attribute to disable
  35750. */
  35751. disableInstanceAttribute(attributeLocation: number): void;
  35752. /**
  35753. * Disable the attribute corresponding to the location in parameter
  35754. * @param attributeLocation defines the attribute location of the attribute to disable
  35755. */
  35756. disableAttributeByIndex(attributeLocation: number): void;
  35757. /**
  35758. * Send a draw order
  35759. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35760. * @param indexStart defines the starting index
  35761. * @param indexCount defines the number of index to draw
  35762. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35763. */
  35764. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35765. /**
  35766. * Draw a list of points
  35767. * @param verticesStart defines the index of first vertex to draw
  35768. * @param verticesCount defines the count of vertices to draw
  35769. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35770. */
  35771. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35772. /**
  35773. * Draw a list of unindexed primitives
  35774. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35775. * @param verticesStart defines the index of first vertex to draw
  35776. * @param verticesCount defines the count of vertices to draw
  35777. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35778. */
  35779. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35780. /**
  35781. * Draw a list of indexed primitives
  35782. * @param fillMode defines the primitive to use
  35783. * @param indexStart defines the starting index
  35784. * @param indexCount defines the number of index to draw
  35785. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35786. */
  35787. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35788. /**
  35789. * Draw a list of unindexed primitives
  35790. * @param fillMode defines the primitive to use
  35791. * @param verticesStart defines the index of first vertex to draw
  35792. * @param verticesCount defines the count of vertices to draw
  35793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35794. */
  35795. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35796. private _drawMode;
  35797. /** @hidden */
  35798. protected _reportDrawCall(): void;
  35799. /** @hidden */
  35800. _releaseEffect(effect: Effect): void;
  35801. /** @hidden */
  35802. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35803. /**
  35804. * Create a new effect (used to store vertex/fragment shaders)
  35805. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35806. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35807. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35808. * @param samplers defines an array of string used to represent textures
  35809. * @param defines defines the string containing the defines to use to compile the shaders
  35810. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35811. * @param onCompiled defines a function to call when the effect creation is successful
  35812. * @param onError defines a function to call when the effect creation has failed
  35813. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35814. * @returns the new Effect
  35815. */
  35816. 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;
  35817. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35818. private _compileShader;
  35819. private _compileRawShader;
  35820. /** @hidden */
  35821. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35822. /**
  35823. * Directly creates a webGL program
  35824. * @param pipelineContext defines the pipeline context to attach to
  35825. * @param vertexCode defines the vertex shader code to use
  35826. * @param fragmentCode defines the fragment shader code to use
  35827. * @param context defines the webGL context to use (if not set, the current one will be used)
  35828. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35829. * @returns the new webGL program
  35830. */
  35831. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35832. /**
  35833. * Creates a webGL program
  35834. * @param pipelineContext defines the pipeline context to attach to
  35835. * @param vertexCode defines the vertex shader code to use
  35836. * @param fragmentCode defines the fragment shader code to use
  35837. * @param defines defines the string containing the defines to use to compile the shaders
  35838. * @param context defines the webGL context to use (if not set, the current one will be used)
  35839. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35840. * @returns the new webGL program
  35841. */
  35842. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35843. /**
  35844. * Creates a new pipeline context
  35845. * @returns the new pipeline
  35846. */
  35847. createPipelineContext(): IPipelineContext;
  35848. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35849. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35850. /** @hidden */
  35851. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35852. /** @hidden */
  35853. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35854. /** @hidden */
  35855. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35856. /**
  35857. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35858. * @param pipelineContext defines the pipeline context to use
  35859. * @param uniformsNames defines the list of uniform names
  35860. * @returns an array of webGL uniform locations
  35861. */
  35862. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35863. /**
  35864. * Gets the lsit of active attributes for a given webGL program
  35865. * @param pipelineContext defines the pipeline context to use
  35866. * @param attributesNames defines the list of attribute names to get
  35867. * @returns an array of indices indicating the offset of each attribute
  35868. */
  35869. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35870. /**
  35871. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35872. * @param effect defines the effect to activate
  35873. */
  35874. enableEffect(effect: Nullable<Effect>): void;
  35875. /**
  35876. * Set the value of an uniform to a number (int)
  35877. * @param uniform defines the webGL uniform location where to store the value
  35878. * @param value defines the int number to store
  35879. */
  35880. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35881. /**
  35882. * Set the value of an uniform to an array of int32
  35883. * @param uniform defines the webGL uniform location where to store the value
  35884. * @param array defines the array of int32 to store
  35885. */
  35886. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35887. /**
  35888. * Set the value of an uniform to an array of int32 (stored as vec2)
  35889. * @param uniform defines the webGL uniform location where to store the value
  35890. * @param array defines the array of int32 to store
  35891. */
  35892. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35893. /**
  35894. * Set the value of an uniform to an array of int32 (stored as vec3)
  35895. * @param uniform defines the webGL uniform location where to store the value
  35896. * @param array defines the array of int32 to store
  35897. */
  35898. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35899. /**
  35900. * Set the value of an uniform to an array of int32 (stored as vec4)
  35901. * @param uniform defines the webGL uniform location where to store the value
  35902. * @param array defines the array of int32 to store
  35903. */
  35904. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35905. /**
  35906. * Set the value of an uniform to an array of number
  35907. * @param uniform defines the webGL uniform location where to store the value
  35908. * @param array defines the array of number to store
  35909. */
  35910. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35911. /**
  35912. * Set the value of an uniform to an array of number (stored as vec2)
  35913. * @param uniform defines the webGL uniform location where to store the value
  35914. * @param array defines the array of number to store
  35915. */
  35916. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35917. /**
  35918. * Set the value of an uniform to an array of number (stored as vec3)
  35919. * @param uniform defines the webGL uniform location where to store the value
  35920. * @param array defines the array of number to store
  35921. */
  35922. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35923. /**
  35924. * Set the value of an uniform to an array of number (stored as vec4)
  35925. * @param uniform defines the webGL uniform location where to store the value
  35926. * @param array defines the array of number to store
  35927. */
  35928. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35929. /**
  35930. * Set the value of an uniform to an array of float32 (stored as matrices)
  35931. * @param uniform defines the webGL uniform location where to store the value
  35932. * @param matrices defines the array of float32 to store
  35933. */
  35934. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35935. /**
  35936. * Set the value of an uniform to a matrix (3x3)
  35937. * @param uniform defines the webGL uniform location where to store the value
  35938. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35939. */
  35940. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35941. /**
  35942. * Set the value of an uniform to a matrix (2x2)
  35943. * @param uniform defines the webGL uniform location where to store the value
  35944. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35945. */
  35946. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35947. /**
  35948. * Set the value of an uniform to a number (float)
  35949. * @param uniform defines the webGL uniform location where to store the value
  35950. * @param value defines the float number to store
  35951. */
  35952. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35953. /**
  35954. * Set the value of an uniform to a vec2
  35955. * @param uniform defines the webGL uniform location where to store the value
  35956. * @param x defines the 1st component of the value
  35957. * @param y defines the 2nd component of the value
  35958. */
  35959. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35960. /**
  35961. * Set the value of an uniform to a vec3
  35962. * @param uniform defines the webGL uniform location where to store the value
  35963. * @param x defines the 1st component of the value
  35964. * @param y defines the 2nd component of the value
  35965. * @param z defines the 3rd component of the value
  35966. */
  35967. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35968. /**
  35969. * Set the value of an uniform to a vec4
  35970. * @param uniform defines the webGL uniform location where to store the value
  35971. * @param x defines the 1st component of the value
  35972. * @param y defines the 2nd component of the value
  35973. * @param z defines the 3rd component of the value
  35974. * @param w defines the 4th component of the value
  35975. */
  35976. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35977. /**
  35978. * Apply all cached states (depth, culling, stencil and alpha)
  35979. */
  35980. applyStates(): void;
  35981. /**
  35982. * Enable or disable color writing
  35983. * @param enable defines the state to set
  35984. */
  35985. setColorWrite(enable: boolean): void;
  35986. /**
  35987. * Gets a boolean indicating if color writing is enabled
  35988. * @returns the current color writing state
  35989. */
  35990. getColorWrite(): boolean;
  35991. /**
  35992. * Gets the depth culling state manager
  35993. */
  35994. get depthCullingState(): DepthCullingState;
  35995. /**
  35996. * Gets the alpha state manager
  35997. */
  35998. get alphaState(): AlphaState;
  35999. /**
  36000. * Gets the stencil state manager
  36001. */
  36002. get stencilState(): StencilState;
  36003. /**
  36004. * Clears the list of texture accessible through engine.
  36005. * This can help preventing texture load conflict due to name collision.
  36006. */
  36007. clearInternalTexturesCache(): void;
  36008. /**
  36009. * Force the entire cache to be cleared
  36010. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36011. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36012. */
  36013. wipeCaches(bruteForce?: boolean): void;
  36014. /** @hidden */
  36015. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36016. min: number;
  36017. mag: number;
  36018. };
  36019. /** @hidden */
  36020. _createTexture(): WebGLTexture;
  36021. /**
  36022. * Usually called from Texture.ts.
  36023. * Passed information to create a WebGLTexture
  36024. * @param url defines a value which contains one of the following:
  36025. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36026. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36027. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36028. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36029. * @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)
  36030. * @param scene needed for loading to the correct scene
  36031. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36032. * @param onLoad optional callback to be called upon successful completion
  36033. * @param onError optional callback to be called upon failure
  36034. * @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
  36035. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36036. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36037. * @param forcedExtension defines the extension to use to pick the right loader
  36038. * @param mimeType defines an optional mime type
  36039. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36040. */
  36041. 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;
  36042. /**
  36043. * Loads an image as an HTMLImageElement.
  36044. * @param input url string, ArrayBuffer, or Blob to load
  36045. * @param onLoad callback called when the image successfully loads
  36046. * @param onError callback called when the image fails to load
  36047. * @param offlineProvider offline provider for caching
  36048. * @param mimeType optional mime type
  36049. * @returns the HTMLImageElement of the loaded image
  36050. * @hidden
  36051. */
  36052. 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>;
  36053. /**
  36054. * @hidden
  36055. */
  36056. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36057. private _unpackFlipYCached;
  36058. /**
  36059. * In case you are sharing the context with other applications, it might
  36060. * be interested to not cache the unpack flip y state to ensure a consistent
  36061. * value would be set.
  36062. */
  36063. enableUnpackFlipYCached: boolean;
  36064. /** @hidden */
  36065. _unpackFlipY(value: boolean): void;
  36066. /** @hidden */
  36067. _getUnpackAlignement(): number;
  36068. private _getTextureTarget;
  36069. /**
  36070. * Update the sampling mode of a given texture
  36071. * @param samplingMode defines the required sampling mode
  36072. * @param texture defines the texture to update
  36073. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36074. */
  36075. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36076. /**
  36077. * Update the sampling mode of a given texture
  36078. * @param texture defines the texture to update
  36079. * @param wrapU defines the texture wrap mode of the u coordinates
  36080. * @param wrapV defines the texture wrap mode of the v coordinates
  36081. * @param wrapR defines the texture wrap mode of the r coordinates
  36082. */
  36083. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36084. /** @hidden */
  36085. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36086. width: number;
  36087. height: number;
  36088. layers?: number;
  36089. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36090. /** @hidden */
  36091. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36092. /** @hidden */
  36093. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36094. /**
  36095. * Update a portion of an internal texture
  36096. * @param texture defines the texture to update
  36097. * @param imageData defines the data to store into the texture
  36098. * @param xOffset defines the x coordinates of the update rectangle
  36099. * @param yOffset defines the y coordinates of the update rectangle
  36100. * @param width defines the width of the update rectangle
  36101. * @param height defines the height of the update rectangle
  36102. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36103. * @param lod defines the lod level to update (0 by default)
  36104. */
  36105. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36106. /** @hidden */
  36107. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36108. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36109. private _prepareWebGLTexture;
  36110. /** @hidden */
  36111. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36112. private _getDepthStencilBuffer;
  36113. /** @hidden */
  36114. _releaseFramebufferObjects(texture: InternalTexture): void;
  36115. /** @hidden */
  36116. _releaseTexture(texture: InternalTexture): void;
  36117. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36118. protected _setProgram(program: WebGLProgram): void;
  36119. protected _boundUniforms: {
  36120. [key: number]: WebGLUniformLocation;
  36121. };
  36122. /**
  36123. * Binds an effect to the webGL context
  36124. * @param effect defines the effect to bind
  36125. */
  36126. bindSamplers(effect: Effect): void;
  36127. private _activateCurrentTexture;
  36128. /** @hidden */
  36129. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36130. /** @hidden */
  36131. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36132. /**
  36133. * Unbind all textures from the webGL context
  36134. */
  36135. unbindAllTextures(): void;
  36136. /**
  36137. * Sets a texture to the according uniform.
  36138. * @param channel The texture channel
  36139. * @param uniform The uniform to set
  36140. * @param texture The texture to apply
  36141. */
  36142. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36143. private _bindSamplerUniformToChannel;
  36144. private _getTextureWrapMode;
  36145. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36146. /**
  36147. * Sets an array of texture to the webGL context
  36148. * @param channel defines the channel where the texture array must be set
  36149. * @param uniform defines the associated uniform location
  36150. * @param textures defines the array of textures to bind
  36151. */
  36152. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36153. /** @hidden */
  36154. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36155. private _setTextureParameterFloat;
  36156. private _setTextureParameterInteger;
  36157. /**
  36158. * Unbind all vertex attributes from the webGL context
  36159. */
  36160. unbindAllAttributes(): void;
  36161. /**
  36162. * 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
  36163. */
  36164. releaseEffects(): void;
  36165. /**
  36166. * Dispose and release all associated resources
  36167. */
  36168. dispose(): void;
  36169. /**
  36170. * Attach a new callback raised when context lost event is fired
  36171. * @param callback defines the callback to call
  36172. */
  36173. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36174. /**
  36175. * Attach a new callback raised when context restored event is fired
  36176. * @param callback defines the callback to call
  36177. */
  36178. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36179. /**
  36180. * Get the current error code of the webGL context
  36181. * @returns the error code
  36182. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36183. */
  36184. getError(): number;
  36185. private _canRenderToFloatFramebuffer;
  36186. private _canRenderToHalfFloatFramebuffer;
  36187. private _canRenderToFramebuffer;
  36188. /** @hidden */
  36189. _getWebGLTextureType(type: number): number;
  36190. /** @hidden */
  36191. _getInternalFormat(format: number): number;
  36192. /** @hidden */
  36193. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36194. /** @hidden */
  36195. _getRGBAMultiSampleBufferFormat(type: number): number;
  36196. /** @hidden */
  36197. _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;
  36198. /**
  36199. * Loads a file from a url
  36200. * @param url url to load
  36201. * @param onSuccess callback called when the file successfully loads
  36202. * @param onProgress callback called while file is loading (if the server supports this mode)
  36203. * @param offlineProvider defines the offline provider for caching
  36204. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36205. * @param onError callback called when the file fails to load
  36206. * @returns a file request object
  36207. * @hidden
  36208. */
  36209. 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;
  36210. /**
  36211. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36212. * @param x defines the x coordinate of the rectangle where pixels must be read
  36213. * @param y defines the y coordinate of the rectangle where pixels must be read
  36214. * @param width defines the width of the rectangle where pixels must be read
  36215. * @param height defines the height of the rectangle where pixels must be read
  36216. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36217. * @returns a Uint8Array containing RGBA colors
  36218. */
  36219. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36220. private static _isSupported;
  36221. /**
  36222. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36223. * @returns true if the engine can be created
  36224. * @ignorenaming
  36225. */
  36226. static isSupported(): boolean;
  36227. /**
  36228. * Find the next highest power of two.
  36229. * @param x Number to start search from.
  36230. * @return Next highest power of two.
  36231. */
  36232. static CeilingPOT(x: number): number;
  36233. /**
  36234. * Find the next lowest power of two.
  36235. * @param x Number to start search from.
  36236. * @return Next lowest power of two.
  36237. */
  36238. static FloorPOT(x: number): number;
  36239. /**
  36240. * Find the nearest power of two.
  36241. * @param x Number to start search from.
  36242. * @return Next nearest power of two.
  36243. */
  36244. static NearestPOT(x: number): number;
  36245. /**
  36246. * Get the closest exponent of two
  36247. * @param value defines the value to approximate
  36248. * @param max defines the maximum value to return
  36249. * @param mode defines how to define the closest value
  36250. * @returns closest exponent of two of the given value
  36251. */
  36252. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36253. /**
  36254. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36255. * @param func - the function to be called
  36256. * @param requester - the object that will request the next frame. Falls back to window.
  36257. * @returns frame number
  36258. */
  36259. static QueueNewFrame(func: () => void, requester?: any): number;
  36260. /**
  36261. * Gets host document
  36262. * @returns the host document object
  36263. */
  36264. getHostDocument(): Nullable<Document>;
  36265. }
  36266. }
  36267. declare module "babylonjs/Maths/sphericalPolynomial" {
  36268. import { Vector3 } from "babylonjs/Maths/math.vector";
  36269. import { Color3 } from "babylonjs/Maths/math.color";
  36270. /**
  36271. * Class representing spherical harmonics coefficients to the 3rd degree
  36272. */
  36273. export class SphericalHarmonics {
  36274. /**
  36275. * Defines whether or not the harmonics have been prescaled for rendering.
  36276. */
  36277. preScaled: boolean;
  36278. /**
  36279. * The l0,0 coefficients of the spherical harmonics
  36280. */
  36281. l00: Vector3;
  36282. /**
  36283. * The l1,-1 coefficients of the spherical harmonics
  36284. */
  36285. l1_1: Vector3;
  36286. /**
  36287. * The l1,0 coefficients of the spherical harmonics
  36288. */
  36289. l10: Vector3;
  36290. /**
  36291. * The l1,1 coefficients of the spherical harmonics
  36292. */
  36293. l11: Vector3;
  36294. /**
  36295. * The l2,-2 coefficients of the spherical harmonics
  36296. */
  36297. l2_2: Vector3;
  36298. /**
  36299. * The l2,-1 coefficients of the spherical harmonics
  36300. */
  36301. l2_1: Vector3;
  36302. /**
  36303. * The l2,0 coefficients of the spherical harmonics
  36304. */
  36305. l20: Vector3;
  36306. /**
  36307. * The l2,1 coefficients of the spherical harmonics
  36308. */
  36309. l21: Vector3;
  36310. /**
  36311. * The l2,2 coefficients of the spherical harmonics
  36312. */
  36313. l22: Vector3;
  36314. /**
  36315. * Adds a light to the spherical harmonics
  36316. * @param direction the direction of the light
  36317. * @param color the color of the light
  36318. * @param deltaSolidAngle the delta solid angle of the light
  36319. */
  36320. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36321. /**
  36322. * Scales the spherical harmonics by the given amount
  36323. * @param scale the amount to scale
  36324. */
  36325. scaleInPlace(scale: number): void;
  36326. /**
  36327. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36328. *
  36329. * ```
  36330. * E_lm = A_l * L_lm
  36331. * ```
  36332. *
  36333. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36334. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36335. * the scaling factors are given in equation 9.
  36336. */
  36337. convertIncidentRadianceToIrradiance(): void;
  36338. /**
  36339. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36340. *
  36341. * ```
  36342. * L = (1/pi) * E * rho
  36343. * ```
  36344. *
  36345. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36346. */
  36347. convertIrradianceToLambertianRadiance(): void;
  36348. /**
  36349. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36350. * required operations at run time.
  36351. *
  36352. * This is simply done by scaling back the SH with Ylm constants parameter.
  36353. * The trigonometric part being applied by the shader at run time.
  36354. */
  36355. preScaleForRendering(): void;
  36356. /**
  36357. * Constructs a spherical harmonics from an array.
  36358. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36359. * @returns the spherical harmonics
  36360. */
  36361. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36362. /**
  36363. * Gets the spherical harmonics from polynomial
  36364. * @param polynomial the spherical polynomial
  36365. * @returns the spherical harmonics
  36366. */
  36367. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36368. }
  36369. /**
  36370. * Class representing spherical polynomial coefficients to the 3rd degree
  36371. */
  36372. export class SphericalPolynomial {
  36373. private _harmonics;
  36374. /**
  36375. * The spherical harmonics used to create the polynomials.
  36376. */
  36377. get preScaledHarmonics(): SphericalHarmonics;
  36378. /**
  36379. * The x coefficients of the spherical polynomial
  36380. */
  36381. x: Vector3;
  36382. /**
  36383. * The y coefficients of the spherical polynomial
  36384. */
  36385. y: Vector3;
  36386. /**
  36387. * The z coefficients of the spherical polynomial
  36388. */
  36389. z: Vector3;
  36390. /**
  36391. * The xx coefficients of the spherical polynomial
  36392. */
  36393. xx: Vector3;
  36394. /**
  36395. * The yy coefficients of the spherical polynomial
  36396. */
  36397. yy: Vector3;
  36398. /**
  36399. * The zz coefficients of the spherical polynomial
  36400. */
  36401. zz: Vector3;
  36402. /**
  36403. * The xy coefficients of the spherical polynomial
  36404. */
  36405. xy: Vector3;
  36406. /**
  36407. * The yz coefficients of the spherical polynomial
  36408. */
  36409. yz: Vector3;
  36410. /**
  36411. * The zx coefficients of the spherical polynomial
  36412. */
  36413. zx: Vector3;
  36414. /**
  36415. * Adds an ambient color to the spherical polynomial
  36416. * @param color the color to add
  36417. */
  36418. addAmbient(color: Color3): void;
  36419. /**
  36420. * Scales the spherical polynomial by the given amount
  36421. * @param scale the amount to scale
  36422. */
  36423. scaleInPlace(scale: number): void;
  36424. /**
  36425. * Gets the spherical polynomial from harmonics
  36426. * @param harmonics the spherical harmonics
  36427. * @returns the spherical polynomial
  36428. */
  36429. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36430. /**
  36431. * Constructs a spherical polynomial from an array.
  36432. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36433. * @returns the spherical polynomial
  36434. */
  36435. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36436. }
  36437. }
  36438. declare module "babylonjs/Materials/Textures/internalTexture" {
  36439. import { Observable } from "babylonjs/Misc/observable";
  36440. import { Nullable, int } from "babylonjs/types";
  36441. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36442. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36443. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36444. /**
  36445. * Defines the source of the internal texture
  36446. */
  36447. export enum InternalTextureSource {
  36448. /**
  36449. * The source of the texture data is unknown
  36450. */
  36451. Unknown = 0,
  36452. /**
  36453. * Texture data comes from an URL
  36454. */
  36455. Url = 1,
  36456. /**
  36457. * Texture data is only used for temporary storage
  36458. */
  36459. Temp = 2,
  36460. /**
  36461. * Texture data comes from raw data (ArrayBuffer)
  36462. */
  36463. Raw = 3,
  36464. /**
  36465. * Texture content is dynamic (video or dynamic texture)
  36466. */
  36467. Dynamic = 4,
  36468. /**
  36469. * Texture content is generated by rendering to it
  36470. */
  36471. RenderTarget = 5,
  36472. /**
  36473. * Texture content is part of a multi render target process
  36474. */
  36475. MultiRenderTarget = 6,
  36476. /**
  36477. * Texture data comes from a cube data file
  36478. */
  36479. Cube = 7,
  36480. /**
  36481. * Texture data comes from a raw cube data
  36482. */
  36483. CubeRaw = 8,
  36484. /**
  36485. * Texture data come from a prefiltered cube data file
  36486. */
  36487. CubePrefiltered = 9,
  36488. /**
  36489. * Texture content is raw 3D data
  36490. */
  36491. Raw3D = 10,
  36492. /**
  36493. * Texture content is raw 2D array data
  36494. */
  36495. Raw2DArray = 11,
  36496. /**
  36497. * Texture content is a depth texture
  36498. */
  36499. Depth = 12,
  36500. /**
  36501. * Texture data comes from a raw cube data encoded with RGBD
  36502. */
  36503. CubeRawRGBD = 13
  36504. }
  36505. /**
  36506. * Class used to store data associated with WebGL texture data for the engine
  36507. * This class should not be used directly
  36508. */
  36509. export class InternalTexture {
  36510. /** @hidden */
  36511. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36512. /**
  36513. * Defines if the texture is ready
  36514. */
  36515. isReady: boolean;
  36516. /**
  36517. * Defines if the texture is a cube texture
  36518. */
  36519. isCube: boolean;
  36520. /**
  36521. * Defines if the texture contains 3D data
  36522. */
  36523. is3D: boolean;
  36524. /**
  36525. * Defines if the texture contains 2D array data
  36526. */
  36527. is2DArray: boolean;
  36528. /**
  36529. * Defines if the texture contains multiview data
  36530. */
  36531. isMultiview: boolean;
  36532. /**
  36533. * Gets the URL used to load this texture
  36534. */
  36535. url: string;
  36536. /**
  36537. * Gets the sampling mode of the texture
  36538. */
  36539. samplingMode: number;
  36540. /**
  36541. * Gets a boolean indicating if the texture needs mipmaps generation
  36542. */
  36543. generateMipMaps: boolean;
  36544. /**
  36545. * Gets the number of samples used by the texture (WebGL2+ only)
  36546. */
  36547. samples: number;
  36548. /**
  36549. * Gets the type of the texture (int, float...)
  36550. */
  36551. type: number;
  36552. /**
  36553. * Gets the format of the texture (RGB, RGBA...)
  36554. */
  36555. format: number;
  36556. /**
  36557. * Observable called when the texture is loaded
  36558. */
  36559. onLoadedObservable: Observable<InternalTexture>;
  36560. /**
  36561. * Gets the width of the texture
  36562. */
  36563. width: number;
  36564. /**
  36565. * Gets the height of the texture
  36566. */
  36567. height: number;
  36568. /**
  36569. * Gets the depth of the texture
  36570. */
  36571. depth: number;
  36572. /**
  36573. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36574. */
  36575. baseWidth: number;
  36576. /**
  36577. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36578. */
  36579. baseHeight: number;
  36580. /**
  36581. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36582. */
  36583. baseDepth: number;
  36584. /**
  36585. * Gets a boolean indicating if the texture is inverted on Y axis
  36586. */
  36587. invertY: boolean;
  36588. /** @hidden */
  36589. _invertVScale: boolean;
  36590. /** @hidden */
  36591. _associatedChannel: number;
  36592. /** @hidden */
  36593. _source: InternalTextureSource;
  36594. /** @hidden */
  36595. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36596. /** @hidden */
  36597. _bufferView: Nullable<ArrayBufferView>;
  36598. /** @hidden */
  36599. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36600. /** @hidden */
  36601. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36602. /** @hidden */
  36603. _size: number;
  36604. /** @hidden */
  36605. _extension: string;
  36606. /** @hidden */
  36607. _files: Nullable<string[]>;
  36608. /** @hidden */
  36609. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36610. /** @hidden */
  36611. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36612. /** @hidden */
  36613. _framebuffer: Nullable<WebGLFramebuffer>;
  36614. /** @hidden */
  36615. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36616. /** @hidden */
  36617. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36618. /** @hidden */
  36619. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36620. /** @hidden */
  36621. _attachments: Nullable<number[]>;
  36622. /** @hidden */
  36623. _cachedCoordinatesMode: Nullable<number>;
  36624. /** @hidden */
  36625. _cachedWrapU: Nullable<number>;
  36626. /** @hidden */
  36627. _cachedWrapV: Nullable<number>;
  36628. /** @hidden */
  36629. _cachedWrapR: Nullable<number>;
  36630. /** @hidden */
  36631. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36632. /** @hidden */
  36633. _isDisabled: boolean;
  36634. /** @hidden */
  36635. _compression: Nullable<string>;
  36636. /** @hidden */
  36637. _generateStencilBuffer: boolean;
  36638. /** @hidden */
  36639. _generateDepthBuffer: boolean;
  36640. /** @hidden */
  36641. _comparisonFunction: number;
  36642. /** @hidden */
  36643. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36644. /** @hidden */
  36645. _lodGenerationScale: number;
  36646. /** @hidden */
  36647. _lodGenerationOffset: number;
  36648. /** @hidden */
  36649. _depthStencilTexture: Nullable<InternalTexture>;
  36650. /** @hidden */
  36651. _colorTextureArray: Nullable<WebGLTexture>;
  36652. /** @hidden */
  36653. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36654. /** @hidden */
  36655. _lodTextureHigh: Nullable<BaseTexture>;
  36656. /** @hidden */
  36657. _lodTextureMid: Nullable<BaseTexture>;
  36658. /** @hidden */
  36659. _lodTextureLow: Nullable<BaseTexture>;
  36660. /** @hidden */
  36661. _isRGBD: boolean;
  36662. /** @hidden */
  36663. _linearSpecularLOD: boolean;
  36664. /** @hidden */
  36665. _irradianceTexture: Nullable<BaseTexture>;
  36666. /** @hidden */
  36667. _webGLTexture: Nullable<WebGLTexture>;
  36668. /** @hidden */
  36669. _references: number;
  36670. private _engine;
  36671. /**
  36672. * Gets the Engine the texture belongs to.
  36673. * @returns The babylon engine
  36674. */
  36675. getEngine(): ThinEngine;
  36676. /**
  36677. * Gets the data source type of the texture
  36678. */
  36679. get source(): InternalTextureSource;
  36680. /**
  36681. * Creates a new InternalTexture
  36682. * @param engine defines the engine to use
  36683. * @param source defines the type of data that will be used
  36684. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36685. */
  36686. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36687. /**
  36688. * Increments the number of references (ie. the number of Texture that point to it)
  36689. */
  36690. incrementReferences(): void;
  36691. /**
  36692. * Change the size of the texture (not the size of the content)
  36693. * @param width defines the new width
  36694. * @param height defines the new height
  36695. * @param depth defines the new depth (1 by default)
  36696. */
  36697. updateSize(width: int, height: int, depth?: int): void;
  36698. /** @hidden */
  36699. _rebuild(): void;
  36700. /** @hidden */
  36701. _swapAndDie(target: InternalTexture): void;
  36702. /**
  36703. * Dispose the current allocated resources
  36704. */
  36705. dispose(): void;
  36706. }
  36707. }
  36708. declare module "babylonjs/Audio/analyser" {
  36709. import { Scene } from "babylonjs/scene";
  36710. /**
  36711. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36713. */
  36714. export class Analyser {
  36715. /**
  36716. * Gets or sets the smoothing
  36717. * @ignorenaming
  36718. */
  36719. SMOOTHING: number;
  36720. /**
  36721. * Gets or sets the FFT table size
  36722. * @ignorenaming
  36723. */
  36724. FFT_SIZE: number;
  36725. /**
  36726. * Gets or sets the bar graph amplitude
  36727. * @ignorenaming
  36728. */
  36729. BARGRAPHAMPLITUDE: number;
  36730. /**
  36731. * Gets or sets the position of the debug canvas
  36732. * @ignorenaming
  36733. */
  36734. DEBUGCANVASPOS: {
  36735. x: number;
  36736. y: number;
  36737. };
  36738. /**
  36739. * Gets or sets the debug canvas size
  36740. * @ignorenaming
  36741. */
  36742. DEBUGCANVASSIZE: {
  36743. width: number;
  36744. height: number;
  36745. };
  36746. private _byteFreqs;
  36747. private _byteTime;
  36748. private _floatFreqs;
  36749. private _webAudioAnalyser;
  36750. private _debugCanvas;
  36751. private _debugCanvasContext;
  36752. private _scene;
  36753. private _registerFunc;
  36754. private _audioEngine;
  36755. /**
  36756. * Creates a new analyser
  36757. * @param scene defines hosting scene
  36758. */
  36759. constructor(scene: Scene);
  36760. /**
  36761. * Get the number of data values you will have to play with for the visualization
  36762. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36763. * @returns a number
  36764. */
  36765. getFrequencyBinCount(): number;
  36766. /**
  36767. * Gets the current frequency data as a byte array
  36768. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36769. * @returns a Uint8Array
  36770. */
  36771. getByteFrequencyData(): Uint8Array;
  36772. /**
  36773. * Gets the current waveform as a byte array
  36774. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36775. * @returns a Uint8Array
  36776. */
  36777. getByteTimeDomainData(): Uint8Array;
  36778. /**
  36779. * Gets the current frequency data as a float array
  36780. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36781. * @returns a Float32Array
  36782. */
  36783. getFloatFrequencyData(): Float32Array;
  36784. /**
  36785. * Renders the debug canvas
  36786. */
  36787. drawDebugCanvas(): void;
  36788. /**
  36789. * Stops rendering the debug canvas and removes it
  36790. */
  36791. stopDebugCanvas(): void;
  36792. /**
  36793. * Connects two audio nodes
  36794. * @param inputAudioNode defines first node to connect
  36795. * @param outputAudioNode defines second node to connect
  36796. */
  36797. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36798. /**
  36799. * Releases all associated resources
  36800. */
  36801. dispose(): void;
  36802. }
  36803. }
  36804. declare module "babylonjs/Audio/audioEngine" {
  36805. import { IDisposable } from "babylonjs/scene";
  36806. import { Analyser } from "babylonjs/Audio/analyser";
  36807. import { Nullable } from "babylonjs/types";
  36808. import { Observable } from "babylonjs/Misc/observable";
  36809. /**
  36810. * This represents an audio engine and it is responsible
  36811. * to play, synchronize and analyse sounds throughout the application.
  36812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36813. */
  36814. export interface IAudioEngine extends IDisposable {
  36815. /**
  36816. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36817. */
  36818. readonly canUseWebAudio: boolean;
  36819. /**
  36820. * Gets the current AudioContext if available.
  36821. */
  36822. readonly audioContext: Nullable<AudioContext>;
  36823. /**
  36824. * The master gain node defines the global audio volume of your audio engine.
  36825. */
  36826. readonly masterGain: GainNode;
  36827. /**
  36828. * Gets whether or not mp3 are supported by your browser.
  36829. */
  36830. readonly isMP3supported: boolean;
  36831. /**
  36832. * Gets whether or not ogg are supported by your browser.
  36833. */
  36834. readonly isOGGsupported: boolean;
  36835. /**
  36836. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36837. * @ignoreNaming
  36838. */
  36839. WarnedWebAudioUnsupported: boolean;
  36840. /**
  36841. * Defines if the audio engine relies on a custom unlocked button.
  36842. * In this case, the embedded button will not be displayed.
  36843. */
  36844. useCustomUnlockedButton: boolean;
  36845. /**
  36846. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36847. */
  36848. readonly unlocked: boolean;
  36849. /**
  36850. * Event raised when audio has been unlocked on the browser.
  36851. */
  36852. onAudioUnlockedObservable: Observable<AudioEngine>;
  36853. /**
  36854. * Event raised when audio has been locked on the browser.
  36855. */
  36856. onAudioLockedObservable: Observable<AudioEngine>;
  36857. /**
  36858. * Flags the audio engine in Locked state.
  36859. * This happens due to new browser policies preventing audio to autoplay.
  36860. */
  36861. lock(): void;
  36862. /**
  36863. * Unlocks the audio engine once a user action has been done on the dom.
  36864. * This is helpful to resume play once browser policies have been satisfied.
  36865. */
  36866. unlock(): void;
  36867. /**
  36868. * Gets the global volume sets on the master gain.
  36869. * @returns the global volume if set or -1 otherwise
  36870. */
  36871. getGlobalVolume(): number;
  36872. /**
  36873. * Sets the global volume of your experience (sets on the master gain).
  36874. * @param newVolume Defines the new global volume of the application
  36875. */
  36876. setGlobalVolume(newVolume: number): void;
  36877. /**
  36878. * Connect the audio engine to an audio analyser allowing some amazing
  36879. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36881. * @param analyser The analyser to connect to the engine
  36882. */
  36883. connectToAnalyser(analyser: Analyser): void;
  36884. }
  36885. /**
  36886. * This represents the default audio engine used in babylon.
  36887. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36889. */
  36890. export class AudioEngine implements IAudioEngine {
  36891. private _audioContext;
  36892. private _audioContextInitialized;
  36893. private _muteButton;
  36894. private _hostElement;
  36895. /**
  36896. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36897. */
  36898. canUseWebAudio: boolean;
  36899. /**
  36900. * The master gain node defines the global audio volume of your audio engine.
  36901. */
  36902. masterGain: GainNode;
  36903. /**
  36904. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36905. * @ignoreNaming
  36906. */
  36907. WarnedWebAudioUnsupported: boolean;
  36908. /**
  36909. * Gets whether or not mp3 are supported by your browser.
  36910. */
  36911. isMP3supported: boolean;
  36912. /**
  36913. * Gets whether or not ogg are supported by your browser.
  36914. */
  36915. isOGGsupported: boolean;
  36916. /**
  36917. * Gets whether audio has been unlocked on the device.
  36918. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36919. * a user interaction has happened.
  36920. */
  36921. unlocked: boolean;
  36922. /**
  36923. * Defines if the audio engine relies on a custom unlocked button.
  36924. * In this case, the embedded button will not be displayed.
  36925. */
  36926. useCustomUnlockedButton: boolean;
  36927. /**
  36928. * Event raised when audio has been unlocked on the browser.
  36929. */
  36930. onAudioUnlockedObservable: Observable<AudioEngine>;
  36931. /**
  36932. * Event raised when audio has been locked on the browser.
  36933. */
  36934. onAudioLockedObservable: Observable<AudioEngine>;
  36935. /**
  36936. * Gets the current AudioContext if available.
  36937. */
  36938. get audioContext(): Nullable<AudioContext>;
  36939. private _connectedAnalyser;
  36940. /**
  36941. * Instantiates a new audio engine.
  36942. *
  36943. * There should be only one per page as some browsers restrict the number
  36944. * of audio contexts you can create.
  36945. * @param hostElement defines the host element where to display the mute icon if necessary
  36946. */
  36947. constructor(hostElement?: Nullable<HTMLElement>);
  36948. /**
  36949. * Flags the audio engine in Locked state.
  36950. * This happens due to new browser policies preventing audio to autoplay.
  36951. */
  36952. lock(): void;
  36953. /**
  36954. * Unlocks the audio engine once a user action has been done on the dom.
  36955. * This is helpful to resume play once browser policies have been satisfied.
  36956. */
  36957. unlock(): void;
  36958. private _resumeAudioContext;
  36959. private _initializeAudioContext;
  36960. private _tryToRun;
  36961. private _triggerRunningState;
  36962. private _triggerSuspendedState;
  36963. private _displayMuteButton;
  36964. private _moveButtonToTopLeft;
  36965. private _onResize;
  36966. private _hideMuteButton;
  36967. /**
  36968. * Destroy and release the resources associated with the audio ccontext.
  36969. */
  36970. dispose(): void;
  36971. /**
  36972. * Gets the global volume sets on the master gain.
  36973. * @returns the global volume if set or -1 otherwise
  36974. */
  36975. getGlobalVolume(): number;
  36976. /**
  36977. * Sets the global volume of your experience (sets on the master gain).
  36978. * @param newVolume Defines the new global volume of the application
  36979. */
  36980. setGlobalVolume(newVolume: number): void;
  36981. /**
  36982. * Connect the audio engine to an audio analyser allowing some amazing
  36983. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36985. * @param analyser The analyser to connect to the engine
  36986. */
  36987. connectToAnalyser(analyser: Analyser): void;
  36988. }
  36989. }
  36990. declare module "babylonjs/Loading/loadingScreen" {
  36991. /**
  36992. * Interface used to present a loading screen while loading a scene
  36993. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36994. */
  36995. export interface ILoadingScreen {
  36996. /**
  36997. * Function called to display the loading screen
  36998. */
  36999. displayLoadingUI: () => void;
  37000. /**
  37001. * Function called to hide the loading screen
  37002. */
  37003. hideLoadingUI: () => void;
  37004. /**
  37005. * Gets or sets the color to use for the background
  37006. */
  37007. loadingUIBackgroundColor: string;
  37008. /**
  37009. * Gets or sets the text to display while loading
  37010. */
  37011. loadingUIText: string;
  37012. }
  37013. /**
  37014. * Class used for the default loading screen
  37015. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37016. */
  37017. export class DefaultLoadingScreen implements ILoadingScreen {
  37018. private _renderingCanvas;
  37019. private _loadingText;
  37020. private _loadingDivBackgroundColor;
  37021. private _loadingDiv;
  37022. private _loadingTextDiv;
  37023. /** Gets or sets the logo url to use for the default loading screen */
  37024. static DefaultLogoUrl: string;
  37025. /** Gets or sets the spinner url to use for the default loading screen */
  37026. static DefaultSpinnerUrl: string;
  37027. /**
  37028. * Creates a new default loading screen
  37029. * @param _renderingCanvas defines the canvas used to render the scene
  37030. * @param _loadingText defines the default text to display
  37031. * @param _loadingDivBackgroundColor defines the default background color
  37032. */
  37033. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37034. /**
  37035. * Function called to display the loading screen
  37036. */
  37037. displayLoadingUI(): void;
  37038. /**
  37039. * Function called to hide the loading screen
  37040. */
  37041. hideLoadingUI(): void;
  37042. /**
  37043. * Gets or sets the text to display while loading
  37044. */
  37045. set loadingUIText(text: string);
  37046. get loadingUIText(): string;
  37047. /**
  37048. * Gets or sets the color to use for the background
  37049. */
  37050. get loadingUIBackgroundColor(): string;
  37051. set loadingUIBackgroundColor(color: string);
  37052. private _resizeLoadingUI;
  37053. }
  37054. }
  37055. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37056. /**
  37057. * Interface for any object that can request an animation frame
  37058. */
  37059. export interface ICustomAnimationFrameRequester {
  37060. /**
  37061. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37062. */
  37063. renderFunction?: Function;
  37064. /**
  37065. * Called to request the next frame to render to
  37066. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37067. */
  37068. requestAnimationFrame: Function;
  37069. /**
  37070. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37071. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37072. */
  37073. requestID?: number;
  37074. }
  37075. }
  37076. declare module "babylonjs/Misc/performanceMonitor" {
  37077. /**
  37078. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37079. */
  37080. export class PerformanceMonitor {
  37081. private _enabled;
  37082. private _rollingFrameTime;
  37083. private _lastFrameTimeMs;
  37084. /**
  37085. * constructor
  37086. * @param frameSampleSize The number of samples required to saturate the sliding window
  37087. */
  37088. constructor(frameSampleSize?: number);
  37089. /**
  37090. * Samples current frame
  37091. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37092. */
  37093. sampleFrame(timeMs?: number): void;
  37094. /**
  37095. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37096. */
  37097. get averageFrameTime(): number;
  37098. /**
  37099. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37100. */
  37101. get averageFrameTimeVariance(): number;
  37102. /**
  37103. * Returns the frame time of the most recent frame
  37104. */
  37105. get instantaneousFrameTime(): number;
  37106. /**
  37107. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37108. */
  37109. get averageFPS(): number;
  37110. /**
  37111. * Returns the average framerate in frames per second using the most recent frame time
  37112. */
  37113. get instantaneousFPS(): number;
  37114. /**
  37115. * Returns true if enough samples have been taken to completely fill the sliding window
  37116. */
  37117. get isSaturated(): boolean;
  37118. /**
  37119. * Enables contributions to the sliding window sample set
  37120. */
  37121. enable(): void;
  37122. /**
  37123. * Disables contributions to the sliding window sample set
  37124. * Samples will not be interpolated over the disabled period
  37125. */
  37126. disable(): void;
  37127. /**
  37128. * Returns true if sampling is enabled
  37129. */
  37130. get isEnabled(): boolean;
  37131. /**
  37132. * Resets performance monitor
  37133. */
  37134. reset(): void;
  37135. }
  37136. /**
  37137. * RollingAverage
  37138. *
  37139. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37140. */
  37141. export class RollingAverage {
  37142. /**
  37143. * Current average
  37144. */
  37145. average: number;
  37146. /**
  37147. * Current variance
  37148. */
  37149. variance: number;
  37150. protected _samples: Array<number>;
  37151. protected _sampleCount: number;
  37152. protected _pos: number;
  37153. protected _m2: number;
  37154. /**
  37155. * constructor
  37156. * @param length The number of samples required to saturate the sliding window
  37157. */
  37158. constructor(length: number);
  37159. /**
  37160. * Adds a sample to the sample set
  37161. * @param v The sample value
  37162. */
  37163. add(v: number): void;
  37164. /**
  37165. * Returns previously added values or null if outside of history or outside the sliding window domain
  37166. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37167. * @return Value previously recorded with add() or null if outside of range
  37168. */
  37169. history(i: number): number;
  37170. /**
  37171. * Returns true if enough samples have been taken to completely fill the sliding window
  37172. * @return true if sample-set saturated
  37173. */
  37174. isSaturated(): boolean;
  37175. /**
  37176. * Resets the rolling average (equivalent to 0 samples taken so far)
  37177. */
  37178. reset(): void;
  37179. /**
  37180. * Wraps a value around the sample range boundaries
  37181. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37182. * @return Wrapped position in sample range
  37183. */
  37184. protected _wrapPosition(i: number): number;
  37185. }
  37186. }
  37187. declare module "babylonjs/Misc/perfCounter" {
  37188. /**
  37189. * This class is used to track a performance counter which is number based.
  37190. * The user has access to many properties which give statistics of different nature.
  37191. *
  37192. * The implementer can track two kinds of Performance Counter: time and count.
  37193. * 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.
  37194. * 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.
  37195. */
  37196. export class PerfCounter {
  37197. /**
  37198. * Gets or sets a global boolean to turn on and off all the counters
  37199. */
  37200. static Enabled: boolean;
  37201. /**
  37202. * Returns the smallest value ever
  37203. */
  37204. get min(): number;
  37205. /**
  37206. * Returns the biggest value ever
  37207. */
  37208. get max(): number;
  37209. /**
  37210. * Returns the average value since the performance counter is running
  37211. */
  37212. get average(): number;
  37213. /**
  37214. * Returns the average value of the last second the counter was monitored
  37215. */
  37216. get lastSecAverage(): number;
  37217. /**
  37218. * Returns the current value
  37219. */
  37220. get current(): number;
  37221. /**
  37222. * Gets the accumulated total
  37223. */
  37224. get total(): number;
  37225. /**
  37226. * Gets the total value count
  37227. */
  37228. get count(): number;
  37229. /**
  37230. * Creates a new counter
  37231. */
  37232. constructor();
  37233. /**
  37234. * Call this method to start monitoring a new frame.
  37235. * 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.
  37236. */
  37237. fetchNewFrame(): void;
  37238. /**
  37239. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37240. * @param newCount the count value to add to the monitored count
  37241. * @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.
  37242. */
  37243. addCount(newCount: number, fetchResult: boolean): void;
  37244. /**
  37245. * Start monitoring this performance counter
  37246. */
  37247. beginMonitoring(): void;
  37248. /**
  37249. * Compute the time lapsed since the previous beginMonitoring() call.
  37250. * @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
  37251. */
  37252. endMonitoring(newFrame?: boolean): void;
  37253. private _fetchResult;
  37254. private _startMonitoringTime;
  37255. private _min;
  37256. private _max;
  37257. private _average;
  37258. private _current;
  37259. private _totalValueCount;
  37260. private _totalAccumulated;
  37261. private _lastSecAverage;
  37262. private _lastSecAccumulated;
  37263. private _lastSecTime;
  37264. private _lastSecValueCount;
  37265. }
  37266. }
  37267. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37268. module "babylonjs/Engines/thinEngine" {
  37269. interface ThinEngine {
  37270. /**
  37271. * Sets alpha constants used by some alpha blending modes
  37272. * @param r defines the red component
  37273. * @param g defines the green component
  37274. * @param b defines the blue component
  37275. * @param a defines the alpha component
  37276. */
  37277. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37278. /**
  37279. * Sets the current alpha mode
  37280. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37281. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37282. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37283. */
  37284. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37285. /**
  37286. * Gets the current alpha mode
  37287. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37288. * @returns the current alpha mode
  37289. */
  37290. getAlphaMode(): number;
  37291. /**
  37292. * Sets the current alpha equation
  37293. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37294. */
  37295. setAlphaEquation(equation: number): void;
  37296. /**
  37297. * Gets the current alpha equation.
  37298. * @returns the current alpha equation
  37299. */
  37300. getAlphaEquation(): number;
  37301. }
  37302. }
  37303. }
  37304. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37305. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37306. import { Nullable } from "babylonjs/types";
  37307. module "babylonjs/Engines/thinEngine" {
  37308. interface ThinEngine {
  37309. /** @hidden */
  37310. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37311. }
  37312. }
  37313. }
  37314. declare module "babylonjs/Engines/engine" {
  37315. import { Observable } from "babylonjs/Misc/observable";
  37316. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37317. import { Scene } from "babylonjs/scene";
  37318. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37319. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37320. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37321. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37322. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37323. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37324. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37325. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37326. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37328. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37329. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37330. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37331. import "babylonjs/Engines/Extensions/engine.alpha";
  37332. import "babylonjs/Engines/Extensions/engine.readTexture";
  37333. import { Material } from "babylonjs/Materials/material";
  37334. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37335. /**
  37336. * Defines the interface used by display changed events
  37337. */
  37338. export interface IDisplayChangedEventArgs {
  37339. /** Gets the vrDisplay object (if any) */
  37340. vrDisplay: Nullable<any>;
  37341. /** Gets a boolean indicating if webVR is supported */
  37342. vrSupported: boolean;
  37343. }
  37344. /**
  37345. * Defines the interface used by objects containing a viewport (like a camera)
  37346. */
  37347. interface IViewportOwnerLike {
  37348. /**
  37349. * Gets or sets the viewport
  37350. */
  37351. viewport: IViewportLike;
  37352. }
  37353. /**
  37354. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37355. */
  37356. export class Engine extends ThinEngine {
  37357. /** Defines that alpha blending is disabled */
  37358. static readonly ALPHA_DISABLE: number;
  37359. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37360. static readonly ALPHA_ADD: number;
  37361. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37362. static readonly ALPHA_COMBINE: number;
  37363. /** Defines that alpha blending to DEST - SRC * DEST */
  37364. static readonly ALPHA_SUBTRACT: number;
  37365. /** Defines that alpha blending to SRC * DEST */
  37366. static readonly ALPHA_MULTIPLY: number;
  37367. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37368. static readonly ALPHA_MAXIMIZED: number;
  37369. /** Defines that alpha blending to SRC + DEST */
  37370. static readonly ALPHA_ONEONE: number;
  37371. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37372. static readonly ALPHA_PREMULTIPLIED: number;
  37373. /**
  37374. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37375. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37376. */
  37377. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37378. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37379. static readonly ALPHA_INTERPOLATE: number;
  37380. /**
  37381. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37382. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37383. */
  37384. static readonly ALPHA_SCREENMODE: number;
  37385. /** Defines that the ressource is not delayed*/
  37386. static readonly DELAYLOADSTATE_NONE: number;
  37387. /** Defines that the ressource was successfully delay loaded */
  37388. static readonly DELAYLOADSTATE_LOADED: number;
  37389. /** Defines that the ressource is currently delay loading */
  37390. static readonly DELAYLOADSTATE_LOADING: number;
  37391. /** Defines that the ressource is delayed and has not started loading */
  37392. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37393. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37394. static readonly NEVER: number;
  37395. /** 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 */
  37396. static readonly ALWAYS: number;
  37397. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37398. static readonly LESS: number;
  37399. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37400. static readonly EQUAL: number;
  37401. /** 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 */
  37402. static readonly LEQUAL: number;
  37403. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37404. static readonly GREATER: number;
  37405. /** 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 */
  37406. static readonly GEQUAL: number;
  37407. /** 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 */
  37408. static readonly NOTEQUAL: number;
  37409. /** Passed to stencilOperation to specify that stencil value must be kept */
  37410. static readonly KEEP: number;
  37411. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37412. static readonly REPLACE: number;
  37413. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37414. static readonly INCR: number;
  37415. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37416. static readonly DECR: number;
  37417. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37418. static readonly INVERT: number;
  37419. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37420. static readonly INCR_WRAP: number;
  37421. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37422. static readonly DECR_WRAP: number;
  37423. /** Texture is not repeating outside of 0..1 UVs */
  37424. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37425. /** Texture is repeating outside of 0..1 UVs */
  37426. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37427. /** Texture is repeating and mirrored */
  37428. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37429. /** ALPHA */
  37430. static readonly TEXTUREFORMAT_ALPHA: number;
  37431. /** LUMINANCE */
  37432. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37433. /** LUMINANCE_ALPHA */
  37434. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37435. /** RGB */
  37436. static readonly TEXTUREFORMAT_RGB: number;
  37437. /** RGBA */
  37438. static readonly TEXTUREFORMAT_RGBA: number;
  37439. /** RED */
  37440. static readonly TEXTUREFORMAT_RED: number;
  37441. /** RED (2nd reference) */
  37442. static readonly TEXTUREFORMAT_R: number;
  37443. /** RG */
  37444. static readonly TEXTUREFORMAT_RG: number;
  37445. /** RED_INTEGER */
  37446. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37447. /** RED_INTEGER (2nd reference) */
  37448. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37449. /** RG_INTEGER */
  37450. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37451. /** RGB_INTEGER */
  37452. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37453. /** RGBA_INTEGER */
  37454. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37455. /** UNSIGNED_BYTE */
  37456. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37457. /** UNSIGNED_BYTE (2nd reference) */
  37458. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37459. /** FLOAT */
  37460. static readonly TEXTURETYPE_FLOAT: number;
  37461. /** HALF_FLOAT */
  37462. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37463. /** BYTE */
  37464. static readonly TEXTURETYPE_BYTE: number;
  37465. /** SHORT */
  37466. static readonly TEXTURETYPE_SHORT: number;
  37467. /** UNSIGNED_SHORT */
  37468. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37469. /** INT */
  37470. static readonly TEXTURETYPE_INT: number;
  37471. /** UNSIGNED_INT */
  37472. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37473. /** UNSIGNED_SHORT_4_4_4_4 */
  37474. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37475. /** UNSIGNED_SHORT_5_5_5_1 */
  37476. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37477. /** UNSIGNED_SHORT_5_6_5 */
  37478. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37479. /** UNSIGNED_INT_2_10_10_10_REV */
  37480. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37481. /** UNSIGNED_INT_24_8 */
  37482. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37483. /** UNSIGNED_INT_10F_11F_11F_REV */
  37484. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37485. /** UNSIGNED_INT_5_9_9_9_REV */
  37486. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37487. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37488. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37489. /** nearest is mag = nearest and min = nearest and mip = linear */
  37490. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37491. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37492. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37493. /** Trilinear is mag = linear and min = linear and mip = linear */
  37494. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37495. /** nearest is mag = nearest and min = nearest and mip = linear */
  37496. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37497. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37498. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37499. /** Trilinear is mag = linear and min = linear and mip = linear */
  37500. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37501. /** mag = nearest and min = nearest and mip = nearest */
  37502. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37503. /** mag = nearest and min = linear and mip = nearest */
  37504. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37505. /** mag = nearest and min = linear and mip = linear */
  37506. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37507. /** mag = nearest and min = linear and mip = none */
  37508. static readonly TEXTURE_NEAREST_LINEAR: number;
  37509. /** mag = nearest and min = nearest and mip = none */
  37510. static readonly TEXTURE_NEAREST_NEAREST: number;
  37511. /** mag = linear and min = nearest and mip = nearest */
  37512. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37513. /** mag = linear and min = nearest and mip = linear */
  37514. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37515. /** mag = linear and min = linear and mip = none */
  37516. static readonly TEXTURE_LINEAR_LINEAR: number;
  37517. /** mag = linear and min = nearest and mip = none */
  37518. static readonly TEXTURE_LINEAR_NEAREST: number;
  37519. /** Explicit coordinates mode */
  37520. static readonly TEXTURE_EXPLICIT_MODE: number;
  37521. /** Spherical coordinates mode */
  37522. static readonly TEXTURE_SPHERICAL_MODE: number;
  37523. /** Planar coordinates mode */
  37524. static readonly TEXTURE_PLANAR_MODE: number;
  37525. /** Cubic coordinates mode */
  37526. static readonly TEXTURE_CUBIC_MODE: number;
  37527. /** Projection coordinates mode */
  37528. static readonly TEXTURE_PROJECTION_MODE: number;
  37529. /** Skybox coordinates mode */
  37530. static readonly TEXTURE_SKYBOX_MODE: number;
  37531. /** Inverse Cubic coordinates mode */
  37532. static readonly TEXTURE_INVCUBIC_MODE: number;
  37533. /** Equirectangular coordinates mode */
  37534. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37535. /** Equirectangular Fixed coordinates mode */
  37536. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37537. /** Equirectangular Fixed Mirrored coordinates mode */
  37538. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37539. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37540. static readonly SCALEMODE_FLOOR: number;
  37541. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37542. static readonly SCALEMODE_NEAREST: number;
  37543. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37544. static readonly SCALEMODE_CEILING: number;
  37545. /**
  37546. * Returns the current npm package of the sdk
  37547. */
  37548. static get NpmPackage(): string;
  37549. /**
  37550. * Returns the current version of the framework
  37551. */
  37552. static get Version(): string;
  37553. /** Gets the list of created engines */
  37554. static get Instances(): Engine[];
  37555. /**
  37556. * Gets the latest created engine
  37557. */
  37558. static get LastCreatedEngine(): Nullable<Engine>;
  37559. /**
  37560. * Gets the latest created scene
  37561. */
  37562. static get LastCreatedScene(): Nullable<Scene>;
  37563. /**
  37564. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37565. * @param flag defines which part of the materials must be marked as dirty
  37566. * @param predicate defines a predicate used to filter which materials should be affected
  37567. */
  37568. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37569. /**
  37570. * Method called to create the default loading screen.
  37571. * This can be overriden in your own app.
  37572. * @param canvas The rendering canvas element
  37573. * @returns The loading screen
  37574. */
  37575. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37576. /**
  37577. * Method called to create the default rescale post process on each engine.
  37578. */
  37579. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37580. /**
  37581. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37582. **/
  37583. enableOfflineSupport: boolean;
  37584. /**
  37585. * 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)
  37586. **/
  37587. disableManifestCheck: boolean;
  37588. /**
  37589. * Gets the list of created scenes
  37590. */
  37591. scenes: Scene[];
  37592. /**
  37593. * Event raised when a new scene is created
  37594. */
  37595. onNewSceneAddedObservable: Observable<Scene>;
  37596. /**
  37597. * Gets the list of created postprocesses
  37598. */
  37599. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37600. /**
  37601. * Gets a boolean indicating if the pointer is currently locked
  37602. */
  37603. isPointerLock: boolean;
  37604. /**
  37605. * Observable event triggered each time the rendering canvas is resized
  37606. */
  37607. onResizeObservable: Observable<Engine>;
  37608. /**
  37609. * Observable event triggered each time the canvas loses focus
  37610. */
  37611. onCanvasBlurObservable: Observable<Engine>;
  37612. /**
  37613. * Observable event triggered each time the canvas gains focus
  37614. */
  37615. onCanvasFocusObservable: Observable<Engine>;
  37616. /**
  37617. * Observable event triggered each time the canvas receives pointerout event
  37618. */
  37619. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37620. /**
  37621. * Observable raised when the engine begins a new frame
  37622. */
  37623. onBeginFrameObservable: Observable<Engine>;
  37624. /**
  37625. * If set, will be used to request the next animation frame for the render loop
  37626. */
  37627. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37628. /**
  37629. * Observable raised when the engine ends the current frame
  37630. */
  37631. onEndFrameObservable: Observable<Engine>;
  37632. /**
  37633. * Observable raised when the engine is about to compile a shader
  37634. */
  37635. onBeforeShaderCompilationObservable: Observable<Engine>;
  37636. /**
  37637. * Observable raised when the engine has jsut compiled a shader
  37638. */
  37639. onAfterShaderCompilationObservable: Observable<Engine>;
  37640. /**
  37641. * Gets the audio engine
  37642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37643. * @ignorenaming
  37644. */
  37645. static audioEngine: IAudioEngine;
  37646. /**
  37647. * Default AudioEngine factory responsible of creating the Audio Engine.
  37648. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37649. */
  37650. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37651. /**
  37652. * Default offline support factory responsible of creating a tool used to store data locally.
  37653. * By default, this will create a Database object if the workload has been embedded.
  37654. */
  37655. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37656. private _loadingScreen;
  37657. private _pointerLockRequested;
  37658. private _rescalePostProcess;
  37659. private _deterministicLockstep;
  37660. private _lockstepMaxSteps;
  37661. private _timeStep;
  37662. protected get _supportsHardwareTextureRescaling(): boolean;
  37663. private _fps;
  37664. private _deltaTime;
  37665. /** @hidden */
  37666. _drawCalls: PerfCounter;
  37667. /** 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 */
  37668. canvasTabIndex: number;
  37669. /**
  37670. * Turn this value on if you want to pause FPS computation when in background
  37671. */
  37672. disablePerformanceMonitorInBackground: boolean;
  37673. private _performanceMonitor;
  37674. /**
  37675. * Gets the performance monitor attached to this engine
  37676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37677. */
  37678. get performanceMonitor(): PerformanceMonitor;
  37679. private _onFocus;
  37680. private _onBlur;
  37681. private _onCanvasPointerOut;
  37682. private _onCanvasBlur;
  37683. private _onCanvasFocus;
  37684. private _onFullscreenChange;
  37685. private _onPointerLockChange;
  37686. /**
  37687. * Gets the HTML element used to attach event listeners
  37688. * @returns a HTML element
  37689. */
  37690. getInputElement(): Nullable<HTMLElement>;
  37691. /**
  37692. * Creates a new engine
  37693. * @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
  37694. * @param antialias defines enable antialiasing (default: false)
  37695. * @param options defines further options to be sent to the getContext() function
  37696. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37697. */
  37698. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37699. /**
  37700. * Gets current aspect ratio
  37701. * @param viewportOwner defines the camera to use to get the aspect ratio
  37702. * @param useScreen defines if screen size must be used (or the current render target if any)
  37703. * @returns a number defining the aspect ratio
  37704. */
  37705. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37706. /**
  37707. * Gets current screen aspect ratio
  37708. * @returns a number defining the aspect ratio
  37709. */
  37710. getScreenAspectRatio(): number;
  37711. /**
  37712. * Gets the client rect of the HTML canvas attached with the current webGL context
  37713. * @returns a client rectanglee
  37714. */
  37715. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37716. /**
  37717. * Gets the client rect of the HTML element used for events
  37718. * @returns a client rectanglee
  37719. */
  37720. getInputElementClientRect(): Nullable<ClientRect>;
  37721. /**
  37722. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37723. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37724. * @returns true if engine is in deterministic lock step mode
  37725. */
  37726. isDeterministicLockStep(): boolean;
  37727. /**
  37728. * Gets the max steps when engine is running in deterministic lock step
  37729. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37730. * @returns the max steps
  37731. */
  37732. getLockstepMaxSteps(): number;
  37733. /**
  37734. * Returns the time in ms between steps when using deterministic lock step.
  37735. * @returns time step in (ms)
  37736. */
  37737. getTimeStep(): number;
  37738. /**
  37739. * Force the mipmap generation for the given render target texture
  37740. * @param texture defines the render target texture to use
  37741. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37742. */
  37743. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37744. /** States */
  37745. /**
  37746. * Set various states to the webGL context
  37747. * @param culling defines backface culling state
  37748. * @param zOffset defines the value to apply to zOffset (0 by default)
  37749. * @param force defines if states must be applied even if cache is up to date
  37750. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37751. */
  37752. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37753. /**
  37754. * Set the z offset to apply to current rendering
  37755. * @param value defines the offset to apply
  37756. */
  37757. setZOffset(value: number): void;
  37758. /**
  37759. * Gets the current value of the zOffset
  37760. * @returns the current zOffset state
  37761. */
  37762. getZOffset(): number;
  37763. /**
  37764. * Enable or disable depth buffering
  37765. * @param enable defines the state to set
  37766. */
  37767. setDepthBuffer(enable: boolean): void;
  37768. /**
  37769. * Gets a boolean indicating if depth writing is enabled
  37770. * @returns the current depth writing state
  37771. */
  37772. getDepthWrite(): boolean;
  37773. /**
  37774. * Enable or disable depth writing
  37775. * @param enable defines the state to set
  37776. */
  37777. setDepthWrite(enable: boolean): void;
  37778. /**
  37779. * Gets a boolean indicating if stencil buffer is enabled
  37780. * @returns the current stencil buffer state
  37781. */
  37782. getStencilBuffer(): boolean;
  37783. /**
  37784. * Enable or disable the stencil buffer
  37785. * @param enable defines if the stencil buffer must be enabled or disabled
  37786. */
  37787. setStencilBuffer(enable: boolean): void;
  37788. /**
  37789. * Gets the current stencil mask
  37790. * @returns a number defining the new stencil mask to use
  37791. */
  37792. getStencilMask(): number;
  37793. /**
  37794. * Sets the current stencil mask
  37795. * @param mask defines the new stencil mask to use
  37796. */
  37797. setStencilMask(mask: number): void;
  37798. /**
  37799. * Gets the current stencil function
  37800. * @returns a number defining the stencil function to use
  37801. */
  37802. getStencilFunction(): number;
  37803. /**
  37804. * Gets the current stencil reference value
  37805. * @returns a number defining the stencil reference value to use
  37806. */
  37807. getStencilFunctionReference(): number;
  37808. /**
  37809. * Gets the current stencil mask
  37810. * @returns a number defining the stencil mask to use
  37811. */
  37812. getStencilFunctionMask(): number;
  37813. /**
  37814. * Sets the current stencil function
  37815. * @param stencilFunc defines the new stencil function to use
  37816. */
  37817. setStencilFunction(stencilFunc: number): void;
  37818. /**
  37819. * Sets the current stencil reference
  37820. * @param reference defines the new stencil reference to use
  37821. */
  37822. setStencilFunctionReference(reference: number): void;
  37823. /**
  37824. * Sets the current stencil mask
  37825. * @param mask defines the new stencil mask to use
  37826. */
  37827. setStencilFunctionMask(mask: number): void;
  37828. /**
  37829. * Gets the current stencil operation when stencil fails
  37830. * @returns a number defining stencil operation to use when stencil fails
  37831. */
  37832. getStencilOperationFail(): number;
  37833. /**
  37834. * Gets the current stencil operation when depth fails
  37835. * @returns a number defining stencil operation to use when depth fails
  37836. */
  37837. getStencilOperationDepthFail(): number;
  37838. /**
  37839. * Gets the current stencil operation when stencil passes
  37840. * @returns a number defining stencil operation to use when stencil passes
  37841. */
  37842. getStencilOperationPass(): number;
  37843. /**
  37844. * Sets the stencil operation to use when stencil fails
  37845. * @param operation defines the stencil operation to use when stencil fails
  37846. */
  37847. setStencilOperationFail(operation: number): void;
  37848. /**
  37849. * Sets the stencil operation to use when depth fails
  37850. * @param operation defines the stencil operation to use when depth fails
  37851. */
  37852. setStencilOperationDepthFail(operation: number): void;
  37853. /**
  37854. * Sets the stencil operation to use when stencil passes
  37855. * @param operation defines the stencil operation to use when stencil passes
  37856. */
  37857. setStencilOperationPass(operation: number): void;
  37858. /**
  37859. * Sets a boolean indicating if the dithering state is enabled or disabled
  37860. * @param value defines the dithering state
  37861. */
  37862. setDitheringState(value: boolean): void;
  37863. /**
  37864. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37865. * @param value defines the rasterizer state
  37866. */
  37867. setRasterizerState(value: boolean): void;
  37868. /**
  37869. * Gets the current depth function
  37870. * @returns a number defining the depth function
  37871. */
  37872. getDepthFunction(): Nullable<number>;
  37873. /**
  37874. * Sets the current depth function
  37875. * @param depthFunc defines the function to use
  37876. */
  37877. setDepthFunction(depthFunc: number): void;
  37878. /**
  37879. * Sets the current depth function to GREATER
  37880. */
  37881. setDepthFunctionToGreater(): void;
  37882. /**
  37883. * Sets the current depth function to GEQUAL
  37884. */
  37885. setDepthFunctionToGreaterOrEqual(): void;
  37886. /**
  37887. * Sets the current depth function to LESS
  37888. */
  37889. setDepthFunctionToLess(): void;
  37890. /**
  37891. * Sets the current depth function to LEQUAL
  37892. */
  37893. setDepthFunctionToLessOrEqual(): void;
  37894. private _cachedStencilBuffer;
  37895. private _cachedStencilFunction;
  37896. private _cachedStencilMask;
  37897. private _cachedStencilOperationPass;
  37898. private _cachedStencilOperationFail;
  37899. private _cachedStencilOperationDepthFail;
  37900. private _cachedStencilReference;
  37901. /**
  37902. * Caches the the state of the stencil buffer
  37903. */
  37904. cacheStencilState(): void;
  37905. /**
  37906. * Restores the state of the stencil buffer
  37907. */
  37908. restoreStencilState(): void;
  37909. /**
  37910. * Directly set the WebGL Viewport
  37911. * @param x defines the x coordinate of the viewport (in screen space)
  37912. * @param y defines the y coordinate of the viewport (in screen space)
  37913. * @param width defines the width of the viewport (in screen space)
  37914. * @param height defines the height of the viewport (in screen space)
  37915. * @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
  37916. */
  37917. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37918. /**
  37919. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37920. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37921. * @param y defines the y-coordinate of the corner of the clear rectangle
  37922. * @param width defines the width of the clear rectangle
  37923. * @param height defines the height of the clear rectangle
  37924. * @param clearColor defines the clear color
  37925. */
  37926. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37927. /**
  37928. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37929. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37930. * @param y defines the y-coordinate of the corner of the clear rectangle
  37931. * @param width defines the width of the clear rectangle
  37932. * @param height defines the height of the clear rectangle
  37933. */
  37934. enableScissor(x: number, y: number, width: number, height: number): void;
  37935. /**
  37936. * Disable previously set scissor test rectangle
  37937. */
  37938. disableScissor(): void;
  37939. protected _reportDrawCall(): void;
  37940. /**
  37941. * Initializes a webVR display and starts listening to display change events
  37942. * The onVRDisplayChangedObservable will be notified upon these changes
  37943. * @returns The onVRDisplayChangedObservable
  37944. */
  37945. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37946. /** @hidden */
  37947. _prepareVRComponent(): void;
  37948. /** @hidden */
  37949. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37950. /** @hidden */
  37951. _submitVRFrame(): void;
  37952. /**
  37953. * Call this function to leave webVR mode
  37954. * Will do nothing if webVR is not supported or if there is no webVR device
  37955. * @see http://doc.babylonjs.com/how_to/webvr_camera
  37956. */
  37957. disableVR(): void;
  37958. /**
  37959. * Gets a boolean indicating that the system is in VR mode and is presenting
  37960. * @returns true if VR mode is engaged
  37961. */
  37962. isVRPresenting(): boolean;
  37963. /** @hidden */
  37964. _requestVRFrame(): void;
  37965. /** @hidden */
  37966. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37967. /**
  37968. * Gets the source code of the vertex shader associated with a specific webGL program
  37969. * @param program defines the program to use
  37970. * @returns a string containing the source code of the vertex shader associated with the program
  37971. */
  37972. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37973. /**
  37974. * Gets the source code of the fragment shader associated with a specific webGL program
  37975. * @param program defines the program to use
  37976. * @returns a string containing the source code of the fragment shader associated with the program
  37977. */
  37978. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37979. /**
  37980. * Sets a depth stencil texture from a render target to the according uniform.
  37981. * @param channel The texture channel
  37982. * @param uniform The uniform to set
  37983. * @param texture The render target texture containing the depth stencil texture to apply
  37984. */
  37985. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37986. /**
  37987. * Sets a texture to the webGL context from a postprocess
  37988. * @param channel defines the channel to use
  37989. * @param postProcess defines the source postprocess
  37990. */
  37991. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37992. /**
  37993. * Binds the output of the passed in post process to the texture channel specified
  37994. * @param channel The channel the texture should be bound to
  37995. * @param postProcess The post process which's output should be bound
  37996. */
  37997. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37998. protected _rebuildBuffers(): void;
  37999. /** @hidden */
  38000. _renderFrame(): void;
  38001. _renderLoop(): void;
  38002. /** @hidden */
  38003. _renderViews(): boolean;
  38004. /**
  38005. * Toggle full screen mode
  38006. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38007. */
  38008. switchFullscreen(requestPointerLock: boolean): void;
  38009. /**
  38010. * Enters full screen mode
  38011. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38012. */
  38013. enterFullscreen(requestPointerLock: boolean): void;
  38014. /**
  38015. * Exits full screen mode
  38016. */
  38017. exitFullscreen(): void;
  38018. /**
  38019. * Enters Pointerlock mode
  38020. */
  38021. enterPointerlock(): void;
  38022. /**
  38023. * Exits Pointerlock mode
  38024. */
  38025. exitPointerlock(): void;
  38026. /**
  38027. * Begin a new frame
  38028. */
  38029. beginFrame(): void;
  38030. /**
  38031. * Enf the current frame
  38032. */
  38033. endFrame(): void;
  38034. resize(): void;
  38035. /**
  38036. * Force a specific size of the canvas
  38037. * @param width defines the new canvas' width
  38038. * @param height defines the new canvas' height
  38039. */
  38040. setSize(width: number, height: number): void;
  38041. /**
  38042. * Updates a dynamic vertex buffer.
  38043. * @param vertexBuffer the vertex buffer to update
  38044. * @param data the data used to update the vertex buffer
  38045. * @param byteOffset the byte offset of the data
  38046. * @param byteLength the byte length of the data
  38047. */
  38048. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38049. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38050. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38051. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38052. _releaseTexture(texture: InternalTexture): void;
  38053. /**
  38054. * @hidden
  38055. * Rescales a texture
  38056. * @param source input texutre
  38057. * @param destination destination texture
  38058. * @param scene scene to use to render the resize
  38059. * @param internalFormat format to use when resizing
  38060. * @param onComplete callback to be called when resize has completed
  38061. */
  38062. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38063. /**
  38064. * Gets the current framerate
  38065. * @returns a number representing the framerate
  38066. */
  38067. getFps(): number;
  38068. /**
  38069. * Gets the time spent between current and previous frame
  38070. * @returns a number representing the delta time in ms
  38071. */
  38072. getDeltaTime(): number;
  38073. private _measureFps;
  38074. /** @hidden */
  38075. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38076. /**
  38077. * Update a dynamic index buffer
  38078. * @param indexBuffer defines the target index buffer
  38079. * @param indices defines the data to update
  38080. * @param offset defines the offset in the target index buffer where update should start
  38081. */
  38082. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38083. /**
  38084. * Updates the sample count of a render target texture
  38085. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38086. * @param texture defines the texture to update
  38087. * @param samples defines the sample count to set
  38088. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38089. */
  38090. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38091. /**
  38092. * Updates a depth texture Comparison Mode and Function.
  38093. * If the comparison Function is equal to 0, the mode will be set to none.
  38094. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38095. * @param texture The texture to set the comparison function for
  38096. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38097. */
  38098. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38099. /**
  38100. * Creates a webGL buffer to use with instanciation
  38101. * @param capacity defines the size of the buffer
  38102. * @returns the webGL buffer
  38103. */
  38104. createInstancesBuffer(capacity: number): DataBuffer;
  38105. /**
  38106. * Delete a webGL buffer used with instanciation
  38107. * @param buffer defines the webGL buffer to delete
  38108. */
  38109. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38110. private _clientWaitAsync;
  38111. /** @hidden */
  38112. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38113. dispose(): void;
  38114. private _disableTouchAction;
  38115. /**
  38116. * Display the loading screen
  38117. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38118. */
  38119. displayLoadingUI(): void;
  38120. /**
  38121. * Hide the loading screen
  38122. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38123. */
  38124. hideLoadingUI(): void;
  38125. /**
  38126. * Gets the current loading screen object
  38127. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38128. */
  38129. get loadingScreen(): ILoadingScreen;
  38130. /**
  38131. * Sets the current loading screen object
  38132. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38133. */
  38134. set loadingScreen(loadingScreen: ILoadingScreen);
  38135. /**
  38136. * Sets the current loading screen text
  38137. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38138. */
  38139. set loadingUIText(text: string);
  38140. /**
  38141. * Sets the current loading screen background color
  38142. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38143. */
  38144. set loadingUIBackgroundColor(color: string);
  38145. /** Pointerlock and fullscreen */
  38146. /**
  38147. * Ask the browser to promote the current element to pointerlock mode
  38148. * @param element defines the DOM element to promote
  38149. */
  38150. static _RequestPointerlock(element: HTMLElement): void;
  38151. /**
  38152. * Asks the browser to exit pointerlock mode
  38153. */
  38154. static _ExitPointerlock(): void;
  38155. /**
  38156. * Ask the browser to promote the current element to fullscreen rendering mode
  38157. * @param element defines the DOM element to promote
  38158. */
  38159. static _RequestFullscreen(element: HTMLElement): void;
  38160. /**
  38161. * Asks the browser to exit fullscreen mode
  38162. */
  38163. static _ExitFullscreen(): void;
  38164. }
  38165. }
  38166. declare module "babylonjs/Engines/engineStore" {
  38167. import { Nullable } from "babylonjs/types";
  38168. import { Engine } from "babylonjs/Engines/engine";
  38169. import { Scene } from "babylonjs/scene";
  38170. /**
  38171. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38172. * during the life time of the application.
  38173. */
  38174. export class EngineStore {
  38175. /** Gets the list of created engines */
  38176. static Instances: import("babylonjs/Engines/engine").Engine[];
  38177. /** @hidden */
  38178. static _LastCreatedScene: Nullable<Scene>;
  38179. /**
  38180. * Gets the latest created engine
  38181. */
  38182. static get LastCreatedEngine(): Nullable<Engine>;
  38183. /**
  38184. * Gets the latest created scene
  38185. */
  38186. static get LastCreatedScene(): Nullable<Scene>;
  38187. /**
  38188. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38189. * @ignorenaming
  38190. */
  38191. static UseFallbackTexture: boolean;
  38192. /**
  38193. * Texture content used if a texture cannot loaded
  38194. * @ignorenaming
  38195. */
  38196. static FallbackTexture: string;
  38197. }
  38198. }
  38199. declare module "babylonjs/Misc/promise" {
  38200. /**
  38201. * Helper class that provides a small promise polyfill
  38202. */
  38203. export class PromisePolyfill {
  38204. /**
  38205. * Static function used to check if the polyfill is required
  38206. * If this is the case then the function will inject the polyfill to window.Promise
  38207. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38208. */
  38209. static Apply(force?: boolean): void;
  38210. }
  38211. }
  38212. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38213. /**
  38214. * Interface for screenshot methods with describe argument called `size` as object with options
  38215. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38216. */
  38217. export interface IScreenshotSize {
  38218. /**
  38219. * number in pixels for canvas height
  38220. */
  38221. height?: number;
  38222. /**
  38223. * multiplier allowing render at a higher or lower resolution
  38224. * If value is defined then height and width will be ignored and taken from camera
  38225. */
  38226. precision?: number;
  38227. /**
  38228. * number in pixels for canvas width
  38229. */
  38230. width?: number;
  38231. }
  38232. }
  38233. declare module "babylonjs/Misc/tools" {
  38234. import { Nullable, float } from "babylonjs/types";
  38235. import { DomManagement } from "babylonjs/Misc/domManagement";
  38236. import { WebRequest } from "babylonjs/Misc/webRequest";
  38237. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38238. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38239. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38240. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38241. import { Camera } from "babylonjs/Cameras/camera";
  38242. import { Engine } from "babylonjs/Engines/engine";
  38243. interface IColor4Like {
  38244. r: float;
  38245. g: float;
  38246. b: float;
  38247. a: float;
  38248. }
  38249. /**
  38250. * Class containing a set of static utilities functions
  38251. */
  38252. export class Tools {
  38253. /**
  38254. * Gets or sets the base URL to use to load assets
  38255. */
  38256. static get BaseUrl(): string;
  38257. static set BaseUrl(value: string);
  38258. /**
  38259. * Enable/Disable Custom HTTP Request Headers globally.
  38260. * default = false
  38261. * @see CustomRequestHeaders
  38262. */
  38263. static UseCustomRequestHeaders: boolean;
  38264. /**
  38265. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38266. * i.e. when loading files, where the server/service expects an Authorization header
  38267. */
  38268. static CustomRequestHeaders: {
  38269. [key: string]: string;
  38270. };
  38271. /**
  38272. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38273. */
  38274. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38275. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38276. /**
  38277. * Default behaviour for cors in the application.
  38278. * It can be a string if the expected behavior is identical in the entire app.
  38279. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38280. */
  38281. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38282. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38283. /**
  38284. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38285. * @ignorenaming
  38286. */
  38287. static get UseFallbackTexture(): boolean;
  38288. static set UseFallbackTexture(value: boolean);
  38289. /**
  38290. * Use this object to register external classes like custom textures or material
  38291. * to allow the laoders to instantiate them
  38292. */
  38293. static get RegisteredExternalClasses(): {
  38294. [key: string]: Object;
  38295. };
  38296. static set RegisteredExternalClasses(classes: {
  38297. [key: string]: Object;
  38298. });
  38299. /**
  38300. * Texture content used if a texture cannot loaded
  38301. * @ignorenaming
  38302. */
  38303. static get fallbackTexture(): string;
  38304. static set fallbackTexture(value: string);
  38305. /**
  38306. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38307. * @param u defines the coordinate on X axis
  38308. * @param v defines the coordinate on Y axis
  38309. * @param width defines the width of the source data
  38310. * @param height defines the height of the source data
  38311. * @param pixels defines the source byte array
  38312. * @param color defines the output color
  38313. */
  38314. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38315. /**
  38316. * Interpolates between a and b via alpha
  38317. * @param a The lower value (returned when alpha = 0)
  38318. * @param b The upper value (returned when alpha = 1)
  38319. * @param alpha The interpolation-factor
  38320. * @return The mixed value
  38321. */
  38322. static Mix(a: number, b: number, alpha: number): number;
  38323. /**
  38324. * Tries to instantiate a new object from a given class name
  38325. * @param className defines the class name to instantiate
  38326. * @returns the new object or null if the system was not able to do the instantiation
  38327. */
  38328. static Instantiate(className: string): any;
  38329. /**
  38330. * Provides a slice function that will work even on IE
  38331. * @param data defines the array to slice
  38332. * @param start defines the start of the data (optional)
  38333. * @param end defines the end of the data (optional)
  38334. * @returns the new sliced array
  38335. */
  38336. static Slice<T>(data: T, start?: number, end?: number): T;
  38337. /**
  38338. * Polyfill for setImmediate
  38339. * @param action defines the action to execute after the current execution block
  38340. */
  38341. static SetImmediate(action: () => void): void;
  38342. /**
  38343. * Function indicating if a number is an exponent of 2
  38344. * @param value defines the value to test
  38345. * @returns true if the value is an exponent of 2
  38346. */
  38347. static IsExponentOfTwo(value: number): boolean;
  38348. private static _tmpFloatArray;
  38349. /**
  38350. * Returns the nearest 32-bit single precision float representation of a Number
  38351. * @param value A Number. If the parameter is of a different type, it will get converted
  38352. * to a number or to NaN if it cannot be converted
  38353. * @returns number
  38354. */
  38355. static FloatRound(value: number): number;
  38356. /**
  38357. * Extracts the filename from a path
  38358. * @param path defines the path to use
  38359. * @returns the filename
  38360. */
  38361. static GetFilename(path: string): string;
  38362. /**
  38363. * Extracts the "folder" part of a path (everything before the filename).
  38364. * @param uri The URI to extract the info from
  38365. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38366. * @returns The "folder" part of the path
  38367. */
  38368. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38369. /**
  38370. * Extracts text content from a DOM element hierarchy
  38371. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38372. */
  38373. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38374. /**
  38375. * Convert an angle in radians to degrees
  38376. * @param angle defines the angle to convert
  38377. * @returns the angle in degrees
  38378. */
  38379. static ToDegrees(angle: number): number;
  38380. /**
  38381. * Convert an angle in degrees to radians
  38382. * @param angle defines the angle to convert
  38383. * @returns the angle in radians
  38384. */
  38385. static ToRadians(angle: number): number;
  38386. /**
  38387. * Returns an array if obj is not an array
  38388. * @param obj defines the object to evaluate as an array
  38389. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38390. * @returns either obj directly if obj is an array or a new array containing obj
  38391. */
  38392. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38393. /**
  38394. * Gets the pointer prefix to use
  38395. * @param engine defines the engine we are finding the prefix for
  38396. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38397. */
  38398. static GetPointerPrefix(engine: Engine): string;
  38399. /**
  38400. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38401. * @param url define the url we are trying
  38402. * @param element define the dom element where to configure the cors policy
  38403. */
  38404. static SetCorsBehavior(url: string | string[], element: {
  38405. crossOrigin: string | null;
  38406. }): void;
  38407. /**
  38408. * Removes unwanted characters from an url
  38409. * @param url defines the url to clean
  38410. * @returns the cleaned url
  38411. */
  38412. static CleanUrl(url: string): string;
  38413. /**
  38414. * Gets or sets a function used to pre-process url before using them to load assets
  38415. */
  38416. static get PreprocessUrl(): (url: string) => string;
  38417. static set PreprocessUrl(processor: (url: string) => string);
  38418. /**
  38419. * Loads an image as an HTMLImageElement.
  38420. * @param input url string, ArrayBuffer, or Blob to load
  38421. * @param onLoad callback called when the image successfully loads
  38422. * @param onError callback called when the image fails to load
  38423. * @param offlineProvider offline provider for caching
  38424. * @param mimeType optional mime type
  38425. * @returns the HTMLImageElement of the loaded image
  38426. */
  38427. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38428. /**
  38429. * Loads a file from a url
  38430. * @param url url string, ArrayBuffer, or Blob to load
  38431. * @param onSuccess callback called when the file successfully loads
  38432. * @param onProgress callback called while file is loading (if the server supports this mode)
  38433. * @param offlineProvider defines the offline provider for caching
  38434. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38435. * @param onError callback called when the file fails to load
  38436. * @returns a file request object
  38437. */
  38438. 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;
  38439. /**
  38440. * Loads a file from a url
  38441. * @param url the file url to load
  38442. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38443. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38444. */
  38445. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38446. /**
  38447. * Load a script (identified by an url). When the url returns, the
  38448. * content of this file is added into a new script element, attached to the DOM (body element)
  38449. * @param scriptUrl defines the url of the script to laod
  38450. * @param onSuccess defines the callback called when the script is loaded
  38451. * @param onError defines the callback to call if an error occurs
  38452. * @param scriptId defines the id of the script element
  38453. */
  38454. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38455. /**
  38456. * Load an asynchronous script (identified by an url). When the url returns, the
  38457. * content of this file is added into a new script element, attached to the DOM (body element)
  38458. * @param scriptUrl defines the url of the script to laod
  38459. * @param scriptId defines the id of the script element
  38460. * @returns a promise request object
  38461. */
  38462. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38463. /**
  38464. * Loads a file from a blob
  38465. * @param fileToLoad defines the blob to use
  38466. * @param callback defines the callback to call when data is loaded
  38467. * @param progressCallback defines the callback to call during loading process
  38468. * @returns a file request object
  38469. */
  38470. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38471. /**
  38472. * Reads a file from a File object
  38473. * @param file defines the file to load
  38474. * @param onSuccess defines the callback to call when data is loaded
  38475. * @param onProgress defines the callback to call during loading process
  38476. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38477. * @param onError defines the callback to call when an error occurs
  38478. * @returns a file request object
  38479. */
  38480. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38481. /**
  38482. * Creates a data url from a given string content
  38483. * @param content defines the content to convert
  38484. * @returns the new data url link
  38485. */
  38486. static FileAsURL(content: string): string;
  38487. /**
  38488. * Format the given number to a specific decimal format
  38489. * @param value defines the number to format
  38490. * @param decimals defines the number of decimals to use
  38491. * @returns the formatted string
  38492. */
  38493. static Format(value: number, decimals?: number): string;
  38494. /**
  38495. * Tries to copy an object by duplicating every property
  38496. * @param source defines the source object
  38497. * @param destination defines the target object
  38498. * @param doNotCopyList defines a list of properties to avoid
  38499. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38500. */
  38501. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38502. /**
  38503. * Gets a boolean indicating if the given object has no own property
  38504. * @param obj defines the object to test
  38505. * @returns true if object has no own property
  38506. */
  38507. static IsEmpty(obj: any): boolean;
  38508. /**
  38509. * Function used to register events at window level
  38510. * @param windowElement defines the Window object to use
  38511. * @param events defines the events to register
  38512. */
  38513. static RegisterTopRootEvents(windowElement: Window, events: {
  38514. name: string;
  38515. handler: Nullable<(e: FocusEvent) => any>;
  38516. }[]): void;
  38517. /**
  38518. * Function used to unregister events from window level
  38519. * @param windowElement defines the Window object to use
  38520. * @param events defines the events to unregister
  38521. */
  38522. static UnregisterTopRootEvents(windowElement: Window, events: {
  38523. name: string;
  38524. handler: Nullable<(e: FocusEvent) => any>;
  38525. }[]): void;
  38526. /**
  38527. * @ignore
  38528. */
  38529. static _ScreenshotCanvas: HTMLCanvasElement;
  38530. /**
  38531. * Dumps the current bound framebuffer
  38532. * @param width defines the rendering width
  38533. * @param height defines the rendering height
  38534. * @param engine defines the hosting engine
  38535. * @param successCallback defines the callback triggered once the data are available
  38536. * @param mimeType defines the mime type of the result
  38537. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38538. */
  38539. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38540. /**
  38541. * Converts the canvas data to blob.
  38542. * This acts as a polyfill for browsers not supporting the to blob function.
  38543. * @param canvas Defines the canvas to extract the data from
  38544. * @param successCallback Defines the callback triggered once the data are available
  38545. * @param mimeType Defines the mime type of the result
  38546. */
  38547. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38548. /**
  38549. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38550. * @param successCallback defines the callback triggered once the data are available
  38551. * @param mimeType defines the mime type of the result
  38552. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38553. */
  38554. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38555. /**
  38556. * Downloads a blob in the browser
  38557. * @param blob defines the blob to download
  38558. * @param fileName defines the name of the downloaded file
  38559. */
  38560. static Download(blob: Blob, fileName: string): void;
  38561. /**
  38562. * Captures a screenshot of the current rendering
  38563. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38564. * @param engine defines the rendering engine
  38565. * @param camera defines the source camera
  38566. * @param size This parameter can be set to a single number or to an object with the
  38567. * following (optional) properties: precision, width, height. If a single number is passed,
  38568. * it will be used for both width and height. If an object is passed, the screenshot size
  38569. * will be derived from the parameters. The precision property is a multiplier allowing
  38570. * rendering at a higher or lower resolution
  38571. * @param successCallback defines the callback receives a single parameter which contains the
  38572. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38573. * src parameter of an <img> to display it
  38574. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38575. * Check your browser for supported MIME types
  38576. */
  38577. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38578. /**
  38579. * Captures a screenshot of the current rendering
  38580. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38581. * @param engine defines the rendering engine
  38582. * @param camera defines the source camera
  38583. * @param size This parameter can be set to a single number or to an object with the
  38584. * following (optional) properties: precision, width, height. If a single number is passed,
  38585. * it will be used for both width and height. If an object is passed, the screenshot size
  38586. * will be derived from the parameters. The precision property is a multiplier allowing
  38587. * rendering at a higher or lower resolution
  38588. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38589. * Check your browser for supported MIME types
  38590. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38591. * to the src parameter of an <img> to display it
  38592. */
  38593. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38594. /**
  38595. * Generates an image screenshot from the specified camera.
  38596. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38597. * @param engine The engine to use for rendering
  38598. * @param camera The camera to use for rendering
  38599. * @param size This parameter can be set to a single number or to an object with the
  38600. * following (optional) properties: precision, width, height. If a single number is passed,
  38601. * it will be used for both width and height. If an object is passed, the screenshot size
  38602. * will be derived from the parameters. The precision property is a multiplier allowing
  38603. * rendering at a higher or lower resolution
  38604. * @param successCallback The callback receives a single parameter which contains the
  38605. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38606. * src parameter of an <img> to display it
  38607. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38608. * Check your browser for supported MIME types
  38609. * @param samples Texture samples (default: 1)
  38610. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38611. * @param fileName A name for for the downloaded file.
  38612. */
  38613. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38614. /**
  38615. * Generates an image screenshot from the specified camera.
  38616. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38617. * @param engine The engine to use for rendering
  38618. * @param camera The camera to use for rendering
  38619. * @param size This parameter can be set to a single number or to an object with the
  38620. * following (optional) properties: precision, width, height. If a single number is passed,
  38621. * it will be used for both width and height. If an object is passed, the screenshot size
  38622. * will be derived from the parameters. The precision property is a multiplier allowing
  38623. * rendering at a higher or lower resolution
  38624. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38625. * Check your browser for supported MIME types
  38626. * @param samples Texture samples (default: 1)
  38627. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38628. * @param fileName A name for for the downloaded file.
  38629. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38630. * to the src parameter of an <img> to display it
  38631. */
  38632. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38633. /**
  38634. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38635. * Be aware Math.random() could cause collisions, but:
  38636. * "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"
  38637. * @returns a pseudo random id
  38638. */
  38639. static RandomId(): string;
  38640. /**
  38641. * Test if the given uri is a base64 string
  38642. * @param uri The uri to test
  38643. * @return True if the uri is a base64 string or false otherwise
  38644. */
  38645. static IsBase64(uri: string): boolean;
  38646. /**
  38647. * Decode the given base64 uri.
  38648. * @param uri The uri to decode
  38649. * @return The decoded base64 data.
  38650. */
  38651. static DecodeBase64(uri: string): ArrayBuffer;
  38652. /**
  38653. * Gets the absolute url.
  38654. * @param url the input url
  38655. * @return the absolute url
  38656. */
  38657. static GetAbsoluteUrl(url: string): string;
  38658. /**
  38659. * No log
  38660. */
  38661. static readonly NoneLogLevel: number;
  38662. /**
  38663. * Only message logs
  38664. */
  38665. static readonly MessageLogLevel: number;
  38666. /**
  38667. * Only warning logs
  38668. */
  38669. static readonly WarningLogLevel: number;
  38670. /**
  38671. * Only error logs
  38672. */
  38673. static readonly ErrorLogLevel: number;
  38674. /**
  38675. * All logs
  38676. */
  38677. static readonly AllLogLevel: number;
  38678. /**
  38679. * Gets a value indicating the number of loading errors
  38680. * @ignorenaming
  38681. */
  38682. static get errorsCount(): number;
  38683. /**
  38684. * Callback called when a new log is added
  38685. */
  38686. static OnNewCacheEntry: (entry: string) => void;
  38687. /**
  38688. * Log a message to the console
  38689. * @param message defines the message to log
  38690. */
  38691. static Log(message: string): void;
  38692. /**
  38693. * Write a warning message to the console
  38694. * @param message defines the message to log
  38695. */
  38696. static Warn(message: string): void;
  38697. /**
  38698. * Write an error message to the console
  38699. * @param message defines the message to log
  38700. */
  38701. static Error(message: string): void;
  38702. /**
  38703. * Gets current log cache (list of logs)
  38704. */
  38705. static get LogCache(): string;
  38706. /**
  38707. * Clears the log cache
  38708. */
  38709. static ClearLogCache(): void;
  38710. /**
  38711. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38712. */
  38713. static set LogLevels(level: number);
  38714. /**
  38715. * Checks if the window object exists
  38716. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38717. */
  38718. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38719. /**
  38720. * No performance log
  38721. */
  38722. static readonly PerformanceNoneLogLevel: number;
  38723. /**
  38724. * Use user marks to log performance
  38725. */
  38726. static readonly PerformanceUserMarkLogLevel: number;
  38727. /**
  38728. * Log performance to the console
  38729. */
  38730. static readonly PerformanceConsoleLogLevel: number;
  38731. private static _performance;
  38732. /**
  38733. * Sets the current performance log level
  38734. */
  38735. static set PerformanceLogLevel(level: number);
  38736. private static _StartPerformanceCounterDisabled;
  38737. private static _EndPerformanceCounterDisabled;
  38738. private static _StartUserMark;
  38739. private static _EndUserMark;
  38740. private static _StartPerformanceConsole;
  38741. private static _EndPerformanceConsole;
  38742. /**
  38743. * Starts a performance counter
  38744. */
  38745. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38746. /**
  38747. * Ends a specific performance coutner
  38748. */
  38749. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38750. /**
  38751. * Gets either window.performance.now() if supported or Date.now() else
  38752. */
  38753. static get Now(): number;
  38754. /**
  38755. * This method will return the name of the class used to create the instance of the given object.
  38756. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38757. * @param object the object to get the class name from
  38758. * @param isType defines if the object is actually a type
  38759. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38760. */
  38761. static GetClassName(object: any, isType?: boolean): string;
  38762. /**
  38763. * Gets the first element of an array satisfying a given predicate
  38764. * @param array defines the array to browse
  38765. * @param predicate defines the predicate to use
  38766. * @returns null if not found or the element
  38767. */
  38768. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38769. /**
  38770. * This method will return the name of the full name of the class, including its owning module (if any).
  38771. * 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).
  38772. * @param object the object to get the class name from
  38773. * @param isType defines if the object is actually a type
  38774. * @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.
  38775. * @ignorenaming
  38776. */
  38777. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38778. /**
  38779. * Returns a promise that resolves after the given amount of time.
  38780. * @param delay Number of milliseconds to delay
  38781. * @returns Promise that resolves after the given amount of time
  38782. */
  38783. static DelayAsync(delay: number): Promise<void>;
  38784. /**
  38785. * Utility function to detect if the current user agent is Safari
  38786. * @returns whether or not the current user agent is safari
  38787. */
  38788. static IsSafari(): boolean;
  38789. }
  38790. /**
  38791. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38792. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38793. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38794. * @param name The name of the class, case should be preserved
  38795. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38796. */
  38797. export function className(name: string, module?: string): (target: Object) => void;
  38798. /**
  38799. * An implementation of a loop for asynchronous functions.
  38800. */
  38801. export class AsyncLoop {
  38802. /**
  38803. * Defines the number of iterations for the loop
  38804. */
  38805. iterations: number;
  38806. /**
  38807. * Defines the current index of the loop.
  38808. */
  38809. index: number;
  38810. private _done;
  38811. private _fn;
  38812. private _successCallback;
  38813. /**
  38814. * Constructor.
  38815. * @param iterations the number of iterations.
  38816. * @param func the function to run each iteration
  38817. * @param successCallback the callback that will be called upon succesful execution
  38818. * @param offset starting offset.
  38819. */
  38820. constructor(
  38821. /**
  38822. * Defines the number of iterations for the loop
  38823. */
  38824. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38825. /**
  38826. * Execute the next iteration. Must be called after the last iteration was finished.
  38827. */
  38828. executeNext(): void;
  38829. /**
  38830. * Break the loop and run the success callback.
  38831. */
  38832. breakLoop(): void;
  38833. /**
  38834. * Create and run an async loop.
  38835. * @param iterations the number of iterations.
  38836. * @param fn the function to run each iteration
  38837. * @param successCallback the callback that will be called upon succesful execution
  38838. * @param offset starting offset.
  38839. * @returns the created async loop object
  38840. */
  38841. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38842. /**
  38843. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38844. * @param iterations total number of iterations
  38845. * @param syncedIterations number of synchronous iterations in each async iteration.
  38846. * @param fn the function to call each iteration.
  38847. * @param callback a success call back that will be called when iterating stops.
  38848. * @param breakFunction a break condition (optional)
  38849. * @param timeout timeout settings for the setTimeout function. default - 0.
  38850. * @returns the created async loop object
  38851. */
  38852. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38853. }
  38854. }
  38855. declare module "babylonjs/Misc/stringDictionary" {
  38856. import { Nullable } from "babylonjs/types";
  38857. /**
  38858. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38859. * The underlying implementation relies on an associative array to ensure the best performances.
  38860. * The value can be anything including 'null' but except 'undefined'
  38861. */
  38862. export class StringDictionary<T> {
  38863. /**
  38864. * This will clear this dictionary and copy the content from the 'source' one.
  38865. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38866. * @param source the dictionary to take the content from and copy to this dictionary
  38867. */
  38868. copyFrom(source: StringDictionary<T>): void;
  38869. /**
  38870. * Get a value based from its key
  38871. * @param key the given key to get the matching value from
  38872. * @return the value if found, otherwise undefined is returned
  38873. */
  38874. get(key: string): T | undefined;
  38875. /**
  38876. * Get a value from its key or add it if it doesn't exist.
  38877. * This method will ensure you that a given key/data will be present in the dictionary.
  38878. * @param key the given key to get the matching value from
  38879. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38880. * The factory will only be invoked if there's no data for the given key.
  38881. * @return the value corresponding to the key.
  38882. */
  38883. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38884. /**
  38885. * Get a value from its key if present in the dictionary otherwise add it
  38886. * @param key the key to get the value from
  38887. * @param val if there's no such key/value pair in the dictionary add it with this value
  38888. * @return the value corresponding to the key
  38889. */
  38890. getOrAdd(key: string, val: T): T;
  38891. /**
  38892. * Check if there's a given key in the dictionary
  38893. * @param key the key to check for
  38894. * @return true if the key is present, false otherwise
  38895. */
  38896. contains(key: string): boolean;
  38897. /**
  38898. * Add a new key and its corresponding value
  38899. * @param key the key to add
  38900. * @param value the value corresponding to the key
  38901. * @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
  38902. */
  38903. add(key: string, value: T): boolean;
  38904. /**
  38905. * Update a specific value associated to a key
  38906. * @param key defines the key to use
  38907. * @param value defines the value to store
  38908. * @returns true if the value was updated (or false if the key was not found)
  38909. */
  38910. set(key: string, value: T): boolean;
  38911. /**
  38912. * Get the element of the given key and remove it from the dictionary
  38913. * @param key defines the key to search
  38914. * @returns the value associated with the key or null if not found
  38915. */
  38916. getAndRemove(key: string): Nullable<T>;
  38917. /**
  38918. * Remove a key/value from the dictionary.
  38919. * @param key the key to remove
  38920. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38921. */
  38922. remove(key: string): boolean;
  38923. /**
  38924. * Clear the whole content of the dictionary
  38925. */
  38926. clear(): void;
  38927. /**
  38928. * Gets the current count
  38929. */
  38930. get count(): number;
  38931. /**
  38932. * Execute a callback on each key/val of the dictionary.
  38933. * Note that you can remove any element in this dictionary in the callback implementation
  38934. * @param callback the callback to execute on a given key/value pair
  38935. */
  38936. forEach(callback: (key: string, val: T) => void): void;
  38937. /**
  38938. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38939. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38940. * Note that you can remove any element in this dictionary in the callback implementation
  38941. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38942. * @returns the first item
  38943. */
  38944. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38945. private _count;
  38946. private _data;
  38947. }
  38948. }
  38949. declare module "babylonjs/Collisions/collisionCoordinator" {
  38950. import { Nullable } from "babylonjs/types";
  38951. import { Scene } from "babylonjs/scene";
  38952. import { Vector3 } from "babylonjs/Maths/math.vector";
  38953. import { Collider } from "babylonjs/Collisions/collider";
  38954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38955. /** @hidden */
  38956. export interface ICollisionCoordinator {
  38957. createCollider(): Collider;
  38958. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38959. init(scene: Scene): void;
  38960. }
  38961. /** @hidden */
  38962. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38963. private _scene;
  38964. private _scaledPosition;
  38965. private _scaledVelocity;
  38966. private _finalPosition;
  38967. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38968. createCollider(): Collider;
  38969. init(scene: Scene): void;
  38970. private _collideWithWorld;
  38971. }
  38972. }
  38973. declare module "babylonjs/Inputs/scene.inputManager" {
  38974. import { Nullable } from "babylonjs/types";
  38975. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  38976. import { Vector2 } from "babylonjs/Maths/math.vector";
  38977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38978. import { Scene } from "babylonjs/scene";
  38979. /**
  38980. * Class used to manage all inputs for the scene.
  38981. */
  38982. export class InputManager {
  38983. /** The distance in pixel that you have to move to prevent some events */
  38984. static DragMovementThreshold: number;
  38985. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38986. static LongPressDelay: number;
  38987. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38988. static DoubleClickDelay: number;
  38989. /** If you need to check double click without raising a single click at first click, enable this flag */
  38990. static ExclusiveDoubleClickMode: boolean;
  38991. private _wheelEventName;
  38992. private _onPointerMove;
  38993. private _onPointerDown;
  38994. private _onPointerUp;
  38995. private _initClickEvent;
  38996. private _initActionManager;
  38997. private _delayedSimpleClick;
  38998. private _delayedSimpleClickTimeout;
  38999. private _previousDelayedSimpleClickTimeout;
  39000. private _meshPickProceed;
  39001. private _previousButtonPressed;
  39002. private _currentPickResult;
  39003. private _previousPickResult;
  39004. private _totalPointersPressed;
  39005. private _doubleClickOccured;
  39006. private _pointerOverMesh;
  39007. private _pickedDownMesh;
  39008. private _pickedUpMesh;
  39009. private _pointerX;
  39010. private _pointerY;
  39011. private _unTranslatedPointerX;
  39012. private _unTranslatedPointerY;
  39013. private _startingPointerPosition;
  39014. private _previousStartingPointerPosition;
  39015. private _startingPointerTime;
  39016. private _previousStartingPointerTime;
  39017. private _pointerCaptures;
  39018. private _onKeyDown;
  39019. private _onKeyUp;
  39020. private _onCanvasFocusObserver;
  39021. private _onCanvasBlurObserver;
  39022. private _scene;
  39023. /**
  39024. * Creates a new InputManager
  39025. * @param scene defines the hosting scene
  39026. */
  39027. constructor(scene: Scene);
  39028. /**
  39029. * Gets the mesh that is currently under the pointer
  39030. */
  39031. get meshUnderPointer(): Nullable<AbstractMesh>;
  39032. /**
  39033. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39034. */
  39035. get unTranslatedPointer(): Vector2;
  39036. /**
  39037. * Gets or sets the current on-screen X position of the pointer
  39038. */
  39039. get pointerX(): number;
  39040. set pointerX(value: number);
  39041. /**
  39042. * Gets or sets the current on-screen Y position of the pointer
  39043. */
  39044. get pointerY(): number;
  39045. set pointerY(value: number);
  39046. private _updatePointerPosition;
  39047. private _processPointerMove;
  39048. private _setRayOnPointerInfo;
  39049. private _checkPrePointerObservable;
  39050. /**
  39051. * Use this method to simulate a pointer move on a mesh
  39052. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39053. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39054. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39055. */
  39056. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39057. /**
  39058. * Use this method to simulate a pointer down on a mesh
  39059. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39060. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39061. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39062. */
  39063. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39064. private _processPointerDown;
  39065. /** @hidden */
  39066. _isPointerSwiping(): boolean;
  39067. /**
  39068. * Use this method to simulate a pointer up on a mesh
  39069. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39070. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39071. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39072. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39073. */
  39074. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39075. private _processPointerUp;
  39076. /**
  39077. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39078. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39079. * @returns true if the pointer was captured
  39080. */
  39081. isPointerCaptured(pointerId?: number): boolean;
  39082. /**
  39083. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39084. * @param attachUp defines if you want to attach events to pointerup
  39085. * @param attachDown defines if you want to attach events to pointerdown
  39086. * @param attachMove defines if you want to attach events to pointermove
  39087. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39088. */
  39089. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39090. /**
  39091. * Detaches all event handlers
  39092. */
  39093. detachControl(): void;
  39094. /**
  39095. * Force the value of meshUnderPointer
  39096. * @param mesh defines the mesh to use
  39097. */
  39098. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39099. /**
  39100. * Gets the mesh under the pointer
  39101. * @returns a Mesh or null if no mesh is under the pointer
  39102. */
  39103. getPointerOverMesh(): Nullable<AbstractMesh>;
  39104. }
  39105. }
  39106. declare module "babylonjs/Animations/animationGroup" {
  39107. import { Animatable } from "babylonjs/Animations/animatable";
  39108. import { Animation } from "babylonjs/Animations/animation";
  39109. import { Scene, IDisposable } from "babylonjs/scene";
  39110. import { Observable } from "babylonjs/Misc/observable";
  39111. import { Nullable } from "babylonjs/types";
  39112. import "babylonjs/Animations/animatable";
  39113. /**
  39114. * This class defines the direct association between an animation and a target
  39115. */
  39116. export class TargetedAnimation {
  39117. /**
  39118. * Animation to perform
  39119. */
  39120. animation: Animation;
  39121. /**
  39122. * Target to animate
  39123. */
  39124. target: any;
  39125. /**
  39126. * Serialize the object
  39127. * @returns the JSON object representing the current entity
  39128. */
  39129. serialize(): any;
  39130. }
  39131. /**
  39132. * Use this class to create coordinated animations on multiple targets
  39133. */
  39134. export class AnimationGroup implements IDisposable {
  39135. /** The name of the animation group */
  39136. name: string;
  39137. private _scene;
  39138. private _targetedAnimations;
  39139. private _animatables;
  39140. private _from;
  39141. private _to;
  39142. private _isStarted;
  39143. private _isPaused;
  39144. private _speedRatio;
  39145. private _loopAnimation;
  39146. private _isAdditive;
  39147. /**
  39148. * Gets or sets the unique id of the node
  39149. */
  39150. uniqueId: number;
  39151. /**
  39152. * This observable will notify when one animation have ended
  39153. */
  39154. onAnimationEndObservable: Observable<TargetedAnimation>;
  39155. /**
  39156. * Observer raised when one animation loops
  39157. */
  39158. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39159. /**
  39160. * Observer raised when all animations have looped
  39161. */
  39162. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39163. /**
  39164. * This observable will notify when all animations have ended.
  39165. */
  39166. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39167. /**
  39168. * This observable will notify when all animations have paused.
  39169. */
  39170. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39171. /**
  39172. * This observable will notify when all animations are playing.
  39173. */
  39174. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39175. /**
  39176. * Gets the first frame
  39177. */
  39178. get from(): number;
  39179. /**
  39180. * Gets the last frame
  39181. */
  39182. get to(): number;
  39183. /**
  39184. * Define if the animations are started
  39185. */
  39186. get isStarted(): boolean;
  39187. /**
  39188. * Gets a value indicating that the current group is playing
  39189. */
  39190. get isPlaying(): boolean;
  39191. /**
  39192. * Gets or sets the speed ratio to use for all animations
  39193. */
  39194. get speedRatio(): number;
  39195. /**
  39196. * Gets or sets the speed ratio to use for all animations
  39197. */
  39198. set speedRatio(value: number);
  39199. /**
  39200. * Gets or sets if all animations should loop or not
  39201. */
  39202. get loopAnimation(): boolean;
  39203. set loopAnimation(value: boolean);
  39204. /**
  39205. * Gets or sets if all animations should be evaluated additively
  39206. */
  39207. get isAdditive(): boolean;
  39208. set isAdditive(value: boolean);
  39209. /**
  39210. * Gets the targeted animations for this animation group
  39211. */
  39212. get targetedAnimations(): Array<TargetedAnimation>;
  39213. /**
  39214. * returning the list of animatables controlled by this animation group.
  39215. */
  39216. get animatables(): Array<Animatable>;
  39217. /**
  39218. * Instantiates a new Animation Group.
  39219. * This helps managing several animations at once.
  39220. * @see http://doc.babylonjs.com/how_to/group
  39221. * @param name Defines the name of the group
  39222. * @param scene Defines the scene the group belongs to
  39223. */
  39224. constructor(
  39225. /** The name of the animation group */
  39226. name: string, scene?: Nullable<Scene>);
  39227. /**
  39228. * Add an animation (with its target) in the group
  39229. * @param animation defines the animation we want to add
  39230. * @param target defines the target of the animation
  39231. * @returns the TargetedAnimation object
  39232. */
  39233. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39234. /**
  39235. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39236. * It can add constant keys at begin or end
  39237. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39238. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39239. * @returns the animation group
  39240. */
  39241. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39242. private _animationLoopCount;
  39243. private _animationLoopFlags;
  39244. private _processLoop;
  39245. /**
  39246. * Start all animations on given targets
  39247. * @param loop defines if animations must loop
  39248. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39249. * @param from defines the from key (optional)
  39250. * @param to defines the to key (optional)
  39251. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39252. * @returns the current animation group
  39253. */
  39254. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39255. /**
  39256. * Pause all animations
  39257. * @returns the animation group
  39258. */
  39259. pause(): AnimationGroup;
  39260. /**
  39261. * Play all animations to initial state
  39262. * This function will start() the animations if they were not started or will restart() them if they were paused
  39263. * @param loop defines if animations must loop
  39264. * @returns the animation group
  39265. */
  39266. play(loop?: boolean): AnimationGroup;
  39267. /**
  39268. * Reset all animations to initial state
  39269. * @returns the animation group
  39270. */
  39271. reset(): AnimationGroup;
  39272. /**
  39273. * Restart animations from key 0
  39274. * @returns the animation group
  39275. */
  39276. restart(): AnimationGroup;
  39277. /**
  39278. * Stop all animations
  39279. * @returns the animation group
  39280. */
  39281. stop(): AnimationGroup;
  39282. /**
  39283. * Set animation weight for all animatables
  39284. * @param weight defines the weight to use
  39285. * @return the animationGroup
  39286. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39287. */
  39288. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39289. /**
  39290. * Synchronize and normalize all animatables with a source animatable
  39291. * @param root defines the root animatable to synchronize with
  39292. * @return the animationGroup
  39293. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39294. */
  39295. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39296. /**
  39297. * Goes to a specific frame in this animation group
  39298. * @param frame the frame number to go to
  39299. * @return the animationGroup
  39300. */
  39301. goToFrame(frame: number): AnimationGroup;
  39302. /**
  39303. * Dispose all associated resources
  39304. */
  39305. dispose(): void;
  39306. private _checkAnimationGroupEnded;
  39307. /**
  39308. * Clone the current animation group and returns a copy
  39309. * @param newName defines the name of the new group
  39310. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39311. * @returns the new aniamtion group
  39312. */
  39313. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39314. /**
  39315. * Serializes the animationGroup to an object
  39316. * @returns Serialized object
  39317. */
  39318. serialize(): any;
  39319. /**
  39320. * Returns a new AnimationGroup object parsed from the source provided.
  39321. * @param parsedAnimationGroup defines the source
  39322. * @param scene defines the scene that will receive the animationGroup
  39323. * @returns a new AnimationGroup
  39324. */
  39325. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39326. /**
  39327. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39328. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39329. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39330. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39331. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39332. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39333. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39334. */
  39335. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39336. /**
  39337. * Returns the string "AnimationGroup"
  39338. * @returns "AnimationGroup"
  39339. */
  39340. getClassName(): string;
  39341. /**
  39342. * Creates a detailled string about the object
  39343. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39344. * @returns a string representing the object
  39345. */
  39346. toString(fullDetails?: boolean): string;
  39347. }
  39348. }
  39349. declare module "babylonjs/scene" {
  39350. import { Nullable } from "babylonjs/types";
  39351. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39352. import { Observable } from "babylonjs/Misc/observable";
  39353. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39354. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39355. import { Geometry } from "babylonjs/Meshes/geometry";
  39356. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39357. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39359. import { Mesh } from "babylonjs/Meshes/mesh";
  39360. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39361. import { Bone } from "babylonjs/Bones/bone";
  39362. import { Skeleton } from "babylonjs/Bones/skeleton";
  39363. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39364. import { Camera } from "babylonjs/Cameras/camera";
  39365. import { AbstractScene } from "babylonjs/abstractScene";
  39366. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39367. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39368. import { Material } from "babylonjs/Materials/material";
  39369. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39370. import { Effect } from "babylonjs/Materials/effect";
  39371. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39372. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39373. import { Light } from "babylonjs/Lights/light";
  39374. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39375. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39376. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39377. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39378. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39379. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39380. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39381. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39382. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39383. import { Engine } from "babylonjs/Engines/engine";
  39384. import { Node } from "babylonjs/node";
  39385. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39386. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39387. import { WebRequest } from "babylonjs/Misc/webRequest";
  39388. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39389. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39390. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39391. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39392. import { Plane } from "babylonjs/Maths/math.plane";
  39393. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39394. import { Ray } from "babylonjs/Culling/ray";
  39395. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39396. import { Animation } from "babylonjs/Animations/animation";
  39397. import { Animatable } from "babylonjs/Animations/animatable";
  39398. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39399. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39400. import { Collider } from "babylonjs/Collisions/collider";
  39401. /**
  39402. * Define an interface for all classes that will hold resources
  39403. */
  39404. export interface IDisposable {
  39405. /**
  39406. * Releases all held resources
  39407. */
  39408. dispose(): void;
  39409. }
  39410. /** Interface defining initialization parameters for Scene class */
  39411. export interface SceneOptions {
  39412. /**
  39413. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39414. * It will improve performance when the number of geometries becomes important.
  39415. */
  39416. useGeometryUniqueIdsMap?: boolean;
  39417. /**
  39418. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39419. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39420. */
  39421. useMaterialMeshMap?: boolean;
  39422. /**
  39423. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39424. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39425. */
  39426. useClonedMeshMap?: boolean;
  39427. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39428. virtual?: boolean;
  39429. }
  39430. /**
  39431. * Represents a scene to be rendered by the engine.
  39432. * @see http://doc.babylonjs.com/features/scene
  39433. */
  39434. export class Scene extends AbstractScene implements IAnimatable {
  39435. /** The fog is deactivated */
  39436. static readonly FOGMODE_NONE: number;
  39437. /** The fog density is following an exponential function */
  39438. static readonly FOGMODE_EXP: number;
  39439. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39440. static readonly FOGMODE_EXP2: number;
  39441. /** The fog density is following a linear function. */
  39442. static readonly FOGMODE_LINEAR: number;
  39443. /**
  39444. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39445. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39446. */
  39447. static MinDeltaTime: number;
  39448. /**
  39449. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39450. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39451. */
  39452. static MaxDeltaTime: number;
  39453. /**
  39454. * Factory used to create the default material.
  39455. * @param name The name of the material to create
  39456. * @param scene The scene to create the material for
  39457. * @returns The default material
  39458. */
  39459. static DefaultMaterialFactory(scene: Scene): Material;
  39460. /**
  39461. * Factory used to create the a collision coordinator.
  39462. * @returns The collision coordinator
  39463. */
  39464. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39465. /** @hidden */
  39466. _inputManager: InputManager;
  39467. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39468. cameraToUseForPointers: Nullable<Camera>;
  39469. /** @hidden */
  39470. readonly _isScene: boolean;
  39471. /** @hidden */
  39472. _blockEntityCollection: boolean;
  39473. /**
  39474. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39475. */
  39476. autoClear: boolean;
  39477. /**
  39478. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39479. */
  39480. autoClearDepthAndStencil: boolean;
  39481. /**
  39482. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39483. */
  39484. clearColor: Color4;
  39485. /**
  39486. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39487. */
  39488. ambientColor: Color3;
  39489. /**
  39490. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39491. * It should only be one of the following (if not the default embedded one):
  39492. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39493. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39494. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39495. * The material properties need to be setup according to the type of texture in use.
  39496. */
  39497. environmentBRDFTexture: BaseTexture;
  39498. /** @hidden */
  39499. protected _environmentTexture: Nullable<BaseTexture>;
  39500. /**
  39501. * Texture used in all pbr material as the reflection texture.
  39502. * As in the majority of the scene they are the same (exception for multi room and so on),
  39503. * this is easier to reference from here than from all the materials.
  39504. */
  39505. get environmentTexture(): Nullable<BaseTexture>;
  39506. /**
  39507. * Texture used in all pbr material as the reflection texture.
  39508. * As in the majority of the scene they are the same (exception for multi room and so on),
  39509. * this is easier to set here than in all the materials.
  39510. */
  39511. set environmentTexture(value: Nullable<BaseTexture>);
  39512. /** @hidden */
  39513. protected _environmentIntensity: number;
  39514. /**
  39515. * Intensity of the environment in all pbr material.
  39516. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39517. * As in the majority of the scene they are the same (exception for multi room and so on),
  39518. * this is easier to reference from here than from all the materials.
  39519. */
  39520. get environmentIntensity(): number;
  39521. /**
  39522. * Intensity of the environment in all pbr material.
  39523. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39524. * As in the majority of the scene they are the same (exception for multi room and so on),
  39525. * this is easier to set here than in all the materials.
  39526. */
  39527. set environmentIntensity(value: number);
  39528. /** @hidden */
  39529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39530. /**
  39531. * Default image processing configuration used either in the rendering
  39532. * Forward main pass or through the imageProcessingPostProcess if present.
  39533. * As in the majority of the scene they are the same (exception for multi camera),
  39534. * this is easier to reference from here than from all the materials and post process.
  39535. *
  39536. * No setter as we it is a shared configuration, you can set the values instead.
  39537. */
  39538. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39539. private _forceWireframe;
  39540. /**
  39541. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39542. */
  39543. set forceWireframe(value: boolean);
  39544. get forceWireframe(): boolean;
  39545. private _skipFrustumClipping;
  39546. /**
  39547. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39548. */
  39549. set skipFrustumClipping(value: boolean);
  39550. get skipFrustumClipping(): boolean;
  39551. private _forcePointsCloud;
  39552. /**
  39553. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39554. */
  39555. set forcePointsCloud(value: boolean);
  39556. get forcePointsCloud(): boolean;
  39557. /**
  39558. * Gets or sets the active clipplane 1
  39559. */
  39560. clipPlane: Nullable<Plane>;
  39561. /**
  39562. * Gets or sets the active clipplane 2
  39563. */
  39564. clipPlane2: Nullable<Plane>;
  39565. /**
  39566. * Gets or sets the active clipplane 3
  39567. */
  39568. clipPlane3: Nullable<Plane>;
  39569. /**
  39570. * Gets or sets the active clipplane 4
  39571. */
  39572. clipPlane4: Nullable<Plane>;
  39573. /**
  39574. * Gets or sets the active clipplane 5
  39575. */
  39576. clipPlane5: Nullable<Plane>;
  39577. /**
  39578. * Gets or sets the active clipplane 6
  39579. */
  39580. clipPlane6: Nullable<Plane>;
  39581. /**
  39582. * Gets or sets a boolean indicating if animations are enabled
  39583. */
  39584. animationsEnabled: boolean;
  39585. private _animationPropertiesOverride;
  39586. /**
  39587. * Gets or sets the animation properties override
  39588. */
  39589. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39590. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39591. /**
  39592. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39593. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39594. */
  39595. useConstantAnimationDeltaTime: boolean;
  39596. /**
  39597. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39598. * Please note that it requires to run a ray cast through the scene on every frame
  39599. */
  39600. constantlyUpdateMeshUnderPointer: boolean;
  39601. /**
  39602. * Defines the HTML cursor to use when hovering over interactive elements
  39603. */
  39604. hoverCursor: string;
  39605. /**
  39606. * Defines the HTML default cursor to use (empty by default)
  39607. */
  39608. defaultCursor: string;
  39609. /**
  39610. * Defines whether cursors are handled by the scene.
  39611. */
  39612. doNotHandleCursors: boolean;
  39613. /**
  39614. * This is used to call preventDefault() on pointer down
  39615. * in order to block unwanted artifacts like system double clicks
  39616. */
  39617. preventDefaultOnPointerDown: boolean;
  39618. /**
  39619. * This is used to call preventDefault() on pointer up
  39620. * in order to block unwanted artifacts like system double clicks
  39621. */
  39622. preventDefaultOnPointerUp: boolean;
  39623. /**
  39624. * Gets or sets user defined metadata
  39625. */
  39626. metadata: any;
  39627. /**
  39628. * For internal use only. Please do not use.
  39629. */
  39630. reservedDataStore: any;
  39631. /**
  39632. * Gets the name of the plugin used to load this scene (null by default)
  39633. */
  39634. loadingPluginName: string;
  39635. /**
  39636. * Use this array to add regular expressions used to disable offline support for specific urls
  39637. */
  39638. disableOfflineSupportExceptionRules: RegExp[];
  39639. /**
  39640. * An event triggered when the scene is disposed.
  39641. */
  39642. onDisposeObservable: Observable<Scene>;
  39643. private _onDisposeObserver;
  39644. /** Sets a function to be executed when this scene is disposed. */
  39645. set onDispose(callback: () => void);
  39646. /**
  39647. * An event triggered before rendering the scene (right after animations and physics)
  39648. */
  39649. onBeforeRenderObservable: Observable<Scene>;
  39650. private _onBeforeRenderObserver;
  39651. /** Sets a function to be executed before rendering this scene */
  39652. set beforeRender(callback: Nullable<() => void>);
  39653. /**
  39654. * An event triggered after rendering the scene
  39655. */
  39656. onAfterRenderObservable: Observable<Scene>;
  39657. /**
  39658. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39659. */
  39660. onAfterRenderCameraObservable: Observable<Camera>;
  39661. private _onAfterRenderObserver;
  39662. /** Sets a function to be executed after rendering this scene */
  39663. set afterRender(callback: Nullable<() => void>);
  39664. /**
  39665. * An event triggered before animating the scene
  39666. */
  39667. onBeforeAnimationsObservable: Observable<Scene>;
  39668. /**
  39669. * An event triggered after animations processing
  39670. */
  39671. onAfterAnimationsObservable: Observable<Scene>;
  39672. /**
  39673. * An event triggered before draw calls are ready to be sent
  39674. */
  39675. onBeforeDrawPhaseObservable: Observable<Scene>;
  39676. /**
  39677. * An event triggered after draw calls have been sent
  39678. */
  39679. onAfterDrawPhaseObservable: Observable<Scene>;
  39680. /**
  39681. * An event triggered when the scene is ready
  39682. */
  39683. onReadyObservable: Observable<Scene>;
  39684. /**
  39685. * An event triggered before rendering a camera
  39686. */
  39687. onBeforeCameraRenderObservable: Observable<Camera>;
  39688. private _onBeforeCameraRenderObserver;
  39689. /** Sets a function to be executed before rendering a camera*/
  39690. set beforeCameraRender(callback: () => void);
  39691. /**
  39692. * An event triggered after rendering a camera
  39693. */
  39694. onAfterCameraRenderObservable: Observable<Camera>;
  39695. private _onAfterCameraRenderObserver;
  39696. /** Sets a function to be executed after rendering a camera*/
  39697. set afterCameraRender(callback: () => void);
  39698. /**
  39699. * An event triggered when active meshes evaluation is about to start
  39700. */
  39701. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39702. /**
  39703. * An event triggered when active meshes evaluation is done
  39704. */
  39705. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39706. /**
  39707. * An event triggered when particles rendering is about to start
  39708. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39709. */
  39710. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39711. /**
  39712. * An event triggered when particles rendering is done
  39713. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39714. */
  39715. onAfterParticlesRenderingObservable: Observable<Scene>;
  39716. /**
  39717. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39718. */
  39719. onDataLoadedObservable: Observable<Scene>;
  39720. /**
  39721. * An event triggered when a camera is created
  39722. */
  39723. onNewCameraAddedObservable: Observable<Camera>;
  39724. /**
  39725. * An event triggered when a camera is removed
  39726. */
  39727. onCameraRemovedObservable: Observable<Camera>;
  39728. /**
  39729. * An event triggered when a light is created
  39730. */
  39731. onNewLightAddedObservable: Observable<Light>;
  39732. /**
  39733. * An event triggered when a light is removed
  39734. */
  39735. onLightRemovedObservable: Observable<Light>;
  39736. /**
  39737. * An event triggered when a geometry is created
  39738. */
  39739. onNewGeometryAddedObservable: Observable<Geometry>;
  39740. /**
  39741. * An event triggered when a geometry is removed
  39742. */
  39743. onGeometryRemovedObservable: Observable<Geometry>;
  39744. /**
  39745. * An event triggered when a transform node is created
  39746. */
  39747. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39748. /**
  39749. * An event triggered when a transform node is removed
  39750. */
  39751. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39752. /**
  39753. * An event triggered when a mesh is created
  39754. */
  39755. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39756. /**
  39757. * An event triggered when a mesh is removed
  39758. */
  39759. onMeshRemovedObservable: Observable<AbstractMesh>;
  39760. /**
  39761. * An event triggered when a skeleton is created
  39762. */
  39763. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39764. /**
  39765. * An event triggered when a skeleton is removed
  39766. */
  39767. onSkeletonRemovedObservable: Observable<Skeleton>;
  39768. /**
  39769. * An event triggered when a material is created
  39770. */
  39771. onNewMaterialAddedObservable: Observable<Material>;
  39772. /**
  39773. * An event triggered when a material is removed
  39774. */
  39775. onMaterialRemovedObservable: Observable<Material>;
  39776. /**
  39777. * An event triggered when a texture is created
  39778. */
  39779. onNewTextureAddedObservable: Observable<BaseTexture>;
  39780. /**
  39781. * An event triggered when a texture is removed
  39782. */
  39783. onTextureRemovedObservable: Observable<BaseTexture>;
  39784. /**
  39785. * An event triggered when render targets are about to be rendered
  39786. * Can happen multiple times per frame.
  39787. */
  39788. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39789. /**
  39790. * An event triggered when render targets were rendered.
  39791. * Can happen multiple times per frame.
  39792. */
  39793. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39794. /**
  39795. * An event triggered before calculating deterministic simulation step
  39796. */
  39797. onBeforeStepObservable: Observable<Scene>;
  39798. /**
  39799. * An event triggered after calculating deterministic simulation step
  39800. */
  39801. onAfterStepObservable: Observable<Scene>;
  39802. /**
  39803. * An event triggered when the activeCamera property is updated
  39804. */
  39805. onActiveCameraChanged: Observable<Scene>;
  39806. /**
  39807. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39808. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39809. * 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)
  39810. */
  39811. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39812. /**
  39813. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39814. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39815. * 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)
  39816. */
  39817. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39818. /**
  39819. * This Observable will when a mesh has been imported into the scene.
  39820. */
  39821. onMeshImportedObservable: Observable<AbstractMesh>;
  39822. /**
  39823. * This Observable will when an animation file has been imported into the scene.
  39824. */
  39825. onAnimationFileImportedObservable: Observable<Scene>;
  39826. /**
  39827. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39828. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39829. */
  39830. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39831. /** @hidden */
  39832. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39833. /**
  39834. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39835. */
  39836. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39837. /**
  39838. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39839. */
  39840. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39841. /**
  39842. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39843. */
  39844. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39845. /** Callback called when a pointer move is detected */
  39846. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39847. /** Callback called when a pointer down is detected */
  39848. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39849. /** Callback called when a pointer up is detected */
  39850. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39851. /** Callback called when a pointer pick is detected */
  39852. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39853. /**
  39854. * 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).
  39855. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39856. */
  39857. onPrePointerObservable: Observable<PointerInfoPre>;
  39858. /**
  39859. * Observable event triggered each time an input event is received from the rendering canvas
  39860. */
  39861. onPointerObservable: Observable<PointerInfo>;
  39862. /**
  39863. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39864. */
  39865. get unTranslatedPointer(): Vector2;
  39866. /**
  39867. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39868. */
  39869. static get DragMovementThreshold(): number;
  39870. static set DragMovementThreshold(value: number);
  39871. /**
  39872. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39873. */
  39874. static get LongPressDelay(): number;
  39875. static set LongPressDelay(value: number);
  39876. /**
  39877. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39878. */
  39879. static get DoubleClickDelay(): number;
  39880. static set DoubleClickDelay(value: number);
  39881. /** If you need to check double click without raising a single click at first click, enable this flag */
  39882. static get ExclusiveDoubleClickMode(): boolean;
  39883. static set ExclusiveDoubleClickMode(value: boolean);
  39884. /** @hidden */
  39885. _mirroredCameraPosition: Nullable<Vector3>;
  39886. /**
  39887. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39888. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39889. */
  39890. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39891. /**
  39892. * Observable event triggered each time an keyboard event is received from the hosting window
  39893. */
  39894. onKeyboardObservable: Observable<KeyboardInfo>;
  39895. private _useRightHandedSystem;
  39896. /**
  39897. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39898. */
  39899. set useRightHandedSystem(value: boolean);
  39900. get useRightHandedSystem(): boolean;
  39901. private _timeAccumulator;
  39902. private _currentStepId;
  39903. private _currentInternalStep;
  39904. /**
  39905. * Sets the step Id used by deterministic lock step
  39906. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39907. * @param newStepId defines the step Id
  39908. */
  39909. setStepId(newStepId: number): void;
  39910. /**
  39911. * Gets the step Id used by deterministic lock step
  39912. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39913. * @returns the step Id
  39914. */
  39915. getStepId(): number;
  39916. /**
  39917. * Gets the internal step used by deterministic lock step
  39918. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39919. * @returns the internal step
  39920. */
  39921. getInternalStep(): number;
  39922. private _fogEnabled;
  39923. /**
  39924. * Gets or sets a boolean indicating if fog is enabled on this scene
  39925. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39926. * (Default is true)
  39927. */
  39928. set fogEnabled(value: boolean);
  39929. get fogEnabled(): boolean;
  39930. private _fogMode;
  39931. /**
  39932. * Gets or sets the fog mode to use
  39933. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39934. * | mode | value |
  39935. * | --- | --- |
  39936. * | FOGMODE_NONE | 0 |
  39937. * | FOGMODE_EXP | 1 |
  39938. * | FOGMODE_EXP2 | 2 |
  39939. * | FOGMODE_LINEAR | 3 |
  39940. */
  39941. set fogMode(value: number);
  39942. get fogMode(): number;
  39943. /**
  39944. * Gets or sets the fog color to use
  39945. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39946. * (Default is Color3(0.2, 0.2, 0.3))
  39947. */
  39948. fogColor: Color3;
  39949. /**
  39950. * Gets or sets the fog density to use
  39951. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39952. * (Default is 0.1)
  39953. */
  39954. fogDensity: number;
  39955. /**
  39956. * Gets or sets the fog start distance to use
  39957. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39958. * (Default is 0)
  39959. */
  39960. fogStart: number;
  39961. /**
  39962. * Gets or sets the fog end distance to use
  39963. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39964. * (Default is 1000)
  39965. */
  39966. fogEnd: number;
  39967. private _shadowsEnabled;
  39968. /**
  39969. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39970. */
  39971. set shadowsEnabled(value: boolean);
  39972. get shadowsEnabled(): boolean;
  39973. private _lightsEnabled;
  39974. /**
  39975. * Gets or sets a boolean indicating if lights are enabled on this scene
  39976. */
  39977. set lightsEnabled(value: boolean);
  39978. get lightsEnabled(): boolean;
  39979. /** All of the active cameras added to this scene. */
  39980. activeCameras: Camera[];
  39981. /** @hidden */
  39982. _activeCamera: Nullable<Camera>;
  39983. /** Gets or sets the current active camera */
  39984. get activeCamera(): Nullable<Camera>;
  39985. set activeCamera(value: Nullable<Camera>);
  39986. private _defaultMaterial;
  39987. /** The default material used on meshes when no material is affected */
  39988. get defaultMaterial(): Material;
  39989. /** The default material used on meshes when no material is affected */
  39990. set defaultMaterial(value: Material);
  39991. private _texturesEnabled;
  39992. /**
  39993. * Gets or sets a boolean indicating if textures are enabled on this scene
  39994. */
  39995. set texturesEnabled(value: boolean);
  39996. get texturesEnabled(): boolean;
  39997. /**
  39998. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39999. */
  40000. physicsEnabled: boolean;
  40001. /**
  40002. * Gets or sets a boolean indicating if particles are enabled on this scene
  40003. */
  40004. particlesEnabled: boolean;
  40005. /**
  40006. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40007. */
  40008. spritesEnabled: boolean;
  40009. private _skeletonsEnabled;
  40010. /**
  40011. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40012. */
  40013. set skeletonsEnabled(value: boolean);
  40014. get skeletonsEnabled(): boolean;
  40015. /**
  40016. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40017. */
  40018. lensFlaresEnabled: boolean;
  40019. /**
  40020. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40021. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40022. */
  40023. collisionsEnabled: boolean;
  40024. private _collisionCoordinator;
  40025. /** @hidden */
  40026. get collisionCoordinator(): ICollisionCoordinator;
  40027. /**
  40028. * Defines the gravity applied to this scene (used only for collisions)
  40029. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40030. */
  40031. gravity: Vector3;
  40032. /**
  40033. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40034. */
  40035. postProcessesEnabled: boolean;
  40036. /**
  40037. * The list of postprocesses added to the scene
  40038. */
  40039. postProcesses: PostProcess[];
  40040. /**
  40041. * Gets the current postprocess manager
  40042. */
  40043. postProcessManager: PostProcessManager;
  40044. /**
  40045. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40046. */
  40047. renderTargetsEnabled: boolean;
  40048. /**
  40049. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40050. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40051. */
  40052. dumpNextRenderTargets: boolean;
  40053. /**
  40054. * The list of user defined render targets added to the scene
  40055. */
  40056. customRenderTargets: RenderTargetTexture[];
  40057. /**
  40058. * Defines if texture loading must be delayed
  40059. * If true, textures will only be loaded when they need to be rendered
  40060. */
  40061. useDelayedTextureLoading: boolean;
  40062. /**
  40063. * Gets the list of meshes imported to the scene through SceneLoader
  40064. */
  40065. importedMeshesFiles: String[];
  40066. /**
  40067. * Gets or sets a boolean indicating if probes are enabled on this scene
  40068. */
  40069. probesEnabled: boolean;
  40070. /**
  40071. * Gets or sets the current offline provider to use to store scene data
  40072. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40073. */
  40074. offlineProvider: IOfflineProvider;
  40075. /**
  40076. * Gets or sets the action manager associated with the scene
  40077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40078. */
  40079. actionManager: AbstractActionManager;
  40080. private _meshesForIntersections;
  40081. /**
  40082. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40083. */
  40084. proceduralTexturesEnabled: boolean;
  40085. private _engine;
  40086. private _totalVertices;
  40087. /** @hidden */
  40088. _activeIndices: PerfCounter;
  40089. /** @hidden */
  40090. _activeParticles: PerfCounter;
  40091. /** @hidden */
  40092. _activeBones: PerfCounter;
  40093. private _animationRatio;
  40094. /** @hidden */
  40095. _animationTimeLast: number;
  40096. /** @hidden */
  40097. _animationTime: number;
  40098. /**
  40099. * Gets or sets a general scale for animation speed
  40100. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40101. */
  40102. animationTimeScale: number;
  40103. /** @hidden */
  40104. _cachedMaterial: Nullable<Material>;
  40105. /** @hidden */
  40106. _cachedEffect: Nullable<Effect>;
  40107. /** @hidden */
  40108. _cachedVisibility: Nullable<number>;
  40109. private _renderId;
  40110. private _frameId;
  40111. private _executeWhenReadyTimeoutId;
  40112. private _intermediateRendering;
  40113. private _viewUpdateFlag;
  40114. private _projectionUpdateFlag;
  40115. /** @hidden */
  40116. _toBeDisposed: Nullable<IDisposable>[];
  40117. private _activeRequests;
  40118. /** @hidden */
  40119. _pendingData: any[];
  40120. private _isDisposed;
  40121. /**
  40122. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40123. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40124. */
  40125. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40126. private _activeMeshes;
  40127. private _processedMaterials;
  40128. private _renderTargets;
  40129. /** @hidden */
  40130. _activeParticleSystems: SmartArray<IParticleSystem>;
  40131. private _activeSkeletons;
  40132. private _softwareSkinnedMeshes;
  40133. private _renderingManager;
  40134. /** @hidden */
  40135. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40136. private _transformMatrix;
  40137. private _sceneUbo;
  40138. /** @hidden */
  40139. _viewMatrix: Matrix;
  40140. private _projectionMatrix;
  40141. /** @hidden */
  40142. _forcedViewPosition: Nullable<Vector3>;
  40143. /** @hidden */
  40144. _frustumPlanes: Plane[];
  40145. /**
  40146. * Gets the list of frustum planes (built from the active camera)
  40147. */
  40148. get frustumPlanes(): Plane[];
  40149. /**
  40150. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40151. * This is useful if there are more lights that the maximum simulteanous authorized
  40152. */
  40153. requireLightSorting: boolean;
  40154. /** @hidden */
  40155. readonly useMaterialMeshMap: boolean;
  40156. /** @hidden */
  40157. readonly useClonedMeshMap: boolean;
  40158. private _externalData;
  40159. private _uid;
  40160. /**
  40161. * @hidden
  40162. * Backing store of defined scene components.
  40163. */
  40164. _components: ISceneComponent[];
  40165. /**
  40166. * @hidden
  40167. * Backing store of defined scene components.
  40168. */
  40169. _serializableComponents: ISceneSerializableComponent[];
  40170. /**
  40171. * List of components to register on the next registration step.
  40172. */
  40173. private _transientComponents;
  40174. /**
  40175. * Registers the transient components if needed.
  40176. */
  40177. private _registerTransientComponents;
  40178. /**
  40179. * @hidden
  40180. * Add a component to the scene.
  40181. * Note that the ccomponent could be registered on th next frame if this is called after
  40182. * the register component stage.
  40183. * @param component Defines the component to add to the scene
  40184. */
  40185. _addComponent(component: ISceneComponent): void;
  40186. /**
  40187. * @hidden
  40188. * Gets a component from the scene.
  40189. * @param name defines the name of the component to retrieve
  40190. * @returns the component or null if not present
  40191. */
  40192. _getComponent(name: string): Nullable<ISceneComponent>;
  40193. /**
  40194. * @hidden
  40195. * Defines the actions happening before camera updates.
  40196. */
  40197. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40198. /**
  40199. * @hidden
  40200. * Defines the actions happening before clear the canvas.
  40201. */
  40202. _beforeClearStage: Stage<SimpleStageAction>;
  40203. /**
  40204. * @hidden
  40205. * Defines the actions when collecting render targets for the frame.
  40206. */
  40207. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40208. /**
  40209. * @hidden
  40210. * Defines the actions happening for one camera in the frame.
  40211. */
  40212. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40213. /**
  40214. * @hidden
  40215. * Defines the actions happening during the per mesh ready checks.
  40216. */
  40217. _isReadyForMeshStage: Stage<MeshStageAction>;
  40218. /**
  40219. * @hidden
  40220. * Defines the actions happening before evaluate active mesh checks.
  40221. */
  40222. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40223. /**
  40224. * @hidden
  40225. * Defines the actions happening during the evaluate sub mesh checks.
  40226. */
  40227. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40228. /**
  40229. * @hidden
  40230. * Defines the actions happening during the active mesh stage.
  40231. */
  40232. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40233. /**
  40234. * @hidden
  40235. * Defines the actions happening during the per camera render target step.
  40236. */
  40237. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40238. /**
  40239. * @hidden
  40240. * Defines the actions happening just before the active camera is drawing.
  40241. */
  40242. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40243. /**
  40244. * @hidden
  40245. * Defines the actions happening just before a render target is drawing.
  40246. */
  40247. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40248. /**
  40249. * @hidden
  40250. * Defines the actions happening just before a rendering group is drawing.
  40251. */
  40252. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40253. /**
  40254. * @hidden
  40255. * Defines the actions happening just before a mesh is drawing.
  40256. */
  40257. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40258. /**
  40259. * @hidden
  40260. * Defines the actions happening just after a mesh has been drawn.
  40261. */
  40262. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40263. /**
  40264. * @hidden
  40265. * Defines the actions happening just after a rendering group has been drawn.
  40266. */
  40267. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40268. /**
  40269. * @hidden
  40270. * Defines the actions happening just after the active camera has been drawn.
  40271. */
  40272. _afterCameraDrawStage: Stage<CameraStageAction>;
  40273. /**
  40274. * @hidden
  40275. * Defines the actions happening just after a render target has been drawn.
  40276. */
  40277. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40278. /**
  40279. * @hidden
  40280. * Defines the actions happening just after rendering all cameras and computing intersections.
  40281. */
  40282. _afterRenderStage: Stage<SimpleStageAction>;
  40283. /**
  40284. * @hidden
  40285. * Defines the actions happening when a pointer move event happens.
  40286. */
  40287. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40288. /**
  40289. * @hidden
  40290. * Defines the actions happening when a pointer down event happens.
  40291. */
  40292. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40293. /**
  40294. * @hidden
  40295. * Defines the actions happening when a pointer up event happens.
  40296. */
  40297. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40298. /**
  40299. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40300. */
  40301. private geometriesByUniqueId;
  40302. /**
  40303. * Creates a new Scene
  40304. * @param engine defines the engine to use to render this scene
  40305. * @param options defines the scene options
  40306. */
  40307. constructor(engine: Engine, options?: SceneOptions);
  40308. /**
  40309. * Gets a string idenfifying the name of the class
  40310. * @returns "Scene" string
  40311. */
  40312. getClassName(): string;
  40313. private _defaultMeshCandidates;
  40314. /**
  40315. * @hidden
  40316. */
  40317. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40318. private _defaultSubMeshCandidates;
  40319. /**
  40320. * @hidden
  40321. */
  40322. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40323. /**
  40324. * Sets the default candidate providers for the scene.
  40325. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40326. * and getCollidingSubMeshCandidates to their default function
  40327. */
  40328. setDefaultCandidateProviders(): void;
  40329. /**
  40330. * Gets the mesh that is currently under the pointer
  40331. */
  40332. get meshUnderPointer(): Nullable<AbstractMesh>;
  40333. /**
  40334. * Gets or sets the current on-screen X position of the pointer
  40335. */
  40336. get pointerX(): number;
  40337. set pointerX(value: number);
  40338. /**
  40339. * Gets or sets the current on-screen Y position of the pointer
  40340. */
  40341. get pointerY(): number;
  40342. set pointerY(value: number);
  40343. /**
  40344. * Gets the cached material (ie. the latest rendered one)
  40345. * @returns the cached material
  40346. */
  40347. getCachedMaterial(): Nullable<Material>;
  40348. /**
  40349. * Gets the cached effect (ie. the latest rendered one)
  40350. * @returns the cached effect
  40351. */
  40352. getCachedEffect(): Nullable<Effect>;
  40353. /**
  40354. * Gets the cached visibility state (ie. the latest rendered one)
  40355. * @returns the cached visibility state
  40356. */
  40357. getCachedVisibility(): Nullable<number>;
  40358. /**
  40359. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40360. * @param material defines the current material
  40361. * @param effect defines the current effect
  40362. * @param visibility defines the current visibility state
  40363. * @returns true if one parameter is not cached
  40364. */
  40365. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40366. /**
  40367. * Gets the engine associated with the scene
  40368. * @returns an Engine
  40369. */
  40370. getEngine(): Engine;
  40371. /**
  40372. * Gets the total number of vertices rendered per frame
  40373. * @returns the total number of vertices rendered per frame
  40374. */
  40375. getTotalVertices(): number;
  40376. /**
  40377. * Gets the performance counter for total vertices
  40378. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40379. */
  40380. get totalVerticesPerfCounter(): PerfCounter;
  40381. /**
  40382. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40383. * @returns the total number of active indices rendered per frame
  40384. */
  40385. getActiveIndices(): number;
  40386. /**
  40387. * Gets the performance counter for active indices
  40388. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40389. */
  40390. get totalActiveIndicesPerfCounter(): PerfCounter;
  40391. /**
  40392. * Gets the total number of active particles rendered per frame
  40393. * @returns the total number of active particles rendered per frame
  40394. */
  40395. getActiveParticles(): number;
  40396. /**
  40397. * Gets the performance counter for active particles
  40398. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40399. */
  40400. get activeParticlesPerfCounter(): PerfCounter;
  40401. /**
  40402. * Gets the total number of active bones rendered per frame
  40403. * @returns the total number of active bones rendered per frame
  40404. */
  40405. getActiveBones(): number;
  40406. /**
  40407. * Gets the performance counter for active bones
  40408. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40409. */
  40410. get activeBonesPerfCounter(): PerfCounter;
  40411. /**
  40412. * Gets the array of active meshes
  40413. * @returns an array of AbstractMesh
  40414. */
  40415. getActiveMeshes(): SmartArray<AbstractMesh>;
  40416. /**
  40417. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40418. * @returns a number
  40419. */
  40420. getAnimationRatio(): number;
  40421. /**
  40422. * Gets an unique Id for the current render phase
  40423. * @returns a number
  40424. */
  40425. getRenderId(): number;
  40426. /**
  40427. * Gets an unique Id for the current frame
  40428. * @returns a number
  40429. */
  40430. getFrameId(): number;
  40431. /** Call this function if you want to manually increment the render Id*/
  40432. incrementRenderId(): void;
  40433. private _createUbo;
  40434. /**
  40435. * Use this method to simulate a pointer move on a mesh
  40436. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40437. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40438. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40439. * @returns the current scene
  40440. */
  40441. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40442. /**
  40443. * Use this method to simulate a pointer down on a mesh
  40444. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40445. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40446. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40447. * @returns the current scene
  40448. */
  40449. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40450. /**
  40451. * Use this method to simulate a pointer up on a mesh
  40452. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40453. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40454. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40455. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40456. * @returns the current scene
  40457. */
  40458. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40459. /**
  40460. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40461. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40462. * @returns true if the pointer was captured
  40463. */
  40464. isPointerCaptured(pointerId?: number): boolean;
  40465. /**
  40466. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40467. * @param attachUp defines if you want to attach events to pointerup
  40468. * @param attachDown defines if you want to attach events to pointerdown
  40469. * @param attachMove defines if you want to attach events to pointermove
  40470. */
  40471. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40472. /** Detaches all event handlers*/
  40473. detachControl(): void;
  40474. /**
  40475. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40476. * Delay loaded resources are not taking in account
  40477. * @return true if all required resources are ready
  40478. */
  40479. isReady(): boolean;
  40480. /** Resets all cached information relative to material (including effect and visibility) */
  40481. resetCachedMaterial(): void;
  40482. /**
  40483. * Registers a function to be called before every frame render
  40484. * @param func defines the function to register
  40485. */
  40486. registerBeforeRender(func: () => void): void;
  40487. /**
  40488. * Unregisters a function called before every frame render
  40489. * @param func defines the function to unregister
  40490. */
  40491. unregisterBeforeRender(func: () => void): void;
  40492. /**
  40493. * Registers a function to be called after every frame render
  40494. * @param func defines the function to register
  40495. */
  40496. registerAfterRender(func: () => void): void;
  40497. /**
  40498. * Unregisters a function called after every frame render
  40499. * @param func defines the function to unregister
  40500. */
  40501. unregisterAfterRender(func: () => void): void;
  40502. private _executeOnceBeforeRender;
  40503. /**
  40504. * The provided function will run before render once and will be disposed afterwards.
  40505. * A timeout delay can be provided so that the function will be executed in N ms.
  40506. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40507. * @param func The function to be executed.
  40508. * @param timeout optional delay in ms
  40509. */
  40510. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40511. /** @hidden */
  40512. _addPendingData(data: any): void;
  40513. /** @hidden */
  40514. _removePendingData(data: any): void;
  40515. /**
  40516. * Returns the number of items waiting to be loaded
  40517. * @returns the number of items waiting to be loaded
  40518. */
  40519. getWaitingItemsCount(): number;
  40520. /**
  40521. * Returns a boolean indicating if the scene is still loading data
  40522. */
  40523. get isLoading(): boolean;
  40524. /**
  40525. * Registers a function to be executed when the scene is ready
  40526. * @param {Function} func - the function to be executed
  40527. */
  40528. executeWhenReady(func: () => void): void;
  40529. /**
  40530. * Returns a promise that resolves when the scene is ready
  40531. * @returns A promise that resolves when the scene is ready
  40532. */
  40533. whenReadyAsync(): Promise<void>;
  40534. /** @hidden */
  40535. _checkIsReady(): void;
  40536. /**
  40537. * Gets all animatable attached to the scene
  40538. */
  40539. get animatables(): Animatable[];
  40540. /**
  40541. * Resets the last animation time frame.
  40542. * Useful to override when animations start running when loading a scene for the first time.
  40543. */
  40544. resetLastAnimationTimeFrame(): void;
  40545. /**
  40546. * Gets the current view matrix
  40547. * @returns a Matrix
  40548. */
  40549. getViewMatrix(): Matrix;
  40550. /**
  40551. * Gets the current projection matrix
  40552. * @returns a Matrix
  40553. */
  40554. getProjectionMatrix(): Matrix;
  40555. /**
  40556. * Gets the current transform matrix
  40557. * @returns a Matrix made of View * Projection
  40558. */
  40559. getTransformMatrix(): Matrix;
  40560. /**
  40561. * Sets the current transform matrix
  40562. * @param viewL defines the View matrix to use
  40563. * @param projectionL defines the Projection matrix to use
  40564. * @param viewR defines the right View matrix to use (if provided)
  40565. * @param projectionR defines the right Projection matrix to use (if provided)
  40566. */
  40567. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40568. /**
  40569. * Gets the uniform buffer used to store scene data
  40570. * @returns a UniformBuffer
  40571. */
  40572. getSceneUniformBuffer(): UniformBuffer;
  40573. /**
  40574. * Gets an unique (relatively to the current scene) Id
  40575. * @returns an unique number for the scene
  40576. */
  40577. getUniqueId(): number;
  40578. /**
  40579. * Add a mesh to the list of scene's meshes
  40580. * @param newMesh defines the mesh to add
  40581. * @param recursive if all child meshes should also be added to the scene
  40582. */
  40583. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40584. /**
  40585. * Remove a mesh for the list of scene's meshes
  40586. * @param toRemove defines the mesh to remove
  40587. * @param recursive if all child meshes should also be removed from the scene
  40588. * @returns the index where the mesh was in the mesh list
  40589. */
  40590. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40591. /**
  40592. * Add a transform node to the list of scene's transform nodes
  40593. * @param newTransformNode defines the transform node to add
  40594. */
  40595. addTransformNode(newTransformNode: TransformNode): void;
  40596. /**
  40597. * Remove a transform node for the list of scene's transform nodes
  40598. * @param toRemove defines the transform node to remove
  40599. * @returns the index where the transform node was in the transform node list
  40600. */
  40601. removeTransformNode(toRemove: TransformNode): number;
  40602. /**
  40603. * Remove a skeleton for the list of scene's skeletons
  40604. * @param toRemove defines the skeleton to remove
  40605. * @returns the index where the skeleton was in the skeleton list
  40606. */
  40607. removeSkeleton(toRemove: Skeleton): number;
  40608. /**
  40609. * Remove a morph target for the list of scene's morph targets
  40610. * @param toRemove defines the morph target to remove
  40611. * @returns the index where the morph target was in the morph target list
  40612. */
  40613. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40614. /**
  40615. * Remove a light for the list of scene's lights
  40616. * @param toRemove defines the light to remove
  40617. * @returns the index where the light was in the light list
  40618. */
  40619. removeLight(toRemove: Light): number;
  40620. /**
  40621. * Remove a camera for the list of scene's cameras
  40622. * @param toRemove defines the camera to remove
  40623. * @returns the index where the camera was in the camera list
  40624. */
  40625. removeCamera(toRemove: Camera): number;
  40626. /**
  40627. * Remove a particle system for the list of scene's particle systems
  40628. * @param toRemove defines the particle system to remove
  40629. * @returns the index where the particle system was in the particle system list
  40630. */
  40631. removeParticleSystem(toRemove: IParticleSystem): number;
  40632. /**
  40633. * Remove a animation for the list of scene's animations
  40634. * @param toRemove defines the animation to remove
  40635. * @returns the index where the animation was in the animation list
  40636. */
  40637. removeAnimation(toRemove: Animation): number;
  40638. /**
  40639. * Will stop the animation of the given target
  40640. * @param target - the target
  40641. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40642. * @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)
  40643. */
  40644. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40645. /**
  40646. * Removes the given animation group from this scene.
  40647. * @param toRemove The animation group to remove
  40648. * @returns The index of the removed animation group
  40649. */
  40650. removeAnimationGroup(toRemove: AnimationGroup): number;
  40651. /**
  40652. * Removes the given multi-material from this scene.
  40653. * @param toRemove The multi-material to remove
  40654. * @returns The index of the removed multi-material
  40655. */
  40656. removeMultiMaterial(toRemove: MultiMaterial): number;
  40657. /**
  40658. * Removes the given material from this scene.
  40659. * @param toRemove The material to remove
  40660. * @returns The index of the removed material
  40661. */
  40662. removeMaterial(toRemove: Material): number;
  40663. /**
  40664. * Removes the given action manager from this scene.
  40665. * @param toRemove The action manager to remove
  40666. * @returns The index of the removed action manager
  40667. */
  40668. removeActionManager(toRemove: AbstractActionManager): number;
  40669. /**
  40670. * Removes the given texture from this scene.
  40671. * @param toRemove The texture to remove
  40672. * @returns The index of the removed texture
  40673. */
  40674. removeTexture(toRemove: BaseTexture): number;
  40675. /**
  40676. * Adds the given light to this scene
  40677. * @param newLight The light to add
  40678. */
  40679. addLight(newLight: Light): void;
  40680. /**
  40681. * Sorts the list list based on light priorities
  40682. */
  40683. sortLightsByPriority(): void;
  40684. /**
  40685. * Adds the given camera to this scene
  40686. * @param newCamera The camera to add
  40687. */
  40688. addCamera(newCamera: Camera): void;
  40689. /**
  40690. * Adds the given skeleton to this scene
  40691. * @param newSkeleton The skeleton to add
  40692. */
  40693. addSkeleton(newSkeleton: Skeleton): void;
  40694. /**
  40695. * Adds the given particle system to this scene
  40696. * @param newParticleSystem The particle system to add
  40697. */
  40698. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40699. /**
  40700. * Adds the given animation to this scene
  40701. * @param newAnimation The animation to add
  40702. */
  40703. addAnimation(newAnimation: Animation): void;
  40704. /**
  40705. * Adds the given animation group to this scene.
  40706. * @param newAnimationGroup The animation group to add
  40707. */
  40708. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40709. /**
  40710. * Adds the given multi-material to this scene
  40711. * @param newMultiMaterial The multi-material to add
  40712. */
  40713. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40714. /**
  40715. * Adds the given material to this scene
  40716. * @param newMaterial The material to add
  40717. */
  40718. addMaterial(newMaterial: Material): void;
  40719. /**
  40720. * Adds the given morph target to this scene
  40721. * @param newMorphTargetManager The morph target to add
  40722. */
  40723. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40724. /**
  40725. * Adds the given geometry to this scene
  40726. * @param newGeometry The geometry to add
  40727. */
  40728. addGeometry(newGeometry: Geometry): void;
  40729. /**
  40730. * Adds the given action manager to this scene
  40731. * @param newActionManager The action manager to add
  40732. */
  40733. addActionManager(newActionManager: AbstractActionManager): void;
  40734. /**
  40735. * Adds the given texture to this scene.
  40736. * @param newTexture The texture to add
  40737. */
  40738. addTexture(newTexture: BaseTexture): void;
  40739. /**
  40740. * Switch active camera
  40741. * @param newCamera defines the new active camera
  40742. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40743. */
  40744. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40745. /**
  40746. * sets the active camera of the scene using its ID
  40747. * @param id defines the camera's ID
  40748. * @return the new active camera or null if none found.
  40749. */
  40750. setActiveCameraByID(id: string): Nullable<Camera>;
  40751. /**
  40752. * sets the active camera of the scene using its name
  40753. * @param name defines the camera's name
  40754. * @returns the new active camera or null if none found.
  40755. */
  40756. setActiveCameraByName(name: string): Nullable<Camera>;
  40757. /**
  40758. * get an animation group using its name
  40759. * @param name defines the material's name
  40760. * @return the animation group or null if none found.
  40761. */
  40762. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40763. /**
  40764. * Get a material using its unique id
  40765. * @param uniqueId defines the material's unique id
  40766. * @return the material or null if none found.
  40767. */
  40768. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40769. /**
  40770. * get a material using its id
  40771. * @param id defines the material's ID
  40772. * @return the material or null if none found.
  40773. */
  40774. getMaterialByID(id: string): Nullable<Material>;
  40775. /**
  40776. * Gets a the last added material using a given id
  40777. * @param id defines the material's ID
  40778. * @return the last material with the given id or null if none found.
  40779. */
  40780. getLastMaterialByID(id: string): Nullable<Material>;
  40781. /**
  40782. * Gets a material using its name
  40783. * @param name defines the material's name
  40784. * @return the material or null if none found.
  40785. */
  40786. getMaterialByName(name: string): Nullable<Material>;
  40787. /**
  40788. * Get a texture using its unique id
  40789. * @param uniqueId defines the texture's unique id
  40790. * @return the texture or null if none found.
  40791. */
  40792. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40793. /**
  40794. * Gets a camera using its id
  40795. * @param id defines the id to look for
  40796. * @returns the camera or null if not found
  40797. */
  40798. getCameraByID(id: string): Nullable<Camera>;
  40799. /**
  40800. * Gets a camera using its unique id
  40801. * @param uniqueId defines the unique id to look for
  40802. * @returns the camera or null if not found
  40803. */
  40804. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40805. /**
  40806. * Gets a camera using its name
  40807. * @param name defines the camera's name
  40808. * @return the camera or null if none found.
  40809. */
  40810. getCameraByName(name: string): Nullable<Camera>;
  40811. /**
  40812. * Gets a bone using its id
  40813. * @param id defines the bone's id
  40814. * @return the bone or null if not found
  40815. */
  40816. getBoneByID(id: string): Nullable<Bone>;
  40817. /**
  40818. * Gets a bone using its id
  40819. * @param name defines the bone's name
  40820. * @return the bone or null if not found
  40821. */
  40822. getBoneByName(name: string): Nullable<Bone>;
  40823. /**
  40824. * Gets a light node using its name
  40825. * @param name defines the the light's name
  40826. * @return the light or null if none found.
  40827. */
  40828. getLightByName(name: string): Nullable<Light>;
  40829. /**
  40830. * Gets a light node using its id
  40831. * @param id defines the light's id
  40832. * @return the light or null if none found.
  40833. */
  40834. getLightByID(id: string): Nullable<Light>;
  40835. /**
  40836. * Gets a light node using its scene-generated unique ID
  40837. * @param uniqueId defines the light's unique id
  40838. * @return the light or null if none found.
  40839. */
  40840. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40841. /**
  40842. * Gets a particle system by id
  40843. * @param id defines the particle system id
  40844. * @return the corresponding system or null if none found
  40845. */
  40846. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40847. /**
  40848. * Gets a geometry using its ID
  40849. * @param id defines the geometry's id
  40850. * @return the geometry or null if none found.
  40851. */
  40852. getGeometryByID(id: string): Nullable<Geometry>;
  40853. private _getGeometryByUniqueID;
  40854. /**
  40855. * Add a new geometry to this scene
  40856. * @param geometry defines the geometry to be added to the scene.
  40857. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40858. * @return a boolean defining if the geometry was added or not
  40859. */
  40860. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40861. /**
  40862. * Removes an existing geometry
  40863. * @param geometry defines the geometry to be removed from the scene
  40864. * @return a boolean defining if the geometry was removed or not
  40865. */
  40866. removeGeometry(geometry: Geometry): boolean;
  40867. /**
  40868. * Gets the list of geometries attached to the scene
  40869. * @returns an array of Geometry
  40870. */
  40871. getGeometries(): Geometry[];
  40872. /**
  40873. * Gets the first added mesh found of a given ID
  40874. * @param id defines the id to search for
  40875. * @return the mesh found or null if not found at all
  40876. */
  40877. getMeshByID(id: string): Nullable<AbstractMesh>;
  40878. /**
  40879. * Gets a list of meshes using their id
  40880. * @param id defines the id to search for
  40881. * @returns a list of meshes
  40882. */
  40883. getMeshesByID(id: string): Array<AbstractMesh>;
  40884. /**
  40885. * Gets the first added transform node found of a given ID
  40886. * @param id defines the id to search for
  40887. * @return the found transform node or null if not found at all.
  40888. */
  40889. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40890. /**
  40891. * Gets a transform node with its auto-generated unique id
  40892. * @param uniqueId efines the unique id to search for
  40893. * @return the found transform node or null if not found at all.
  40894. */
  40895. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40896. /**
  40897. * Gets a list of transform nodes using their id
  40898. * @param id defines the id to search for
  40899. * @returns a list of transform nodes
  40900. */
  40901. getTransformNodesByID(id: string): Array<TransformNode>;
  40902. /**
  40903. * Gets a mesh with its auto-generated unique id
  40904. * @param uniqueId defines the unique id to search for
  40905. * @return the found mesh or null if not found at all.
  40906. */
  40907. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40908. /**
  40909. * Gets a the last added mesh using a given id
  40910. * @param id defines the id to search for
  40911. * @return the found mesh or null if not found at all.
  40912. */
  40913. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40914. /**
  40915. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40916. * @param id defines the id to search for
  40917. * @return the found node or null if not found at all
  40918. */
  40919. getLastEntryByID(id: string): Nullable<Node>;
  40920. /**
  40921. * Gets a node (Mesh, Camera, Light) using a given id
  40922. * @param id defines the id to search for
  40923. * @return the found node or null if not found at all
  40924. */
  40925. getNodeByID(id: string): Nullable<Node>;
  40926. /**
  40927. * Gets a node (Mesh, Camera, Light) using a given name
  40928. * @param name defines the name to search for
  40929. * @return the found node or null if not found at all.
  40930. */
  40931. getNodeByName(name: string): Nullable<Node>;
  40932. /**
  40933. * Gets a mesh using a given name
  40934. * @param name defines the name to search for
  40935. * @return the found mesh or null if not found at all.
  40936. */
  40937. getMeshByName(name: string): Nullable<AbstractMesh>;
  40938. /**
  40939. * Gets a transform node using a given name
  40940. * @param name defines the name to search for
  40941. * @return the found transform node or null if not found at all.
  40942. */
  40943. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40944. /**
  40945. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40946. * @param id defines the id to search for
  40947. * @return the found skeleton or null if not found at all.
  40948. */
  40949. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40950. /**
  40951. * Gets a skeleton using a given auto generated unique id
  40952. * @param uniqueId defines the unique id to search for
  40953. * @return the found skeleton or null if not found at all.
  40954. */
  40955. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40956. /**
  40957. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40958. * @param id defines the id to search for
  40959. * @return the found skeleton or null if not found at all.
  40960. */
  40961. getSkeletonById(id: string): Nullable<Skeleton>;
  40962. /**
  40963. * Gets a skeleton using a given name
  40964. * @param name defines the name to search for
  40965. * @return the found skeleton or null if not found at all.
  40966. */
  40967. getSkeletonByName(name: string): Nullable<Skeleton>;
  40968. /**
  40969. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40970. * @param id defines the id to search for
  40971. * @return the found morph target manager or null if not found at all.
  40972. */
  40973. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40974. /**
  40975. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40976. * @param id defines the id to search for
  40977. * @return the found morph target or null if not found at all.
  40978. */
  40979. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40980. /**
  40981. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40982. * @param name defines the name to search for
  40983. * @return the found morph target or null if not found at all.
  40984. */
  40985. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40986. /**
  40987. * Gets a boolean indicating if the given mesh is active
  40988. * @param mesh defines the mesh to look for
  40989. * @returns true if the mesh is in the active list
  40990. */
  40991. isActiveMesh(mesh: AbstractMesh): boolean;
  40992. /**
  40993. * Return a unique id as a string which can serve as an identifier for the scene
  40994. */
  40995. get uid(): string;
  40996. /**
  40997. * Add an externaly attached data from its key.
  40998. * This method call will fail and return false, if such key already exists.
  40999. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41000. * @param key the unique key that identifies the data
  41001. * @param data the data object to associate to the key for this Engine instance
  41002. * @return true if no such key were already present and the data was added successfully, false otherwise
  41003. */
  41004. addExternalData<T>(key: string, data: T): boolean;
  41005. /**
  41006. * Get an externaly attached data from its key
  41007. * @param key the unique key that identifies the data
  41008. * @return the associated data, if present (can be null), or undefined if not present
  41009. */
  41010. getExternalData<T>(key: string): Nullable<T>;
  41011. /**
  41012. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41013. * @param key the unique key that identifies the data
  41014. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41015. * @return the associated data, can be null if the factory returned null.
  41016. */
  41017. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41018. /**
  41019. * Remove an externaly attached data from the Engine instance
  41020. * @param key the unique key that identifies the data
  41021. * @return true if the data was successfully removed, false if it doesn't exist
  41022. */
  41023. removeExternalData(key: string): boolean;
  41024. private _evaluateSubMesh;
  41025. /**
  41026. * Clear the processed materials smart array preventing retention point in material dispose.
  41027. */
  41028. freeProcessedMaterials(): void;
  41029. private _preventFreeActiveMeshesAndRenderingGroups;
  41030. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41031. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41032. * when disposing several meshes in a row or a hierarchy of meshes.
  41033. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41034. */
  41035. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41036. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41037. /**
  41038. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41039. */
  41040. freeActiveMeshes(): void;
  41041. /**
  41042. * Clear the info related to rendering groups preventing retention points during dispose.
  41043. */
  41044. freeRenderingGroups(): void;
  41045. /** @hidden */
  41046. _isInIntermediateRendering(): boolean;
  41047. /**
  41048. * Lambda returning the list of potentially active meshes.
  41049. */
  41050. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41051. /**
  41052. * Lambda returning the list of potentially active sub meshes.
  41053. */
  41054. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41055. /**
  41056. * Lambda returning the list of potentially intersecting sub meshes.
  41057. */
  41058. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41059. /**
  41060. * Lambda returning the list of potentially colliding sub meshes.
  41061. */
  41062. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41063. private _activeMeshesFrozen;
  41064. private _skipEvaluateActiveMeshesCompletely;
  41065. /**
  41066. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41067. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41068. * @returns the current scene
  41069. */
  41070. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41071. /**
  41072. * Use this function to restart evaluating active meshes on every frame
  41073. * @returns the current scene
  41074. */
  41075. unfreezeActiveMeshes(): Scene;
  41076. private _evaluateActiveMeshes;
  41077. private _activeMesh;
  41078. /**
  41079. * Update the transform matrix to update from the current active camera
  41080. * @param force defines a boolean used to force the update even if cache is up to date
  41081. */
  41082. updateTransformMatrix(force?: boolean): void;
  41083. private _bindFrameBuffer;
  41084. /** @hidden */
  41085. _allowPostProcessClearColor: boolean;
  41086. /** @hidden */
  41087. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41088. private _processSubCameras;
  41089. private _checkIntersections;
  41090. /** @hidden */
  41091. _advancePhysicsEngineStep(step: number): void;
  41092. /**
  41093. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41094. */
  41095. getDeterministicFrameTime: () => number;
  41096. /** @hidden */
  41097. _animate(): void;
  41098. /** Execute all animations (for a frame) */
  41099. animate(): void;
  41100. /**
  41101. * Render the scene
  41102. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41103. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41104. */
  41105. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41106. /**
  41107. * Freeze all materials
  41108. * A frozen material will not be updatable but should be faster to render
  41109. */
  41110. freezeMaterials(): void;
  41111. /**
  41112. * Unfreeze all materials
  41113. * A frozen material will not be updatable but should be faster to render
  41114. */
  41115. unfreezeMaterials(): void;
  41116. /**
  41117. * Releases all held ressources
  41118. */
  41119. dispose(): void;
  41120. /**
  41121. * Gets if the scene is already disposed
  41122. */
  41123. get isDisposed(): boolean;
  41124. /**
  41125. * Call this function to reduce memory footprint of the scene.
  41126. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41127. */
  41128. clearCachedVertexData(): void;
  41129. /**
  41130. * This function will remove the local cached buffer data from texture.
  41131. * It will save memory but will prevent the texture from being rebuilt
  41132. */
  41133. cleanCachedTextureBuffer(): void;
  41134. /**
  41135. * Get the world extend vectors with an optional filter
  41136. *
  41137. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41138. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41139. */
  41140. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41141. min: Vector3;
  41142. max: Vector3;
  41143. };
  41144. /**
  41145. * Creates a ray that can be used to pick in the scene
  41146. * @param x defines the x coordinate of the origin (on-screen)
  41147. * @param y defines the y coordinate of the origin (on-screen)
  41148. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41149. * @param camera defines the camera to use for the picking
  41150. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41151. * @returns a Ray
  41152. */
  41153. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41154. /**
  41155. * Creates a ray that can be used to pick in the scene
  41156. * @param x defines the x coordinate of the origin (on-screen)
  41157. * @param y defines the y coordinate of the origin (on-screen)
  41158. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41159. * @param result defines the ray where to store the picking ray
  41160. * @param camera defines the camera to use for the picking
  41161. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41162. * @returns the current scene
  41163. */
  41164. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41165. /**
  41166. * Creates a ray that can be used to pick in the scene
  41167. * @param x defines the x coordinate of the origin (on-screen)
  41168. * @param y defines the y coordinate of the origin (on-screen)
  41169. * @param camera defines the camera to use for the picking
  41170. * @returns a Ray
  41171. */
  41172. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41173. /**
  41174. * Creates a ray that can be used to pick in the scene
  41175. * @param x defines the x coordinate of the origin (on-screen)
  41176. * @param y defines the y coordinate of the origin (on-screen)
  41177. * @param result defines the ray where to store the picking ray
  41178. * @param camera defines the camera to use for the picking
  41179. * @returns the current scene
  41180. */
  41181. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41182. /** Launch a ray to try to pick a mesh in the scene
  41183. * @param x position on screen
  41184. * @param y position on screen
  41185. * @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
  41186. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41187. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41188. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41189. * @returns a PickingInfo
  41190. */
  41191. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41192. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41193. * @param x position on screen
  41194. * @param y position on screen
  41195. * @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
  41196. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41197. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41198. * @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)
  41199. */
  41200. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41201. /** Use the given ray to pick a mesh in the scene
  41202. * @param ray The ray to use to pick meshes
  41203. * @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
  41204. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41205. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41206. * @returns a PickingInfo
  41207. */
  41208. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41209. /**
  41210. * Launch a ray to try to pick a mesh in the scene
  41211. * @param x X position on screen
  41212. * @param y Y position on screen
  41213. * @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
  41214. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41215. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41216. * @returns an array of PickingInfo
  41217. */
  41218. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41219. /**
  41220. * Launch a ray to try to pick a mesh in the scene
  41221. * @param ray Ray to use
  41222. * @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
  41223. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41224. * @returns an array of PickingInfo
  41225. */
  41226. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41227. /**
  41228. * Force the value of meshUnderPointer
  41229. * @param mesh defines the mesh to use
  41230. */
  41231. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41232. /**
  41233. * Gets the mesh under the pointer
  41234. * @returns a Mesh or null if no mesh is under the pointer
  41235. */
  41236. getPointerOverMesh(): Nullable<AbstractMesh>;
  41237. /** @hidden */
  41238. _rebuildGeometries(): void;
  41239. /** @hidden */
  41240. _rebuildTextures(): void;
  41241. private _getByTags;
  41242. /**
  41243. * Get a list of meshes by tags
  41244. * @param tagsQuery defines the tags query to use
  41245. * @param forEach defines a predicate used to filter results
  41246. * @returns an array of Mesh
  41247. */
  41248. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41249. /**
  41250. * Get a list of cameras by tags
  41251. * @param tagsQuery defines the tags query to use
  41252. * @param forEach defines a predicate used to filter results
  41253. * @returns an array of Camera
  41254. */
  41255. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41256. /**
  41257. * Get a list of lights by tags
  41258. * @param tagsQuery defines the tags query to use
  41259. * @param forEach defines a predicate used to filter results
  41260. * @returns an array of Light
  41261. */
  41262. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41263. /**
  41264. * Get a list of materials by tags
  41265. * @param tagsQuery defines the tags query to use
  41266. * @param forEach defines a predicate used to filter results
  41267. * @returns an array of Material
  41268. */
  41269. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41270. /**
  41271. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41272. * This allowed control for front to back rendering or reversly depending of the special needs.
  41273. *
  41274. * @param renderingGroupId The rendering group id corresponding to its index
  41275. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41276. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41277. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41278. */
  41279. 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;
  41280. /**
  41281. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41282. *
  41283. * @param renderingGroupId The rendering group id corresponding to its index
  41284. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41285. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41286. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41287. */
  41288. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41289. /**
  41290. * Gets the current auto clear configuration for one rendering group of the rendering
  41291. * manager.
  41292. * @param index the rendering group index to get the information for
  41293. * @returns The auto clear setup for the requested rendering group
  41294. */
  41295. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41296. private _blockMaterialDirtyMechanism;
  41297. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41298. get blockMaterialDirtyMechanism(): boolean;
  41299. set blockMaterialDirtyMechanism(value: boolean);
  41300. /**
  41301. * Will flag all materials as dirty to trigger new shader compilation
  41302. * @param flag defines the flag used to specify which material part must be marked as dirty
  41303. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41304. */
  41305. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41306. /** @hidden */
  41307. _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;
  41308. /** @hidden */
  41309. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41310. /** @hidden */
  41311. _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;
  41312. /** @hidden */
  41313. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41314. /** @hidden */
  41315. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41316. /** @hidden */
  41317. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41318. }
  41319. }
  41320. declare module "babylonjs/assetContainer" {
  41321. import { AbstractScene } from "babylonjs/abstractScene";
  41322. import { Scene } from "babylonjs/scene";
  41323. import { Mesh } from "babylonjs/Meshes/mesh";
  41324. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41325. import { Skeleton } from "babylonjs/Bones/skeleton";
  41326. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41327. import { Animatable } from "babylonjs/Animations/animatable";
  41328. import { Nullable } from "babylonjs/types";
  41329. import { Node } from "babylonjs/node";
  41330. /**
  41331. * Set of assets to keep when moving a scene into an asset container.
  41332. */
  41333. export class KeepAssets extends AbstractScene {
  41334. }
  41335. /**
  41336. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41337. */
  41338. export class InstantiatedEntries {
  41339. /**
  41340. * List of new root nodes (eg. nodes with no parent)
  41341. */
  41342. rootNodes: TransformNode[];
  41343. /**
  41344. * List of new skeletons
  41345. */
  41346. skeletons: Skeleton[];
  41347. /**
  41348. * List of new animation groups
  41349. */
  41350. animationGroups: AnimationGroup[];
  41351. }
  41352. /**
  41353. * Container with a set of assets that can be added or removed from a scene.
  41354. */
  41355. export class AssetContainer extends AbstractScene {
  41356. private _wasAddedToScene;
  41357. /**
  41358. * The scene the AssetContainer belongs to.
  41359. */
  41360. scene: Scene;
  41361. /**
  41362. * Instantiates an AssetContainer.
  41363. * @param scene The scene the AssetContainer belongs to.
  41364. */
  41365. constructor(scene: Scene);
  41366. /**
  41367. * Instantiate or clone all meshes and add the new ones to the scene.
  41368. * Skeletons and animation groups will all be cloned
  41369. * @param nameFunction defines an optional function used to get new names for clones
  41370. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41371. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41372. */
  41373. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41374. /**
  41375. * Adds all the assets from the container to the scene.
  41376. */
  41377. addAllToScene(): void;
  41378. /**
  41379. * Removes all the assets in the container from the scene
  41380. */
  41381. removeAllFromScene(): void;
  41382. /**
  41383. * Disposes all the assets in the container
  41384. */
  41385. dispose(): void;
  41386. private _moveAssets;
  41387. /**
  41388. * Removes all the assets contained in the scene and adds them to the container.
  41389. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41390. */
  41391. moveAllFromScene(keepAssets?: KeepAssets): void;
  41392. /**
  41393. * 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.
  41394. * @returns the root mesh
  41395. */
  41396. createRootMesh(): Mesh;
  41397. /**
  41398. * Merge animations (direct and animation groups) from this asset container into a scene
  41399. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41400. * @param animatables set of animatables to retarget to a node from the scene
  41401. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41402. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41403. */
  41404. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41405. }
  41406. }
  41407. declare module "babylonjs/abstractScene" {
  41408. import { Scene } from "babylonjs/scene";
  41409. import { Nullable } from "babylonjs/types";
  41410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41411. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41412. import { Geometry } from "babylonjs/Meshes/geometry";
  41413. import { Skeleton } from "babylonjs/Bones/skeleton";
  41414. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41415. import { AssetContainer } from "babylonjs/assetContainer";
  41416. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41417. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41418. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41419. import { Material } from "babylonjs/Materials/material";
  41420. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41421. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41422. import { Camera } from "babylonjs/Cameras/camera";
  41423. import { Light } from "babylonjs/Lights/light";
  41424. import { Node } from "babylonjs/node";
  41425. import { Animation } from "babylonjs/Animations/animation";
  41426. /**
  41427. * Defines how the parser contract is defined.
  41428. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41429. */
  41430. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41431. /**
  41432. * Defines how the individual parser contract is defined.
  41433. * These parser can parse an individual asset
  41434. */
  41435. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41436. /**
  41437. * Base class of the scene acting as a container for the different elements composing a scene.
  41438. * This class is dynamically extended by the different components of the scene increasing
  41439. * flexibility and reducing coupling
  41440. */
  41441. export abstract class AbstractScene {
  41442. /**
  41443. * Stores the list of available parsers in the application.
  41444. */
  41445. private static _BabylonFileParsers;
  41446. /**
  41447. * Stores the list of available individual parsers in the application.
  41448. */
  41449. private static _IndividualBabylonFileParsers;
  41450. /**
  41451. * Adds a parser in the list of available ones
  41452. * @param name Defines the name of the parser
  41453. * @param parser Defines the parser to add
  41454. */
  41455. static AddParser(name: string, parser: BabylonFileParser): void;
  41456. /**
  41457. * Gets a general parser from the list of avaialble ones
  41458. * @param name Defines the name of the parser
  41459. * @returns the requested parser or null
  41460. */
  41461. static GetParser(name: string): Nullable<BabylonFileParser>;
  41462. /**
  41463. * Adds n individual parser in the list of available ones
  41464. * @param name Defines the name of the parser
  41465. * @param parser Defines the parser to add
  41466. */
  41467. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41468. /**
  41469. * Gets an individual parser from the list of avaialble ones
  41470. * @param name Defines the name of the parser
  41471. * @returns the requested parser or null
  41472. */
  41473. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41474. /**
  41475. * Parser json data and populate both a scene and its associated container object
  41476. * @param jsonData Defines the data to parse
  41477. * @param scene Defines the scene to parse the data for
  41478. * @param container Defines the container attached to the parsing sequence
  41479. * @param rootUrl Defines the root url of the data
  41480. */
  41481. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41482. /**
  41483. * Gets the list of root nodes (ie. nodes with no parent)
  41484. */
  41485. rootNodes: Node[];
  41486. /** All of the cameras added to this scene
  41487. * @see http://doc.babylonjs.com/babylon101/cameras
  41488. */
  41489. cameras: Camera[];
  41490. /**
  41491. * All of the lights added to this scene
  41492. * @see http://doc.babylonjs.com/babylon101/lights
  41493. */
  41494. lights: Light[];
  41495. /**
  41496. * All of the (abstract) meshes added to this scene
  41497. */
  41498. meshes: AbstractMesh[];
  41499. /**
  41500. * The list of skeletons added to the scene
  41501. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41502. */
  41503. skeletons: Skeleton[];
  41504. /**
  41505. * All of the particle systems added to this scene
  41506. * @see http://doc.babylonjs.com/babylon101/particles
  41507. */
  41508. particleSystems: IParticleSystem[];
  41509. /**
  41510. * Gets a list of Animations associated with the scene
  41511. */
  41512. animations: Animation[];
  41513. /**
  41514. * All of the animation groups added to this scene
  41515. * @see http://doc.babylonjs.com/how_to/group
  41516. */
  41517. animationGroups: AnimationGroup[];
  41518. /**
  41519. * All of the multi-materials added to this scene
  41520. * @see http://doc.babylonjs.com/how_to/multi_materials
  41521. */
  41522. multiMaterials: MultiMaterial[];
  41523. /**
  41524. * All of the materials added to this scene
  41525. * In the context of a Scene, it is not supposed to be modified manually.
  41526. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41527. * Note also that the order of the Material within the array is not significant and might change.
  41528. * @see http://doc.babylonjs.com/babylon101/materials
  41529. */
  41530. materials: Material[];
  41531. /**
  41532. * The list of morph target managers added to the scene
  41533. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41534. */
  41535. morphTargetManagers: MorphTargetManager[];
  41536. /**
  41537. * The list of geometries used in the scene.
  41538. */
  41539. geometries: Geometry[];
  41540. /**
  41541. * All of the tranform nodes added to this scene
  41542. * In the context of a Scene, it is not supposed to be modified manually.
  41543. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41544. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41545. * @see http://doc.babylonjs.com/how_to/transformnode
  41546. */
  41547. transformNodes: TransformNode[];
  41548. /**
  41549. * ActionManagers available on the scene.
  41550. */
  41551. actionManagers: AbstractActionManager[];
  41552. /**
  41553. * Textures to keep.
  41554. */
  41555. textures: BaseTexture[];
  41556. /**
  41557. * Environment texture for the scene
  41558. */
  41559. environmentTexture: Nullable<BaseTexture>;
  41560. /**
  41561. * @returns all meshes, lights, cameras, transformNodes and bones
  41562. */
  41563. getNodes(): Array<Node>;
  41564. }
  41565. }
  41566. declare module "babylonjs/Audio/sound" {
  41567. import { Observable } from "babylonjs/Misc/observable";
  41568. import { Vector3 } from "babylonjs/Maths/math.vector";
  41569. import { Nullable } from "babylonjs/types";
  41570. import { Scene } from "babylonjs/scene";
  41571. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41572. /**
  41573. * Interface used to define options for Sound class
  41574. */
  41575. export interface ISoundOptions {
  41576. /**
  41577. * Does the sound autoplay once loaded.
  41578. */
  41579. autoplay?: boolean;
  41580. /**
  41581. * Does the sound loop after it finishes playing once.
  41582. */
  41583. loop?: boolean;
  41584. /**
  41585. * Sound's volume
  41586. */
  41587. volume?: number;
  41588. /**
  41589. * Is it a spatial sound?
  41590. */
  41591. spatialSound?: boolean;
  41592. /**
  41593. * Maximum distance to hear that sound
  41594. */
  41595. maxDistance?: number;
  41596. /**
  41597. * Uses user defined attenuation function
  41598. */
  41599. useCustomAttenuation?: boolean;
  41600. /**
  41601. * Define the roll off factor of spatial sounds.
  41602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41603. */
  41604. rolloffFactor?: number;
  41605. /**
  41606. * Define the reference distance the sound should be heard perfectly.
  41607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41608. */
  41609. refDistance?: number;
  41610. /**
  41611. * Define the distance attenuation model the sound will follow.
  41612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41613. */
  41614. distanceModel?: string;
  41615. /**
  41616. * Defines the playback speed (1 by default)
  41617. */
  41618. playbackRate?: number;
  41619. /**
  41620. * Defines if the sound is from a streaming source
  41621. */
  41622. streaming?: boolean;
  41623. /**
  41624. * Defines an optional length (in seconds) inside the sound file
  41625. */
  41626. length?: number;
  41627. /**
  41628. * Defines an optional offset (in seconds) inside the sound file
  41629. */
  41630. offset?: number;
  41631. /**
  41632. * If true, URLs will not be required to state the audio file codec to use.
  41633. */
  41634. skipCodecCheck?: boolean;
  41635. }
  41636. /**
  41637. * Defines a sound that can be played in the application.
  41638. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41640. */
  41641. export class Sound {
  41642. /**
  41643. * The name of the sound in the scene.
  41644. */
  41645. name: string;
  41646. /**
  41647. * Does the sound autoplay once loaded.
  41648. */
  41649. autoplay: boolean;
  41650. /**
  41651. * Does the sound loop after it finishes playing once.
  41652. */
  41653. loop: boolean;
  41654. /**
  41655. * Does the sound use a custom attenuation curve to simulate the falloff
  41656. * happening when the source gets further away from the camera.
  41657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41658. */
  41659. useCustomAttenuation: boolean;
  41660. /**
  41661. * The sound track id this sound belongs to.
  41662. */
  41663. soundTrackId: number;
  41664. /**
  41665. * Is this sound currently played.
  41666. */
  41667. isPlaying: boolean;
  41668. /**
  41669. * Is this sound currently paused.
  41670. */
  41671. isPaused: boolean;
  41672. /**
  41673. * Does this sound enables spatial sound.
  41674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41675. */
  41676. spatialSound: boolean;
  41677. /**
  41678. * Define the reference distance the sound should be heard perfectly.
  41679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41680. */
  41681. refDistance: number;
  41682. /**
  41683. * Define the roll off factor of spatial sounds.
  41684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41685. */
  41686. rolloffFactor: number;
  41687. /**
  41688. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41690. */
  41691. maxDistance: number;
  41692. /**
  41693. * Define the distance attenuation model the sound will follow.
  41694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41695. */
  41696. distanceModel: string;
  41697. /**
  41698. * @hidden
  41699. * Back Compat
  41700. **/
  41701. onended: () => any;
  41702. /**
  41703. * Gets or sets an object used to store user defined information for the sound.
  41704. */
  41705. metadata: any;
  41706. /**
  41707. * Observable event when the current playing sound finishes.
  41708. */
  41709. onEndedObservable: Observable<Sound>;
  41710. private _panningModel;
  41711. private _playbackRate;
  41712. private _streaming;
  41713. private _startTime;
  41714. private _startOffset;
  41715. private _position;
  41716. /** @hidden */
  41717. _positionInEmitterSpace: boolean;
  41718. private _localDirection;
  41719. private _volume;
  41720. private _isReadyToPlay;
  41721. private _isDirectional;
  41722. private _readyToPlayCallback;
  41723. private _audioBuffer;
  41724. private _soundSource;
  41725. private _streamingSource;
  41726. private _soundPanner;
  41727. private _soundGain;
  41728. private _inputAudioNode;
  41729. private _outputAudioNode;
  41730. private _coneInnerAngle;
  41731. private _coneOuterAngle;
  41732. private _coneOuterGain;
  41733. private _scene;
  41734. private _connectedTransformNode;
  41735. private _customAttenuationFunction;
  41736. private _registerFunc;
  41737. private _isOutputConnected;
  41738. private _htmlAudioElement;
  41739. private _urlType;
  41740. private _length?;
  41741. private _offset?;
  41742. /** @hidden */
  41743. static _SceneComponentInitialization: (scene: Scene) => void;
  41744. /**
  41745. * Create a sound and attach it to a scene
  41746. * @param name Name of your sound
  41747. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41748. * @param scene defines the scene the sound belongs to
  41749. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41750. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41751. */
  41752. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41753. /**
  41754. * Release the sound and its associated resources
  41755. */
  41756. dispose(): void;
  41757. /**
  41758. * Gets if the sounds is ready to be played or not.
  41759. * @returns true if ready, otherwise false
  41760. */
  41761. isReady(): boolean;
  41762. private _soundLoaded;
  41763. /**
  41764. * Sets the data of the sound from an audiobuffer
  41765. * @param audioBuffer The audioBuffer containing the data
  41766. */
  41767. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41768. /**
  41769. * Updates the current sounds options such as maxdistance, loop...
  41770. * @param options A JSON object containing values named as the object properties
  41771. */
  41772. updateOptions(options: ISoundOptions): void;
  41773. private _createSpatialParameters;
  41774. private _updateSpatialParameters;
  41775. /**
  41776. * Switch the panning model to HRTF:
  41777. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41779. */
  41780. switchPanningModelToHRTF(): void;
  41781. /**
  41782. * Switch the panning model to Equal Power:
  41783. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41785. */
  41786. switchPanningModelToEqualPower(): void;
  41787. private _switchPanningModel;
  41788. /**
  41789. * Connect this sound to a sound track audio node like gain...
  41790. * @param soundTrackAudioNode the sound track audio node to connect to
  41791. */
  41792. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41793. /**
  41794. * Transform this sound into a directional source
  41795. * @param coneInnerAngle Size of the inner cone in degree
  41796. * @param coneOuterAngle Size of the outer cone in degree
  41797. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41798. */
  41799. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41800. /**
  41801. * Gets or sets the inner angle for the directional cone.
  41802. */
  41803. get directionalConeInnerAngle(): number;
  41804. /**
  41805. * Gets or sets the inner angle for the directional cone.
  41806. */
  41807. set directionalConeInnerAngle(value: number);
  41808. /**
  41809. * Gets or sets the outer angle for the directional cone.
  41810. */
  41811. get directionalConeOuterAngle(): number;
  41812. /**
  41813. * Gets or sets the outer angle for the directional cone.
  41814. */
  41815. set directionalConeOuterAngle(value: number);
  41816. /**
  41817. * Sets the position of the emitter if spatial sound is enabled
  41818. * @param newPosition Defines the new posisiton
  41819. */
  41820. setPosition(newPosition: Vector3): void;
  41821. /**
  41822. * Sets the local direction of the emitter if spatial sound is enabled
  41823. * @param newLocalDirection Defines the new local direction
  41824. */
  41825. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41826. private _updateDirection;
  41827. /** @hidden */
  41828. updateDistanceFromListener(): void;
  41829. /**
  41830. * Sets a new custom attenuation function for the sound.
  41831. * @param callback Defines the function used for the attenuation
  41832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41833. */
  41834. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41835. /**
  41836. * Play the sound
  41837. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41838. * @param offset (optional) Start the sound at a specific time in seconds
  41839. * @param length (optional) Sound duration (in seconds)
  41840. */
  41841. play(time?: number, offset?: number, length?: number): void;
  41842. private _onended;
  41843. /**
  41844. * Stop the sound
  41845. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41846. */
  41847. stop(time?: number): void;
  41848. /**
  41849. * Put the sound in pause
  41850. */
  41851. pause(): void;
  41852. /**
  41853. * Sets a dedicated volume for this sounds
  41854. * @param newVolume Define the new volume of the sound
  41855. * @param time Define time for gradual change to new volume
  41856. */
  41857. setVolume(newVolume: number, time?: number): void;
  41858. /**
  41859. * Set the sound play back rate
  41860. * @param newPlaybackRate Define the playback rate the sound should be played at
  41861. */
  41862. setPlaybackRate(newPlaybackRate: number): void;
  41863. /**
  41864. * Gets the volume of the sound.
  41865. * @returns the volume of the sound
  41866. */
  41867. getVolume(): number;
  41868. /**
  41869. * Attach the sound to a dedicated mesh
  41870. * @param transformNode The transform node to connect the sound with
  41871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41872. */
  41873. attachToMesh(transformNode: TransformNode): void;
  41874. /**
  41875. * Detach the sound from the previously attached mesh
  41876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41877. */
  41878. detachFromMesh(): void;
  41879. private _onRegisterAfterWorldMatrixUpdate;
  41880. /**
  41881. * Clone the current sound in the scene.
  41882. * @returns the new sound clone
  41883. */
  41884. clone(): Nullable<Sound>;
  41885. /**
  41886. * Gets the current underlying audio buffer containing the data
  41887. * @returns the audio buffer
  41888. */
  41889. getAudioBuffer(): Nullable<AudioBuffer>;
  41890. /**
  41891. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41892. * @returns the source node
  41893. */
  41894. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41895. /**
  41896. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41897. * @returns the gain node
  41898. */
  41899. getSoundGain(): Nullable<GainNode>;
  41900. /**
  41901. * Serializes the Sound in a JSON representation
  41902. * @returns the JSON representation of the sound
  41903. */
  41904. serialize(): any;
  41905. /**
  41906. * Parse a JSON representation of a sound to innstantiate in a given scene
  41907. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41908. * @param scene Define the scene the new parsed sound should be created in
  41909. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41910. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41911. * @returns the newly parsed sound
  41912. */
  41913. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41914. }
  41915. }
  41916. declare module "babylonjs/Actions/directAudioActions" {
  41917. import { Action } from "babylonjs/Actions/action";
  41918. import { Condition } from "babylonjs/Actions/condition";
  41919. import { Sound } from "babylonjs/Audio/sound";
  41920. /**
  41921. * This defines an action helpful to play a defined sound on a triggered action.
  41922. */
  41923. export class PlaySoundAction extends Action {
  41924. private _sound;
  41925. /**
  41926. * Instantiate the action
  41927. * @param triggerOptions defines the trigger options
  41928. * @param sound defines the sound to play
  41929. * @param condition defines the trigger related conditions
  41930. */
  41931. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41932. /** @hidden */
  41933. _prepare(): void;
  41934. /**
  41935. * Execute the action and play the sound.
  41936. */
  41937. execute(): void;
  41938. /**
  41939. * Serializes the actions and its related information.
  41940. * @param parent defines the object to serialize in
  41941. * @returns the serialized object
  41942. */
  41943. serialize(parent: any): any;
  41944. }
  41945. /**
  41946. * This defines an action helpful to stop a defined sound on a triggered action.
  41947. */
  41948. export class StopSoundAction extends Action {
  41949. private _sound;
  41950. /**
  41951. * Instantiate the action
  41952. * @param triggerOptions defines the trigger options
  41953. * @param sound defines the sound to stop
  41954. * @param condition defines the trigger related conditions
  41955. */
  41956. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41957. /** @hidden */
  41958. _prepare(): void;
  41959. /**
  41960. * Execute the action and stop the sound.
  41961. */
  41962. execute(): void;
  41963. /**
  41964. * Serializes the actions and its related information.
  41965. * @param parent defines the object to serialize in
  41966. * @returns the serialized object
  41967. */
  41968. serialize(parent: any): any;
  41969. }
  41970. }
  41971. declare module "babylonjs/Actions/interpolateValueAction" {
  41972. import { Action } from "babylonjs/Actions/action";
  41973. import { Condition } from "babylonjs/Actions/condition";
  41974. import { Observable } from "babylonjs/Misc/observable";
  41975. /**
  41976. * This defines an action responsible to change the value of a property
  41977. * by interpolating between its current value and the newly set one once triggered.
  41978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  41979. */
  41980. export class InterpolateValueAction extends Action {
  41981. /**
  41982. * Defines the path of the property where the value should be interpolated
  41983. */
  41984. propertyPath: string;
  41985. /**
  41986. * Defines the target value at the end of the interpolation.
  41987. */
  41988. value: any;
  41989. /**
  41990. * Defines the time it will take for the property to interpolate to the value.
  41991. */
  41992. duration: number;
  41993. /**
  41994. * Defines if the other scene animations should be stopped when the action has been triggered
  41995. */
  41996. stopOtherAnimations?: boolean;
  41997. /**
  41998. * Defines a callback raised once the interpolation animation has been done.
  41999. */
  42000. onInterpolationDone?: () => void;
  42001. /**
  42002. * Observable triggered once the interpolation animation has been done.
  42003. */
  42004. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42005. private _target;
  42006. private _effectiveTarget;
  42007. private _property;
  42008. /**
  42009. * Instantiate the action
  42010. * @param triggerOptions defines the trigger options
  42011. * @param target defines the object containing the value to interpolate
  42012. * @param propertyPath defines the path to the property in the target object
  42013. * @param value defines the target value at the end of the interpolation
  42014. * @param duration deines the time it will take for the property to interpolate to the value.
  42015. * @param condition defines the trigger related conditions
  42016. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42017. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42018. */
  42019. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42020. /** @hidden */
  42021. _prepare(): void;
  42022. /**
  42023. * Execute the action starts the value interpolation.
  42024. */
  42025. execute(): void;
  42026. /**
  42027. * Serializes the actions and its related information.
  42028. * @param parent defines the object to serialize in
  42029. * @returns the serialized object
  42030. */
  42031. serialize(parent: any): any;
  42032. }
  42033. }
  42034. declare module "babylonjs/Actions/index" {
  42035. export * from "babylonjs/Actions/abstractActionManager";
  42036. export * from "babylonjs/Actions/action";
  42037. export * from "babylonjs/Actions/actionEvent";
  42038. export * from "babylonjs/Actions/actionManager";
  42039. export * from "babylonjs/Actions/condition";
  42040. export * from "babylonjs/Actions/directActions";
  42041. export * from "babylonjs/Actions/directAudioActions";
  42042. export * from "babylonjs/Actions/interpolateValueAction";
  42043. }
  42044. declare module "babylonjs/Animations/index" {
  42045. export * from "babylonjs/Animations/animatable";
  42046. export * from "babylonjs/Animations/animation";
  42047. export * from "babylonjs/Animations/animationGroup";
  42048. export * from "babylonjs/Animations/animationPropertiesOverride";
  42049. export * from "babylonjs/Animations/easing";
  42050. export * from "babylonjs/Animations/runtimeAnimation";
  42051. export * from "babylonjs/Animations/animationEvent";
  42052. export * from "babylonjs/Animations/animationGroup";
  42053. export * from "babylonjs/Animations/animationKey";
  42054. export * from "babylonjs/Animations/animationRange";
  42055. export * from "babylonjs/Animations/animatable.interface";
  42056. }
  42057. declare module "babylonjs/Audio/soundTrack" {
  42058. import { Sound } from "babylonjs/Audio/sound";
  42059. import { Analyser } from "babylonjs/Audio/analyser";
  42060. import { Scene } from "babylonjs/scene";
  42061. /**
  42062. * Options allowed during the creation of a sound track.
  42063. */
  42064. export interface ISoundTrackOptions {
  42065. /**
  42066. * The volume the sound track should take during creation
  42067. */
  42068. volume?: number;
  42069. /**
  42070. * Define if the sound track is the main sound track of the scene
  42071. */
  42072. mainTrack?: boolean;
  42073. }
  42074. /**
  42075. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42076. * It will be also used in a future release to apply effects on a specific track.
  42077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42078. */
  42079. export class SoundTrack {
  42080. /**
  42081. * The unique identifier of the sound track in the scene.
  42082. */
  42083. id: number;
  42084. /**
  42085. * The list of sounds included in the sound track.
  42086. */
  42087. soundCollection: Array<Sound>;
  42088. private _outputAudioNode;
  42089. private _scene;
  42090. private _connectedAnalyser;
  42091. private _options;
  42092. private _isInitialized;
  42093. /**
  42094. * Creates a new sound track.
  42095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42096. * @param scene Define the scene the sound track belongs to
  42097. * @param options
  42098. */
  42099. constructor(scene: Scene, options?: ISoundTrackOptions);
  42100. private _initializeSoundTrackAudioGraph;
  42101. /**
  42102. * Release the sound track and its associated resources
  42103. */
  42104. dispose(): void;
  42105. /**
  42106. * Adds a sound to this sound track
  42107. * @param sound define the cound to add
  42108. * @ignoreNaming
  42109. */
  42110. AddSound(sound: Sound): void;
  42111. /**
  42112. * Removes a sound to this sound track
  42113. * @param sound define the cound to remove
  42114. * @ignoreNaming
  42115. */
  42116. RemoveSound(sound: Sound): void;
  42117. /**
  42118. * Set a global volume for the full sound track.
  42119. * @param newVolume Define the new volume of the sound track
  42120. */
  42121. setVolume(newVolume: number): void;
  42122. /**
  42123. * Switch the panning model to HRTF:
  42124. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42126. */
  42127. switchPanningModelToHRTF(): void;
  42128. /**
  42129. * Switch the panning model to Equal Power:
  42130. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42131. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42132. */
  42133. switchPanningModelToEqualPower(): void;
  42134. /**
  42135. * Connect the sound track to an audio analyser allowing some amazing
  42136. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42138. * @param analyser The analyser to connect to the engine
  42139. */
  42140. connectToAnalyser(analyser: Analyser): void;
  42141. }
  42142. }
  42143. declare module "babylonjs/Audio/audioSceneComponent" {
  42144. import { Sound } from "babylonjs/Audio/sound";
  42145. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42146. import { Nullable } from "babylonjs/types";
  42147. import { Vector3 } from "babylonjs/Maths/math.vector";
  42148. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42149. import { Scene } from "babylonjs/scene";
  42150. import { AbstractScene } from "babylonjs/abstractScene";
  42151. import "babylonjs/Audio/audioEngine";
  42152. module "babylonjs/abstractScene" {
  42153. interface AbstractScene {
  42154. /**
  42155. * The list of sounds used in the scene.
  42156. */
  42157. sounds: Nullable<Array<Sound>>;
  42158. }
  42159. }
  42160. module "babylonjs/scene" {
  42161. interface Scene {
  42162. /**
  42163. * @hidden
  42164. * Backing field
  42165. */
  42166. _mainSoundTrack: SoundTrack;
  42167. /**
  42168. * The main sound track played by the scene.
  42169. * It cotains your primary collection of sounds.
  42170. */
  42171. mainSoundTrack: SoundTrack;
  42172. /**
  42173. * The list of sound tracks added to the scene
  42174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42175. */
  42176. soundTracks: Nullable<Array<SoundTrack>>;
  42177. /**
  42178. * Gets a sound using a given name
  42179. * @param name defines the name to search for
  42180. * @return the found sound or null if not found at all.
  42181. */
  42182. getSoundByName(name: string): Nullable<Sound>;
  42183. /**
  42184. * Gets or sets if audio support is enabled
  42185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42186. */
  42187. audioEnabled: boolean;
  42188. /**
  42189. * Gets or sets if audio will be output to headphones
  42190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42191. */
  42192. headphone: boolean;
  42193. /**
  42194. * Gets or sets custom audio listener position provider
  42195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42196. */
  42197. audioListenerPositionProvider: Nullable<() => Vector3>;
  42198. /**
  42199. * Gets or sets a refresh rate when using 3D audio positioning
  42200. */
  42201. audioPositioningRefreshRate: number;
  42202. }
  42203. }
  42204. /**
  42205. * Defines the sound scene component responsible to manage any sounds
  42206. * in a given scene.
  42207. */
  42208. export class AudioSceneComponent implements ISceneSerializableComponent {
  42209. /**
  42210. * The component name helpfull to identify the component in the list of scene components.
  42211. */
  42212. readonly name: string;
  42213. /**
  42214. * The scene the component belongs to.
  42215. */
  42216. scene: Scene;
  42217. private _audioEnabled;
  42218. /**
  42219. * Gets whether audio is enabled or not.
  42220. * Please use related enable/disable method to switch state.
  42221. */
  42222. get audioEnabled(): boolean;
  42223. private _headphone;
  42224. /**
  42225. * Gets whether audio is outputing to headphone or not.
  42226. * Please use the according Switch methods to change output.
  42227. */
  42228. get headphone(): boolean;
  42229. /**
  42230. * Gets or sets a refresh rate when using 3D audio positioning
  42231. */
  42232. audioPositioningRefreshRate: number;
  42233. private _audioListenerPositionProvider;
  42234. /**
  42235. * Gets the current audio listener position provider
  42236. */
  42237. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42238. /**
  42239. * Sets a custom listener position for all sounds in the scene
  42240. * By default, this is the position of the first active camera
  42241. */
  42242. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42243. /**
  42244. * Creates a new instance of the component for the given scene
  42245. * @param scene Defines the scene to register the component in
  42246. */
  42247. constructor(scene: Scene);
  42248. /**
  42249. * Registers the component in a given scene
  42250. */
  42251. register(): void;
  42252. /**
  42253. * Rebuilds the elements related to this component in case of
  42254. * context lost for instance.
  42255. */
  42256. rebuild(): void;
  42257. /**
  42258. * Serializes the component data to the specified json object
  42259. * @param serializationObject The object to serialize to
  42260. */
  42261. serialize(serializationObject: any): void;
  42262. /**
  42263. * Adds all the elements from the container to the scene
  42264. * @param container the container holding the elements
  42265. */
  42266. addFromContainer(container: AbstractScene): void;
  42267. /**
  42268. * Removes all the elements in the container from the scene
  42269. * @param container contains the elements to remove
  42270. * @param dispose if the removed element should be disposed (default: false)
  42271. */
  42272. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42273. /**
  42274. * Disposes the component and the associated ressources.
  42275. */
  42276. dispose(): void;
  42277. /**
  42278. * Disables audio in the associated scene.
  42279. */
  42280. disableAudio(): void;
  42281. /**
  42282. * Enables audio in the associated scene.
  42283. */
  42284. enableAudio(): void;
  42285. /**
  42286. * Switch audio to headphone output.
  42287. */
  42288. switchAudioModeForHeadphones(): void;
  42289. /**
  42290. * Switch audio to normal speakers.
  42291. */
  42292. switchAudioModeForNormalSpeakers(): void;
  42293. private _cachedCameraDirection;
  42294. private _cachedCameraPosition;
  42295. private _lastCheck;
  42296. private _afterRender;
  42297. }
  42298. }
  42299. declare module "babylonjs/Audio/weightedsound" {
  42300. import { Sound } from "babylonjs/Audio/sound";
  42301. /**
  42302. * Wraps one or more Sound objects and selects one with random weight for playback.
  42303. */
  42304. export class WeightedSound {
  42305. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42306. loop: boolean;
  42307. private _coneInnerAngle;
  42308. private _coneOuterAngle;
  42309. private _volume;
  42310. /** A Sound is currently playing. */
  42311. isPlaying: boolean;
  42312. /** A Sound is currently paused. */
  42313. isPaused: boolean;
  42314. private _sounds;
  42315. private _weights;
  42316. private _currentIndex?;
  42317. /**
  42318. * Creates a new WeightedSound from the list of sounds given.
  42319. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42320. * @param sounds Array of Sounds that will be selected from.
  42321. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42322. */
  42323. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42324. /**
  42325. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42326. */
  42327. get directionalConeInnerAngle(): number;
  42328. /**
  42329. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42330. */
  42331. set directionalConeInnerAngle(value: number);
  42332. /**
  42333. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42334. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42335. */
  42336. get directionalConeOuterAngle(): number;
  42337. /**
  42338. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42339. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42340. */
  42341. set directionalConeOuterAngle(value: number);
  42342. /**
  42343. * Playback volume.
  42344. */
  42345. get volume(): number;
  42346. /**
  42347. * Playback volume.
  42348. */
  42349. set volume(value: number);
  42350. private _onended;
  42351. /**
  42352. * Suspend playback
  42353. */
  42354. pause(): void;
  42355. /**
  42356. * Stop playback
  42357. */
  42358. stop(): void;
  42359. /**
  42360. * Start playback.
  42361. * @param startOffset Position the clip head at a specific time in seconds.
  42362. */
  42363. play(startOffset?: number): void;
  42364. }
  42365. }
  42366. declare module "babylonjs/Audio/index" {
  42367. export * from "babylonjs/Audio/analyser";
  42368. export * from "babylonjs/Audio/audioEngine";
  42369. export * from "babylonjs/Audio/audioSceneComponent";
  42370. export * from "babylonjs/Audio/sound";
  42371. export * from "babylonjs/Audio/soundTrack";
  42372. export * from "babylonjs/Audio/weightedsound";
  42373. }
  42374. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42375. import { Behavior } from "babylonjs/Behaviors/behavior";
  42376. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42377. import { BackEase } from "babylonjs/Animations/easing";
  42378. /**
  42379. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42380. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42381. */
  42382. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42383. /**
  42384. * Gets the name of the behavior.
  42385. */
  42386. get name(): string;
  42387. /**
  42388. * The easing function used by animations
  42389. */
  42390. static EasingFunction: BackEase;
  42391. /**
  42392. * The easing mode used by animations
  42393. */
  42394. static EasingMode: number;
  42395. /**
  42396. * The duration of the animation, in milliseconds
  42397. */
  42398. transitionDuration: number;
  42399. /**
  42400. * Length of the distance animated by the transition when lower radius is reached
  42401. */
  42402. lowerRadiusTransitionRange: number;
  42403. /**
  42404. * Length of the distance animated by the transition when upper radius is reached
  42405. */
  42406. upperRadiusTransitionRange: number;
  42407. private _autoTransitionRange;
  42408. /**
  42409. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42410. */
  42411. get autoTransitionRange(): boolean;
  42412. /**
  42413. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42414. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42415. */
  42416. set autoTransitionRange(value: boolean);
  42417. private _attachedCamera;
  42418. private _onAfterCheckInputsObserver;
  42419. private _onMeshTargetChangedObserver;
  42420. /**
  42421. * Initializes the behavior.
  42422. */
  42423. init(): void;
  42424. /**
  42425. * Attaches the behavior to its arc rotate camera.
  42426. * @param camera Defines the camera to attach the behavior to
  42427. */
  42428. attach(camera: ArcRotateCamera): void;
  42429. /**
  42430. * Detaches the behavior from its current arc rotate camera.
  42431. */
  42432. detach(): void;
  42433. private _radiusIsAnimating;
  42434. private _radiusBounceTransition;
  42435. private _animatables;
  42436. private _cachedWheelPrecision;
  42437. /**
  42438. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42439. * @param radiusLimit The limit to check against.
  42440. * @return Bool to indicate if at limit.
  42441. */
  42442. private _isRadiusAtLimit;
  42443. /**
  42444. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42445. * @param radiusDelta The delta by which to animate to. Can be negative.
  42446. */
  42447. private _applyBoundRadiusAnimation;
  42448. /**
  42449. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42450. */
  42451. protected _clearAnimationLocks(): void;
  42452. /**
  42453. * Stops and removes all animations that have been applied to the camera
  42454. */
  42455. stopAllAnimations(): void;
  42456. }
  42457. }
  42458. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42459. import { Behavior } from "babylonjs/Behaviors/behavior";
  42460. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42461. import { ExponentialEase } from "babylonjs/Animations/easing";
  42462. import { Nullable } from "babylonjs/types";
  42463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42464. import { Vector3 } from "babylonjs/Maths/math.vector";
  42465. /**
  42466. * 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.
  42467. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42468. */
  42469. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42470. /**
  42471. * Gets the name of the behavior.
  42472. */
  42473. get name(): string;
  42474. private _mode;
  42475. private _radiusScale;
  42476. private _positionScale;
  42477. private _defaultElevation;
  42478. private _elevationReturnTime;
  42479. private _elevationReturnWaitTime;
  42480. private _zoomStopsAnimation;
  42481. private _framingTime;
  42482. /**
  42483. * The easing function used by animations
  42484. */
  42485. static EasingFunction: ExponentialEase;
  42486. /**
  42487. * The easing mode used by animations
  42488. */
  42489. static EasingMode: number;
  42490. /**
  42491. * Sets the current mode used by the behavior
  42492. */
  42493. set mode(mode: number);
  42494. /**
  42495. * Gets current mode used by the behavior.
  42496. */
  42497. get mode(): number;
  42498. /**
  42499. * Sets the scale applied to the radius (1 by default)
  42500. */
  42501. set radiusScale(radius: number);
  42502. /**
  42503. * Gets the scale applied to the radius
  42504. */
  42505. get radiusScale(): number;
  42506. /**
  42507. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42508. */
  42509. set positionScale(scale: number);
  42510. /**
  42511. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42512. */
  42513. get positionScale(): number;
  42514. /**
  42515. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42516. * behaviour is triggered, in radians.
  42517. */
  42518. set defaultElevation(elevation: number);
  42519. /**
  42520. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42521. * behaviour is triggered, in radians.
  42522. */
  42523. get defaultElevation(): number;
  42524. /**
  42525. * Sets the time (in milliseconds) taken to return to the default beta position.
  42526. * Negative value indicates camera should not return to default.
  42527. */
  42528. set elevationReturnTime(speed: number);
  42529. /**
  42530. * Gets the time (in milliseconds) taken to return to the default beta position.
  42531. * Negative value indicates camera should not return to default.
  42532. */
  42533. get elevationReturnTime(): number;
  42534. /**
  42535. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42536. */
  42537. set elevationReturnWaitTime(time: number);
  42538. /**
  42539. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42540. */
  42541. get elevationReturnWaitTime(): number;
  42542. /**
  42543. * Sets the flag that indicates if user zooming should stop animation.
  42544. */
  42545. set zoomStopsAnimation(flag: boolean);
  42546. /**
  42547. * Gets the flag that indicates if user zooming should stop animation.
  42548. */
  42549. get zoomStopsAnimation(): boolean;
  42550. /**
  42551. * Sets the transition time when framing the mesh, in milliseconds
  42552. */
  42553. set framingTime(time: number);
  42554. /**
  42555. * Gets the transition time when framing the mesh, in milliseconds
  42556. */
  42557. get framingTime(): number;
  42558. /**
  42559. * Define if the behavior should automatically change the configured
  42560. * camera limits and sensibilities.
  42561. */
  42562. autoCorrectCameraLimitsAndSensibility: boolean;
  42563. private _onPrePointerObservableObserver;
  42564. private _onAfterCheckInputsObserver;
  42565. private _onMeshTargetChangedObserver;
  42566. private _attachedCamera;
  42567. private _isPointerDown;
  42568. private _lastInteractionTime;
  42569. /**
  42570. * Initializes the behavior.
  42571. */
  42572. init(): void;
  42573. /**
  42574. * Attaches the behavior to its arc rotate camera.
  42575. * @param camera Defines the camera to attach the behavior to
  42576. */
  42577. attach(camera: ArcRotateCamera): void;
  42578. /**
  42579. * Detaches the behavior from its current arc rotate camera.
  42580. */
  42581. detach(): void;
  42582. private _animatables;
  42583. private _betaIsAnimating;
  42584. private _betaTransition;
  42585. private _radiusTransition;
  42586. private _vectorTransition;
  42587. /**
  42588. * Targets the given mesh and updates zoom level accordingly.
  42589. * @param mesh The mesh to target.
  42590. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42591. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42592. */
  42593. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42594. /**
  42595. * Targets the given mesh with its children and updates zoom level accordingly.
  42596. * @param mesh The mesh to target.
  42597. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42598. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42599. */
  42600. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42601. /**
  42602. * Targets the given meshes with their children and updates zoom level accordingly.
  42603. * @param meshes The mesh to target.
  42604. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42605. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42606. */
  42607. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42608. /**
  42609. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42610. * @param minimumWorld Determines the smaller position of the bounding box extend
  42611. * @param maximumWorld Determines the bigger position of the bounding box extend
  42612. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42613. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42614. */
  42615. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42616. /**
  42617. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42618. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42619. * frustum width.
  42620. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42621. * to fully enclose the mesh in the viewing frustum.
  42622. */
  42623. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42624. /**
  42625. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42626. * is automatically returned to its default position (expected to be above ground plane).
  42627. */
  42628. private _maintainCameraAboveGround;
  42629. /**
  42630. * Returns the frustum slope based on the canvas ratio and camera FOV
  42631. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42632. */
  42633. private _getFrustumSlope;
  42634. /**
  42635. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42636. */
  42637. private _clearAnimationLocks;
  42638. /**
  42639. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42640. */
  42641. private _applyUserInteraction;
  42642. /**
  42643. * Stops and removes all animations that have been applied to the camera
  42644. */
  42645. stopAllAnimations(): void;
  42646. /**
  42647. * Gets a value indicating if the user is moving the camera
  42648. */
  42649. get isUserIsMoving(): boolean;
  42650. /**
  42651. * The camera can move all the way towards the mesh.
  42652. */
  42653. static IgnoreBoundsSizeMode: number;
  42654. /**
  42655. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42656. */
  42657. static FitFrustumSidesMode: number;
  42658. }
  42659. }
  42660. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42661. import { Nullable } from "babylonjs/types";
  42662. import { Camera } from "babylonjs/Cameras/camera";
  42663. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42664. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42665. /**
  42666. * Base class for Camera Pointer Inputs.
  42667. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42668. * for example usage.
  42669. */
  42670. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42671. /**
  42672. * Defines the camera the input is attached to.
  42673. */
  42674. abstract camera: Camera;
  42675. /**
  42676. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42677. */
  42678. protected _altKey: boolean;
  42679. protected _ctrlKey: boolean;
  42680. protected _metaKey: boolean;
  42681. protected _shiftKey: boolean;
  42682. /**
  42683. * Which mouse buttons were pressed at time of last mouse event.
  42684. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42685. */
  42686. protected _buttonsPressed: number;
  42687. /**
  42688. * Defines the buttons associated with the input to handle camera move.
  42689. */
  42690. buttons: number[];
  42691. /**
  42692. * Attach the input controls to a specific dom element to get the input from.
  42693. * @param element Defines the element the controls should be listened from
  42694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42695. */
  42696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42697. /**
  42698. * Detach the current controls from the specified dom element.
  42699. * @param element Defines the element to stop listening the inputs from
  42700. */
  42701. detachControl(element: Nullable<HTMLElement>): void;
  42702. /**
  42703. * Gets the class name of the current input.
  42704. * @returns the class name
  42705. */
  42706. getClassName(): string;
  42707. /**
  42708. * Get the friendly name associated with the input class.
  42709. * @returns the input friendly name
  42710. */
  42711. getSimpleName(): string;
  42712. /**
  42713. * Called on pointer POINTERDOUBLETAP event.
  42714. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42715. */
  42716. protected onDoubleTap(type: string): void;
  42717. /**
  42718. * Called on pointer POINTERMOVE event if only a single touch is active.
  42719. * Override this method to provide functionality.
  42720. */
  42721. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42722. /**
  42723. * Called on pointer POINTERMOVE event if multiple touches are active.
  42724. * Override this method to provide functionality.
  42725. */
  42726. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42727. /**
  42728. * Called on JS contextmenu event.
  42729. * Override this method to provide functionality.
  42730. */
  42731. protected onContextMenu(evt: PointerEvent): void;
  42732. /**
  42733. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42734. * press.
  42735. * Override this method to provide functionality.
  42736. */
  42737. protected onButtonDown(evt: PointerEvent): void;
  42738. /**
  42739. * Called each time a new POINTERUP event occurs. Ie, for each button
  42740. * release.
  42741. * Override this method to provide functionality.
  42742. */
  42743. protected onButtonUp(evt: PointerEvent): void;
  42744. /**
  42745. * Called when window becomes inactive.
  42746. * Override this method to provide functionality.
  42747. */
  42748. protected onLostFocus(): void;
  42749. private _pointerInput;
  42750. private _observer;
  42751. private _onLostFocus;
  42752. private pointA;
  42753. private pointB;
  42754. }
  42755. }
  42756. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  42757. import { Nullable } from "babylonjs/types";
  42758. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42759. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42760. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42761. /**
  42762. * Manage the pointers inputs to control an arc rotate camera.
  42763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42764. */
  42765. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42766. /**
  42767. * Defines the camera the input is attached to.
  42768. */
  42769. camera: ArcRotateCamera;
  42770. /**
  42771. * Gets the class name of the current input.
  42772. * @returns the class name
  42773. */
  42774. getClassName(): string;
  42775. /**
  42776. * Defines the buttons associated with the input to handle camera move.
  42777. */
  42778. buttons: number[];
  42779. /**
  42780. * Defines the pointer angular sensibility along the X axis or how fast is
  42781. * the camera rotating.
  42782. */
  42783. angularSensibilityX: number;
  42784. /**
  42785. * Defines the pointer angular sensibility along the Y axis or how fast is
  42786. * the camera rotating.
  42787. */
  42788. angularSensibilityY: number;
  42789. /**
  42790. * Defines the pointer pinch precision or how fast is the camera zooming.
  42791. */
  42792. pinchPrecision: number;
  42793. /**
  42794. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42795. * from 0.
  42796. * It defines the percentage of current camera.radius to use as delta when
  42797. * pinch zoom is used.
  42798. */
  42799. pinchDeltaPercentage: number;
  42800. /**
  42801. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42802. * that any object in the plane at the camera's target point will scale
  42803. * perfectly with finger motion.
  42804. * Overrides pinchDeltaPercentage and pinchPrecision.
  42805. */
  42806. useNaturalPinchZoom: boolean;
  42807. /**
  42808. * Defines the pointer panning sensibility or how fast is the camera moving.
  42809. */
  42810. panningSensibility: number;
  42811. /**
  42812. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42813. */
  42814. multiTouchPanning: boolean;
  42815. /**
  42816. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42817. * zoom (pinch) through multitouch.
  42818. */
  42819. multiTouchPanAndZoom: boolean;
  42820. /**
  42821. * Revers pinch action direction.
  42822. */
  42823. pinchInwards: boolean;
  42824. private _isPanClick;
  42825. private _twoFingerActivityCount;
  42826. private _isPinching;
  42827. /**
  42828. * Called on pointer POINTERMOVE event if only a single touch is active.
  42829. */
  42830. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42831. /**
  42832. * Called on pointer POINTERDOUBLETAP event.
  42833. */
  42834. protected onDoubleTap(type: string): void;
  42835. /**
  42836. * Called on pointer POINTERMOVE event if multiple touches are active.
  42837. */
  42838. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42839. /**
  42840. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42841. * press.
  42842. */
  42843. protected onButtonDown(evt: PointerEvent): void;
  42844. /**
  42845. * Called each time a new POINTERUP event occurs. Ie, for each button
  42846. * release.
  42847. */
  42848. protected onButtonUp(evt: PointerEvent): void;
  42849. /**
  42850. * Called when window becomes inactive.
  42851. */
  42852. protected onLostFocus(): void;
  42853. }
  42854. }
  42855. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  42856. import { Nullable } from "babylonjs/types";
  42857. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42858. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42859. /**
  42860. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42862. */
  42863. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42864. /**
  42865. * Defines the camera the input is attached to.
  42866. */
  42867. camera: ArcRotateCamera;
  42868. /**
  42869. * Defines the list of key codes associated with the up action (increase alpha)
  42870. */
  42871. keysUp: number[];
  42872. /**
  42873. * Defines the list of key codes associated with the down action (decrease alpha)
  42874. */
  42875. keysDown: number[];
  42876. /**
  42877. * Defines the list of key codes associated with the left action (increase beta)
  42878. */
  42879. keysLeft: number[];
  42880. /**
  42881. * Defines the list of key codes associated with the right action (decrease beta)
  42882. */
  42883. keysRight: number[];
  42884. /**
  42885. * Defines the list of key codes associated with the reset action.
  42886. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42887. */
  42888. keysReset: number[];
  42889. /**
  42890. * Defines the panning sensibility of the inputs.
  42891. * (How fast is the camera panning)
  42892. */
  42893. panningSensibility: number;
  42894. /**
  42895. * Defines the zooming sensibility of the inputs.
  42896. * (How fast is the camera zooming)
  42897. */
  42898. zoomingSensibility: number;
  42899. /**
  42900. * Defines whether maintaining the alt key down switch the movement mode from
  42901. * orientation to zoom.
  42902. */
  42903. useAltToZoom: boolean;
  42904. /**
  42905. * Rotation speed of the camera
  42906. */
  42907. angularSpeed: number;
  42908. private _keys;
  42909. private _ctrlPressed;
  42910. private _altPressed;
  42911. private _onCanvasBlurObserver;
  42912. private _onKeyboardObserver;
  42913. private _engine;
  42914. private _scene;
  42915. /**
  42916. * Attach the input controls to a specific dom element to get the input from.
  42917. * @param element Defines the element the controls should be listened from
  42918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42919. */
  42920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42921. /**
  42922. * Detach the current controls from the specified dom element.
  42923. * @param element Defines the element to stop listening the inputs from
  42924. */
  42925. detachControl(element: Nullable<HTMLElement>): void;
  42926. /**
  42927. * Update the current camera state depending on the inputs that have been used this frame.
  42928. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42929. */
  42930. checkInputs(): void;
  42931. /**
  42932. * Gets the class name of the current intput.
  42933. * @returns the class name
  42934. */
  42935. getClassName(): string;
  42936. /**
  42937. * Get the friendly name associated with the input class.
  42938. * @returns the input friendly name
  42939. */
  42940. getSimpleName(): string;
  42941. }
  42942. }
  42943. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  42944. import { Nullable } from "babylonjs/types";
  42945. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42946. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42947. /**
  42948. * Manage the mouse wheel inputs to control an arc rotate camera.
  42949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42950. */
  42951. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42952. /**
  42953. * Defines the camera the input is attached to.
  42954. */
  42955. camera: ArcRotateCamera;
  42956. /**
  42957. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42958. */
  42959. wheelPrecision: number;
  42960. /**
  42961. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42962. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42963. */
  42964. wheelDeltaPercentage: number;
  42965. private _wheel;
  42966. private _observer;
  42967. private computeDeltaFromMouseWheelLegacyEvent;
  42968. /**
  42969. * Attach the input controls to a specific dom element to get the input from.
  42970. * @param element Defines the element the controls should be listened from
  42971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42972. */
  42973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42974. /**
  42975. * Detach the current controls from the specified dom element.
  42976. * @param element Defines the element to stop listening the inputs from
  42977. */
  42978. detachControl(element: Nullable<HTMLElement>): void;
  42979. /**
  42980. * Gets the class name of the current intput.
  42981. * @returns the class name
  42982. */
  42983. getClassName(): string;
  42984. /**
  42985. * Get the friendly name associated with the input class.
  42986. * @returns the input friendly name
  42987. */
  42988. getSimpleName(): string;
  42989. }
  42990. }
  42991. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42992. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42993. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42994. /**
  42995. * Default Inputs manager for the ArcRotateCamera.
  42996. * It groups all the default supported inputs for ease of use.
  42997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42998. */
  42999. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43000. /**
  43001. * Instantiates a new ArcRotateCameraInputsManager.
  43002. * @param camera Defines the camera the inputs belong to
  43003. */
  43004. constructor(camera: ArcRotateCamera);
  43005. /**
  43006. * Add mouse wheel input support to the input manager.
  43007. * @returns the current input manager
  43008. */
  43009. addMouseWheel(): ArcRotateCameraInputsManager;
  43010. /**
  43011. * Add pointers input support to the input manager.
  43012. * @returns the current input manager
  43013. */
  43014. addPointers(): ArcRotateCameraInputsManager;
  43015. /**
  43016. * Add keyboard input support to the input manager.
  43017. * @returns the current input manager
  43018. */
  43019. addKeyboard(): ArcRotateCameraInputsManager;
  43020. }
  43021. }
  43022. declare module "babylonjs/Cameras/arcRotateCamera" {
  43023. import { Observable } from "babylonjs/Misc/observable";
  43024. import { Nullable } from "babylonjs/types";
  43025. import { Scene } from "babylonjs/scene";
  43026. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43028. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43029. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43030. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43031. import { Camera } from "babylonjs/Cameras/camera";
  43032. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43033. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43034. import { Collider } from "babylonjs/Collisions/collider";
  43035. /**
  43036. * This represents an orbital type of camera.
  43037. *
  43038. * 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.
  43039. * 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.
  43040. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43041. */
  43042. export class ArcRotateCamera extends TargetCamera {
  43043. /**
  43044. * Defines the rotation angle of the camera along the longitudinal axis.
  43045. */
  43046. alpha: number;
  43047. /**
  43048. * Defines the rotation angle of the camera along the latitudinal axis.
  43049. */
  43050. beta: number;
  43051. /**
  43052. * Defines the radius of the camera from it s target point.
  43053. */
  43054. radius: number;
  43055. protected _target: Vector3;
  43056. protected _targetHost: Nullable<AbstractMesh>;
  43057. /**
  43058. * Defines the target point of the camera.
  43059. * The camera looks towards it form the radius distance.
  43060. */
  43061. get target(): Vector3;
  43062. set target(value: Vector3);
  43063. /**
  43064. * Define the current local position of the camera in the scene
  43065. */
  43066. get position(): Vector3;
  43067. set position(newPosition: Vector3);
  43068. protected _upVector: Vector3;
  43069. protected _upToYMatrix: Matrix;
  43070. protected _YToUpMatrix: Matrix;
  43071. /**
  43072. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43073. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43074. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43075. */
  43076. set upVector(vec: Vector3);
  43077. get upVector(): Vector3;
  43078. /**
  43079. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43080. */
  43081. setMatUp(): void;
  43082. /**
  43083. * Current inertia value on the longitudinal axis.
  43084. * The bigger this number the longer it will take for the camera to stop.
  43085. */
  43086. inertialAlphaOffset: number;
  43087. /**
  43088. * Current inertia value on the latitudinal axis.
  43089. * The bigger this number the longer it will take for the camera to stop.
  43090. */
  43091. inertialBetaOffset: number;
  43092. /**
  43093. * Current inertia value on the radius axis.
  43094. * The bigger this number the longer it will take for the camera to stop.
  43095. */
  43096. inertialRadiusOffset: number;
  43097. /**
  43098. * Minimum allowed angle on the longitudinal axis.
  43099. * This can help limiting how the Camera is able to move in the scene.
  43100. */
  43101. lowerAlphaLimit: Nullable<number>;
  43102. /**
  43103. * Maximum allowed angle on the longitudinal axis.
  43104. * This can help limiting how the Camera is able to move in the scene.
  43105. */
  43106. upperAlphaLimit: Nullable<number>;
  43107. /**
  43108. * Minimum allowed angle on the latitudinal axis.
  43109. * This can help limiting how the Camera is able to move in the scene.
  43110. */
  43111. lowerBetaLimit: number;
  43112. /**
  43113. * Maximum allowed angle on the latitudinal axis.
  43114. * This can help limiting how the Camera is able to move in the scene.
  43115. */
  43116. upperBetaLimit: number;
  43117. /**
  43118. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43119. * This can help limiting how the Camera is able to move in the scene.
  43120. */
  43121. lowerRadiusLimit: Nullable<number>;
  43122. /**
  43123. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43124. * This can help limiting how the Camera is able to move in the scene.
  43125. */
  43126. upperRadiusLimit: Nullable<number>;
  43127. /**
  43128. * Defines the current inertia value used during panning of the camera along the X axis.
  43129. */
  43130. inertialPanningX: number;
  43131. /**
  43132. * Defines the current inertia value used during panning of the camera along the Y axis.
  43133. */
  43134. inertialPanningY: number;
  43135. /**
  43136. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43137. * Basically if your fingers moves away from more than this distance you will be considered
  43138. * in pinch mode.
  43139. */
  43140. pinchToPanMaxDistance: number;
  43141. /**
  43142. * Defines the maximum distance the camera can pan.
  43143. * This could help keeping the cammera always in your scene.
  43144. */
  43145. panningDistanceLimit: Nullable<number>;
  43146. /**
  43147. * Defines the target of the camera before paning.
  43148. */
  43149. panningOriginTarget: Vector3;
  43150. /**
  43151. * Defines the value of the inertia used during panning.
  43152. * 0 would mean stop inertia and one would mean no decelleration at all.
  43153. */
  43154. panningInertia: number;
  43155. /**
  43156. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43157. */
  43158. get angularSensibilityX(): number;
  43159. set angularSensibilityX(value: number);
  43160. /**
  43161. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43162. */
  43163. get angularSensibilityY(): number;
  43164. set angularSensibilityY(value: number);
  43165. /**
  43166. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43167. */
  43168. get pinchPrecision(): number;
  43169. set pinchPrecision(value: number);
  43170. /**
  43171. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43172. * It will be used instead of pinchDeltaPrecision if different from 0.
  43173. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43174. */
  43175. get pinchDeltaPercentage(): number;
  43176. set pinchDeltaPercentage(value: number);
  43177. /**
  43178. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43179. * and pinch delta percentage.
  43180. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43181. * that any object in the plane at the camera's target point will scale
  43182. * perfectly with finger motion.
  43183. */
  43184. get useNaturalPinchZoom(): boolean;
  43185. set useNaturalPinchZoom(value: boolean);
  43186. /**
  43187. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43188. */
  43189. get panningSensibility(): number;
  43190. set panningSensibility(value: number);
  43191. /**
  43192. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43193. */
  43194. get keysUp(): number[];
  43195. set keysUp(value: number[]);
  43196. /**
  43197. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43198. */
  43199. get keysDown(): number[];
  43200. set keysDown(value: number[]);
  43201. /**
  43202. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43203. */
  43204. get keysLeft(): number[];
  43205. set keysLeft(value: number[]);
  43206. /**
  43207. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43208. */
  43209. get keysRight(): number[];
  43210. set keysRight(value: number[]);
  43211. /**
  43212. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43213. */
  43214. get wheelPrecision(): number;
  43215. set wheelPrecision(value: number);
  43216. /**
  43217. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43218. * It will be used instead of pinchDeltaPrecision if different from 0.
  43219. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43220. */
  43221. get wheelDeltaPercentage(): number;
  43222. set wheelDeltaPercentage(value: number);
  43223. /**
  43224. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43225. */
  43226. zoomOnFactor: number;
  43227. /**
  43228. * Defines a screen offset for the camera position.
  43229. */
  43230. targetScreenOffset: Vector2;
  43231. /**
  43232. * Allows the camera to be completely reversed.
  43233. * If false the camera can not arrive upside down.
  43234. */
  43235. allowUpsideDown: boolean;
  43236. /**
  43237. * Define if double tap/click is used to restore the previously saved state of the camera.
  43238. */
  43239. useInputToRestoreState: boolean;
  43240. /** @hidden */
  43241. _viewMatrix: Matrix;
  43242. /** @hidden */
  43243. _useCtrlForPanning: boolean;
  43244. /** @hidden */
  43245. _panningMouseButton: number;
  43246. /**
  43247. * Defines the input associated to the camera.
  43248. */
  43249. inputs: ArcRotateCameraInputsManager;
  43250. /** @hidden */
  43251. _reset: () => void;
  43252. /**
  43253. * Defines the allowed panning axis.
  43254. */
  43255. panningAxis: Vector3;
  43256. protected _localDirection: Vector3;
  43257. protected _transformedDirection: Vector3;
  43258. private _bouncingBehavior;
  43259. /**
  43260. * Gets the bouncing behavior of the camera if it has been enabled.
  43261. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43262. */
  43263. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43264. /**
  43265. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43266. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43267. */
  43268. get useBouncingBehavior(): boolean;
  43269. set useBouncingBehavior(value: boolean);
  43270. private _framingBehavior;
  43271. /**
  43272. * Gets the framing behavior of the camera if it has been enabled.
  43273. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43274. */
  43275. get framingBehavior(): Nullable<FramingBehavior>;
  43276. /**
  43277. * Defines if the framing behavior of the camera is enabled on the camera.
  43278. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43279. */
  43280. get useFramingBehavior(): boolean;
  43281. set useFramingBehavior(value: boolean);
  43282. private _autoRotationBehavior;
  43283. /**
  43284. * Gets the auto rotation behavior of the camera if it has been enabled.
  43285. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43286. */
  43287. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43288. /**
  43289. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43291. */
  43292. get useAutoRotationBehavior(): boolean;
  43293. set useAutoRotationBehavior(value: boolean);
  43294. /**
  43295. * Observable triggered when the mesh target has been changed on the camera.
  43296. */
  43297. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43298. /**
  43299. * Event raised when the camera is colliding with a mesh.
  43300. */
  43301. onCollide: (collidedMesh: AbstractMesh) => void;
  43302. /**
  43303. * Defines whether the camera should check collision with the objects oh the scene.
  43304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43305. */
  43306. checkCollisions: boolean;
  43307. /**
  43308. * Defines the collision radius of the camera.
  43309. * This simulates a sphere around the camera.
  43310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43311. */
  43312. collisionRadius: Vector3;
  43313. protected _collider: Collider;
  43314. protected _previousPosition: Vector3;
  43315. protected _collisionVelocity: Vector3;
  43316. protected _newPosition: Vector3;
  43317. protected _previousAlpha: number;
  43318. protected _previousBeta: number;
  43319. protected _previousRadius: number;
  43320. protected _collisionTriggered: boolean;
  43321. protected _targetBoundingCenter: Nullable<Vector3>;
  43322. private _computationVector;
  43323. /**
  43324. * Instantiates a new ArcRotateCamera in a given scene
  43325. * @param name Defines the name of the camera
  43326. * @param alpha Defines the camera rotation along the logitudinal axis
  43327. * @param beta Defines the camera rotation along the latitudinal axis
  43328. * @param radius Defines the camera distance from its target
  43329. * @param target Defines the camera target
  43330. * @param scene Defines the scene the camera belongs to
  43331. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43332. */
  43333. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43334. /** @hidden */
  43335. _initCache(): void;
  43336. /** @hidden */
  43337. _updateCache(ignoreParentClass?: boolean): void;
  43338. protected _getTargetPosition(): Vector3;
  43339. private _storedAlpha;
  43340. private _storedBeta;
  43341. private _storedRadius;
  43342. private _storedTarget;
  43343. private _storedTargetScreenOffset;
  43344. /**
  43345. * Stores the current state of the camera (alpha, beta, radius and target)
  43346. * @returns the camera itself
  43347. */
  43348. storeState(): Camera;
  43349. /**
  43350. * @hidden
  43351. * Restored camera state. You must call storeState() first
  43352. */
  43353. _restoreStateValues(): boolean;
  43354. /** @hidden */
  43355. _isSynchronizedViewMatrix(): boolean;
  43356. /**
  43357. * Attached controls to the current camera.
  43358. * @param element Defines the element the controls should be listened from
  43359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43360. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43361. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43362. */
  43363. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43364. /**
  43365. * Detach the current controls from the camera.
  43366. * The camera will stop reacting to inputs.
  43367. * @param element Defines the element to stop listening the inputs from
  43368. */
  43369. detachControl(element: HTMLElement): void;
  43370. /** @hidden */
  43371. _checkInputs(): void;
  43372. protected _checkLimits(): void;
  43373. /**
  43374. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43375. */
  43376. rebuildAnglesAndRadius(): void;
  43377. /**
  43378. * Use a position to define the current camera related information like alpha, beta and radius
  43379. * @param position Defines the position to set the camera at
  43380. */
  43381. setPosition(position: Vector3): void;
  43382. /**
  43383. * Defines the target the camera should look at.
  43384. * This will automatically adapt alpha beta and radius to fit within the new target.
  43385. * @param target Defines the new target as a Vector or a mesh
  43386. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43387. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43388. */
  43389. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43390. /** @hidden */
  43391. _getViewMatrix(): Matrix;
  43392. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43393. /**
  43394. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43395. * @param meshes Defines the mesh to zoom on
  43396. * @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)
  43397. */
  43398. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43399. /**
  43400. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43401. * The target will be changed but the radius
  43402. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43403. * @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)
  43404. */
  43405. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43406. min: Vector3;
  43407. max: Vector3;
  43408. distance: number;
  43409. }, doNotUpdateMaxZ?: boolean): void;
  43410. /**
  43411. * @override
  43412. * Override Camera.createRigCamera
  43413. */
  43414. createRigCamera(name: string, cameraIndex: number): Camera;
  43415. /**
  43416. * @hidden
  43417. * @override
  43418. * Override Camera._updateRigCameras
  43419. */
  43420. _updateRigCameras(): void;
  43421. /**
  43422. * Destroy the camera and release the current resources hold by it.
  43423. */
  43424. dispose(): void;
  43425. /**
  43426. * Gets the current object class name.
  43427. * @return the class name
  43428. */
  43429. getClassName(): string;
  43430. }
  43431. }
  43432. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43433. import { Behavior } from "babylonjs/Behaviors/behavior";
  43434. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43435. /**
  43436. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43437. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43438. */
  43439. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43440. /**
  43441. * Gets the name of the behavior.
  43442. */
  43443. get name(): string;
  43444. private _zoomStopsAnimation;
  43445. private _idleRotationSpeed;
  43446. private _idleRotationWaitTime;
  43447. private _idleRotationSpinupTime;
  43448. /**
  43449. * Sets the flag that indicates if user zooming should stop animation.
  43450. */
  43451. set zoomStopsAnimation(flag: boolean);
  43452. /**
  43453. * Gets the flag that indicates if user zooming should stop animation.
  43454. */
  43455. get zoomStopsAnimation(): boolean;
  43456. /**
  43457. * Sets the default speed at which the camera rotates around the model.
  43458. */
  43459. set idleRotationSpeed(speed: number);
  43460. /**
  43461. * Gets the default speed at which the camera rotates around the model.
  43462. */
  43463. get idleRotationSpeed(): number;
  43464. /**
  43465. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43466. */
  43467. set idleRotationWaitTime(time: number);
  43468. /**
  43469. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43470. */
  43471. get idleRotationWaitTime(): number;
  43472. /**
  43473. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43474. */
  43475. set idleRotationSpinupTime(time: number);
  43476. /**
  43477. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43478. */
  43479. get idleRotationSpinupTime(): number;
  43480. /**
  43481. * Gets a value indicating if the camera is currently rotating because of this behavior
  43482. */
  43483. get rotationInProgress(): boolean;
  43484. private _onPrePointerObservableObserver;
  43485. private _onAfterCheckInputsObserver;
  43486. private _attachedCamera;
  43487. private _isPointerDown;
  43488. private _lastFrameTime;
  43489. private _lastInteractionTime;
  43490. private _cameraRotationSpeed;
  43491. /**
  43492. * Initializes the behavior.
  43493. */
  43494. init(): void;
  43495. /**
  43496. * Attaches the behavior to its arc rotate camera.
  43497. * @param camera Defines the camera to attach the behavior to
  43498. */
  43499. attach(camera: ArcRotateCamera): void;
  43500. /**
  43501. * Detaches the behavior from its current arc rotate camera.
  43502. */
  43503. detach(): void;
  43504. /**
  43505. * Returns true if user is scrolling.
  43506. * @return true if user is scrolling.
  43507. */
  43508. private _userIsZooming;
  43509. private _lastFrameRadius;
  43510. private _shouldAnimationStopForInteraction;
  43511. /**
  43512. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43513. */
  43514. private _applyUserInteraction;
  43515. private _userIsMoving;
  43516. }
  43517. }
  43518. declare module "babylonjs/Behaviors/Cameras/index" {
  43519. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43520. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43521. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43522. }
  43523. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43524. import { Mesh } from "babylonjs/Meshes/mesh";
  43525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43526. import { Behavior } from "babylonjs/Behaviors/behavior";
  43527. /**
  43528. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43529. */
  43530. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43531. private ui;
  43532. /**
  43533. * The name of the behavior
  43534. */
  43535. name: string;
  43536. /**
  43537. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43538. */
  43539. distanceAwayFromFace: number;
  43540. /**
  43541. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43542. */
  43543. distanceAwayFromBottomOfFace: number;
  43544. private _faceVectors;
  43545. private _target;
  43546. private _scene;
  43547. private _onRenderObserver;
  43548. private _tmpMatrix;
  43549. private _tmpVector;
  43550. /**
  43551. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43552. * @param ui The transform node that should be attched to the mesh
  43553. */
  43554. constructor(ui: TransformNode);
  43555. /**
  43556. * Initializes the behavior
  43557. */
  43558. init(): void;
  43559. private _closestFace;
  43560. private _zeroVector;
  43561. private _lookAtTmpMatrix;
  43562. private _lookAtToRef;
  43563. /**
  43564. * Attaches the AttachToBoxBehavior to the passed in mesh
  43565. * @param target The mesh that the specified node will be attached to
  43566. */
  43567. attach(target: Mesh): void;
  43568. /**
  43569. * Detaches the behavior from the mesh
  43570. */
  43571. detach(): void;
  43572. }
  43573. }
  43574. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43575. import { Behavior } from "babylonjs/Behaviors/behavior";
  43576. import { Mesh } from "babylonjs/Meshes/mesh";
  43577. /**
  43578. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43579. */
  43580. export class FadeInOutBehavior implements Behavior<Mesh> {
  43581. /**
  43582. * Time in milliseconds to delay before fading in (Default: 0)
  43583. */
  43584. delay: number;
  43585. /**
  43586. * Time in milliseconds for the mesh to fade in (Default: 300)
  43587. */
  43588. fadeInTime: number;
  43589. private _millisecondsPerFrame;
  43590. private _hovered;
  43591. private _hoverValue;
  43592. private _ownerNode;
  43593. /**
  43594. * Instatiates the FadeInOutBehavior
  43595. */
  43596. constructor();
  43597. /**
  43598. * The name of the behavior
  43599. */
  43600. get name(): string;
  43601. /**
  43602. * Initializes the behavior
  43603. */
  43604. init(): void;
  43605. /**
  43606. * Attaches the fade behavior on the passed in mesh
  43607. * @param ownerNode The mesh that will be faded in/out once attached
  43608. */
  43609. attach(ownerNode: Mesh): void;
  43610. /**
  43611. * Detaches the behavior from the mesh
  43612. */
  43613. detach(): void;
  43614. /**
  43615. * Triggers the mesh to begin fading in or out
  43616. * @param value if the object should fade in or out (true to fade in)
  43617. */
  43618. fadeIn(value: boolean): void;
  43619. private _update;
  43620. private _setAllVisibility;
  43621. }
  43622. }
  43623. declare module "babylonjs/Misc/pivotTools" {
  43624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43625. /**
  43626. * Class containing a set of static utilities functions for managing Pivots
  43627. * @hidden
  43628. */
  43629. export class PivotTools {
  43630. private static _PivotCached;
  43631. private static _OldPivotPoint;
  43632. private static _PivotTranslation;
  43633. private static _PivotTmpVector;
  43634. /** @hidden */
  43635. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43636. /** @hidden */
  43637. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43638. }
  43639. }
  43640. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43641. import { Scene } from "babylonjs/scene";
  43642. import { Vector4 } from "babylonjs/Maths/math.vector";
  43643. import { Mesh } from "babylonjs/Meshes/mesh";
  43644. import { Nullable } from "babylonjs/types";
  43645. import { Plane } from "babylonjs/Maths/math.plane";
  43646. /**
  43647. * Class containing static functions to help procedurally build meshes
  43648. */
  43649. export class PlaneBuilder {
  43650. /**
  43651. * Creates a plane mesh
  43652. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43653. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43654. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43658. * @param name defines the name of the mesh
  43659. * @param options defines the options used to create the mesh
  43660. * @param scene defines the hosting scene
  43661. * @returns the plane mesh
  43662. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43663. */
  43664. static CreatePlane(name: string, options: {
  43665. size?: number;
  43666. width?: number;
  43667. height?: number;
  43668. sideOrientation?: number;
  43669. frontUVs?: Vector4;
  43670. backUVs?: Vector4;
  43671. updatable?: boolean;
  43672. sourcePlane?: Plane;
  43673. }, scene?: Nullable<Scene>): Mesh;
  43674. }
  43675. }
  43676. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43677. import { Behavior } from "babylonjs/Behaviors/behavior";
  43678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43679. import { Observable } from "babylonjs/Misc/observable";
  43680. import { Vector3 } from "babylonjs/Maths/math.vector";
  43681. import { Ray } from "babylonjs/Culling/ray";
  43682. import "babylonjs/Meshes/Builders/planeBuilder";
  43683. /**
  43684. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43685. */
  43686. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43687. private static _AnyMouseID;
  43688. /**
  43689. * Abstract mesh the behavior is set on
  43690. */
  43691. attachedNode: AbstractMesh;
  43692. private _dragPlane;
  43693. private _scene;
  43694. private _pointerObserver;
  43695. private _beforeRenderObserver;
  43696. private static _planeScene;
  43697. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43698. /**
  43699. * 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)
  43700. */
  43701. maxDragAngle: number;
  43702. /**
  43703. * @hidden
  43704. */
  43705. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43706. /**
  43707. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43708. */
  43709. currentDraggingPointerID: number;
  43710. /**
  43711. * The last position where the pointer hit the drag plane in world space
  43712. */
  43713. lastDragPosition: Vector3;
  43714. /**
  43715. * If the behavior is currently in a dragging state
  43716. */
  43717. dragging: boolean;
  43718. /**
  43719. * 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)
  43720. */
  43721. dragDeltaRatio: number;
  43722. /**
  43723. * If the drag plane orientation should be updated during the dragging (Default: true)
  43724. */
  43725. updateDragPlane: boolean;
  43726. private _debugMode;
  43727. private _moving;
  43728. /**
  43729. * Fires each time the attached mesh is dragged with the pointer
  43730. * * delta between last drag position and current drag position in world space
  43731. * * dragDistance along the drag axis
  43732. * * dragPlaneNormal normal of the current drag plane used during the drag
  43733. * * dragPlanePoint in world space where the drag intersects the drag plane
  43734. */
  43735. onDragObservable: Observable<{
  43736. delta: Vector3;
  43737. dragPlanePoint: Vector3;
  43738. dragPlaneNormal: Vector3;
  43739. dragDistance: number;
  43740. pointerId: number;
  43741. }>;
  43742. /**
  43743. * Fires each time a drag begins (eg. mouse down on mesh)
  43744. */
  43745. onDragStartObservable: Observable<{
  43746. dragPlanePoint: Vector3;
  43747. pointerId: number;
  43748. }>;
  43749. /**
  43750. * Fires each time a drag ends (eg. mouse release after drag)
  43751. */
  43752. onDragEndObservable: Observable<{
  43753. dragPlanePoint: Vector3;
  43754. pointerId: number;
  43755. }>;
  43756. /**
  43757. * If the attached mesh should be moved when dragged
  43758. */
  43759. moveAttached: boolean;
  43760. /**
  43761. * If the drag behavior will react to drag events (Default: true)
  43762. */
  43763. enabled: boolean;
  43764. /**
  43765. * If pointer events should start and release the drag (Default: true)
  43766. */
  43767. startAndReleaseDragOnPointerEvents: boolean;
  43768. /**
  43769. * If camera controls should be detached during the drag
  43770. */
  43771. detachCameraControls: boolean;
  43772. /**
  43773. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43774. */
  43775. useObjectOrientationForDragging: boolean;
  43776. private _options;
  43777. /**
  43778. * Gets the options used by the behavior
  43779. */
  43780. get options(): {
  43781. dragAxis?: Vector3;
  43782. dragPlaneNormal?: Vector3;
  43783. };
  43784. /**
  43785. * Sets the options used by the behavior
  43786. */
  43787. set options(options: {
  43788. dragAxis?: Vector3;
  43789. dragPlaneNormal?: Vector3;
  43790. });
  43791. /**
  43792. * Creates a pointer drag behavior that can be attached to a mesh
  43793. * @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)
  43794. */
  43795. constructor(options?: {
  43796. dragAxis?: Vector3;
  43797. dragPlaneNormal?: Vector3;
  43798. });
  43799. /**
  43800. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43801. */
  43802. validateDrag: (targetPosition: Vector3) => boolean;
  43803. /**
  43804. * The name of the behavior
  43805. */
  43806. get name(): string;
  43807. /**
  43808. * Initializes the behavior
  43809. */
  43810. init(): void;
  43811. private _tmpVector;
  43812. private _alternatePickedPoint;
  43813. private _worldDragAxis;
  43814. private _targetPosition;
  43815. private _attachedElement;
  43816. /**
  43817. * Attaches the drag behavior the passed in mesh
  43818. * @param ownerNode The mesh that will be dragged around once attached
  43819. * @param predicate Predicate to use for pick filtering
  43820. */
  43821. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43822. /**
  43823. * Force relase the drag action by code.
  43824. */
  43825. releaseDrag(): void;
  43826. private _startDragRay;
  43827. private _lastPointerRay;
  43828. /**
  43829. * Simulates the start of a pointer drag event on the behavior
  43830. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43831. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43832. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43833. */
  43834. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43835. private _startDrag;
  43836. private _dragDelta;
  43837. private _moveDrag;
  43838. private _pickWithRayOnDragPlane;
  43839. private _pointA;
  43840. private _pointB;
  43841. private _pointC;
  43842. private _lineA;
  43843. private _lineB;
  43844. private _localAxis;
  43845. private _lookAt;
  43846. private _updateDragPlanePosition;
  43847. /**
  43848. * Detaches the behavior from the mesh
  43849. */
  43850. detach(): void;
  43851. }
  43852. }
  43853. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  43854. import { Mesh } from "babylonjs/Meshes/mesh";
  43855. import { Behavior } from "babylonjs/Behaviors/behavior";
  43856. /**
  43857. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43858. */
  43859. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43860. private _dragBehaviorA;
  43861. private _dragBehaviorB;
  43862. private _startDistance;
  43863. private _initialScale;
  43864. private _targetScale;
  43865. private _ownerNode;
  43866. private _sceneRenderObserver;
  43867. /**
  43868. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43869. */
  43870. constructor();
  43871. /**
  43872. * The name of the behavior
  43873. */
  43874. get name(): string;
  43875. /**
  43876. * Initializes the behavior
  43877. */
  43878. init(): void;
  43879. private _getCurrentDistance;
  43880. /**
  43881. * Attaches the scale behavior the passed in mesh
  43882. * @param ownerNode The mesh that will be scaled around once attached
  43883. */
  43884. attach(ownerNode: Mesh): void;
  43885. /**
  43886. * Detaches the behavior from the mesh
  43887. */
  43888. detach(): void;
  43889. }
  43890. }
  43891. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  43892. import { Behavior } from "babylonjs/Behaviors/behavior";
  43893. import { Mesh } from "babylonjs/Meshes/mesh";
  43894. import { Observable } from "babylonjs/Misc/observable";
  43895. /**
  43896. * 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
  43897. */
  43898. export class SixDofDragBehavior implements Behavior<Mesh> {
  43899. private static _virtualScene;
  43900. private _ownerNode;
  43901. private _sceneRenderObserver;
  43902. private _scene;
  43903. private _targetPosition;
  43904. private _virtualOriginMesh;
  43905. private _virtualDragMesh;
  43906. private _pointerObserver;
  43907. private _moving;
  43908. private _startingOrientation;
  43909. private _attachedElement;
  43910. /**
  43911. * 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)
  43912. */
  43913. private zDragFactor;
  43914. /**
  43915. * If the object should rotate to face the drag origin
  43916. */
  43917. rotateDraggedObject: boolean;
  43918. /**
  43919. * If the behavior is currently in a dragging state
  43920. */
  43921. dragging: boolean;
  43922. /**
  43923. * 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)
  43924. */
  43925. dragDeltaRatio: number;
  43926. /**
  43927. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43928. */
  43929. currentDraggingPointerID: number;
  43930. /**
  43931. * If camera controls should be detached during the drag
  43932. */
  43933. detachCameraControls: boolean;
  43934. /**
  43935. * Fires each time a drag starts
  43936. */
  43937. onDragStartObservable: Observable<{}>;
  43938. /**
  43939. * Fires each time a drag ends (eg. mouse release after drag)
  43940. */
  43941. onDragEndObservable: Observable<{}>;
  43942. /**
  43943. * 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
  43944. */
  43945. constructor();
  43946. /**
  43947. * The name of the behavior
  43948. */
  43949. get name(): string;
  43950. /**
  43951. * Initializes the behavior
  43952. */
  43953. init(): void;
  43954. /**
  43955. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43956. */
  43957. private get _pointerCamera();
  43958. /**
  43959. * Attaches the scale behavior the passed in mesh
  43960. * @param ownerNode The mesh that will be scaled around once attached
  43961. */
  43962. attach(ownerNode: Mesh): void;
  43963. /**
  43964. * Detaches the behavior from the mesh
  43965. */
  43966. detach(): void;
  43967. }
  43968. }
  43969. declare module "babylonjs/Behaviors/Meshes/index" {
  43970. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  43971. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  43972. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  43973. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43974. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43975. }
  43976. declare module "babylonjs/Behaviors/index" {
  43977. export * from "babylonjs/Behaviors/behavior";
  43978. export * from "babylonjs/Behaviors/Cameras/index";
  43979. export * from "babylonjs/Behaviors/Meshes/index";
  43980. }
  43981. declare module "babylonjs/Bones/boneIKController" {
  43982. import { Bone } from "babylonjs/Bones/bone";
  43983. import { Vector3 } from "babylonjs/Maths/math.vector";
  43984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43985. import { Nullable } from "babylonjs/types";
  43986. /**
  43987. * Class used to apply inverse kinematics to bones
  43988. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43989. */
  43990. export class BoneIKController {
  43991. private static _tmpVecs;
  43992. private static _tmpQuat;
  43993. private static _tmpMats;
  43994. /**
  43995. * Gets or sets the target mesh
  43996. */
  43997. targetMesh: AbstractMesh;
  43998. /** Gets or sets the mesh used as pole */
  43999. poleTargetMesh: AbstractMesh;
  44000. /**
  44001. * Gets or sets the bone used as pole
  44002. */
  44003. poleTargetBone: Nullable<Bone>;
  44004. /**
  44005. * Gets or sets the target position
  44006. */
  44007. targetPosition: Vector3;
  44008. /**
  44009. * Gets or sets the pole target position
  44010. */
  44011. poleTargetPosition: Vector3;
  44012. /**
  44013. * Gets or sets the pole target local offset
  44014. */
  44015. poleTargetLocalOffset: Vector3;
  44016. /**
  44017. * Gets or sets the pole angle
  44018. */
  44019. poleAngle: number;
  44020. /**
  44021. * Gets or sets the mesh associated with the controller
  44022. */
  44023. mesh: AbstractMesh;
  44024. /**
  44025. * 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)
  44026. */
  44027. slerpAmount: number;
  44028. private _bone1Quat;
  44029. private _bone1Mat;
  44030. private _bone2Ang;
  44031. private _bone1;
  44032. private _bone2;
  44033. private _bone1Length;
  44034. private _bone2Length;
  44035. private _maxAngle;
  44036. private _maxReach;
  44037. private _rightHandedSystem;
  44038. private _bendAxis;
  44039. private _slerping;
  44040. private _adjustRoll;
  44041. /**
  44042. * Gets or sets maximum allowed angle
  44043. */
  44044. get maxAngle(): number;
  44045. set maxAngle(value: number);
  44046. /**
  44047. * Creates a new BoneIKController
  44048. * @param mesh defines the mesh to control
  44049. * @param bone defines the bone to control
  44050. * @param options defines options to set up the controller
  44051. */
  44052. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44053. targetMesh?: AbstractMesh;
  44054. poleTargetMesh?: AbstractMesh;
  44055. poleTargetBone?: Bone;
  44056. poleTargetLocalOffset?: Vector3;
  44057. poleAngle?: number;
  44058. bendAxis?: Vector3;
  44059. maxAngle?: number;
  44060. slerpAmount?: number;
  44061. });
  44062. private _setMaxAngle;
  44063. /**
  44064. * Force the controller to update the bones
  44065. */
  44066. update(): void;
  44067. }
  44068. }
  44069. declare module "babylonjs/Bones/boneLookController" {
  44070. import { Vector3 } from "babylonjs/Maths/math.vector";
  44071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44072. import { Bone } from "babylonjs/Bones/bone";
  44073. import { Space } from "babylonjs/Maths/math.axis";
  44074. /**
  44075. * Class used to make a bone look toward a point in space
  44076. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44077. */
  44078. export class BoneLookController {
  44079. private static _tmpVecs;
  44080. private static _tmpQuat;
  44081. private static _tmpMats;
  44082. /**
  44083. * The target Vector3 that the bone will look at
  44084. */
  44085. target: Vector3;
  44086. /**
  44087. * The mesh that the bone is attached to
  44088. */
  44089. mesh: AbstractMesh;
  44090. /**
  44091. * The bone that will be looking to the target
  44092. */
  44093. bone: Bone;
  44094. /**
  44095. * The up axis of the coordinate system that is used when the bone is rotated
  44096. */
  44097. upAxis: Vector3;
  44098. /**
  44099. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44100. */
  44101. upAxisSpace: Space;
  44102. /**
  44103. * Used to make an adjustment to the yaw of the bone
  44104. */
  44105. adjustYaw: number;
  44106. /**
  44107. * Used to make an adjustment to the pitch of the bone
  44108. */
  44109. adjustPitch: number;
  44110. /**
  44111. * Used to make an adjustment to the roll of the bone
  44112. */
  44113. adjustRoll: number;
  44114. /**
  44115. * 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)
  44116. */
  44117. slerpAmount: number;
  44118. private _minYaw;
  44119. private _maxYaw;
  44120. private _minPitch;
  44121. private _maxPitch;
  44122. private _minYawSin;
  44123. private _minYawCos;
  44124. private _maxYawSin;
  44125. private _maxYawCos;
  44126. private _midYawConstraint;
  44127. private _minPitchTan;
  44128. private _maxPitchTan;
  44129. private _boneQuat;
  44130. private _slerping;
  44131. private _transformYawPitch;
  44132. private _transformYawPitchInv;
  44133. private _firstFrameSkipped;
  44134. private _yawRange;
  44135. private _fowardAxis;
  44136. /**
  44137. * Gets or sets the minimum yaw angle that the bone can look to
  44138. */
  44139. get minYaw(): number;
  44140. set minYaw(value: number);
  44141. /**
  44142. * Gets or sets the maximum yaw angle that the bone can look to
  44143. */
  44144. get maxYaw(): number;
  44145. set maxYaw(value: number);
  44146. /**
  44147. * Gets or sets the minimum pitch angle that the bone can look to
  44148. */
  44149. get minPitch(): number;
  44150. set minPitch(value: number);
  44151. /**
  44152. * Gets or sets the maximum pitch angle that the bone can look to
  44153. */
  44154. get maxPitch(): number;
  44155. set maxPitch(value: number);
  44156. /**
  44157. * Create a BoneLookController
  44158. * @param mesh the mesh that the bone belongs to
  44159. * @param bone the bone that will be looking to the target
  44160. * @param target the target Vector3 to look at
  44161. * @param options optional settings:
  44162. * * maxYaw: the maximum angle the bone will yaw to
  44163. * * minYaw: the minimum angle the bone will yaw to
  44164. * * maxPitch: the maximum angle the bone will pitch to
  44165. * * minPitch: the minimum angle the bone will yaw to
  44166. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44167. * * upAxis: the up axis of the coordinate system
  44168. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44169. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44170. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44171. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44172. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44173. * * adjustRoll: used to make an adjustment to the roll of the bone
  44174. **/
  44175. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44176. maxYaw?: number;
  44177. minYaw?: number;
  44178. maxPitch?: number;
  44179. minPitch?: number;
  44180. slerpAmount?: number;
  44181. upAxis?: Vector3;
  44182. upAxisSpace?: Space;
  44183. yawAxis?: Vector3;
  44184. pitchAxis?: Vector3;
  44185. adjustYaw?: number;
  44186. adjustPitch?: number;
  44187. adjustRoll?: number;
  44188. });
  44189. /**
  44190. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44191. */
  44192. update(): void;
  44193. private _getAngleDiff;
  44194. private _getAngleBetween;
  44195. private _isAngleBetween;
  44196. }
  44197. }
  44198. declare module "babylonjs/Bones/index" {
  44199. export * from "babylonjs/Bones/bone";
  44200. export * from "babylonjs/Bones/boneIKController";
  44201. export * from "babylonjs/Bones/boneLookController";
  44202. export * from "babylonjs/Bones/skeleton";
  44203. }
  44204. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44205. import { Nullable } from "babylonjs/types";
  44206. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44207. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44208. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44209. /**
  44210. * Manage the gamepad inputs to control an arc rotate camera.
  44211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44212. */
  44213. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44214. /**
  44215. * Defines the camera the input is attached to.
  44216. */
  44217. camera: ArcRotateCamera;
  44218. /**
  44219. * Defines the gamepad the input is gathering event from.
  44220. */
  44221. gamepad: Nullable<Gamepad>;
  44222. /**
  44223. * Defines the gamepad rotation sensiblity.
  44224. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44225. */
  44226. gamepadRotationSensibility: number;
  44227. /**
  44228. * Defines the gamepad move sensiblity.
  44229. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44230. */
  44231. gamepadMoveSensibility: number;
  44232. private _yAxisScale;
  44233. /**
  44234. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44235. */
  44236. get invertYAxis(): boolean;
  44237. set invertYAxis(value: boolean);
  44238. private _onGamepadConnectedObserver;
  44239. private _onGamepadDisconnectedObserver;
  44240. /**
  44241. * Attach the input controls to a specific dom element to get the input from.
  44242. * @param element Defines the element the controls should be listened from
  44243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44244. */
  44245. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44246. /**
  44247. * Detach the current controls from the specified dom element.
  44248. * @param element Defines the element to stop listening the inputs from
  44249. */
  44250. detachControl(element: Nullable<HTMLElement>): void;
  44251. /**
  44252. * Update the current camera state depending on the inputs that have been used this frame.
  44253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44254. */
  44255. checkInputs(): void;
  44256. /**
  44257. * Gets the class name of the current intput.
  44258. * @returns the class name
  44259. */
  44260. getClassName(): string;
  44261. /**
  44262. * Get the friendly name associated with the input class.
  44263. * @returns the input friendly name
  44264. */
  44265. getSimpleName(): string;
  44266. }
  44267. }
  44268. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44269. import { Nullable } from "babylonjs/types";
  44270. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44271. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44272. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44273. interface ArcRotateCameraInputsManager {
  44274. /**
  44275. * Add orientation input support to the input manager.
  44276. * @returns the current input manager
  44277. */
  44278. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44279. }
  44280. }
  44281. /**
  44282. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44284. */
  44285. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44286. /**
  44287. * Defines the camera the input is attached to.
  44288. */
  44289. camera: ArcRotateCamera;
  44290. /**
  44291. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44292. */
  44293. alphaCorrection: number;
  44294. /**
  44295. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44296. */
  44297. gammaCorrection: number;
  44298. private _alpha;
  44299. private _gamma;
  44300. private _dirty;
  44301. private _deviceOrientationHandler;
  44302. /**
  44303. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44304. */
  44305. constructor();
  44306. /**
  44307. * Attach the input controls to a specific dom element to get the input from.
  44308. * @param element Defines the element the controls should be listened from
  44309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44310. */
  44311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44312. /** @hidden */
  44313. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44314. /**
  44315. * Update the current camera state depending on the inputs that have been used this frame.
  44316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44317. */
  44318. checkInputs(): void;
  44319. /**
  44320. * Detach the current controls from the specified dom element.
  44321. * @param element Defines the element to stop listening the inputs from
  44322. */
  44323. detachControl(element: Nullable<HTMLElement>): void;
  44324. /**
  44325. * Gets the class name of the current intput.
  44326. * @returns the class name
  44327. */
  44328. getClassName(): string;
  44329. /**
  44330. * Get the friendly name associated with the input class.
  44331. * @returns the input friendly name
  44332. */
  44333. getSimpleName(): string;
  44334. }
  44335. }
  44336. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44337. import { Nullable } from "babylonjs/types";
  44338. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44339. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44340. /**
  44341. * Listen to mouse events to control the camera.
  44342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44343. */
  44344. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44345. /**
  44346. * Defines the camera the input is attached to.
  44347. */
  44348. camera: FlyCamera;
  44349. /**
  44350. * Defines if touch is enabled. (Default is true.)
  44351. */
  44352. touchEnabled: boolean;
  44353. /**
  44354. * Defines the buttons associated with the input to handle camera rotation.
  44355. */
  44356. buttons: number[];
  44357. /**
  44358. * Assign buttons for Yaw control.
  44359. */
  44360. buttonsYaw: number[];
  44361. /**
  44362. * Assign buttons for Pitch control.
  44363. */
  44364. buttonsPitch: number[];
  44365. /**
  44366. * Assign buttons for Roll control.
  44367. */
  44368. buttonsRoll: number[];
  44369. /**
  44370. * Detect if any button is being pressed while mouse is moved.
  44371. * -1 = Mouse locked.
  44372. * 0 = Left button.
  44373. * 1 = Middle Button.
  44374. * 2 = Right Button.
  44375. */
  44376. activeButton: number;
  44377. /**
  44378. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44379. * Higher values reduce its sensitivity.
  44380. */
  44381. angularSensibility: number;
  44382. private _mousemoveCallback;
  44383. private _observer;
  44384. private _rollObserver;
  44385. private previousPosition;
  44386. private noPreventDefault;
  44387. private element;
  44388. /**
  44389. * Listen to mouse events to control the camera.
  44390. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44392. */
  44393. constructor(touchEnabled?: boolean);
  44394. /**
  44395. * Attach the mouse control to the HTML DOM element.
  44396. * @param element Defines the element that listens to the input events.
  44397. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44398. */
  44399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44400. /**
  44401. * Detach the current controls from the specified dom element.
  44402. * @param element Defines the element to stop listening the inputs from
  44403. */
  44404. detachControl(element: Nullable<HTMLElement>): void;
  44405. /**
  44406. * Gets the class name of the current input.
  44407. * @returns the class name.
  44408. */
  44409. getClassName(): string;
  44410. /**
  44411. * Get the friendly name associated with the input class.
  44412. * @returns the input's friendly name.
  44413. */
  44414. getSimpleName(): string;
  44415. private _pointerInput;
  44416. private _onMouseMove;
  44417. /**
  44418. * Rotate camera by mouse offset.
  44419. */
  44420. private rotateCamera;
  44421. }
  44422. }
  44423. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44424. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44425. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44426. /**
  44427. * Default Inputs manager for the FlyCamera.
  44428. * It groups all the default supported inputs for ease of use.
  44429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44430. */
  44431. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44432. /**
  44433. * Instantiates a new FlyCameraInputsManager.
  44434. * @param camera Defines the camera the inputs belong to.
  44435. */
  44436. constructor(camera: FlyCamera);
  44437. /**
  44438. * Add keyboard input support to the input manager.
  44439. * @returns the new FlyCameraKeyboardMoveInput().
  44440. */
  44441. addKeyboard(): FlyCameraInputsManager;
  44442. /**
  44443. * Add mouse input support to the input manager.
  44444. * @param touchEnabled Enable touch screen support.
  44445. * @returns the new FlyCameraMouseInput().
  44446. */
  44447. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44448. }
  44449. }
  44450. declare module "babylonjs/Cameras/flyCamera" {
  44451. import { Scene } from "babylonjs/scene";
  44452. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44454. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44455. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44456. /**
  44457. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44458. * such as in a 3D Space Shooter or a Flight Simulator.
  44459. */
  44460. export class FlyCamera extends TargetCamera {
  44461. /**
  44462. * Define the collision ellipsoid of the camera.
  44463. * This is helpful for simulating a camera body, like a player's body.
  44464. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44465. */
  44466. ellipsoid: Vector3;
  44467. /**
  44468. * Define an offset for the position of the ellipsoid around the camera.
  44469. * This can be helpful if the camera is attached away from the player's body center,
  44470. * such as at its head.
  44471. */
  44472. ellipsoidOffset: Vector3;
  44473. /**
  44474. * Enable or disable collisions of the camera with the rest of the scene objects.
  44475. */
  44476. checkCollisions: boolean;
  44477. /**
  44478. * Enable or disable gravity on the camera.
  44479. */
  44480. applyGravity: boolean;
  44481. /**
  44482. * Define the current direction the camera is moving to.
  44483. */
  44484. cameraDirection: Vector3;
  44485. /**
  44486. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44487. * This overrides and empties cameraRotation.
  44488. */
  44489. rotationQuaternion: Quaternion;
  44490. /**
  44491. * Track Roll to maintain the wanted Rolling when looking around.
  44492. */
  44493. _trackRoll: number;
  44494. /**
  44495. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44496. */
  44497. rollCorrect: number;
  44498. /**
  44499. * Mimic a banked turn, Rolling the camera when Yawing.
  44500. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44501. */
  44502. bankedTurn: boolean;
  44503. /**
  44504. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44505. */
  44506. bankedTurnLimit: number;
  44507. /**
  44508. * Value of 0 disables the banked Roll.
  44509. * Value of 1 is equal to the Yaw angle in radians.
  44510. */
  44511. bankedTurnMultiplier: number;
  44512. /**
  44513. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44514. */
  44515. inputs: FlyCameraInputsManager;
  44516. /**
  44517. * Gets the input sensibility for mouse input.
  44518. * Higher values reduce sensitivity.
  44519. */
  44520. get angularSensibility(): number;
  44521. /**
  44522. * Sets the input sensibility for a mouse input.
  44523. * Higher values reduce sensitivity.
  44524. */
  44525. set angularSensibility(value: number);
  44526. /**
  44527. * Get the keys for camera movement forward.
  44528. */
  44529. get keysForward(): number[];
  44530. /**
  44531. * Set the keys for camera movement forward.
  44532. */
  44533. set keysForward(value: number[]);
  44534. /**
  44535. * Get the keys for camera movement backward.
  44536. */
  44537. get keysBackward(): number[];
  44538. set keysBackward(value: number[]);
  44539. /**
  44540. * Get the keys for camera movement up.
  44541. */
  44542. get keysUp(): number[];
  44543. /**
  44544. * Set the keys for camera movement up.
  44545. */
  44546. set keysUp(value: number[]);
  44547. /**
  44548. * Get the keys for camera movement down.
  44549. */
  44550. get keysDown(): number[];
  44551. /**
  44552. * Set the keys for camera movement down.
  44553. */
  44554. set keysDown(value: number[]);
  44555. /**
  44556. * Get the keys for camera movement left.
  44557. */
  44558. get keysLeft(): number[];
  44559. /**
  44560. * Set the keys for camera movement left.
  44561. */
  44562. set keysLeft(value: number[]);
  44563. /**
  44564. * Set the keys for camera movement right.
  44565. */
  44566. get keysRight(): number[];
  44567. /**
  44568. * Set the keys for camera movement right.
  44569. */
  44570. set keysRight(value: number[]);
  44571. /**
  44572. * Event raised when the camera collides with a mesh in the scene.
  44573. */
  44574. onCollide: (collidedMesh: AbstractMesh) => void;
  44575. private _collider;
  44576. private _needMoveForGravity;
  44577. private _oldPosition;
  44578. private _diffPosition;
  44579. private _newPosition;
  44580. /** @hidden */
  44581. _localDirection: Vector3;
  44582. /** @hidden */
  44583. _transformedDirection: Vector3;
  44584. /**
  44585. * Instantiates a FlyCamera.
  44586. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44587. * such as in a 3D Space Shooter or a Flight Simulator.
  44588. * @param name Define the name of the camera in the scene.
  44589. * @param position Define the starting position of the camera in the scene.
  44590. * @param scene Define the scene the camera belongs to.
  44591. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44592. */
  44593. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44594. /**
  44595. * Attach a control to the HTML DOM element.
  44596. * @param element Defines the element that listens to the input events.
  44597. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44598. */
  44599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44600. /**
  44601. * Detach a control from the HTML DOM element.
  44602. * The camera will stop reacting to that input.
  44603. * @param element Defines the element that listens to the input events.
  44604. */
  44605. detachControl(element: HTMLElement): void;
  44606. private _collisionMask;
  44607. /**
  44608. * Get the mask that the camera ignores in collision events.
  44609. */
  44610. get collisionMask(): number;
  44611. /**
  44612. * Set the mask that the camera ignores in collision events.
  44613. */
  44614. set collisionMask(mask: number);
  44615. /** @hidden */
  44616. _collideWithWorld(displacement: Vector3): void;
  44617. /** @hidden */
  44618. private _onCollisionPositionChange;
  44619. /** @hidden */
  44620. _checkInputs(): void;
  44621. /** @hidden */
  44622. _decideIfNeedsToMove(): boolean;
  44623. /** @hidden */
  44624. _updatePosition(): void;
  44625. /**
  44626. * Restore the Roll to its target value at the rate specified.
  44627. * @param rate - Higher means slower restoring.
  44628. * @hidden
  44629. */
  44630. restoreRoll(rate: number): void;
  44631. /**
  44632. * Destroy the camera and release the current resources held by it.
  44633. */
  44634. dispose(): void;
  44635. /**
  44636. * Get the current object class name.
  44637. * @returns the class name.
  44638. */
  44639. getClassName(): string;
  44640. }
  44641. }
  44642. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44643. import { Nullable } from "babylonjs/types";
  44644. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44645. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44646. /**
  44647. * Listen to keyboard events to control the camera.
  44648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44649. */
  44650. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44651. /**
  44652. * Defines the camera the input is attached to.
  44653. */
  44654. camera: FlyCamera;
  44655. /**
  44656. * The list of keyboard keys used to control the forward move of the camera.
  44657. */
  44658. keysForward: number[];
  44659. /**
  44660. * The list of keyboard keys used to control the backward move of the camera.
  44661. */
  44662. keysBackward: number[];
  44663. /**
  44664. * The list of keyboard keys used to control the forward move of the camera.
  44665. */
  44666. keysUp: number[];
  44667. /**
  44668. * The list of keyboard keys used to control the backward move of the camera.
  44669. */
  44670. keysDown: number[];
  44671. /**
  44672. * The list of keyboard keys used to control the right strafe move of the camera.
  44673. */
  44674. keysRight: number[];
  44675. /**
  44676. * The list of keyboard keys used to control the left strafe move of the camera.
  44677. */
  44678. keysLeft: number[];
  44679. private _keys;
  44680. private _onCanvasBlurObserver;
  44681. private _onKeyboardObserver;
  44682. private _engine;
  44683. private _scene;
  44684. /**
  44685. * Attach the input controls to a specific dom element to get the input from.
  44686. * @param element Defines the element the controls should be listened from
  44687. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44688. */
  44689. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44690. /**
  44691. * Detach the current controls from the specified dom element.
  44692. * @param element Defines the element to stop listening the inputs from
  44693. */
  44694. detachControl(element: Nullable<HTMLElement>): void;
  44695. /**
  44696. * Gets the class name of the current intput.
  44697. * @returns the class name
  44698. */
  44699. getClassName(): string;
  44700. /** @hidden */
  44701. _onLostFocus(e: FocusEvent): void;
  44702. /**
  44703. * Get the friendly name associated with the input class.
  44704. * @returns the input friendly name
  44705. */
  44706. getSimpleName(): string;
  44707. /**
  44708. * Update the current camera state depending on the inputs that have been used this frame.
  44709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44710. */
  44711. checkInputs(): void;
  44712. }
  44713. }
  44714. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44715. import { Nullable } from "babylonjs/types";
  44716. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44717. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44718. /**
  44719. * Manage the mouse wheel inputs to control a follow camera.
  44720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44721. */
  44722. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44723. /**
  44724. * Defines the camera the input is attached to.
  44725. */
  44726. camera: FollowCamera;
  44727. /**
  44728. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44729. */
  44730. axisControlRadius: boolean;
  44731. /**
  44732. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44733. */
  44734. axisControlHeight: boolean;
  44735. /**
  44736. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44737. */
  44738. axisControlRotation: boolean;
  44739. /**
  44740. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44741. * relation to mouseWheel events.
  44742. */
  44743. wheelPrecision: number;
  44744. /**
  44745. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44746. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44747. */
  44748. wheelDeltaPercentage: number;
  44749. private _wheel;
  44750. private _observer;
  44751. /**
  44752. * Attach the input controls to a specific dom element to get the input from.
  44753. * @param element Defines the element the controls should be listened from
  44754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44755. */
  44756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44757. /**
  44758. * Detach the current controls from the specified dom element.
  44759. * @param element Defines the element to stop listening the inputs from
  44760. */
  44761. detachControl(element: Nullable<HTMLElement>): void;
  44762. /**
  44763. * Gets the class name of the current intput.
  44764. * @returns the class name
  44765. */
  44766. getClassName(): string;
  44767. /**
  44768. * Get the friendly name associated with the input class.
  44769. * @returns the input friendly name
  44770. */
  44771. getSimpleName(): string;
  44772. }
  44773. }
  44774. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  44775. import { Nullable } from "babylonjs/types";
  44776. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44777. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44778. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44779. /**
  44780. * Manage the pointers inputs to control an follow camera.
  44781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44782. */
  44783. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44784. /**
  44785. * Defines the camera the input is attached to.
  44786. */
  44787. camera: FollowCamera;
  44788. /**
  44789. * Gets the class name of the current input.
  44790. * @returns the class name
  44791. */
  44792. getClassName(): string;
  44793. /**
  44794. * Defines the pointer angular sensibility along the X axis or how fast is
  44795. * the camera rotating.
  44796. * A negative number will reverse the axis direction.
  44797. */
  44798. angularSensibilityX: number;
  44799. /**
  44800. * Defines the pointer angular sensibility along the Y axis or how fast is
  44801. * the camera rotating.
  44802. * A negative number will reverse the axis direction.
  44803. */
  44804. angularSensibilityY: number;
  44805. /**
  44806. * Defines the pointer pinch precision or how fast is the camera zooming.
  44807. * A negative number will reverse the axis direction.
  44808. */
  44809. pinchPrecision: number;
  44810. /**
  44811. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44812. * from 0.
  44813. * It defines the percentage of current camera.radius to use as delta when
  44814. * pinch zoom is used.
  44815. */
  44816. pinchDeltaPercentage: number;
  44817. /**
  44818. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44819. */
  44820. axisXControlRadius: boolean;
  44821. /**
  44822. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44823. */
  44824. axisXControlHeight: boolean;
  44825. /**
  44826. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44827. */
  44828. axisXControlRotation: boolean;
  44829. /**
  44830. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44831. */
  44832. axisYControlRadius: boolean;
  44833. /**
  44834. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44835. */
  44836. axisYControlHeight: boolean;
  44837. /**
  44838. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44839. */
  44840. axisYControlRotation: boolean;
  44841. /**
  44842. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44843. */
  44844. axisPinchControlRadius: boolean;
  44845. /**
  44846. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44847. */
  44848. axisPinchControlHeight: boolean;
  44849. /**
  44850. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44851. */
  44852. axisPinchControlRotation: boolean;
  44853. /**
  44854. * Log error messages if basic misconfiguration has occurred.
  44855. */
  44856. warningEnable: boolean;
  44857. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44858. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44859. private _warningCounter;
  44860. private _warning;
  44861. }
  44862. }
  44863. declare module "babylonjs/Cameras/followCameraInputsManager" {
  44864. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44865. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44866. /**
  44867. * Default Inputs manager for the FollowCamera.
  44868. * It groups all the default supported inputs for ease of use.
  44869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44870. */
  44871. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44872. /**
  44873. * Instantiates a new FollowCameraInputsManager.
  44874. * @param camera Defines the camera the inputs belong to
  44875. */
  44876. constructor(camera: FollowCamera);
  44877. /**
  44878. * Add keyboard input support to the input manager.
  44879. * @returns the current input manager
  44880. */
  44881. addKeyboard(): FollowCameraInputsManager;
  44882. /**
  44883. * Add mouse wheel input support to the input manager.
  44884. * @returns the current input manager
  44885. */
  44886. addMouseWheel(): FollowCameraInputsManager;
  44887. /**
  44888. * Add pointers input support to the input manager.
  44889. * @returns the current input manager
  44890. */
  44891. addPointers(): FollowCameraInputsManager;
  44892. /**
  44893. * Add orientation input support to the input manager.
  44894. * @returns the current input manager
  44895. */
  44896. addVRDeviceOrientation(): FollowCameraInputsManager;
  44897. }
  44898. }
  44899. declare module "babylonjs/Cameras/followCamera" {
  44900. import { Nullable } from "babylonjs/types";
  44901. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44902. import { Scene } from "babylonjs/scene";
  44903. import { Vector3 } from "babylonjs/Maths/math.vector";
  44904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44905. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  44906. /**
  44907. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44908. * an arc rotate version arcFollowCamera are available.
  44909. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44910. */
  44911. export class FollowCamera extends TargetCamera {
  44912. /**
  44913. * Distance the follow camera should follow an object at
  44914. */
  44915. radius: number;
  44916. /**
  44917. * Minimum allowed distance of the camera to the axis of rotation
  44918. * (The camera can not get closer).
  44919. * This can help limiting how the Camera is able to move in the scene.
  44920. */
  44921. lowerRadiusLimit: Nullable<number>;
  44922. /**
  44923. * Maximum allowed distance of the camera to the axis of rotation
  44924. * (The camera can not get further).
  44925. * This can help limiting how the Camera is able to move in the scene.
  44926. */
  44927. upperRadiusLimit: Nullable<number>;
  44928. /**
  44929. * Define a rotation offset between the camera and the object it follows
  44930. */
  44931. rotationOffset: number;
  44932. /**
  44933. * Minimum allowed angle to camera position relative to target object.
  44934. * This can help limiting how the Camera is able to move in the scene.
  44935. */
  44936. lowerRotationOffsetLimit: Nullable<number>;
  44937. /**
  44938. * Maximum allowed angle to camera position relative to target object.
  44939. * This can help limiting how the Camera is able to move in the scene.
  44940. */
  44941. upperRotationOffsetLimit: Nullable<number>;
  44942. /**
  44943. * Define a height offset between the camera and the object it follows.
  44944. * It can help following an object from the top (like a car chaing a plane)
  44945. */
  44946. heightOffset: number;
  44947. /**
  44948. * Minimum allowed height of camera position relative to target object.
  44949. * This can help limiting how the Camera is able to move in the scene.
  44950. */
  44951. lowerHeightOffsetLimit: Nullable<number>;
  44952. /**
  44953. * Maximum allowed height of camera position relative to target object.
  44954. * This can help limiting how the Camera is able to move in the scene.
  44955. */
  44956. upperHeightOffsetLimit: Nullable<number>;
  44957. /**
  44958. * Define how fast the camera can accelerate to follow it s target.
  44959. */
  44960. cameraAcceleration: number;
  44961. /**
  44962. * Define the speed limit of the camera following an object.
  44963. */
  44964. maxCameraSpeed: number;
  44965. /**
  44966. * Define the target of the camera.
  44967. */
  44968. lockedTarget: Nullable<AbstractMesh>;
  44969. /**
  44970. * Defines the input associated with the camera.
  44971. */
  44972. inputs: FollowCameraInputsManager;
  44973. /**
  44974. * Instantiates the follow camera.
  44975. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44976. * @param name Define the name of the camera in the scene
  44977. * @param position Define the position of the camera
  44978. * @param scene Define the scene the camera belong to
  44979. * @param lockedTarget Define the target of the camera
  44980. */
  44981. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44982. private _follow;
  44983. /**
  44984. * Attached controls to the current camera.
  44985. * @param element Defines the element the controls should be listened from
  44986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44987. */
  44988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44989. /**
  44990. * Detach the current controls from the camera.
  44991. * The camera will stop reacting to inputs.
  44992. * @param element Defines the element to stop listening the inputs from
  44993. */
  44994. detachControl(element: HTMLElement): void;
  44995. /** @hidden */
  44996. _checkInputs(): void;
  44997. private _checkLimits;
  44998. /**
  44999. * Gets the camera class name.
  45000. * @returns the class name
  45001. */
  45002. getClassName(): string;
  45003. }
  45004. /**
  45005. * Arc Rotate version of the follow camera.
  45006. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45007. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45008. */
  45009. export class ArcFollowCamera extends TargetCamera {
  45010. /** The longitudinal angle of the camera */
  45011. alpha: number;
  45012. /** The latitudinal angle of the camera */
  45013. beta: number;
  45014. /** The radius of the camera from its target */
  45015. radius: number;
  45016. /** Define the camera target (the messh it should follow) */
  45017. target: Nullable<AbstractMesh>;
  45018. private _cartesianCoordinates;
  45019. /**
  45020. * Instantiates a new ArcFollowCamera
  45021. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45022. * @param name Define the name of the camera
  45023. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45024. * @param beta Define the rotation angle of the camera around the elevation axis
  45025. * @param radius Define the radius of the camera from its target point
  45026. * @param target Define the target of the camera
  45027. * @param scene Define the scene the camera belongs to
  45028. */
  45029. constructor(name: string,
  45030. /** The longitudinal angle of the camera */
  45031. alpha: number,
  45032. /** The latitudinal angle of the camera */
  45033. beta: number,
  45034. /** The radius of the camera from its target */
  45035. radius: number,
  45036. /** Define the camera target (the messh it should follow) */
  45037. target: Nullable<AbstractMesh>, scene: Scene);
  45038. private _follow;
  45039. /** @hidden */
  45040. _checkInputs(): void;
  45041. /**
  45042. * Returns the class name of the object.
  45043. * It is mostly used internally for serialization purposes.
  45044. */
  45045. getClassName(): string;
  45046. }
  45047. }
  45048. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45049. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45050. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45051. import { Nullable } from "babylonjs/types";
  45052. /**
  45053. * Manage the keyboard inputs to control the movement of a follow camera.
  45054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45055. */
  45056. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45057. /**
  45058. * Defines the camera the input is attached to.
  45059. */
  45060. camera: FollowCamera;
  45061. /**
  45062. * Defines the list of key codes associated with the up action (increase heightOffset)
  45063. */
  45064. keysHeightOffsetIncr: number[];
  45065. /**
  45066. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45067. */
  45068. keysHeightOffsetDecr: number[];
  45069. /**
  45070. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45071. */
  45072. keysHeightOffsetModifierAlt: boolean;
  45073. /**
  45074. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45075. */
  45076. keysHeightOffsetModifierCtrl: boolean;
  45077. /**
  45078. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45079. */
  45080. keysHeightOffsetModifierShift: boolean;
  45081. /**
  45082. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45083. */
  45084. keysRotationOffsetIncr: number[];
  45085. /**
  45086. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45087. */
  45088. keysRotationOffsetDecr: number[];
  45089. /**
  45090. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45091. */
  45092. keysRotationOffsetModifierAlt: boolean;
  45093. /**
  45094. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45095. */
  45096. keysRotationOffsetModifierCtrl: boolean;
  45097. /**
  45098. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45099. */
  45100. keysRotationOffsetModifierShift: boolean;
  45101. /**
  45102. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45103. */
  45104. keysRadiusIncr: number[];
  45105. /**
  45106. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45107. */
  45108. keysRadiusDecr: number[];
  45109. /**
  45110. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45111. */
  45112. keysRadiusModifierAlt: boolean;
  45113. /**
  45114. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45115. */
  45116. keysRadiusModifierCtrl: boolean;
  45117. /**
  45118. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45119. */
  45120. keysRadiusModifierShift: boolean;
  45121. /**
  45122. * Defines the rate of change of heightOffset.
  45123. */
  45124. heightSensibility: number;
  45125. /**
  45126. * Defines the rate of change of rotationOffset.
  45127. */
  45128. rotationSensibility: number;
  45129. /**
  45130. * Defines the rate of change of radius.
  45131. */
  45132. radiusSensibility: number;
  45133. private _keys;
  45134. private _ctrlPressed;
  45135. private _altPressed;
  45136. private _shiftPressed;
  45137. private _onCanvasBlurObserver;
  45138. private _onKeyboardObserver;
  45139. private _engine;
  45140. private _scene;
  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. /**
  45148. * Detach the current controls from the specified dom element.
  45149. * @param element Defines the element to stop listening the inputs from
  45150. */
  45151. detachControl(element: Nullable<HTMLElement>): void;
  45152. /**
  45153. * Update the current camera state depending on the inputs that have been used this frame.
  45154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45155. */
  45156. checkInputs(): void;
  45157. /**
  45158. * Gets the class name of the current input.
  45159. * @returns the class name
  45160. */
  45161. getClassName(): string;
  45162. /**
  45163. * Get the friendly name associated with the input class.
  45164. * @returns the input friendly name
  45165. */
  45166. getSimpleName(): string;
  45167. /**
  45168. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45169. * allow modification of the heightOffset value.
  45170. */
  45171. private _modifierHeightOffset;
  45172. /**
  45173. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45174. * allow modification of the rotationOffset value.
  45175. */
  45176. private _modifierRotationOffset;
  45177. /**
  45178. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45179. * allow modification of the radius value.
  45180. */
  45181. private _modifierRadius;
  45182. }
  45183. }
  45184. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45185. import { Nullable } from "babylonjs/types";
  45186. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45187. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45188. import { Observable } from "babylonjs/Misc/observable";
  45189. module "babylonjs/Cameras/freeCameraInputsManager" {
  45190. interface FreeCameraInputsManager {
  45191. /**
  45192. * @hidden
  45193. */
  45194. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45195. /**
  45196. * Add orientation input support to the input manager.
  45197. * @returns the current input manager
  45198. */
  45199. addDeviceOrientation(): FreeCameraInputsManager;
  45200. }
  45201. }
  45202. /**
  45203. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45204. * Screen rotation is taken into account.
  45205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45206. */
  45207. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45208. private _camera;
  45209. private _screenOrientationAngle;
  45210. private _constantTranform;
  45211. private _screenQuaternion;
  45212. private _alpha;
  45213. private _beta;
  45214. private _gamma;
  45215. /**
  45216. * Can be used to detect if a device orientation sensor is available on a device
  45217. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45218. * @returns a promise that will resolve on orientation change
  45219. */
  45220. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45221. /**
  45222. * @hidden
  45223. */
  45224. _onDeviceOrientationChangedObservable: Observable<void>;
  45225. /**
  45226. * Instantiates a new input
  45227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45228. */
  45229. constructor();
  45230. /**
  45231. * Define the camera controlled by the input.
  45232. */
  45233. get camera(): FreeCamera;
  45234. set camera(camera: FreeCamera);
  45235. /**
  45236. * Attach the input controls to a specific dom element to get the input from.
  45237. * @param element Defines the element the controls should be listened from
  45238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45239. */
  45240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45241. private _orientationChanged;
  45242. private _deviceOrientation;
  45243. /**
  45244. * Detach the current controls from the specified dom element.
  45245. * @param element Defines the element to stop listening the inputs from
  45246. */
  45247. detachControl(element: Nullable<HTMLElement>): void;
  45248. /**
  45249. * Update the current camera state depending on the inputs that have been used this frame.
  45250. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45251. */
  45252. checkInputs(): void;
  45253. /**
  45254. * Gets the class name of the current intput.
  45255. * @returns the class name
  45256. */
  45257. getClassName(): string;
  45258. /**
  45259. * Get the friendly name associated with the input class.
  45260. * @returns the input friendly name
  45261. */
  45262. getSimpleName(): string;
  45263. }
  45264. }
  45265. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45266. import { Nullable } from "babylonjs/types";
  45267. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45268. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45269. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45270. /**
  45271. * Manage the gamepad inputs to control a free camera.
  45272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45273. */
  45274. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45275. /**
  45276. * Define the camera the input is attached to.
  45277. */
  45278. camera: FreeCamera;
  45279. /**
  45280. * Define the Gamepad controlling the input
  45281. */
  45282. gamepad: Nullable<Gamepad>;
  45283. /**
  45284. * Defines the gamepad rotation sensiblity.
  45285. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45286. */
  45287. gamepadAngularSensibility: number;
  45288. /**
  45289. * Defines the gamepad move sensiblity.
  45290. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45291. */
  45292. gamepadMoveSensibility: number;
  45293. private _yAxisScale;
  45294. /**
  45295. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45296. */
  45297. get invertYAxis(): boolean;
  45298. set invertYAxis(value: boolean);
  45299. private _onGamepadConnectedObserver;
  45300. private _onGamepadDisconnectedObserver;
  45301. private _cameraTransform;
  45302. private _deltaTransform;
  45303. private _vector3;
  45304. private _vector2;
  45305. /**
  45306. * Attach the input controls to a specific dom element to get the input from.
  45307. * @param element Defines the element the controls should be listened from
  45308. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45309. */
  45310. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45311. /**
  45312. * Detach the current controls from the specified dom element.
  45313. * @param element Defines the element to stop listening the inputs from
  45314. */
  45315. detachControl(element: Nullable<HTMLElement>): void;
  45316. /**
  45317. * Update the current camera state depending on the inputs that have been used this frame.
  45318. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45319. */
  45320. checkInputs(): void;
  45321. /**
  45322. * Gets the class name of the current intput.
  45323. * @returns the class name
  45324. */
  45325. getClassName(): string;
  45326. /**
  45327. * Get the friendly name associated with the input class.
  45328. * @returns the input friendly name
  45329. */
  45330. getSimpleName(): string;
  45331. }
  45332. }
  45333. declare module "babylonjs/Misc/virtualJoystick" {
  45334. import { Nullable } from "babylonjs/types";
  45335. import { Vector3 } from "babylonjs/Maths/math.vector";
  45336. /**
  45337. * Defines the potential axis of a Joystick
  45338. */
  45339. export enum JoystickAxis {
  45340. /** X axis */
  45341. X = 0,
  45342. /** Y axis */
  45343. Y = 1,
  45344. /** Z axis */
  45345. Z = 2
  45346. }
  45347. /**
  45348. * Class used to define virtual joystick (used in touch mode)
  45349. */
  45350. export class VirtualJoystick {
  45351. /**
  45352. * Gets or sets a boolean indicating that left and right values must be inverted
  45353. */
  45354. reverseLeftRight: boolean;
  45355. /**
  45356. * Gets or sets a boolean indicating that up and down values must be inverted
  45357. */
  45358. reverseUpDown: boolean;
  45359. /**
  45360. * Gets the offset value for the position (ie. the change of the position value)
  45361. */
  45362. deltaPosition: Vector3;
  45363. /**
  45364. * Gets a boolean indicating if the virtual joystick was pressed
  45365. */
  45366. pressed: boolean;
  45367. /**
  45368. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45369. */
  45370. static Canvas: Nullable<HTMLCanvasElement>;
  45371. private static _globalJoystickIndex;
  45372. private static vjCanvasContext;
  45373. private static vjCanvasWidth;
  45374. private static vjCanvasHeight;
  45375. private static halfWidth;
  45376. private _action;
  45377. private _axisTargetedByLeftAndRight;
  45378. private _axisTargetedByUpAndDown;
  45379. private _joystickSensibility;
  45380. private _inversedSensibility;
  45381. private _joystickPointerID;
  45382. private _joystickColor;
  45383. private _joystickPointerPos;
  45384. private _joystickPreviousPointerPos;
  45385. private _joystickPointerStartPos;
  45386. private _deltaJoystickVector;
  45387. private _leftJoystick;
  45388. private _touches;
  45389. private _onPointerDownHandlerRef;
  45390. private _onPointerMoveHandlerRef;
  45391. private _onPointerUpHandlerRef;
  45392. private _onResize;
  45393. /**
  45394. * Creates a new virtual joystick
  45395. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45396. */
  45397. constructor(leftJoystick?: boolean);
  45398. /**
  45399. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45400. * @param newJoystickSensibility defines the new sensibility
  45401. */
  45402. setJoystickSensibility(newJoystickSensibility: number): void;
  45403. private _onPointerDown;
  45404. private _onPointerMove;
  45405. private _onPointerUp;
  45406. /**
  45407. * Change the color of the virtual joystick
  45408. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45409. */
  45410. setJoystickColor(newColor: string): void;
  45411. /**
  45412. * Defines a callback to call when the joystick is touched
  45413. * @param action defines the callback
  45414. */
  45415. setActionOnTouch(action: () => any): void;
  45416. /**
  45417. * Defines which axis you'd like to control for left & right
  45418. * @param axis defines the axis to use
  45419. */
  45420. setAxisForLeftRight(axis: JoystickAxis): void;
  45421. /**
  45422. * Defines which axis you'd like to control for up & down
  45423. * @param axis defines the axis to use
  45424. */
  45425. setAxisForUpDown(axis: JoystickAxis): void;
  45426. private _drawVirtualJoystick;
  45427. /**
  45428. * Release internal HTML canvas
  45429. */
  45430. releaseCanvas(): void;
  45431. }
  45432. }
  45433. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45434. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45435. import { Nullable } from "babylonjs/types";
  45436. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45437. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45438. module "babylonjs/Cameras/freeCameraInputsManager" {
  45439. interface FreeCameraInputsManager {
  45440. /**
  45441. * Add virtual joystick input support to the input manager.
  45442. * @returns the current input manager
  45443. */
  45444. addVirtualJoystick(): FreeCameraInputsManager;
  45445. }
  45446. }
  45447. /**
  45448. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45450. */
  45451. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45452. /**
  45453. * Defines the camera the input is attached to.
  45454. */
  45455. camera: FreeCamera;
  45456. private _leftjoystick;
  45457. private _rightjoystick;
  45458. /**
  45459. * Gets the left stick of the virtual joystick.
  45460. * @returns The virtual Joystick
  45461. */
  45462. getLeftJoystick(): VirtualJoystick;
  45463. /**
  45464. * Gets the right stick of the virtual joystick.
  45465. * @returns The virtual Joystick
  45466. */
  45467. getRightJoystick(): VirtualJoystick;
  45468. /**
  45469. * Update the current camera state depending on the inputs that have been used this frame.
  45470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45471. */
  45472. checkInputs(): void;
  45473. /**
  45474. * Attach the input controls to a specific dom element to get the input from.
  45475. * @param element Defines the element the controls should be listened from
  45476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45477. */
  45478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45479. /**
  45480. * Detach the current controls from the specified dom element.
  45481. * @param element Defines the element to stop listening the inputs from
  45482. */
  45483. detachControl(element: Nullable<HTMLElement>): void;
  45484. /**
  45485. * Gets the class name of the current intput.
  45486. * @returns the class name
  45487. */
  45488. getClassName(): string;
  45489. /**
  45490. * Get the friendly name associated with the input class.
  45491. * @returns the input friendly name
  45492. */
  45493. getSimpleName(): string;
  45494. }
  45495. }
  45496. declare module "babylonjs/Cameras/Inputs/index" {
  45497. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45498. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45499. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45500. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45501. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45502. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45503. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45504. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45505. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45506. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45507. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45508. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45509. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45510. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45511. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45512. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45513. }
  45514. declare module "babylonjs/Cameras/touchCamera" {
  45515. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45516. import { Scene } from "babylonjs/scene";
  45517. import { Vector3 } from "babylonjs/Maths/math.vector";
  45518. /**
  45519. * This represents a FPS type of camera controlled by touch.
  45520. * This is like a universal camera minus the Gamepad controls.
  45521. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45522. */
  45523. export class TouchCamera extends FreeCamera {
  45524. /**
  45525. * Defines the touch sensibility for rotation.
  45526. * The higher the faster.
  45527. */
  45528. get touchAngularSensibility(): number;
  45529. set touchAngularSensibility(value: number);
  45530. /**
  45531. * Defines the touch sensibility for move.
  45532. * The higher the faster.
  45533. */
  45534. get touchMoveSensibility(): number;
  45535. set touchMoveSensibility(value: number);
  45536. /**
  45537. * Instantiates a new touch camera.
  45538. * This represents a FPS type of camera controlled by touch.
  45539. * This is like a universal camera minus the Gamepad controls.
  45540. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45541. * @param name Define the name of the camera in the scene
  45542. * @param position Define the start position of the camera in the scene
  45543. * @param scene Define the scene the camera belongs to
  45544. */
  45545. constructor(name: string, position: Vector3, scene: Scene);
  45546. /**
  45547. * Gets the current object class name.
  45548. * @return the class name
  45549. */
  45550. getClassName(): string;
  45551. /** @hidden */
  45552. _setupInputs(): void;
  45553. }
  45554. }
  45555. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45556. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45557. import { Scene } from "babylonjs/scene";
  45558. import { Vector3 } from "babylonjs/Maths/math.vector";
  45559. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45560. import { Axis } from "babylonjs/Maths/math.axis";
  45561. /**
  45562. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45563. * being tilted forward or back and left or right.
  45564. */
  45565. export class DeviceOrientationCamera extends FreeCamera {
  45566. private _initialQuaternion;
  45567. private _quaternionCache;
  45568. private _tmpDragQuaternion;
  45569. private _disablePointerInputWhenUsingDeviceOrientation;
  45570. /**
  45571. * Creates a new device orientation camera
  45572. * @param name The name of the camera
  45573. * @param position The start position camera
  45574. * @param scene The scene the camera belongs to
  45575. */
  45576. constructor(name: string, position: Vector3, scene: Scene);
  45577. /**
  45578. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45579. */
  45580. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45581. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45582. private _dragFactor;
  45583. /**
  45584. * Enabled turning on the y axis when the orientation sensor is active
  45585. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45586. */
  45587. enableHorizontalDragging(dragFactor?: number): void;
  45588. /**
  45589. * Gets the current instance class name ("DeviceOrientationCamera").
  45590. * This helps avoiding instanceof at run time.
  45591. * @returns the class name
  45592. */
  45593. getClassName(): string;
  45594. /**
  45595. * @hidden
  45596. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45597. */
  45598. _checkInputs(): void;
  45599. /**
  45600. * Reset the camera to its default orientation on the specified axis only.
  45601. * @param axis The axis to reset
  45602. */
  45603. resetToCurrentRotation(axis?: Axis): void;
  45604. }
  45605. }
  45606. declare module "babylonjs/Gamepads/xboxGamepad" {
  45607. import { Observable } from "babylonjs/Misc/observable";
  45608. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45609. /**
  45610. * Defines supported buttons for XBox360 compatible gamepads
  45611. */
  45612. export enum Xbox360Button {
  45613. /** A */
  45614. A = 0,
  45615. /** B */
  45616. B = 1,
  45617. /** X */
  45618. X = 2,
  45619. /** Y */
  45620. Y = 3,
  45621. /** Left button */
  45622. LB = 4,
  45623. /** Right button */
  45624. RB = 5,
  45625. /** Back */
  45626. Back = 8,
  45627. /** Start */
  45628. Start = 9,
  45629. /** Left stick */
  45630. LeftStick = 10,
  45631. /** Right stick */
  45632. RightStick = 11
  45633. }
  45634. /** Defines values for XBox360 DPad */
  45635. export enum Xbox360Dpad {
  45636. /** Up */
  45637. Up = 12,
  45638. /** Down */
  45639. Down = 13,
  45640. /** Left */
  45641. Left = 14,
  45642. /** Right */
  45643. Right = 15
  45644. }
  45645. /**
  45646. * Defines a XBox360 gamepad
  45647. */
  45648. export class Xbox360Pad extends Gamepad {
  45649. private _leftTrigger;
  45650. private _rightTrigger;
  45651. private _onlefttriggerchanged;
  45652. private _onrighttriggerchanged;
  45653. private _onbuttondown;
  45654. private _onbuttonup;
  45655. private _ondpaddown;
  45656. private _ondpadup;
  45657. /** Observable raised when a button is pressed */
  45658. onButtonDownObservable: Observable<Xbox360Button>;
  45659. /** Observable raised when a button is released */
  45660. onButtonUpObservable: Observable<Xbox360Button>;
  45661. /** Observable raised when a pad is pressed */
  45662. onPadDownObservable: Observable<Xbox360Dpad>;
  45663. /** Observable raised when a pad is released */
  45664. onPadUpObservable: Observable<Xbox360Dpad>;
  45665. private _buttonA;
  45666. private _buttonB;
  45667. private _buttonX;
  45668. private _buttonY;
  45669. private _buttonBack;
  45670. private _buttonStart;
  45671. private _buttonLB;
  45672. private _buttonRB;
  45673. private _buttonLeftStick;
  45674. private _buttonRightStick;
  45675. private _dPadUp;
  45676. private _dPadDown;
  45677. private _dPadLeft;
  45678. private _dPadRight;
  45679. private _isXboxOnePad;
  45680. /**
  45681. * Creates a new XBox360 gamepad object
  45682. * @param id defines the id of this gamepad
  45683. * @param index defines its index
  45684. * @param gamepad defines the internal HTML gamepad object
  45685. * @param xboxOne defines if it is a XBox One gamepad
  45686. */
  45687. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45688. /**
  45689. * Defines the callback to call when left trigger is pressed
  45690. * @param callback defines the callback to use
  45691. */
  45692. onlefttriggerchanged(callback: (value: number) => void): void;
  45693. /**
  45694. * Defines the callback to call when right trigger is pressed
  45695. * @param callback defines the callback to use
  45696. */
  45697. onrighttriggerchanged(callback: (value: number) => void): void;
  45698. /**
  45699. * Gets the left trigger value
  45700. */
  45701. get leftTrigger(): number;
  45702. /**
  45703. * Sets the left trigger value
  45704. */
  45705. set leftTrigger(newValue: number);
  45706. /**
  45707. * Gets the right trigger value
  45708. */
  45709. get rightTrigger(): number;
  45710. /**
  45711. * Sets the right trigger value
  45712. */
  45713. set rightTrigger(newValue: number);
  45714. /**
  45715. * Defines the callback to call when a button is pressed
  45716. * @param callback defines the callback to use
  45717. */
  45718. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45719. /**
  45720. * Defines the callback to call when a button is released
  45721. * @param callback defines the callback to use
  45722. */
  45723. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45724. /**
  45725. * Defines the callback to call when a pad is pressed
  45726. * @param callback defines the callback to use
  45727. */
  45728. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45729. /**
  45730. * Defines the callback to call when a pad is released
  45731. * @param callback defines the callback to use
  45732. */
  45733. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45734. private _setButtonValue;
  45735. private _setDPadValue;
  45736. /**
  45737. * Gets the value of the `A` button
  45738. */
  45739. get buttonA(): number;
  45740. /**
  45741. * Sets the value of the `A` button
  45742. */
  45743. set buttonA(value: number);
  45744. /**
  45745. * Gets the value of the `B` button
  45746. */
  45747. get buttonB(): number;
  45748. /**
  45749. * Sets the value of the `B` button
  45750. */
  45751. set buttonB(value: number);
  45752. /**
  45753. * Gets the value of the `X` button
  45754. */
  45755. get buttonX(): number;
  45756. /**
  45757. * Sets the value of the `X` button
  45758. */
  45759. set buttonX(value: number);
  45760. /**
  45761. * Gets the value of the `Y` button
  45762. */
  45763. get buttonY(): number;
  45764. /**
  45765. * Sets the value of the `Y` button
  45766. */
  45767. set buttonY(value: number);
  45768. /**
  45769. * Gets the value of the `Start` button
  45770. */
  45771. get buttonStart(): number;
  45772. /**
  45773. * Sets the value of the `Start` button
  45774. */
  45775. set buttonStart(value: number);
  45776. /**
  45777. * Gets the value of the `Back` button
  45778. */
  45779. get buttonBack(): number;
  45780. /**
  45781. * Sets the value of the `Back` button
  45782. */
  45783. set buttonBack(value: number);
  45784. /**
  45785. * Gets the value of the `Left` button
  45786. */
  45787. get buttonLB(): number;
  45788. /**
  45789. * Sets the value of the `Left` button
  45790. */
  45791. set buttonLB(value: number);
  45792. /**
  45793. * Gets the value of the `Right` button
  45794. */
  45795. get buttonRB(): number;
  45796. /**
  45797. * Sets the value of the `Right` button
  45798. */
  45799. set buttonRB(value: number);
  45800. /**
  45801. * Gets the value of the Left joystick
  45802. */
  45803. get buttonLeftStick(): number;
  45804. /**
  45805. * Sets the value of the Left joystick
  45806. */
  45807. set buttonLeftStick(value: number);
  45808. /**
  45809. * Gets the value of the Right joystick
  45810. */
  45811. get buttonRightStick(): number;
  45812. /**
  45813. * Sets the value of the Right joystick
  45814. */
  45815. set buttonRightStick(value: number);
  45816. /**
  45817. * Gets the value of D-pad up
  45818. */
  45819. get dPadUp(): number;
  45820. /**
  45821. * Sets the value of D-pad up
  45822. */
  45823. set dPadUp(value: number);
  45824. /**
  45825. * Gets the value of D-pad down
  45826. */
  45827. get dPadDown(): number;
  45828. /**
  45829. * Sets the value of D-pad down
  45830. */
  45831. set dPadDown(value: number);
  45832. /**
  45833. * Gets the value of D-pad left
  45834. */
  45835. get dPadLeft(): number;
  45836. /**
  45837. * Sets the value of D-pad left
  45838. */
  45839. set dPadLeft(value: number);
  45840. /**
  45841. * Gets the value of D-pad right
  45842. */
  45843. get dPadRight(): number;
  45844. /**
  45845. * Sets the value of D-pad right
  45846. */
  45847. set dPadRight(value: number);
  45848. /**
  45849. * Force the gamepad to synchronize with device values
  45850. */
  45851. update(): void;
  45852. /**
  45853. * Disposes the gamepad
  45854. */
  45855. dispose(): void;
  45856. }
  45857. }
  45858. declare module "babylonjs/Gamepads/dualShockGamepad" {
  45859. import { Observable } from "babylonjs/Misc/observable";
  45860. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45861. /**
  45862. * Defines supported buttons for DualShock compatible gamepads
  45863. */
  45864. export enum DualShockButton {
  45865. /** Cross */
  45866. Cross = 0,
  45867. /** Circle */
  45868. Circle = 1,
  45869. /** Square */
  45870. Square = 2,
  45871. /** Triangle */
  45872. Triangle = 3,
  45873. /** L1 */
  45874. L1 = 4,
  45875. /** R1 */
  45876. R1 = 5,
  45877. /** Share */
  45878. Share = 8,
  45879. /** Options */
  45880. Options = 9,
  45881. /** Left stick */
  45882. LeftStick = 10,
  45883. /** Right stick */
  45884. RightStick = 11
  45885. }
  45886. /** Defines values for DualShock DPad */
  45887. export enum DualShockDpad {
  45888. /** Up */
  45889. Up = 12,
  45890. /** Down */
  45891. Down = 13,
  45892. /** Left */
  45893. Left = 14,
  45894. /** Right */
  45895. Right = 15
  45896. }
  45897. /**
  45898. * Defines a DualShock gamepad
  45899. */
  45900. export class DualShockPad extends Gamepad {
  45901. private _leftTrigger;
  45902. private _rightTrigger;
  45903. private _onlefttriggerchanged;
  45904. private _onrighttriggerchanged;
  45905. private _onbuttondown;
  45906. private _onbuttonup;
  45907. private _ondpaddown;
  45908. private _ondpadup;
  45909. /** Observable raised when a button is pressed */
  45910. onButtonDownObservable: Observable<DualShockButton>;
  45911. /** Observable raised when a button is released */
  45912. onButtonUpObservable: Observable<DualShockButton>;
  45913. /** Observable raised when a pad is pressed */
  45914. onPadDownObservable: Observable<DualShockDpad>;
  45915. /** Observable raised when a pad is released */
  45916. onPadUpObservable: Observable<DualShockDpad>;
  45917. private _buttonCross;
  45918. private _buttonCircle;
  45919. private _buttonSquare;
  45920. private _buttonTriangle;
  45921. private _buttonShare;
  45922. private _buttonOptions;
  45923. private _buttonL1;
  45924. private _buttonR1;
  45925. private _buttonLeftStick;
  45926. private _buttonRightStick;
  45927. private _dPadUp;
  45928. private _dPadDown;
  45929. private _dPadLeft;
  45930. private _dPadRight;
  45931. /**
  45932. * Creates a new DualShock gamepad object
  45933. * @param id defines the id of this gamepad
  45934. * @param index defines its index
  45935. * @param gamepad defines the internal HTML gamepad object
  45936. */
  45937. constructor(id: string, index: number, gamepad: any);
  45938. /**
  45939. * Defines the callback to call when left trigger is pressed
  45940. * @param callback defines the callback to use
  45941. */
  45942. onlefttriggerchanged(callback: (value: number) => void): void;
  45943. /**
  45944. * Defines the callback to call when right trigger is pressed
  45945. * @param callback defines the callback to use
  45946. */
  45947. onrighttriggerchanged(callback: (value: number) => void): void;
  45948. /**
  45949. * Gets the left trigger value
  45950. */
  45951. get leftTrigger(): number;
  45952. /**
  45953. * Sets the left trigger value
  45954. */
  45955. set leftTrigger(newValue: number);
  45956. /**
  45957. * Gets the right trigger value
  45958. */
  45959. get rightTrigger(): number;
  45960. /**
  45961. * Sets the right trigger value
  45962. */
  45963. set rightTrigger(newValue: number);
  45964. /**
  45965. * Defines the callback to call when a button is pressed
  45966. * @param callback defines the callback to use
  45967. */
  45968. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45969. /**
  45970. * Defines the callback to call when a button is released
  45971. * @param callback defines the callback to use
  45972. */
  45973. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45974. /**
  45975. * Defines the callback to call when a pad is pressed
  45976. * @param callback defines the callback to use
  45977. */
  45978. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45979. /**
  45980. * Defines the callback to call when a pad is released
  45981. * @param callback defines the callback to use
  45982. */
  45983. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45984. private _setButtonValue;
  45985. private _setDPadValue;
  45986. /**
  45987. * Gets the value of the `Cross` button
  45988. */
  45989. get buttonCross(): number;
  45990. /**
  45991. * Sets the value of the `Cross` button
  45992. */
  45993. set buttonCross(value: number);
  45994. /**
  45995. * Gets the value of the `Circle` button
  45996. */
  45997. get buttonCircle(): number;
  45998. /**
  45999. * Sets the value of the `Circle` button
  46000. */
  46001. set buttonCircle(value: number);
  46002. /**
  46003. * Gets the value of the `Square` button
  46004. */
  46005. get buttonSquare(): number;
  46006. /**
  46007. * Sets the value of the `Square` button
  46008. */
  46009. set buttonSquare(value: number);
  46010. /**
  46011. * Gets the value of the `Triangle` button
  46012. */
  46013. get buttonTriangle(): number;
  46014. /**
  46015. * Sets the value of the `Triangle` button
  46016. */
  46017. set buttonTriangle(value: number);
  46018. /**
  46019. * Gets the value of the `Options` button
  46020. */
  46021. get buttonOptions(): number;
  46022. /**
  46023. * Sets the value of the `Options` button
  46024. */
  46025. set buttonOptions(value: number);
  46026. /**
  46027. * Gets the value of the `Share` button
  46028. */
  46029. get buttonShare(): number;
  46030. /**
  46031. * Sets the value of the `Share` button
  46032. */
  46033. set buttonShare(value: number);
  46034. /**
  46035. * Gets the value of the `L1` button
  46036. */
  46037. get buttonL1(): number;
  46038. /**
  46039. * Sets the value of the `L1` button
  46040. */
  46041. set buttonL1(value: number);
  46042. /**
  46043. * Gets the value of the `R1` button
  46044. */
  46045. get buttonR1(): number;
  46046. /**
  46047. * Sets the value of the `R1` button
  46048. */
  46049. set buttonR1(value: number);
  46050. /**
  46051. * Gets the value of the Left joystick
  46052. */
  46053. get buttonLeftStick(): number;
  46054. /**
  46055. * Sets the value of the Left joystick
  46056. */
  46057. set buttonLeftStick(value: number);
  46058. /**
  46059. * Gets the value of the Right joystick
  46060. */
  46061. get buttonRightStick(): number;
  46062. /**
  46063. * Sets the value of the Right joystick
  46064. */
  46065. set buttonRightStick(value: number);
  46066. /**
  46067. * Gets the value of D-pad up
  46068. */
  46069. get dPadUp(): number;
  46070. /**
  46071. * Sets the value of D-pad up
  46072. */
  46073. set dPadUp(value: number);
  46074. /**
  46075. * Gets the value of D-pad down
  46076. */
  46077. get dPadDown(): number;
  46078. /**
  46079. * Sets the value of D-pad down
  46080. */
  46081. set dPadDown(value: number);
  46082. /**
  46083. * Gets the value of D-pad left
  46084. */
  46085. get dPadLeft(): number;
  46086. /**
  46087. * Sets the value of D-pad left
  46088. */
  46089. set dPadLeft(value: number);
  46090. /**
  46091. * Gets the value of D-pad right
  46092. */
  46093. get dPadRight(): number;
  46094. /**
  46095. * Sets the value of D-pad right
  46096. */
  46097. set dPadRight(value: number);
  46098. /**
  46099. * Force the gamepad to synchronize with device values
  46100. */
  46101. update(): void;
  46102. /**
  46103. * Disposes the gamepad
  46104. */
  46105. dispose(): void;
  46106. }
  46107. }
  46108. declare module "babylonjs/Gamepads/gamepadManager" {
  46109. import { Observable } from "babylonjs/Misc/observable";
  46110. import { Nullable } from "babylonjs/types";
  46111. import { Scene } from "babylonjs/scene";
  46112. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46113. /**
  46114. * Manager for handling gamepads
  46115. */
  46116. export class GamepadManager {
  46117. private _scene?;
  46118. private _babylonGamepads;
  46119. private _oneGamepadConnected;
  46120. /** @hidden */
  46121. _isMonitoring: boolean;
  46122. private _gamepadEventSupported;
  46123. private _gamepadSupport?;
  46124. /**
  46125. * observable to be triggered when the gamepad controller has been connected
  46126. */
  46127. onGamepadConnectedObservable: Observable<Gamepad>;
  46128. /**
  46129. * observable to be triggered when the gamepad controller has been disconnected
  46130. */
  46131. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46132. private _onGamepadConnectedEvent;
  46133. private _onGamepadDisconnectedEvent;
  46134. /**
  46135. * Initializes the gamepad manager
  46136. * @param _scene BabylonJS scene
  46137. */
  46138. constructor(_scene?: Scene | undefined);
  46139. /**
  46140. * The gamepads in the game pad manager
  46141. */
  46142. get gamepads(): Gamepad[];
  46143. /**
  46144. * Get the gamepad controllers based on type
  46145. * @param type The type of gamepad controller
  46146. * @returns Nullable gamepad
  46147. */
  46148. getGamepadByType(type?: number): Nullable<Gamepad>;
  46149. /**
  46150. * Disposes the gamepad manager
  46151. */
  46152. dispose(): void;
  46153. private _addNewGamepad;
  46154. private _startMonitoringGamepads;
  46155. private _stopMonitoringGamepads;
  46156. /** @hidden */
  46157. _checkGamepadsStatus(): void;
  46158. private _updateGamepadObjects;
  46159. }
  46160. }
  46161. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46162. import { Nullable } from "babylonjs/types";
  46163. import { Scene } from "babylonjs/scene";
  46164. import { ISceneComponent } from "babylonjs/sceneComponent";
  46165. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46166. module "babylonjs/scene" {
  46167. interface Scene {
  46168. /** @hidden */
  46169. _gamepadManager: Nullable<GamepadManager>;
  46170. /**
  46171. * Gets the gamepad manager associated with the scene
  46172. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46173. */
  46174. gamepadManager: GamepadManager;
  46175. }
  46176. }
  46177. module "babylonjs/Cameras/freeCameraInputsManager" {
  46178. /**
  46179. * Interface representing a free camera inputs manager
  46180. */
  46181. interface FreeCameraInputsManager {
  46182. /**
  46183. * Adds gamepad input support to the FreeCameraInputsManager.
  46184. * @returns the FreeCameraInputsManager
  46185. */
  46186. addGamepad(): FreeCameraInputsManager;
  46187. }
  46188. }
  46189. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46190. /**
  46191. * Interface representing an arc rotate camera inputs manager
  46192. */
  46193. interface ArcRotateCameraInputsManager {
  46194. /**
  46195. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46196. * @returns the camera inputs manager
  46197. */
  46198. addGamepad(): ArcRotateCameraInputsManager;
  46199. }
  46200. }
  46201. /**
  46202. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46203. */
  46204. export class GamepadSystemSceneComponent implements ISceneComponent {
  46205. /**
  46206. * The component name helpfull to identify the component in the list of scene components.
  46207. */
  46208. readonly name: string;
  46209. /**
  46210. * The scene the component belongs to.
  46211. */
  46212. scene: Scene;
  46213. /**
  46214. * Creates a new instance of the component for the given scene
  46215. * @param scene Defines the scene to register the component in
  46216. */
  46217. constructor(scene: Scene);
  46218. /**
  46219. * Registers the component in a given scene
  46220. */
  46221. register(): void;
  46222. /**
  46223. * Rebuilds the elements related to this component in case of
  46224. * context lost for instance.
  46225. */
  46226. rebuild(): void;
  46227. /**
  46228. * Disposes the component and the associated ressources
  46229. */
  46230. dispose(): void;
  46231. private _beforeCameraUpdate;
  46232. }
  46233. }
  46234. declare module "babylonjs/Cameras/universalCamera" {
  46235. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46236. import { Scene } from "babylonjs/scene";
  46237. import { Vector3 } from "babylonjs/Maths/math.vector";
  46238. import "babylonjs/Gamepads/gamepadSceneComponent";
  46239. /**
  46240. * 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,
  46241. * which still works and will still be found in many Playgrounds.
  46242. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46243. */
  46244. export class UniversalCamera extends TouchCamera {
  46245. /**
  46246. * Defines the gamepad rotation sensiblity.
  46247. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46248. */
  46249. get gamepadAngularSensibility(): number;
  46250. set gamepadAngularSensibility(value: number);
  46251. /**
  46252. * Defines the gamepad move sensiblity.
  46253. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46254. */
  46255. get gamepadMoveSensibility(): number;
  46256. set gamepadMoveSensibility(value: number);
  46257. /**
  46258. * 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,
  46259. * which still works and will still be found in many Playgrounds.
  46260. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46261. * @param name Define the name of the camera in the scene
  46262. * @param position Define the start position of the camera in the scene
  46263. * @param scene Define the scene the camera belongs to
  46264. */
  46265. constructor(name: string, position: Vector3, scene: Scene);
  46266. /**
  46267. * Gets the current object class name.
  46268. * @return the class name
  46269. */
  46270. getClassName(): string;
  46271. }
  46272. }
  46273. declare module "babylonjs/Cameras/gamepadCamera" {
  46274. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46275. import { Scene } from "babylonjs/scene";
  46276. import { Vector3 } from "babylonjs/Maths/math.vector";
  46277. /**
  46278. * This represents a FPS type of camera. This is only here for back compat purpose.
  46279. * Please use the UniversalCamera instead as both are identical.
  46280. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46281. */
  46282. export class GamepadCamera extends UniversalCamera {
  46283. /**
  46284. * Instantiates a new Gamepad Camera
  46285. * This represents a FPS type of camera. This is only here for back compat purpose.
  46286. * Please use the UniversalCamera instead as both are identical.
  46287. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46288. * @param name Define the name of the camera in the scene
  46289. * @param position Define the start position of the camera in the scene
  46290. * @param scene Define the scene the camera belongs to
  46291. */
  46292. constructor(name: string, position: Vector3, scene: Scene);
  46293. /**
  46294. * Gets the current object class name.
  46295. * @return the class name
  46296. */
  46297. getClassName(): string;
  46298. }
  46299. }
  46300. declare module "babylonjs/Shaders/pass.fragment" {
  46301. /** @hidden */
  46302. export var passPixelShader: {
  46303. name: string;
  46304. shader: string;
  46305. };
  46306. }
  46307. declare module "babylonjs/Shaders/passCube.fragment" {
  46308. /** @hidden */
  46309. export var passCubePixelShader: {
  46310. name: string;
  46311. shader: string;
  46312. };
  46313. }
  46314. declare module "babylonjs/PostProcesses/passPostProcess" {
  46315. import { Nullable } from "babylonjs/types";
  46316. import { Camera } from "babylonjs/Cameras/camera";
  46317. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46318. import { Engine } from "babylonjs/Engines/engine";
  46319. import "babylonjs/Shaders/pass.fragment";
  46320. import "babylonjs/Shaders/passCube.fragment";
  46321. /**
  46322. * PassPostProcess which produces an output the same as it's input
  46323. */
  46324. export class PassPostProcess extends PostProcess {
  46325. /**
  46326. * Creates the PassPostProcess
  46327. * @param name The name of the effect.
  46328. * @param options The required width/height ratio to downsize to before computing the render pass.
  46329. * @param camera The camera to apply the render pass to.
  46330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46331. * @param engine The engine which the post process will be applied. (default: current engine)
  46332. * @param reusable If the post process can be reused on the same frame. (default: false)
  46333. * @param textureType The type of texture to be used when performing the post processing.
  46334. * @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)
  46335. */
  46336. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46337. }
  46338. /**
  46339. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46340. */
  46341. export class PassCubePostProcess extends PostProcess {
  46342. private _face;
  46343. /**
  46344. * Gets or sets the cube face to display.
  46345. * * 0 is +X
  46346. * * 1 is -X
  46347. * * 2 is +Y
  46348. * * 3 is -Y
  46349. * * 4 is +Z
  46350. * * 5 is -Z
  46351. */
  46352. get face(): number;
  46353. set face(value: number);
  46354. /**
  46355. * Creates the PassCubePostProcess
  46356. * @param name The name of the effect.
  46357. * @param options The required width/height ratio to downsize to before computing the render pass.
  46358. * @param camera The camera to apply the render pass to.
  46359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46360. * @param engine The engine which the post process will be applied. (default: current engine)
  46361. * @param reusable If the post process can be reused on the same frame. (default: false)
  46362. * @param textureType The type of texture to be used when performing the post processing.
  46363. * @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)
  46364. */
  46365. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46366. }
  46367. }
  46368. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46369. /** @hidden */
  46370. export var anaglyphPixelShader: {
  46371. name: string;
  46372. shader: string;
  46373. };
  46374. }
  46375. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46376. import { Engine } from "babylonjs/Engines/engine";
  46377. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46378. import { Camera } from "babylonjs/Cameras/camera";
  46379. import "babylonjs/Shaders/anaglyph.fragment";
  46380. /**
  46381. * Postprocess used to generate anaglyphic rendering
  46382. */
  46383. export class AnaglyphPostProcess extends PostProcess {
  46384. private _passedProcess;
  46385. /**
  46386. * Creates a new AnaglyphPostProcess
  46387. * @param name defines postprocess name
  46388. * @param options defines creation options or target ratio scale
  46389. * @param rigCameras defines cameras using this postprocess
  46390. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46391. * @param engine defines hosting engine
  46392. * @param reusable defines if the postprocess will be reused multiple times per frame
  46393. */
  46394. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46395. }
  46396. }
  46397. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46398. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46399. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46400. import { Scene } from "babylonjs/scene";
  46401. import { Vector3 } from "babylonjs/Maths/math.vector";
  46402. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46403. /**
  46404. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46405. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46406. */
  46407. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46408. /**
  46409. * Creates a new AnaglyphArcRotateCamera
  46410. * @param name defines camera name
  46411. * @param alpha defines alpha angle (in radians)
  46412. * @param beta defines beta angle (in radians)
  46413. * @param radius defines radius
  46414. * @param target defines camera target
  46415. * @param interaxialDistance defines distance between each color axis
  46416. * @param scene defines the hosting scene
  46417. */
  46418. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46419. /**
  46420. * Gets camera class name
  46421. * @returns AnaglyphArcRotateCamera
  46422. */
  46423. getClassName(): string;
  46424. }
  46425. }
  46426. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46427. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46428. import { Scene } from "babylonjs/scene";
  46429. import { Vector3 } from "babylonjs/Maths/math.vector";
  46430. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46431. /**
  46432. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46433. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46434. */
  46435. export class AnaglyphFreeCamera extends FreeCamera {
  46436. /**
  46437. * Creates a new AnaglyphFreeCamera
  46438. * @param name defines camera name
  46439. * @param position defines initial position
  46440. * @param interaxialDistance defines distance between each color axis
  46441. * @param scene defines the hosting scene
  46442. */
  46443. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46444. /**
  46445. * Gets camera class name
  46446. * @returns AnaglyphFreeCamera
  46447. */
  46448. getClassName(): string;
  46449. }
  46450. }
  46451. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46452. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46453. import { Scene } from "babylonjs/scene";
  46454. import { Vector3 } from "babylonjs/Maths/math.vector";
  46455. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46456. /**
  46457. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46458. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46459. */
  46460. export class AnaglyphGamepadCamera extends GamepadCamera {
  46461. /**
  46462. * Creates a new AnaglyphGamepadCamera
  46463. * @param name defines camera name
  46464. * @param position defines initial position
  46465. * @param interaxialDistance defines distance between each color axis
  46466. * @param scene defines the hosting scene
  46467. */
  46468. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46469. /**
  46470. * Gets camera class name
  46471. * @returns AnaglyphGamepadCamera
  46472. */
  46473. getClassName(): string;
  46474. }
  46475. }
  46476. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46477. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46478. import { Scene } from "babylonjs/scene";
  46479. import { Vector3 } from "babylonjs/Maths/math.vector";
  46480. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46481. /**
  46482. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46483. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46484. */
  46485. export class AnaglyphUniversalCamera extends UniversalCamera {
  46486. /**
  46487. * Creates a new AnaglyphUniversalCamera
  46488. * @param name defines camera name
  46489. * @param position defines initial position
  46490. * @param interaxialDistance defines distance between each color axis
  46491. * @param scene defines the hosting scene
  46492. */
  46493. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46494. /**
  46495. * Gets camera class name
  46496. * @returns AnaglyphUniversalCamera
  46497. */
  46498. getClassName(): string;
  46499. }
  46500. }
  46501. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46502. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46503. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46504. import { Scene } from "babylonjs/scene";
  46505. import { Vector3 } from "babylonjs/Maths/math.vector";
  46506. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46507. /**
  46508. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46509. * @see http://doc.babylonjs.com/features/cameras
  46510. */
  46511. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46512. /**
  46513. * Creates a new StereoscopicArcRotateCamera
  46514. * @param name defines camera name
  46515. * @param alpha defines alpha angle (in radians)
  46516. * @param beta defines beta angle (in radians)
  46517. * @param radius defines radius
  46518. * @param target defines camera target
  46519. * @param interaxialDistance defines distance between each color axis
  46520. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46521. * @param scene defines the hosting scene
  46522. */
  46523. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46524. /**
  46525. * Gets camera class name
  46526. * @returns StereoscopicArcRotateCamera
  46527. */
  46528. getClassName(): string;
  46529. }
  46530. }
  46531. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46532. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46533. import { Scene } from "babylonjs/scene";
  46534. import { Vector3 } from "babylonjs/Maths/math.vector";
  46535. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46536. /**
  46537. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46538. * @see http://doc.babylonjs.com/features/cameras
  46539. */
  46540. export class StereoscopicFreeCamera extends FreeCamera {
  46541. /**
  46542. * Creates a new StereoscopicFreeCamera
  46543. * @param name defines camera name
  46544. * @param position defines initial position
  46545. * @param interaxialDistance defines distance between each color axis
  46546. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46547. * @param scene defines the hosting scene
  46548. */
  46549. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46550. /**
  46551. * Gets camera class name
  46552. * @returns StereoscopicFreeCamera
  46553. */
  46554. getClassName(): string;
  46555. }
  46556. }
  46557. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46558. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46559. import { Scene } from "babylonjs/scene";
  46560. import { Vector3 } from "babylonjs/Maths/math.vector";
  46561. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46562. /**
  46563. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46564. * @see http://doc.babylonjs.com/features/cameras
  46565. */
  46566. export class StereoscopicGamepadCamera extends GamepadCamera {
  46567. /**
  46568. * Creates a new StereoscopicGamepadCamera
  46569. * @param name defines camera name
  46570. * @param position defines initial position
  46571. * @param interaxialDistance defines distance between each color axis
  46572. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46573. * @param scene defines the hosting scene
  46574. */
  46575. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46576. /**
  46577. * Gets camera class name
  46578. * @returns StereoscopicGamepadCamera
  46579. */
  46580. getClassName(): string;
  46581. }
  46582. }
  46583. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46584. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46585. import { Scene } from "babylonjs/scene";
  46586. import { Vector3 } from "babylonjs/Maths/math.vector";
  46587. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46588. /**
  46589. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46590. * @see http://doc.babylonjs.com/features/cameras
  46591. */
  46592. export class StereoscopicUniversalCamera extends UniversalCamera {
  46593. /**
  46594. * Creates a new StereoscopicUniversalCamera
  46595. * @param name defines camera name
  46596. * @param position defines initial position
  46597. * @param interaxialDistance defines distance between each color axis
  46598. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46599. * @param scene defines the hosting scene
  46600. */
  46601. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46602. /**
  46603. * Gets camera class name
  46604. * @returns StereoscopicUniversalCamera
  46605. */
  46606. getClassName(): string;
  46607. }
  46608. }
  46609. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46610. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46611. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46612. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46613. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46614. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46615. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46616. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46617. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46618. }
  46619. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46620. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46621. import { Scene } from "babylonjs/scene";
  46622. import { Vector3 } from "babylonjs/Maths/math.vector";
  46623. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46624. /**
  46625. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46626. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46627. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46628. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46629. */
  46630. export class VirtualJoysticksCamera extends FreeCamera {
  46631. /**
  46632. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46633. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46634. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46635. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46636. * @param name Define the name of the camera in the scene
  46637. * @param position Define the start position of the camera in the scene
  46638. * @param scene Define the scene the camera belongs to
  46639. */
  46640. constructor(name: string, position: Vector3, scene: Scene);
  46641. /**
  46642. * Gets the current object class name.
  46643. * @return the class name
  46644. */
  46645. getClassName(): string;
  46646. }
  46647. }
  46648. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46649. import { Matrix } from "babylonjs/Maths/math.vector";
  46650. /**
  46651. * This represents all the required metrics to create a VR camera.
  46652. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46653. */
  46654. export class VRCameraMetrics {
  46655. /**
  46656. * Define the horizontal resolution off the screen.
  46657. */
  46658. hResolution: number;
  46659. /**
  46660. * Define the vertical resolution off the screen.
  46661. */
  46662. vResolution: number;
  46663. /**
  46664. * Define the horizontal screen size.
  46665. */
  46666. hScreenSize: number;
  46667. /**
  46668. * Define the vertical screen size.
  46669. */
  46670. vScreenSize: number;
  46671. /**
  46672. * Define the vertical screen center position.
  46673. */
  46674. vScreenCenter: number;
  46675. /**
  46676. * Define the distance of the eyes to the screen.
  46677. */
  46678. eyeToScreenDistance: number;
  46679. /**
  46680. * Define the distance between both lenses
  46681. */
  46682. lensSeparationDistance: number;
  46683. /**
  46684. * Define the distance between both viewer's eyes.
  46685. */
  46686. interpupillaryDistance: number;
  46687. /**
  46688. * Define the distortion factor of the VR postprocess.
  46689. * Please, touch with care.
  46690. */
  46691. distortionK: number[];
  46692. /**
  46693. * Define the chromatic aberration correction factors for the VR post process.
  46694. */
  46695. chromaAbCorrection: number[];
  46696. /**
  46697. * Define the scale factor of the post process.
  46698. * The smaller the better but the slower.
  46699. */
  46700. postProcessScaleFactor: number;
  46701. /**
  46702. * Define an offset for the lens center.
  46703. */
  46704. lensCenterOffset: number;
  46705. /**
  46706. * Define if the current vr camera should compensate the distortion of the lense or not.
  46707. */
  46708. compensateDistortion: boolean;
  46709. /**
  46710. * Defines if multiview should be enabled when rendering (Default: false)
  46711. */
  46712. multiviewEnabled: boolean;
  46713. /**
  46714. * Gets the rendering aspect ratio based on the provided resolutions.
  46715. */
  46716. get aspectRatio(): number;
  46717. /**
  46718. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46719. */
  46720. get aspectRatioFov(): number;
  46721. /**
  46722. * @hidden
  46723. */
  46724. get leftHMatrix(): Matrix;
  46725. /**
  46726. * @hidden
  46727. */
  46728. get rightHMatrix(): Matrix;
  46729. /**
  46730. * @hidden
  46731. */
  46732. get leftPreViewMatrix(): Matrix;
  46733. /**
  46734. * @hidden
  46735. */
  46736. get rightPreViewMatrix(): Matrix;
  46737. /**
  46738. * Get the default VRMetrics based on the most generic setup.
  46739. * @returns the default vr metrics
  46740. */
  46741. static GetDefault(): VRCameraMetrics;
  46742. }
  46743. }
  46744. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  46745. /** @hidden */
  46746. export var vrDistortionCorrectionPixelShader: {
  46747. name: string;
  46748. shader: string;
  46749. };
  46750. }
  46751. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  46752. import { Camera } from "babylonjs/Cameras/camera";
  46753. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46754. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46755. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  46756. /**
  46757. * VRDistortionCorrectionPostProcess used for mobile VR
  46758. */
  46759. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46760. private _isRightEye;
  46761. private _distortionFactors;
  46762. private _postProcessScaleFactor;
  46763. private _lensCenterOffset;
  46764. private _scaleIn;
  46765. private _scaleFactor;
  46766. private _lensCenter;
  46767. /**
  46768. * Initializes the VRDistortionCorrectionPostProcess
  46769. * @param name The name of the effect.
  46770. * @param camera The camera to apply the render pass to.
  46771. * @param isRightEye If this is for the right eye distortion
  46772. * @param vrMetrics All the required metrics for the VR camera
  46773. */
  46774. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46775. }
  46776. }
  46777. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  46778. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  46779. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46780. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46781. import { Scene } from "babylonjs/scene";
  46782. import { Vector3 } from "babylonjs/Maths/math.vector";
  46783. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46784. import "babylonjs/Cameras/RigModes/vrRigMode";
  46785. /**
  46786. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46787. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46788. */
  46789. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46790. /**
  46791. * Creates a new VRDeviceOrientationArcRotateCamera
  46792. * @param name defines camera name
  46793. * @param alpha defines the camera rotation along the logitudinal axis
  46794. * @param beta defines the camera rotation along the latitudinal axis
  46795. * @param radius defines the camera distance from its target
  46796. * @param target defines the camera target
  46797. * @param scene defines the scene the camera belongs to
  46798. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46799. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46800. */
  46801. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46802. /**
  46803. * Gets camera class name
  46804. * @returns VRDeviceOrientationArcRotateCamera
  46805. */
  46806. getClassName(): string;
  46807. }
  46808. }
  46809. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  46810. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46811. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46812. import { Scene } from "babylonjs/scene";
  46813. import { Vector3 } from "babylonjs/Maths/math.vector";
  46814. import "babylonjs/Cameras/RigModes/vrRigMode";
  46815. /**
  46816. * Camera used to simulate VR rendering (based on FreeCamera)
  46817. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46818. */
  46819. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46820. /**
  46821. * Creates a new VRDeviceOrientationFreeCamera
  46822. * @param name defines camera name
  46823. * @param position defines the start position of the camera
  46824. * @param scene defines the scene the camera belongs to
  46825. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46826. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46827. */
  46828. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46829. /**
  46830. * Gets camera class name
  46831. * @returns VRDeviceOrientationFreeCamera
  46832. */
  46833. getClassName(): string;
  46834. }
  46835. }
  46836. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  46837. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46838. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46839. import { Scene } from "babylonjs/scene";
  46840. import { Vector3 } from "babylonjs/Maths/math.vector";
  46841. import "babylonjs/Gamepads/gamepadSceneComponent";
  46842. /**
  46843. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46844. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46845. */
  46846. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46847. /**
  46848. * Creates a new VRDeviceOrientationGamepadCamera
  46849. * @param name defines camera name
  46850. * @param position defines the start position of the camera
  46851. * @param scene defines the scene the camera belongs to
  46852. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46853. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46854. */
  46855. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46856. /**
  46857. * Gets camera class name
  46858. * @returns VRDeviceOrientationGamepadCamera
  46859. */
  46860. getClassName(): string;
  46861. }
  46862. }
  46863. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  46864. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46865. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46866. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46867. /** @hidden */
  46868. export var imageProcessingPixelShader: {
  46869. name: string;
  46870. shader: string;
  46871. };
  46872. }
  46873. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  46874. import { Nullable } from "babylonjs/types";
  46875. import { Color4 } from "babylonjs/Maths/math.color";
  46876. import { Camera } from "babylonjs/Cameras/camera";
  46877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46878. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46879. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46880. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46881. import { Engine } from "babylonjs/Engines/engine";
  46882. import "babylonjs/Shaders/imageProcessing.fragment";
  46883. import "babylonjs/Shaders/postprocess.vertex";
  46884. /**
  46885. * ImageProcessingPostProcess
  46886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  46887. */
  46888. export class ImageProcessingPostProcess extends PostProcess {
  46889. /**
  46890. * Default configuration related to image processing available in the PBR Material.
  46891. */
  46892. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46893. /**
  46894. * Gets the image processing configuration used either in this material.
  46895. */
  46896. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46897. /**
  46898. * Sets the Default image processing configuration used either in the this material.
  46899. *
  46900. * If sets to null, the scene one is in use.
  46901. */
  46902. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  46903. /**
  46904. * Keep track of the image processing observer to allow dispose and replace.
  46905. */
  46906. private _imageProcessingObserver;
  46907. /**
  46908. * Attaches a new image processing configuration to the PBR Material.
  46909. * @param configuration
  46910. */
  46911. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  46912. /**
  46913. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46914. */
  46915. get colorCurves(): Nullable<ColorCurves>;
  46916. /**
  46917. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46918. */
  46919. set colorCurves(value: Nullable<ColorCurves>);
  46920. /**
  46921. * Gets wether the color curves effect is enabled.
  46922. */
  46923. get colorCurvesEnabled(): boolean;
  46924. /**
  46925. * Sets wether the color curves effect is enabled.
  46926. */
  46927. set colorCurvesEnabled(value: boolean);
  46928. /**
  46929. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46930. */
  46931. get colorGradingTexture(): Nullable<BaseTexture>;
  46932. /**
  46933. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46934. */
  46935. set colorGradingTexture(value: Nullable<BaseTexture>);
  46936. /**
  46937. * Gets wether the color grading effect is enabled.
  46938. */
  46939. get colorGradingEnabled(): boolean;
  46940. /**
  46941. * Gets wether the color grading effect is enabled.
  46942. */
  46943. set colorGradingEnabled(value: boolean);
  46944. /**
  46945. * Gets exposure used in the effect.
  46946. */
  46947. get exposure(): number;
  46948. /**
  46949. * Sets exposure used in the effect.
  46950. */
  46951. set exposure(value: number);
  46952. /**
  46953. * Gets wether tonemapping is enabled or not.
  46954. */
  46955. get toneMappingEnabled(): boolean;
  46956. /**
  46957. * Sets wether tonemapping is enabled or not
  46958. */
  46959. set toneMappingEnabled(value: boolean);
  46960. /**
  46961. * Gets the type of tone mapping effect.
  46962. */
  46963. get toneMappingType(): number;
  46964. /**
  46965. * Sets the type of tone mapping effect.
  46966. */
  46967. set toneMappingType(value: number);
  46968. /**
  46969. * Gets contrast used in the effect.
  46970. */
  46971. get contrast(): number;
  46972. /**
  46973. * Sets contrast used in the effect.
  46974. */
  46975. set contrast(value: number);
  46976. /**
  46977. * Gets Vignette stretch size.
  46978. */
  46979. get vignetteStretch(): number;
  46980. /**
  46981. * Sets Vignette stretch size.
  46982. */
  46983. set vignetteStretch(value: number);
  46984. /**
  46985. * Gets Vignette centre X Offset.
  46986. */
  46987. get vignetteCentreX(): number;
  46988. /**
  46989. * Sets Vignette centre X Offset.
  46990. */
  46991. set vignetteCentreX(value: number);
  46992. /**
  46993. * Gets Vignette centre Y Offset.
  46994. */
  46995. get vignetteCentreY(): number;
  46996. /**
  46997. * Sets Vignette centre Y Offset.
  46998. */
  46999. set vignetteCentreY(value: number);
  47000. /**
  47001. * Gets Vignette weight or intensity of the vignette effect.
  47002. */
  47003. get vignetteWeight(): number;
  47004. /**
  47005. * Sets Vignette weight or intensity of the vignette effect.
  47006. */
  47007. set vignetteWeight(value: number);
  47008. /**
  47009. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47010. * if vignetteEnabled is set to true.
  47011. */
  47012. get vignetteColor(): Color4;
  47013. /**
  47014. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47015. * if vignetteEnabled is set to true.
  47016. */
  47017. set vignetteColor(value: Color4);
  47018. /**
  47019. * Gets Camera field of view used by the Vignette effect.
  47020. */
  47021. get vignetteCameraFov(): number;
  47022. /**
  47023. * Sets Camera field of view used by the Vignette effect.
  47024. */
  47025. set vignetteCameraFov(value: number);
  47026. /**
  47027. * Gets the vignette blend mode allowing different kind of effect.
  47028. */
  47029. get vignetteBlendMode(): number;
  47030. /**
  47031. * Sets the vignette blend mode allowing different kind of effect.
  47032. */
  47033. set vignetteBlendMode(value: number);
  47034. /**
  47035. * Gets wether the vignette effect is enabled.
  47036. */
  47037. get vignetteEnabled(): boolean;
  47038. /**
  47039. * Sets wether the vignette effect is enabled.
  47040. */
  47041. set vignetteEnabled(value: boolean);
  47042. private _fromLinearSpace;
  47043. /**
  47044. * Gets wether the input of the processing is in Gamma or Linear Space.
  47045. */
  47046. get fromLinearSpace(): boolean;
  47047. /**
  47048. * Sets wether the input of the processing is in Gamma or Linear Space.
  47049. */
  47050. set fromLinearSpace(value: boolean);
  47051. /**
  47052. * Defines cache preventing GC.
  47053. */
  47054. private _defines;
  47055. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47056. /**
  47057. * "ImageProcessingPostProcess"
  47058. * @returns "ImageProcessingPostProcess"
  47059. */
  47060. getClassName(): string;
  47061. protected _updateParameters(): void;
  47062. dispose(camera?: Camera): void;
  47063. }
  47064. }
  47065. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47066. import { Scene } from "babylonjs/scene";
  47067. import { Color3 } from "babylonjs/Maths/math.color";
  47068. import { Mesh } from "babylonjs/Meshes/mesh";
  47069. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47070. import { Nullable } from "babylonjs/types";
  47071. /**
  47072. * Class containing static functions to help procedurally build meshes
  47073. */
  47074. export class GroundBuilder {
  47075. /**
  47076. * Creates a ground mesh
  47077. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47078. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47080. * @param name defines the name of the mesh
  47081. * @param options defines the options used to create the mesh
  47082. * @param scene defines the hosting scene
  47083. * @returns the ground mesh
  47084. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47085. */
  47086. static CreateGround(name: string, options: {
  47087. width?: number;
  47088. height?: number;
  47089. subdivisions?: number;
  47090. subdivisionsX?: number;
  47091. subdivisionsY?: number;
  47092. updatable?: boolean;
  47093. }, scene: any): Mesh;
  47094. /**
  47095. * Creates a tiled ground mesh
  47096. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47097. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47098. * * 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
  47099. * * 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
  47100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47101. * @param name defines the name of the mesh
  47102. * @param options defines the options used to create the mesh
  47103. * @param scene defines the hosting scene
  47104. * @returns the tiled ground mesh
  47105. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47106. */
  47107. static CreateTiledGround(name: string, options: {
  47108. xmin: number;
  47109. zmin: number;
  47110. xmax: number;
  47111. zmax: number;
  47112. subdivisions?: {
  47113. w: number;
  47114. h: number;
  47115. };
  47116. precision?: {
  47117. w: number;
  47118. h: number;
  47119. };
  47120. updatable?: boolean;
  47121. }, scene?: Nullable<Scene>): Mesh;
  47122. /**
  47123. * Creates a ground mesh from a height map
  47124. * * The parameter `url` sets the URL of the height map image resource.
  47125. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47126. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47127. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47128. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47129. * * 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.
  47130. * * 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).
  47131. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47133. * @param name defines the name of the mesh
  47134. * @param url defines the url to the height map
  47135. * @param options defines the options used to create the mesh
  47136. * @param scene defines the hosting scene
  47137. * @returns the ground mesh
  47138. * @see https://doc.babylonjs.com/babylon101/height_map
  47139. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47140. */
  47141. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47142. width?: number;
  47143. height?: number;
  47144. subdivisions?: number;
  47145. minHeight?: number;
  47146. maxHeight?: number;
  47147. colorFilter?: Color3;
  47148. alphaFilter?: number;
  47149. updatable?: boolean;
  47150. onReady?: (mesh: GroundMesh) => void;
  47151. }, scene?: Nullable<Scene>): GroundMesh;
  47152. }
  47153. }
  47154. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47155. import { Vector4 } from "babylonjs/Maths/math.vector";
  47156. import { Mesh } from "babylonjs/Meshes/mesh";
  47157. /**
  47158. * Class containing static functions to help procedurally build meshes
  47159. */
  47160. export class TorusBuilder {
  47161. /**
  47162. * Creates a torus mesh
  47163. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47164. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47165. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47169. * @param name defines the name of the mesh
  47170. * @param options defines the options used to create the mesh
  47171. * @param scene defines the hosting scene
  47172. * @returns the torus mesh
  47173. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47174. */
  47175. static CreateTorus(name: string, options: {
  47176. diameter?: number;
  47177. thickness?: number;
  47178. tessellation?: number;
  47179. updatable?: boolean;
  47180. sideOrientation?: number;
  47181. frontUVs?: Vector4;
  47182. backUVs?: Vector4;
  47183. }, scene: any): Mesh;
  47184. }
  47185. }
  47186. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47187. import { Vector4 } from "babylonjs/Maths/math.vector";
  47188. import { Color4 } from "babylonjs/Maths/math.color";
  47189. import { Mesh } from "babylonjs/Meshes/mesh";
  47190. /**
  47191. * Class containing static functions to help procedurally build meshes
  47192. */
  47193. export class CylinderBuilder {
  47194. /**
  47195. * Creates a cylinder or a cone mesh
  47196. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47197. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47198. * * 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.
  47199. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47200. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47201. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47202. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47203. * * 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).
  47204. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47205. * * 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).
  47206. * * 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
  47207. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47208. * * 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
  47209. * * 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.
  47210. * * If `enclose` is false, a ring surface is one element.
  47211. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47212. * * 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
  47213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47216. * @param name defines the name of the mesh
  47217. * @param options defines the options used to create the mesh
  47218. * @param scene defines the hosting scene
  47219. * @returns the cylinder mesh
  47220. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47221. */
  47222. static CreateCylinder(name: string, options: {
  47223. height?: number;
  47224. diameterTop?: number;
  47225. diameterBottom?: number;
  47226. diameter?: number;
  47227. tessellation?: number;
  47228. subdivisions?: number;
  47229. arc?: number;
  47230. faceColors?: Color4[];
  47231. faceUV?: Vector4[];
  47232. updatable?: boolean;
  47233. hasRings?: boolean;
  47234. enclose?: boolean;
  47235. cap?: number;
  47236. sideOrientation?: number;
  47237. frontUVs?: Vector4;
  47238. backUVs?: Vector4;
  47239. }, scene: any): Mesh;
  47240. }
  47241. }
  47242. declare module "babylonjs/XR/webXRTypes" {
  47243. import { Nullable } from "babylonjs/types";
  47244. import { IDisposable } from "babylonjs/scene";
  47245. /**
  47246. * States of the webXR experience
  47247. */
  47248. export enum WebXRState {
  47249. /**
  47250. * Transitioning to being in XR mode
  47251. */
  47252. ENTERING_XR = 0,
  47253. /**
  47254. * Transitioning to non XR mode
  47255. */
  47256. EXITING_XR = 1,
  47257. /**
  47258. * In XR mode and presenting
  47259. */
  47260. IN_XR = 2,
  47261. /**
  47262. * Not entered XR mode
  47263. */
  47264. NOT_IN_XR = 3
  47265. }
  47266. /**
  47267. * Abstraction of the XR render target
  47268. */
  47269. export interface WebXRRenderTarget extends IDisposable {
  47270. /**
  47271. * xrpresent context of the canvas which can be used to display/mirror xr content
  47272. */
  47273. canvasContext: WebGLRenderingContext;
  47274. /**
  47275. * xr layer for the canvas
  47276. */
  47277. xrLayer: Nullable<XRWebGLLayer>;
  47278. /**
  47279. * Initializes the xr layer for the session
  47280. * @param xrSession xr session
  47281. * @returns a promise that will resolve once the XR Layer has been created
  47282. */
  47283. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47284. }
  47285. }
  47286. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47287. import { Nullable } from "babylonjs/types";
  47288. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47289. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47290. /**
  47291. * COnfiguration object for WebXR output canvas
  47292. */
  47293. export class WebXRManagedOutputCanvasOptions {
  47294. /**
  47295. * An optional canvas in case you wish to create it yourself and provide it here.
  47296. * If not provided, a new canvas will be created
  47297. */
  47298. canvasElement?: HTMLCanvasElement;
  47299. /**
  47300. * Options for this XR Layer output
  47301. */
  47302. canvasOptions?: XRWebGLLayerOptions;
  47303. /**
  47304. * CSS styling for a newly created canvas (if not provided)
  47305. */
  47306. newCanvasCssStyle?: string;
  47307. /**
  47308. * Get the default values of the configuration object
  47309. * @returns default values of this configuration object
  47310. */
  47311. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47312. }
  47313. /**
  47314. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47315. */
  47316. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47317. private _options;
  47318. private _canvas;
  47319. private _engine;
  47320. /**
  47321. * Rendering context of the canvas which can be used to display/mirror xr content
  47322. */
  47323. canvasContext: WebGLRenderingContext;
  47324. /**
  47325. * xr layer for the canvas
  47326. */
  47327. xrLayer: Nullable<XRWebGLLayer>;
  47328. /**
  47329. * Initializes the canvas to be added/removed upon entering/exiting xr
  47330. * @param _xrSessionManager The XR Session manager
  47331. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47332. */
  47333. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47334. /**
  47335. * Disposes of the object
  47336. */
  47337. dispose(): void;
  47338. /**
  47339. * Initializes the xr layer for the session
  47340. * @param xrSession xr session
  47341. * @returns a promise that will resolve once the XR Layer has been created
  47342. */
  47343. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47344. private _addCanvas;
  47345. private _removeCanvas;
  47346. private _setManagedOutputCanvas;
  47347. }
  47348. }
  47349. declare module "babylonjs/XR/webXRSessionManager" {
  47350. import { Observable } from "babylonjs/Misc/observable";
  47351. import { Nullable } from "babylonjs/types";
  47352. import { IDisposable, Scene } from "babylonjs/scene";
  47353. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47354. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47355. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47356. /**
  47357. * Manages an XRSession to work with Babylon's engine
  47358. * @see https://doc.babylonjs.com/how_to/webxr
  47359. */
  47360. export class WebXRSessionManager implements IDisposable {
  47361. /** The scene which the session should be created for */
  47362. scene: Scene;
  47363. private _referenceSpace;
  47364. private _rttProvider;
  47365. private _sessionEnded;
  47366. private _xrNavigator;
  47367. private baseLayer;
  47368. /**
  47369. * The base reference space from which the session started. good if you want to reset your
  47370. * reference space
  47371. */
  47372. baseReferenceSpace: XRReferenceSpace;
  47373. /**
  47374. * Current XR frame
  47375. */
  47376. currentFrame: Nullable<XRFrame>;
  47377. /** WebXR timestamp updated every frame */
  47378. currentTimestamp: number;
  47379. /**
  47380. * Used just in case of a failure to initialize an immersive session.
  47381. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47382. */
  47383. defaultHeightCompensation: number;
  47384. /**
  47385. * Fires every time a new xrFrame arrives which can be used to update the camera
  47386. */
  47387. onXRFrameObservable: Observable<XRFrame>;
  47388. /**
  47389. * Fires when the reference space changed
  47390. */
  47391. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47392. /**
  47393. * Fires when the xr session is ended either by the device or manually done
  47394. */
  47395. onXRSessionEnded: Observable<any>;
  47396. /**
  47397. * Fires when the xr session is ended either by the device or manually done
  47398. */
  47399. onXRSessionInit: Observable<XRSession>;
  47400. /**
  47401. * Underlying xr session
  47402. */
  47403. session: XRSession;
  47404. /**
  47405. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47406. * or get the offset the player is currently at.
  47407. */
  47408. viewerReferenceSpace: XRReferenceSpace;
  47409. /**
  47410. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47411. * @param scene The scene which the session should be created for
  47412. */
  47413. constructor(
  47414. /** The scene which the session should be created for */
  47415. scene: Scene);
  47416. /**
  47417. * The current reference space used in this session. This reference space can constantly change!
  47418. * It is mainly used to offset the camera's position.
  47419. */
  47420. get referenceSpace(): XRReferenceSpace;
  47421. /**
  47422. * Set a new reference space and triggers the observable
  47423. */
  47424. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47425. /**
  47426. * Disposes of the session manager
  47427. */
  47428. dispose(): void;
  47429. /**
  47430. * Stops the xrSession and restores the render loop
  47431. * @returns Promise which resolves after it exits XR
  47432. */
  47433. exitXRAsync(): Promise<void>;
  47434. /**
  47435. * Gets the correct render target texture to be rendered this frame for this eye
  47436. * @param eye the eye for which to get the render target
  47437. * @returns the render target for the specified eye
  47438. */
  47439. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47440. /**
  47441. * Creates a WebXRRenderTarget object for the XR session
  47442. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47443. * @param options optional options to provide when creating a new render target
  47444. * @returns a WebXR render target to which the session can render
  47445. */
  47446. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47447. /**
  47448. * Initializes the manager
  47449. * After initialization enterXR can be called to start an XR session
  47450. * @returns Promise which resolves after it is initialized
  47451. */
  47452. initializeAsync(): Promise<void>;
  47453. /**
  47454. * Initializes an xr session
  47455. * @param xrSessionMode mode to initialize
  47456. * @param xrSessionInit defines optional and required values to pass to the session builder
  47457. * @returns a promise which will resolve once the session has been initialized
  47458. */
  47459. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47460. /**
  47461. * Checks if a session would be supported for the creation options specified
  47462. * @param sessionMode session mode to check if supported eg. immersive-vr
  47463. * @returns A Promise that resolves to true if supported and false if not
  47464. */
  47465. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47466. /**
  47467. * Resets the reference space to the one started the session
  47468. */
  47469. resetReferenceSpace(): void;
  47470. /**
  47471. * Starts rendering to the xr layer
  47472. */
  47473. runXRRenderLoop(): void;
  47474. /**
  47475. * Sets the reference space on the xr session
  47476. * @param referenceSpaceType space to set
  47477. * @returns a promise that will resolve once the reference space has been set
  47478. */
  47479. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47480. /**
  47481. * Updates the render state of the session
  47482. * @param state state to set
  47483. * @returns a promise that resolves once the render state has been updated
  47484. */
  47485. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47486. /**
  47487. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47488. * @param sessionMode defines the session to test
  47489. * @returns a promise with boolean as final value
  47490. */
  47491. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47492. private _createRenderTargetTexture;
  47493. }
  47494. }
  47495. declare module "babylonjs/XR/webXRCamera" {
  47496. import { Matrix } from "babylonjs/Maths/math.vector";
  47497. import { Scene } from "babylonjs/scene";
  47498. import { Camera } from "babylonjs/Cameras/camera";
  47499. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47500. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47501. /**
  47502. * WebXR Camera which holds the views for the xrSession
  47503. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47504. */
  47505. export class WebXRCamera extends FreeCamera {
  47506. private _xrSessionManager;
  47507. private _firstFrame;
  47508. private _referenceQuaternion;
  47509. private _referencedPosition;
  47510. private _xrInvPositionCache;
  47511. private _xrInvQuaternionCache;
  47512. /**
  47513. * Should position compensation execute on first frame.
  47514. * This is used when copying the position from a native (non XR) camera
  47515. */
  47516. compensateOnFirstFrame: boolean;
  47517. /**
  47518. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47519. * @param name the name of the camera
  47520. * @param scene the scene to add the camera to
  47521. * @param _xrSessionManager a constructed xr session manager
  47522. */
  47523. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47524. /**
  47525. * Return the user's height, unrelated to the current ground.
  47526. * This will be the y position of this camera, when ground level is 0.
  47527. */
  47528. get realWorldHeight(): number;
  47529. /** @hidden */
  47530. _updateForDualEyeDebugging(): void;
  47531. /**
  47532. * Sets this camera's transformation based on a non-vr camera
  47533. * @param otherCamera the non-vr camera to copy the transformation from
  47534. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47535. */
  47536. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47537. /**
  47538. * Gets the current instance class name ("WebXRCamera").
  47539. * @returns the class name
  47540. */
  47541. getClassName(): string;
  47542. /**
  47543. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47544. */
  47545. _getViewMatrix(): Matrix;
  47546. private _updateFromXRSession;
  47547. private _updateNumberOfRigCameras;
  47548. private _updateReferenceSpace;
  47549. private _updateReferenceSpaceOffset;
  47550. }
  47551. }
  47552. declare module "babylonjs/XR/webXRFeaturesManager" {
  47553. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47554. import { IDisposable } from "babylonjs/scene";
  47555. /**
  47556. * Defining the interface required for a (webxr) feature
  47557. */
  47558. export interface IWebXRFeature extends IDisposable {
  47559. /**
  47560. * Is this feature attached
  47561. */
  47562. attached: boolean;
  47563. /**
  47564. * Should auto-attach be disabled?
  47565. */
  47566. disableAutoAttach: boolean;
  47567. /**
  47568. * Attach the feature to the session
  47569. * Will usually be called by the features manager
  47570. *
  47571. * @param force should attachment be forced (even when already attached)
  47572. * @returns true if successful.
  47573. */
  47574. attach(force?: boolean): boolean;
  47575. /**
  47576. * Detach the feature from the session
  47577. * Will usually be called by the features manager
  47578. *
  47579. * @returns true if successful.
  47580. */
  47581. detach(): boolean;
  47582. }
  47583. /**
  47584. * A list of the currently available features without referencing them
  47585. */
  47586. export class WebXRFeatureName {
  47587. /**
  47588. * The name of the anchor system feature
  47589. */
  47590. static ANCHOR_SYSTEM: string;
  47591. /**
  47592. * The name of the background remover feature
  47593. */
  47594. static BACKGROUND_REMOVER: string;
  47595. /**
  47596. * The name of the hit test feature
  47597. */
  47598. static HIT_TEST: string;
  47599. /**
  47600. * physics impostors for xr controllers feature
  47601. */
  47602. static PHYSICS_CONTROLLERS: string;
  47603. /**
  47604. * The name of the plane detection feature
  47605. */
  47606. static PLANE_DETECTION: string;
  47607. /**
  47608. * The name of the pointer selection feature
  47609. */
  47610. static POINTER_SELECTION: string;
  47611. /**
  47612. * The name of the teleportation feature
  47613. */
  47614. static TELEPORTATION: string;
  47615. }
  47616. /**
  47617. * Defining the constructor of a feature. Used to register the modules.
  47618. */
  47619. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  47620. /**
  47621. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47622. * It is mainly used in AR sessions.
  47623. *
  47624. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47625. */
  47626. export class WebXRFeaturesManager implements IDisposable {
  47627. private _xrSessionManager;
  47628. private static readonly _AvailableFeatures;
  47629. private _features;
  47630. /**
  47631. * constructs a new features manages.
  47632. *
  47633. * @param _xrSessionManager an instance of WebXRSessionManager
  47634. */
  47635. constructor(_xrSessionManager: WebXRSessionManager);
  47636. /**
  47637. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47638. * Mainly used internally.
  47639. *
  47640. * @param featureName the name of the feature to register
  47641. * @param constructorFunction the function used to construct the module
  47642. * @param version the (babylon) version of the module
  47643. * @param stable is that a stable version of this module
  47644. */
  47645. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47646. /**
  47647. * Returns a constructor of a specific feature.
  47648. *
  47649. * @param featureName the name of the feature to construct
  47650. * @param version the version of the feature to load
  47651. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47652. * @param options optional options provided to the module.
  47653. * @returns a function that, when called, will return a new instance of this feature
  47654. */
  47655. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  47656. /**
  47657. * Can be used to return the list of features currently registered
  47658. *
  47659. * @returns an Array of available features
  47660. */
  47661. static GetAvailableFeatures(): string[];
  47662. /**
  47663. * Gets the versions available for a specific feature
  47664. * @param featureName the name of the feature
  47665. * @returns an array with the available versions
  47666. */
  47667. static GetAvailableVersions(featureName: string): string[];
  47668. /**
  47669. * Return the latest unstable version of this feature
  47670. * @param featureName the name of the feature to search
  47671. * @returns the version number. if not found will return -1
  47672. */
  47673. static GetLatestVersionOfFeature(featureName: string): number;
  47674. /**
  47675. * Return the latest stable version of this feature
  47676. * @param featureName the name of the feature to search
  47677. * @returns the version number. if not found will return -1
  47678. */
  47679. static GetStableVersionOfFeature(featureName: string): number;
  47680. /**
  47681. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47682. * Can be used during a session to start a feature
  47683. * @param featureName the name of feature to attach
  47684. */
  47685. attachFeature(featureName: string): void;
  47686. /**
  47687. * Can be used inside a session or when the session ends to detach a specific feature
  47688. * @param featureName the name of the feature to detach
  47689. */
  47690. detachFeature(featureName: string): void;
  47691. /**
  47692. * Used to disable an already-enabled feature
  47693. * The feature will be disposed and will be recreated once enabled.
  47694. * @param featureName the feature to disable
  47695. * @returns true if disable was successful
  47696. */
  47697. disableFeature(featureName: string | {
  47698. Name: string;
  47699. }): boolean;
  47700. /**
  47701. * dispose this features manager
  47702. */
  47703. dispose(): void;
  47704. /**
  47705. * 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.
  47706. * 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.
  47707. *
  47708. * @param featureName the name of the feature to load or the class of the feature
  47709. * @param version optional version to load. if not provided the latest version will be enabled
  47710. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47711. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47712. * @returns a new constructed feature or throws an error if feature not found.
  47713. */
  47714. enableFeature(featureName: string | {
  47715. Name: string;
  47716. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  47717. /**
  47718. * get the implementation of an enabled feature.
  47719. * @param featureName the name of the feature to load
  47720. * @returns the feature class, if found
  47721. */
  47722. getEnabledFeature(featureName: string): IWebXRFeature;
  47723. /**
  47724. * Get the list of enabled features
  47725. * @returns an array of enabled features
  47726. */
  47727. getEnabledFeatures(): string[];
  47728. }
  47729. }
  47730. declare module "babylonjs/XR/webXRExperienceHelper" {
  47731. import { Observable } from "babylonjs/Misc/observable";
  47732. import { IDisposable, Scene } from "babylonjs/scene";
  47733. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47734. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  47735. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47736. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  47737. /**
  47738. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47739. * @see https://doc.babylonjs.com/how_to/webxr
  47740. */
  47741. export class WebXRExperienceHelper implements IDisposable {
  47742. private scene;
  47743. private _nonVRCamera;
  47744. private _originalSceneAutoClear;
  47745. private _supported;
  47746. /**
  47747. * Camera used to render xr content
  47748. */
  47749. camera: WebXRCamera;
  47750. /** A features manager for this xr session */
  47751. featuresManager: WebXRFeaturesManager;
  47752. /**
  47753. * Observers registered here will be triggered after the camera's initial transformation is set
  47754. * This can be used to set a different ground level or an extra rotation.
  47755. *
  47756. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47757. * to the position set after this observable is done executing.
  47758. */
  47759. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47760. /**
  47761. * Fires when the state of the experience helper has changed
  47762. */
  47763. onStateChangedObservable: Observable<WebXRState>;
  47764. /** Session manager used to keep track of xr session */
  47765. sessionManager: WebXRSessionManager;
  47766. /**
  47767. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47768. */
  47769. state: WebXRState;
  47770. /**
  47771. * Creates a WebXRExperienceHelper
  47772. * @param scene The scene the helper should be created in
  47773. */
  47774. private constructor();
  47775. /**
  47776. * Creates the experience helper
  47777. * @param scene the scene to attach the experience helper to
  47778. * @returns a promise for the experience helper
  47779. */
  47780. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47781. /**
  47782. * Disposes of the experience helper
  47783. */
  47784. dispose(): void;
  47785. /**
  47786. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47787. * @param sessionMode options for the XR session
  47788. * @param referenceSpaceType frame of reference of the XR session
  47789. * @param renderTarget the output canvas that will be used to enter XR mode
  47790. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47791. * @returns promise that resolves after xr mode has entered
  47792. */
  47793. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47794. /**
  47795. * Exits XR mode and returns the scene to its original state
  47796. * @returns promise that resolves after xr mode has exited
  47797. */
  47798. exitXRAsync(): Promise<void>;
  47799. private _nonXRToXRCamera;
  47800. private _setState;
  47801. }
  47802. }
  47803. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  47804. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  47805. import { Observable } from "babylonjs/Misc/observable";
  47806. import { IDisposable } from "babylonjs/scene";
  47807. /**
  47808. * X-Y values for axes in WebXR
  47809. */
  47810. export interface IWebXRMotionControllerAxesValue {
  47811. /**
  47812. * The value of the x axis
  47813. */
  47814. x: number;
  47815. /**
  47816. * The value of the y-axis
  47817. */
  47818. y: number;
  47819. }
  47820. /**
  47821. * changed / previous values for the values of this component
  47822. */
  47823. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47824. /**
  47825. * current (this frame) value
  47826. */
  47827. current: T;
  47828. /**
  47829. * previous (last change) value
  47830. */
  47831. previous: T;
  47832. }
  47833. /**
  47834. * Represents changes in the component between current frame and last values recorded
  47835. */
  47836. export interface IWebXRMotionControllerComponentChanges {
  47837. /**
  47838. * will be populated with previous and current values if axes changed
  47839. */
  47840. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47841. /**
  47842. * will be populated with previous and current values if pressed changed
  47843. */
  47844. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47845. /**
  47846. * will be populated with previous and current values if touched changed
  47847. */
  47848. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47849. /**
  47850. * will be populated with previous and current values if value changed
  47851. */
  47852. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47853. }
  47854. /**
  47855. * This class represents a single component (for example button or thumbstick) of a motion controller
  47856. */
  47857. export class WebXRControllerComponent implements IDisposable {
  47858. /**
  47859. * the id of this component
  47860. */
  47861. id: string;
  47862. /**
  47863. * the type of the component
  47864. */
  47865. type: MotionControllerComponentType;
  47866. private _buttonIndex;
  47867. private _axesIndices;
  47868. private _axes;
  47869. private _changes;
  47870. private _currentValue;
  47871. private _hasChanges;
  47872. private _pressed;
  47873. private _touched;
  47874. /**
  47875. * button component type
  47876. */
  47877. static BUTTON_TYPE: MotionControllerComponentType;
  47878. /**
  47879. * squeeze component type
  47880. */
  47881. static SQUEEZE_TYPE: MotionControllerComponentType;
  47882. /**
  47883. * Thumbstick component type
  47884. */
  47885. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47886. /**
  47887. * Touchpad component type
  47888. */
  47889. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47890. /**
  47891. * trigger component type
  47892. */
  47893. static TRIGGER_TYPE: MotionControllerComponentType;
  47894. /**
  47895. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47896. * the axes data changes
  47897. */
  47898. onAxisValueChangedObservable: Observable<{
  47899. x: number;
  47900. y: number;
  47901. }>;
  47902. /**
  47903. * Observers registered here will be triggered when the state of a button changes
  47904. * State change is either pressed / touched / value
  47905. */
  47906. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47907. /**
  47908. * Creates a new component for a motion controller.
  47909. * It is created by the motion controller itself
  47910. *
  47911. * @param id the id of this component
  47912. * @param type the type of the component
  47913. * @param _buttonIndex index in the buttons array of the gamepad
  47914. * @param _axesIndices indices of the values in the axes array of the gamepad
  47915. */
  47916. constructor(
  47917. /**
  47918. * the id of this component
  47919. */
  47920. id: string,
  47921. /**
  47922. * the type of the component
  47923. */
  47924. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47925. /**
  47926. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47927. */
  47928. get axes(): IWebXRMotionControllerAxesValue;
  47929. /**
  47930. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47931. */
  47932. get changes(): IWebXRMotionControllerComponentChanges;
  47933. /**
  47934. * Return whether or not the component changed the last frame
  47935. */
  47936. get hasChanges(): boolean;
  47937. /**
  47938. * is the button currently pressed
  47939. */
  47940. get pressed(): boolean;
  47941. /**
  47942. * is the button currently touched
  47943. */
  47944. get touched(): boolean;
  47945. /**
  47946. * Get the current value of this component
  47947. */
  47948. get value(): number;
  47949. /**
  47950. * Dispose this component
  47951. */
  47952. dispose(): void;
  47953. /**
  47954. * Are there axes correlating to this component
  47955. * @return true is axes data is available
  47956. */
  47957. isAxes(): boolean;
  47958. /**
  47959. * Is this component a button (hence - pressable)
  47960. * @returns true if can be pressed
  47961. */
  47962. isButton(): boolean;
  47963. /**
  47964. * update this component using the gamepad object it is in. Called on every frame
  47965. * @param nativeController the native gamepad controller object
  47966. */
  47967. update(nativeController: IMinimalMotionControllerObject): void;
  47968. }
  47969. }
  47970. declare module "babylonjs/Loading/sceneLoader" {
  47971. import { Observable } from "babylonjs/Misc/observable";
  47972. import { Nullable } from "babylonjs/types";
  47973. import { Scene } from "babylonjs/scene";
  47974. import { Engine } from "babylonjs/Engines/engine";
  47975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47976. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  47977. import { AssetContainer } from "babylonjs/assetContainer";
  47978. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  47979. import { Skeleton } from "babylonjs/Bones/skeleton";
  47980. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  47981. import { WebRequest } from "babylonjs/Misc/webRequest";
  47982. /**
  47983. * Class used to represent data loading progression
  47984. */
  47985. export class SceneLoaderProgressEvent {
  47986. /** defines if data length to load can be evaluated */
  47987. readonly lengthComputable: boolean;
  47988. /** defines the loaded data length */
  47989. readonly loaded: number;
  47990. /** defines the data length to load */
  47991. readonly total: number;
  47992. /**
  47993. * Create a new progress event
  47994. * @param lengthComputable defines if data length to load can be evaluated
  47995. * @param loaded defines the loaded data length
  47996. * @param total defines the data length to load
  47997. */
  47998. constructor(
  47999. /** defines if data length to load can be evaluated */
  48000. lengthComputable: boolean,
  48001. /** defines the loaded data length */
  48002. loaded: number,
  48003. /** defines the data length to load */
  48004. total: number);
  48005. /**
  48006. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48007. * @param event defines the source event
  48008. * @returns a new SceneLoaderProgressEvent
  48009. */
  48010. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  48011. }
  48012. /**
  48013. * Interface used by SceneLoader plugins to define supported file extensions
  48014. */
  48015. export interface ISceneLoaderPluginExtensions {
  48016. /**
  48017. * Defines the list of supported extensions
  48018. */
  48019. [extension: string]: {
  48020. isBinary: boolean;
  48021. };
  48022. }
  48023. /**
  48024. * Interface used by SceneLoader plugin factory
  48025. */
  48026. export interface ISceneLoaderPluginFactory {
  48027. /**
  48028. * Defines the name of the factory
  48029. */
  48030. name: string;
  48031. /**
  48032. * Function called to create a new plugin
  48033. * @return the new plugin
  48034. */
  48035. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48036. /**
  48037. * The callback that returns true if the data can be directly loaded.
  48038. * @param data string containing the file data
  48039. * @returns if the data can be loaded directly
  48040. */
  48041. canDirectLoad?(data: string): boolean;
  48042. }
  48043. /**
  48044. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48045. */
  48046. export interface ISceneLoaderPluginBase {
  48047. /**
  48048. * The friendly name of this plugin.
  48049. */
  48050. name: string;
  48051. /**
  48052. * The file extensions supported by this plugin.
  48053. */
  48054. extensions: string | ISceneLoaderPluginExtensions;
  48055. /**
  48056. * The callback called when loading from a url.
  48057. * @param scene scene loading this url
  48058. * @param url url to load
  48059. * @param onSuccess callback called when the file successfully loads
  48060. * @param onProgress callback called while file is loading (if the server supports this mode)
  48061. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48062. * @param onError callback called when the file fails to load
  48063. * @returns a file request object
  48064. */
  48065. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48066. /**
  48067. * The callback called when loading from a file object.
  48068. * @param scene scene loading this file
  48069. * @param file defines the file to load
  48070. * @param onSuccess defines the callback to call when data is loaded
  48071. * @param onProgress defines the callback to call during loading process
  48072. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48073. * @param onError defines the callback to call when an error occurs
  48074. * @returns a file request object
  48075. */
  48076. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48077. /**
  48078. * The callback that returns true if the data can be directly loaded.
  48079. * @param data string containing the file data
  48080. * @returns if the data can be loaded directly
  48081. */
  48082. canDirectLoad?(data: string): boolean;
  48083. /**
  48084. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48085. * @param scene scene loading this data
  48086. * @param data string containing the data
  48087. * @returns data to pass to the plugin
  48088. */
  48089. directLoad?(scene: Scene, data: string): any;
  48090. /**
  48091. * The callback that allows custom handling of the root url based on the response url.
  48092. * @param rootUrl the original root url
  48093. * @param responseURL the response url if available
  48094. * @returns the new root url
  48095. */
  48096. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48097. }
  48098. /**
  48099. * Interface used to define a SceneLoader plugin
  48100. */
  48101. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48102. /**
  48103. * Import meshes into a scene.
  48104. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48105. * @param scene The scene to import into
  48106. * @param data The data to import
  48107. * @param rootUrl The root url for scene and resources
  48108. * @param meshes The meshes array to import into
  48109. * @param particleSystems The particle systems array to import into
  48110. * @param skeletons The skeletons array to import into
  48111. * @param onError The callback when import fails
  48112. * @returns True if successful or false otherwise
  48113. */
  48114. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48115. /**
  48116. * Load into a scene.
  48117. * @param scene The scene to load into
  48118. * @param data The data to import
  48119. * @param rootUrl The root url for scene and resources
  48120. * @param onError The callback when import fails
  48121. * @returns True if successful or false otherwise
  48122. */
  48123. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48124. /**
  48125. * Load into an asset container.
  48126. * @param scene The scene to load into
  48127. * @param data The data to import
  48128. * @param rootUrl The root url for scene and resources
  48129. * @param onError The callback when import fails
  48130. * @returns The loaded asset container
  48131. */
  48132. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48133. }
  48134. /**
  48135. * Interface used to define an async SceneLoader plugin
  48136. */
  48137. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48138. /**
  48139. * Import meshes into a scene.
  48140. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48141. * @param scene The scene to import into
  48142. * @param data The data to import
  48143. * @param rootUrl The root url for scene and resources
  48144. * @param onProgress The callback when the load progresses
  48145. * @param fileName Defines the name of the file to load
  48146. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48147. */
  48148. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48149. meshes: AbstractMesh[];
  48150. particleSystems: IParticleSystem[];
  48151. skeletons: Skeleton[];
  48152. animationGroups: AnimationGroup[];
  48153. }>;
  48154. /**
  48155. * Load into a scene.
  48156. * @param scene The scene to load into
  48157. * @param data The data to import
  48158. * @param rootUrl The root url for scene and resources
  48159. * @param onProgress The callback when the load progresses
  48160. * @param fileName Defines the name of the file to load
  48161. * @returns Nothing
  48162. */
  48163. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48164. /**
  48165. * Load into an asset container.
  48166. * @param scene The scene to load into
  48167. * @param data The data to import
  48168. * @param rootUrl The root url for scene and resources
  48169. * @param onProgress The callback when the load progresses
  48170. * @param fileName Defines the name of the file to load
  48171. * @returns The loaded asset container
  48172. */
  48173. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48174. }
  48175. /**
  48176. * Mode that determines how to handle old animation groups before loading new ones.
  48177. */
  48178. export enum SceneLoaderAnimationGroupLoadingMode {
  48179. /**
  48180. * Reset all old animations to initial state then dispose them.
  48181. */
  48182. Clean = 0,
  48183. /**
  48184. * Stop all old animations.
  48185. */
  48186. Stop = 1,
  48187. /**
  48188. * Restart old animations from first frame.
  48189. */
  48190. Sync = 2,
  48191. /**
  48192. * Old animations remains untouched.
  48193. */
  48194. NoSync = 3
  48195. }
  48196. /**
  48197. * Class used to load scene from various file formats using registered plugins
  48198. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48199. */
  48200. export class SceneLoader {
  48201. /**
  48202. * No logging while loading
  48203. */
  48204. static readonly NO_LOGGING: number;
  48205. /**
  48206. * Minimal logging while loading
  48207. */
  48208. static readonly MINIMAL_LOGGING: number;
  48209. /**
  48210. * Summary logging while loading
  48211. */
  48212. static readonly SUMMARY_LOGGING: number;
  48213. /**
  48214. * Detailled logging while loading
  48215. */
  48216. static readonly DETAILED_LOGGING: number;
  48217. /**
  48218. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48219. */
  48220. static get ForceFullSceneLoadingForIncremental(): boolean;
  48221. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48222. /**
  48223. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48224. */
  48225. static get ShowLoadingScreen(): boolean;
  48226. static set ShowLoadingScreen(value: boolean);
  48227. /**
  48228. * Defines the current logging level (while loading the scene)
  48229. * @ignorenaming
  48230. */
  48231. static get loggingLevel(): number;
  48232. static set loggingLevel(value: number);
  48233. /**
  48234. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48235. */
  48236. static get CleanBoneMatrixWeights(): boolean;
  48237. static set CleanBoneMatrixWeights(value: boolean);
  48238. /**
  48239. * Event raised when a plugin is used to load a scene
  48240. */
  48241. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48242. private static _registeredPlugins;
  48243. private static _getDefaultPlugin;
  48244. private static _getPluginForExtension;
  48245. private static _getPluginForDirectLoad;
  48246. private static _getPluginForFilename;
  48247. private static _getDirectLoad;
  48248. private static _loadData;
  48249. private static _getFileInfo;
  48250. /**
  48251. * Gets a plugin that can load the given extension
  48252. * @param extension defines the extension to load
  48253. * @returns a plugin or null if none works
  48254. */
  48255. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48256. /**
  48257. * Gets a boolean indicating that the given extension can be loaded
  48258. * @param extension defines the extension to load
  48259. * @returns true if the extension is supported
  48260. */
  48261. static IsPluginForExtensionAvailable(extension: string): boolean;
  48262. /**
  48263. * Adds a new plugin to the list of registered plugins
  48264. * @param plugin defines the plugin to add
  48265. */
  48266. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48267. /**
  48268. * Import meshes into a scene
  48269. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 the instance of BABYLON.Scene to append to
  48273. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48274. * @param onProgress a callback with a progress event for each file being loaded
  48275. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48276. * @param pluginExtension the extension used to determine the plugin
  48277. * @returns The loaded plugin
  48278. */
  48279. 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>;
  48280. /**
  48281. * Import meshes into a scene
  48282. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 the instance of BABYLON.Scene to append to
  48286. * @param onProgress a callback with a progress event for each file being loaded
  48287. * @param pluginExtension the extension used to determine the plugin
  48288. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48289. */
  48290. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48291. meshes: AbstractMesh[];
  48292. particleSystems: IParticleSystem[];
  48293. skeletons: Skeleton[];
  48294. animationGroups: AnimationGroup[];
  48295. }>;
  48296. /**
  48297. * Load a scene
  48298. * @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)
  48299. * @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)
  48300. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48301. * @param onSuccess a callback with the scene when import succeeds
  48302. * @param onProgress a callback with a progress event for each file being loaded
  48303. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48304. * @param pluginExtension the extension used to determine the plugin
  48305. * @returns The loaded plugin
  48306. */
  48307. 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>;
  48308. /**
  48309. * Load a scene
  48310. * @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)
  48311. * @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)
  48312. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48313. * @param onProgress a callback with a progress event for each file being loaded
  48314. * @param pluginExtension the extension used to determine the plugin
  48315. * @returns The loaded scene
  48316. */
  48317. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48318. /**
  48319. * Append a scene
  48320. * @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)
  48321. * @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)
  48322. * @param scene is the instance of BABYLON.Scene to append to
  48323. * @param onSuccess a callback with the scene when import succeeds
  48324. * @param onProgress a callback with a progress event for each file being loaded
  48325. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48326. * @param pluginExtension the extension used to determine the plugin
  48327. * @returns The loaded plugin
  48328. */
  48329. 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>;
  48330. /**
  48331. * Append a scene
  48332. * @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)
  48333. * @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)
  48334. * @param scene is the instance of BABYLON.Scene to append to
  48335. * @param onProgress a callback with a progress event for each file being loaded
  48336. * @param pluginExtension the extension used to determine the plugin
  48337. * @returns The given scene
  48338. */
  48339. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48340. /**
  48341. * Load a scene into an asset container
  48342. * @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)
  48343. * @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)
  48344. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48345. * @param onSuccess a callback with the scene when import succeeds
  48346. * @param onProgress a callback with a progress event for each file being loaded
  48347. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48348. * @param pluginExtension the extension used to determine the plugin
  48349. * @returns The loaded plugin
  48350. */
  48351. 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>;
  48352. /**
  48353. * Load a scene into an asset container
  48354. * @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)
  48355. * @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)
  48356. * @param scene is the instance of Scene to append to
  48357. * @param onProgress a callback with a progress event for each file being loaded
  48358. * @param pluginExtension the extension used to determine the plugin
  48359. * @returns The loaded asset container
  48360. */
  48361. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48362. /**
  48363. * Import animations from a file into a scene
  48364. * @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)
  48365. * @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)
  48366. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48367. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48368. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48369. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48370. * @param onSuccess a callback with the scene when import succeeds
  48371. * @param onProgress a callback with a progress event for each file being loaded
  48372. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48373. */
  48374. 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;
  48375. /**
  48376. * Import animations from a file into a scene
  48377. * @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)
  48378. * @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)
  48379. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48380. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48381. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48382. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48383. * @param onSuccess a callback with the scene when import succeeds
  48384. * @param onProgress a callback with a progress event for each file being loaded
  48385. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48386. * @returns the updated scene with imported animations
  48387. */
  48388. 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>;
  48389. }
  48390. }
  48391. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48392. import { IDisposable, Scene } from "babylonjs/scene";
  48393. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48394. import { Observable } from "babylonjs/Misc/observable";
  48395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48396. import { Nullable } from "babylonjs/types";
  48397. /**
  48398. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48399. */
  48400. export type MotionControllerHandedness = "none" | "left" | "right";
  48401. /**
  48402. * The type of components available in motion controllers.
  48403. * This is not the name of the component.
  48404. */
  48405. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48406. /**
  48407. * The state of a controller component
  48408. */
  48409. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48410. /**
  48411. * The schema of motion controller layout.
  48412. * No object will be initialized using this interface
  48413. * This is used just to define the profile.
  48414. */
  48415. export interface IMotionControllerLayout {
  48416. /**
  48417. * Path to load the assets. Usually relative to the base path
  48418. */
  48419. assetPath: string;
  48420. /**
  48421. * Available components (unsorted)
  48422. */
  48423. components: {
  48424. /**
  48425. * A map of component Ids
  48426. */
  48427. [componentId: string]: {
  48428. /**
  48429. * The type of input the component outputs
  48430. */
  48431. type: MotionControllerComponentType;
  48432. /**
  48433. * The indices of this component in the gamepad object
  48434. */
  48435. gamepadIndices: {
  48436. /**
  48437. * Index of button
  48438. */
  48439. button?: number;
  48440. /**
  48441. * If available, index of x-axis
  48442. */
  48443. xAxis?: number;
  48444. /**
  48445. * If available, index of y-axis
  48446. */
  48447. yAxis?: number;
  48448. };
  48449. /**
  48450. * The mesh's root node name
  48451. */
  48452. rootNodeName: string;
  48453. /**
  48454. * Animation definitions for this model
  48455. */
  48456. visualResponses: {
  48457. [stateKey: string]: {
  48458. /**
  48459. * What property will be animated
  48460. */
  48461. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48462. /**
  48463. * What states influence this visual response
  48464. */
  48465. states: MotionControllerComponentStateType[];
  48466. /**
  48467. * Type of animation - movement or visibility
  48468. */
  48469. valueNodeProperty: "transform" | "visibility";
  48470. /**
  48471. * Base node name to move. Its position will be calculated according to the min and max nodes
  48472. */
  48473. valueNodeName?: string;
  48474. /**
  48475. * Minimum movement node
  48476. */
  48477. minNodeName?: string;
  48478. /**
  48479. * Max movement node
  48480. */
  48481. maxNodeName?: string;
  48482. };
  48483. };
  48484. /**
  48485. * If touch enabled, what is the name of node to display user feedback
  48486. */
  48487. touchPointNodeName?: string;
  48488. };
  48489. };
  48490. /**
  48491. * Is it xr standard mapping or not
  48492. */
  48493. gamepadMapping: "" | "xr-standard";
  48494. /**
  48495. * Base root node of this entire model
  48496. */
  48497. rootNodeName: string;
  48498. /**
  48499. * Defines the main button component id
  48500. */
  48501. selectComponentId: string;
  48502. }
  48503. /**
  48504. * A definition for the layout map in the input profile
  48505. */
  48506. export interface IMotionControllerLayoutMap {
  48507. /**
  48508. * Layouts with handedness type as a key
  48509. */
  48510. [handedness: string]: IMotionControllerLayout;
  48511. }
  48512. /**
  48513. * The XR Input profile schema
  48514. * Profiles can be found here:
  48515. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48516. */
  48517. export interface IMotionControllerProfile {
  48518. /**
  48519. * fallback profiles for this profileId
  48520. */
  48521. fallbackProfileIds: string[];
  48522. /**
  48523. * The layout map, with handedness as key
  48524. */
  48525. layouts: IMotionControllerLayoutMap;
  48526. /**
  48527. * The id of this profile
  48528. * correlates to the profile(s) in the xrInput.profiles array
  48529. */
  48530. profileId: string;
  48531. }
  48532. /**
  48533. * A helper-interface for the 3 meshes needed for controller button animation
  48534. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48535. */
  48536. export interface IMotionControllerButtonMeshMap {
  48537. /**
  48538. * the mesh that defines the pressed value mesh position.
  48539. * This is used to find the max-position of this button
  48540. */
  48541. pressedMesh: AbstractMesh;
  48542. /**
  48543. * the mesh that defines the unpressed value mesh position.
  48544. * This is used to find the min (or initial) position of this button
  48545. */
  48546. unpressedMesh: AbstractMesh;
  48547. /**
  48548. * The mesh that will be changed when value changes
  48549. */
  48550. valueMesh: AbstractMesh;
  48551. }
  48552. /**
  48553. * A helper-interface for the 3 meshes needed for controller axis animation.
  48554. * This will be expanded when touchpad animations are fully supported
  48555. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48556. */
  48557. export interface IMotionControllerMeshMap {
  48558. /**
  48559. * the mesh that defines the maximum value mesh position.
  48560. */
  48561. maxMesh?: AbstractMesh;
  48562. /**
  48563. * the mesh that defines the minimum value mesh position.
  48564. */
  48565. minMesh?: AbstractMesh;
  48566. /**
  48567. * The mesh that will be changed when axis value changes
  48568. */
  48569. valueMesh: AbstractMesh;
  48570. }
  48571. /**
  48572. * The elements needed for change-detection of the gamepad objects in motion controllers
  48573. */
  48574. export interface IMinimalMotionControllerObject {
  48575. /**
  48576. * Available axes of this controller
  48577. */
  48578. axes: number[];
  48579. /**
  48580. * An array of available buttons
  48581. */
  48582. buttons: Array<{
  48583. /**
  48584. * Value of the button/trigger
  48585. */
  48586. value: number;
  48587. /**
  48588. * If the button/trigger is currently touched
  48589. */
  48590. touched: boolean;
  48591. /**
  48592. * If the button/trigger is currently pressed
  48593. */
  48594. pressed: boolean;
  48595. }>;
  48596. /**
  48597. * EXPERIMENTAL haptic support.
  48598. */
  48599. hapticActuators?: Array<{
  48600. pulse: (value: number, duration: number) => Promise<boolean>;
  48601. }>;
  48602. }
  48603. /**
  48604. * An Abstract Motion controller
  48605. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48606. * Each component has an observable to check for changes in value and state
  48607. */
  48608. export abstract class WebXRAbstractMotionController implements IDisposable {
  48609. protected scene: Scene;
  48610. protected layout: IMotionControllerLayout;
  48611. /**
  48612. * The gamepad object correlating to this controller
  48613. */
  48614. gamepadObject: IMinimalMotionControllerObject;
  48615. /**
  48616. * handedness (left/right/none) of this controller
  48617. */
  48618. handedness: MotionControllerHandedness;
  48619. private _initComponent;
  48620. private _modelReady;
  48621. /**
  48622. * A map of components (WebXRControllerComponent) in this motion controller
  48623. * Components have a ComponentType and can also have both button and axis definitions
  48624. */
  48625. readonly components: {
  48626. [id: string]: WebXRControllerComponent;
  48627. };
  48628. /**
  48629. * Disable the model's animation. Can be set at any time.
  48630. */
  48631. disableAnimation: boolean;
  48632. /**
  48633. * Observers registered here will be triggered when the model of this controller is done loading
  48634. */
  48635. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48636. /**
  48637. * The profile id of this motion controller
  48638. */
  48639. abstract profileId: string;
  48640. /**
  48641. * The root mesh of the model. It is null if the model was not yet initialized
  48642. */
  48643. rootMesh: Nullable<AbstractMesh>;
  48644. /**
  48645. * constructs a new abstract motion controller
  48646. * @param scene the scene to which the model of the controller will be added
  48647. * @param layout The profile layout to load
  48648. * @param gamepadObject The gamepad object correlating to this controller
  48649. * @param handedness handedness (left/right/none) of this controller
  48650. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48651. */
  48652. constructor(scene: Scene, layout: IMotionControllerLayout,
  48653. /**
  48654. * The gamepad object correlating to this controller
  48655. */
  48656. gamepadObject: IMinimalMotionControllerObject,
  48657. /**
  48658. * handedness (left/right/none) of this controller
  48659. */
  48660. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48661. /**
  48662. * Dispose this controller, the model mesh and all its components
  48663. */
  48664. dispose(): void;
  48665. /**
  48666. * Returns all components of specific type
  48667. * @param type the type to search for
  48668. * @return an array of components with this type
  48669. */
  48670. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48671. /**
  48672. * get a component based an its component id as defined in layout.components
  48673. * @param id the id of the component
  48674. * @returns the component correlates to the id or undefined if not found
  48675. */
  48676. getComponent(id: string): WebXRControllerComponent;
  48677. /**
  48678. * Get the list of components available in this motion controller
  48679. * @returns an array of strings correlating to available components
  48680. */
  48681. getComponentIds(): string[];
  48682. /**
  48683. * Get the first component of specific type
  48684. * @param type type of component to find
  48685. * @return a controller component or null if not found
  48686. */
  48687. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48688. /**
  48689. * Get the main (Select) component of this controller as defined in the layout
  48690. * @returns the main component of this controller
  48691. */
  48692. getMainComponent(): WebXRControllerComponent;
  48693. /**
  48694. * Loads the model correlating to this controller
  48695. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48696. * @returns A promise fulfilled with the result of the model loading
  48697. */
  48698. loadModel(): Promise<boolean>;
  48699. /**
  48700. * Update this model using the current XRFrame
  48701. * @param xrFrame the current xr frame to use and update the model
  48702. */
  48703. updateFromXRFrame(xrFrame: XRFrame): void;
  48704. /**
  48705. * Backwards compatibility due to a deeply-integrated typo
  48706. */
  48707. get handness(): XREye;
  48708. /**
  48709. * Pulse (vibrate) this controller
  48710. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48711. * Consecutive calls to this function will cancel the last pulse call
  48712. *
  48713. * @param value the strength of the pulse in 0.0...1.0 range
  48714. * @param duration Duration of the pulse in milliseconds
  48715. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48716. * @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
  48717. */
  48718. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48719. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48720. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48721. /**
  48722. * Moves the axis on the controller mesh based on its current state
  48723. * @param axis the index of the axis
  48724. * @param axisValue the value of the axis which determines the meshes new position
  48725. * @hidden
  48726. */
  48727. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48728. /**
  48729. * Update the model itself with the current frame data
  48730. * @param xrFrame the frame to use for updating the model mesh
  48731. */
  48732. protected updateModel(xrFrame: XRFrame): void;
  48733. /**
  48734. * Get the filename and path for this controller's model
  48735. * @returns a map of filename and path
  48736. */
  48737. protected abstract _getFilenameAndPath(): {
  48738. filename: string;
  48739. path: string;
  48740. };
  48741. /**
  48742. * This function is called before the mesh is loaded. It checks for loading constraints.
  48743. * For example, this function can check if the GLB loader is available
  48744. * If this function returns false, the generic controller will be loaded instead
  48745. * @returns Is the client ready to load the mesh
  48746. */
  48747. protected abstract _getModelLoadingConstraints(): boolean;
  48748. /**
  48749. * This function will be called after the model was successfully loaded and can be used
  48750. * for mesh transformations before it is available for the user
  48751. * @param meshes the loaded meshes
  48752. */
  48753. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48754. /**
  48755. * Set the root mesh for this controller. Important for the WebXR controller class
  48756. * @param meshes the loaded meshes
  48757. */
  48758. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48759. /**
  48760. * A function executed each frame that updates the mesh (if needed)
  48761. * @param xrFrame the current xrFrame
  48762. */
  48763. protected abstract _updateModel(xrFrame: XRFrame): void;
  48764. private _getGenericFilenameAndPath;
  48765. private _getGenericParentMesh;
  48766. }
  48767. }
  48768. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  48769. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48771. import { Scene } from "babylonjs/scene";
  48772. /**
  48773. * A generic trigger-only motion controller for WebXR
  48774. */
  48775. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48776. /**
  48777. * Static version of the profile id of this controller
  48778. */
  48779. static ProfileId: string;
  48780. profileId: string;
  48781. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48782. protected _getFilenameAndPath(): {
  48783. filename: string;
  48784. path: string;
  48785. };
  48786. protected _getModelLoadingConstraints(): boolean;
  48787. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48788. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48789. protected _updateModel(): void;
  48790. }
  48791. }
  48792. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  48793. import { Vector4 } from "babylonjs/Maths/math.vector";
  48794. import { Mesh } from "babylonjs/Meshes/mesh";
  48795. import { Scene } from "babylonjs/scene";
  48796. import { Nullable } from "babylonjs/types";
  48797. /**
  48798. * Class containing static functions to help procedurally build meshes
  48799. */
  48800. export class SphereBuilder {
  48801. /**
  48802. * Creates a sphere mesh
  48803. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48804. * * 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`)
  48805. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48806. * * 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
  48807. * * 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)
  48808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48811. * @param name defines the name of the mesh
  48812. * @param options defines the options used to create the mesh
  48813. * @param scene defines the hosting scene
  48814. * @returns the sphere mesh
  48815. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48816. */
  48817. static CreateSphere(name: string, options: {
  48818. segments?: number;
  48819. diameter?: number;
  48820. diameterX?: number;
  48821. diameterY?: number;
  48822. diameterZ?: number;
  48823. arc?: number;
  48824. slice?: number;
  48825. sideOrientation?: number;
  48826. frontUVs?: Vector4;
  48827. backUVs?: Vector4;
  48828. updatable?: boolean;
  48829. }, scene?: Nullable<Scene>): Mesh;
  48830. }
  48831. }
  48832. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  48833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48834. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48835. import { Scene } from "babylonjs/scene";
  48836. /**
  48837. * A profiled motion controller has its profile loaded from an online repository.
  48838. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48839. */
  48840. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48841. private _repositoryUrl;
  48842. private _buttonMeshMapping;
  48843. private _touchDots;
  48844. /**
  48845. * The profile ID of this controller. Will be populated when the controller initializes.
  48846. */
  48847. profileId: string;
  48848. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48849. dispose(): void;
  48850. protected _getFilenameAndPath(): {
  48851. filename: string;
  48852. path: string;
  48853. };
  48854. protected _getModelLoadingConstraints(): boolean;
  48855. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48856. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48857. protected _updateModel(_xrFrame: XRFrame): void;
  48858. }
  48859. }
  48860. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  48861. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48862. import { Scene } from "babylonjs/scene";
  48863. /**
  48864. * A construction function type to create a new controller based on an xrInput object
  48865. */
  48866. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48867. /**
  48868. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48869. *
  48870. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48871. * it should be replaced with auto-loaded controllers.
  48872. *
  48873. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48874. */
  48875. export class WebXRMotionControllerManager {
  48876. private static _AvailableControllers;
  48877. private static _Fallbacks;
  48878. private static _ProfileLoadingPromises;
  48879. private static _ProfilesList;
  48880. /**
  48881. * The base URL of the online controller repository. Can be changed at any time.
  48882. */
  48883. static BaseRepositoryUrl: string;
  48884. /**
  48885. * Which repository gets priority - local or online
  48886. */
  48887. static PrioritizeOnlineRepository: boolean;
  48888. /**
  48889. * Use the online repository, or use only locally-defined controllers
  48890. */
  48891. static UseOnlineRepository: boolean;
  48892. /**
  48893. * Clear the cache used for profile loading and reload when requested again
  48894. */
  48895. static ClearProfilesCache(): void;
  48896. /**
  48897. * Register the default fallbacks.
  48898. * This function is called automatically when this file is imported.
  48899. */
  48900. static DefaultFallbacks(): void;
  48901. /**
  48902. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48903. * @param profileId the profile to which a fallback needs to be found
  48904. * @return an array with corresponding fallback profiles
  48905. */
  48906. static FindFallbackWithProfileId(profileId: string): string[];
  48907. /**
  48908. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48909. * The order of search:
  48910. *
  48911. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48912. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48913. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48914. * 4) return the generic trigger controller if none were found
  48915. *
  48916. * @param xrInput the xrInput to which a new controller is initialized
  48917. * @param scene the scene to which the model will be added
  48918. * @param forceProfile force a certain profile for this controller
  48919. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48920. */
  48921. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48922. /**
  48923. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48924. *
  48925. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48926. *
  48927. * @param type the profile type to register
  48928. * @param constructFunction the function to be called when loading this profile
  48929. */
  48930. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48931. /**
  48932. * Register a fallback to a specific profile.
  48933. * @param profileId the profileId that will receive the fallbacks
  48934. * @param fallbacks A list of fallback profiles
  48935. */
  48936. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48937. /**
  48938. * Will update the list of profiles available in the repository
  48939. * @return a promise that resolves to a map of profiles available online
  48940. */
  48941. static UpdateProfilesList(): Promise<{
  48942. [profile: string]: string;
  48943. }>;
  48944. private static _LoadProfileFromRepository;
  48945. private static _LoadProfilesFromAvailableControllers;
  48946. }
  48947. }
  48948. declare module "babylonjs/XR/webXRInputSource" {
  48949. import { Observable } from "babylonjs/Misc/observable";
  48950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48951. import { Ray } from "babylonjs/Culling/ray";
  48952. import { Scene } from "babylonjs/scene";
  48953. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48954. /**
  48955. * Configuration options for the WebXR controller creation
  48956. */
  48957. export interface IWebXRControllerOptions {
  48958. /**
  48959. * Should the controller mesh be animated when a user interacts with it
  48960. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48961. */
  48962. disableMotionControllerAnimation?: boolean;
  48963. /**
  48964. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48965. */
  48966. doNotLoadControllerMesh?: boolean;
  48967. /**
  48968. * Force a specific controller type for this controller.
  48969. * This can be used when creating your own profile or when testing different controllers
  48970. */
  48971. forceControllerProfile?: string;
  48972. /**
  48973. * Defines a rendering group ID for meshes that will be loaded.
  48974. * This is for the default controllers only.
  48975. */
  48976. renderingGroupId?: number;
  48977. }
  48978. /**
  48979. * Represents an XR controller
  48980. */
  48981. export class WebXRInputSource {
  48982. private _scene;
  48983. /** The underlying input source for the controller */
  48984. inputSource: XRInputSource;
  48985. private _options;
  48986. private _tmpVector;
  48987. private _uniqueId;
  48988. /**
  48989. * 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
  48990. */
  48991. grip?: AbstractMesh;
  48992. /**
  48993. * If available, this is the gamepad object related to this controller.
  48994. * Using this object it is possible to get click events and trackpad changes of the
  48995. * webxr controller that is currently being used.
  48996. */
  48997. motionController?: WebXRAbstractMotionController;
  48998. /**
  48999. * Event that fires when the controller is removed/disposed.
  49000. * The object provided as event data is this controller, after associated assets were disposed.
  49001. * uniqueId is still available.
  49002. */
  49003. onDisposeObservable: Observable<WebXRInputSource>;
  49004. /**
  49005. * Will be triggered when the mesh associated with the motion controller is done loading.
  49006. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49007. * A shortened version of controller -> motion controller -> on mesh loaded.
  49008. */
  49009. onMeshLoadedObservable: Observable<AbstractMesh>;
  49010. /**
  49011. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49012. */
  49013. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49014. /**
  49015. * Pointer which can be used to select objects or attach a visible laser to
  49016. */
  49017. pointer: AbstractMesh;
  49018. /**
  49019. * Creates the controller
  49020. * @see https://doc.babylonjs.com/how_to/webxr
  49021. * @param _scene the scene which the controller should be associated to
  49022. * @param inputSource the underlying input source for the controller
  49023. * @param _options options for this controller creation
  49024. */
  49025. constructor(_scene: Scene,
  49026. /** The underlying input source for the controller */
  49027. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49028. /**
  49029. * Get this controllers unique id
  49030. */
  49031. get uniqueId(): string;
  49032. /**
  49033. * Disposes of the object
  49034. */
  49035. dispose(): void;
  49036. /**
  49037. * Gets a world space ray coming from the pointer or grip
  49038. * @param result the resulting ray
  49039. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49040. */
  49041. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49042. /**
  49043. * Updates the controller pose based on the given XRFrame
  49044. * @param xrFrame xr frame to update the pose with
  49045. * @param referenceSpace reference space to use
  49046. */
  49047. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49048. }
  49049. }
  49050. declare module "babylonjs/XR/webXRInput" {
  49051. import { Observable } from "babylonjs/Misc/observable";
  49052. import { IDisposable } from "babylonjs/scene";
  49053. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49054. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49055. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49056. /**
  49057. * The schema for initialization options of the XR Input class
  49058. */
  49059. export interface IWebXRInputOptions {
  49060. /**
  49061. * If set to true no model will be automatically loaded
  49062. */
  49063. doNotLoadControllerMeshes?: boolean;
  49064. /**
  49065. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49066. * If not found, the xr input profile data will be used.
  49067. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49068. */
  49069. forceInputProfile?: string;
  49070. /**
  49071. * Do not send a request to the controller repository to load the profile.
  49072. *
  49073. * Instead, use the controllers available in babylon itself.
  49074. */
  49075. disableOnlineControllerRepository?: boolean;
  49076. /**
  49077. * A custom URL for the controllers repository
  49078. */
  49079. customControllersRepositoryURL?: string;
  49080. /**
  49081. * Should the controller model's components not move according to the user input
  49082. */
  49083. disableControllerAnimation?: boolean;
  49084. /**
  49085. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49086. */
  49087. controllerOptions?: IWebXRControllerOptions;
  49088. }
  49089. /**
  49090. * XR input used to track XR inputs such as controllers/rays
  49091. */
  49092. export class WebXRInput implements IDisposable {
  49093. /**
  49094. * the xr session manager for this session
  49095. */
  49096. xrSessionManager: WebXRSessionManager;
  49097. /**
  49098. * the WebXR camera for this session. Mainly used for teleportation
  49099. */
  49100. xrCamera: WebXRCamera;
  49101. private readonly options;
  49102. /**
  49103. * XR controllers being tracked
  49104. */
  49105. controllers: Array<WebXRInputSource>;
  49106. private _frameObserver;
  49107. private _sessionEndedObserver;
  49108. private _sessionInitObserver;
  49109. /**
  49110. * Event when a controller has been connected/added
  49111. */
  49112. onControllerAddedObservable: Observable<WebXRInputSource>;
  49113. /**
  49114. * Event when a controller has been removed/disconnected
  49115. */
  49116. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49117. /**
  49118. * Initializes the WebXRInput
  49119. * @param xrSessionManager the xr session manager for this session
  49120. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49121. * @param options = initialization options for this xr input
  49122. */
  49123. constructor(
  49124. /**
  49125. * the xr session manager for this session
  49126. */
  49127. xrSessionManager: WebXRSessionManager,
  49128. /**
  49129. * the WebXR camera for this session. Mainly used for teleportation
  49130. */
  49131. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49132. private _onInputSourcesChange;
  49133. private _addAndRemoveControllers;
  49134. /**
  49135. * Disposes of the object
  49136. */
  49137. dispose(): void;
  49138. }
  49139. }
  49140. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49141. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49142. import { Observable, EventState } from "babylonjs/Misc/observable";
  49143. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49144. /**
  49145. * This is the base class for all WebXR features.
  49146. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49147. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49148. */
  49149. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49150. protected _xrSessionManager: WebXRSessionManager;
  49151. private _attached;
  49152. private _removeOnDetach;
  49153. /**
  49154. * Should auto-attach be disabled?
  49155. */
  49156. disableAutoAttach: boolean;
  49157. /**
  49158. * Construct a new (abstract) WebXR feature
  49159. * @param _xrSessionManager the xr session manager for this feature
  49160. */
  49161. constructor(_xrSessionManager: WebXRSessionManager);
  49162. /**
  49163. * Is this feature attached
  49164. */
  49165. get attached(): boolean;
  49166. /**
  49167. * attach this feature
  49168. *
  49169. * @param force should attachment be forced (even when already attached)
  49170. * @returns true if successful, false is failed or already attached
  49171. */
  49172. attach(force?: boolean): boolean;
  49173. /**
  49174. * detach this feature.
  49175. *
  49176. * @returns true if successful, false if failed or already detached
  49177. */
  49178. detach(): boolean;
  49179. /**
  49180. * Dispose this feature and all of the resources attached
  49181. */
  49182. dispose(): void;
  49183. /**
  49184. * This is used to register callbacks that will automatically be removed when detach is called.
  49185. * @param observable the observable to which the observer will be attached
  49186. * @param callback the callback to register
  49187. */
  49188. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49189. /**
  49190. * Code in this function will be executed on each xrFrame received from the browser.
  49191. * This function will not execute after the feature is detached.
  49192. * @param _xrFrame the current frame
  49193. */
  49194. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49195. }
  49196. }
  49197. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49198. import { IDisposable, Scene } from "babylonjs/scene";
  49199. import { Nullable } from "babylonjs/types";
  49200. import { Observable } from "babylonjs/Misc/observable";
  49201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49202. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49203. import { Camera } from "babylonjs/Cameras/camera";
  49204. /**
  49205. * Renders a layer on top of an existing scene
  49206. */
  49207. export class UtilityLayerRenderer implements IDisposable {
  49208. /** the original scene that will be rendered on top of */
  49209. originalScene: Scene;
  49210. private _pointerCaptures;
  49211. private _lastPointerEvents;
  49212. private static _DefaultUtilityLayer;
  49213. private static _DefaultKeepDepthUtilityLayer;
  49214. private _sharedGizmoLight;
  49215. private _renderCamera;
  49216. /**
  49217. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49218. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49219. * @returns the camera that is used when rendering the utility layer
  49220. */
  49221. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49222. /**
  49223. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49224. * @param cam the camera that should be used when rendering the utility layer
  49225. */
  49226. setRenderCamera(cam: Nullable<Camera>): void;
  49227. /**
  49228. * @hidden
  49229. * Light which used by gizmos to get light shading
  49230. */
  49231. _getSharedGizmoLight(): HemisphericLight;
  49232. /**
  49233. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49234. */
  49235. pickUtilitySceneFirst: boolean;
  49236. /**
  49237. * 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)
  49238. */
  49239. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49240. /**
  49241. * 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)
  49242. */
  49243. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49244. /**
  49245. * The scene that is rendered on top of the original scene
  49246. */
  49247. utilityLayerScene: Scene;
  49248. /**
  49249. * If the utility layer should automatically be rendered on top of existing scene
  49250. */
  49251. shouldRender: boolean;
  49252. /**
  49253. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49254. */
  49255. onlyCheckPointerDownEvents: boolean;
  49256. /**
  49257. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49258. */
  49259. processAllEvents: boolean;
  49260. /**
  49261. * Observable raised when the pointer move from the utility layer scene to the main scene
  49262. */
  49263. onPointerOutObservable: Observable<number>;
  49264. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49265. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49266. private _afterRenderObserver;
  49267. private _sceneDisposeObserver;
  49268. private _originalPointerObserver;
  49269. /**
  49270. * Instantiates a UtilityLayerRenderer
  49271. * @param originalScene the original scene that will be rendered on top of
  49272. * @param handleEvents boolean indicating if the utility layer should handle events
  49273. */
  49274. constructor(
  49275. /** the original scene that will be rendered on top of */
  49276. originalScene: Scene, handleEvents?: boolean);
  49277. private _notifyObservers;
  49278. /**
  49279. * Renders the utility layers scene on top of the original scene
  49280. */
  49281. render(): void;
  49282. /**
  49283. * Disposes of the renderer
  49284. */
  49285. dispose(): void;
  49286. private _updateCamera;
  49287. }
  49288. }
  49289. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49290. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49292. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49293. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49294. import { Scene } from "babylonjs/scene";
  49295. import { Nullable } from "babylonjs/types";
  49296. import { Color3 } from "babylonjs/Maths/math.color";
  49297. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49298. /**
  49299. * Options interface for the pointer selection module
  49300. */
  49301. export interface IWebXRControllerPointerSelectionOptions {
  49302. /**
  49303. * if provided, this scene will be used to render meshes.
  49304. */
  49305. customUtilityLayerScene?: Scene;
  49306. /**
  49307. * 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)
  49308. * If not disabled, the last picked point will be used to execute a pointer up event
  49309. * If disabled, pointer up event will be triggered right after the pointer down event.
  49310. * Used in screen and gaze target ray mode only
  49311. */
  49312. disablePointerUpOnTouchOut: boolean;
  49313. /**
  49314. * For gaze mode (time to select instead of press)
  49315. */
  49316. forceGazeMode: boolean;
  49317. /**
  49318. * 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
  49319. * to start a new countdown to the pointer down event.
  49320. * Defaults to 1.
  49321. */
  49322. gazeModePointerMovedFactor?: number;
  49323. /**
  49324. * Different button type to use instead of the main component
  49325. */
  49326. overrideButtonId?: string;
  49327. /**
  49328. * use this rendering group id for the meshes (optional)
  49329. */
  49330. renderingGroupId?: number;
  49331. /**
  49332. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49333. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49334. * 3000 means 3 seconds between pointing at something and selecting it
  49335. */
  49336. timeToSelect?: number;
  49337. /**
  49338. * Should meshes created here be added to a utility layer or the main scene
  49339. */
  49340. useUtilityLayer?: boolean;
  49341. /**
  49342. * the xr input to use with this pointer selection
  49343. */
  49344. xrInput: WebXRInput;
  49345. }
  49346. /**
  49347. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49348. */
  49349. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49350. private readonly _options;
  49351. private static _idCounter;
  49352. private _attachController;
  49353. private _controllers;
  49354. private _scene;
  49355. private _tmpVectorForPickCompare;
  49356. /**
  49357. * The module's name
  49358. */
  49359. static readonly Name: string;
  49360. /**
  49361. * The (Babylon) version of this module.
  49362. * This is an integer representing the implementation version.
  49363. * This number does not correspond to the WebXR specs version
  49364. */
  49365. static readonly Version: number;
  49366. /**
  49367. * Disable lighting on the laser pointer (so it will always be visible)
  49368. */
  49369. disablePointerLighting: boolean;
  49370. /**
  49371. * Disable lighting on the selection mesh (so it will always be visible)
  49372. */
  49373. disableSelectionMeshLighting: boolean;
  49374. /**
  49375. * Should the laser pointer be displayed
  49376. */
  49377. displayLaserPointer: boolean;
  49378. /**
  49379. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49380. */
  49381. displaySelectionMesh: boolean;
  49382. /**
  49383. * This color will be set to the laser pointer when selection is triggered
  49384. */
  49385. laserPointerPickedColor: Color3;
  49386. /**
  49387. * Default color of the laser pointer
  49388. */
  49389. lasterPointerDefaultColor: Color3;
  49390. /**
  49391. * default color of the selection ring
  49392. */
  49393. selectionMeshDefaultColor: Color3;
  49394. /**
  49395. * This color will be applied to the selection ring when selection is triggered
  49396. */
  49397. selectionMeshPickedColor: Color3;
  49398. /**
  49399. * Optional filter to be used for ray selection. This predicate shares behavior with
  49400. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49401. */
  49402. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49403. /**
  49404. * constructs a new background remover module
  49405. * @param _xrSessionManager the session manager for this module
  49406. * @param _options read-only options to be used in this module
  49407. */
  49408. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49409. /**
  49410. * attach this feature
  49411. * Will usually be called by the features manager
  49412. *
  49413. * @returns true if successful.
  49414. */
  49415. attach(): boolean;
  49416. /**
  49417. * detach this feature.
  49418. * Will usually be called by the features manager
  49419. *
  49420. * @returns true if successful.
  49421. */
  49422. detach(): boolean;
  49423. /**
  49424. * Will get the mesh under a specific pointer.
  49425. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49426. * @param controllerId the controllerId to check
  49427. * @returns The mesh under pointer or null if no mesh is under the pointer
  49428. */
  49429. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49430. /**
  49431. * Get the xr controller that correlates to the pointer id in the pointer event
  49432. *
  49433. * @param id the pointer id to search for
  49434. * @returns the controller that correlates to this id or null if not found
  49435. */
  49436. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49437. protected _onXRFrame(_xrFrame: XRFrame): void;
  49438. private _attachGazeMode;
  49439. private _attachScreenRayMode;
  49440. private _attachTrackedPointerRayMode;
  49441. private _convertNormalToDirectionOfRay;
  49442. private _detachController;
  49443. private _generateNewMeshPair;
  49444. private _pickingMoved;
  49445. private _updatePointerDistance;
  49446. }
  49447. }
  49448. declare module "babylonjs/XR/webXREnterExitUI" {
  49449. import { Nullable } from "babylonjs/types";
  49450. import { Observable } from "babylonjs/Misc/observable";
  49451. import { IDisposable, Scene } from "babylonjs/scene";
  49452. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49453. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49454. /**
  49455. * Button which can be used to enter a different mode of XR
  49456. */
  49457. export class WebXREnterExitUIButton {
  49458. /** button element */
  49459. element: HTMLElement;
  49460. /** XR initialization options for the button */
  49461. sessionMode: XRSessionMode;
  49462. /** Reference space type */
  49463. referenceSpaceType: XRReferenceSpaceType;
  49464. /**
  49465. * Creates a WebXREnterExitUIButton
  49466. * @param element button element
  49467. * @param sessionMode XR initialization session mode
  49468. * @param referenceSpaceType the type of reference space to be used
  49469. */
  49470. constructor(
  49471. /** button element */
  49472. element: HTMLElement,
  49473. /** XR initialization options for the button */
  49474. sessionMode: XRSessionMode,
  49475. /** Reference space type */
  49476. referenceSpaceType: XRReferenceSpaceType);
  49477. /**
  49478. * Extendable function which can be used to update the button's visuals when the state changes
  49479. * @param activeButton the current active button in the UI
  49480. */
  49481. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49482. }
  49483. /**
  49484. * Options to create the webXR UI
  49485. */
  49486. export class WebXREnterExitUIOptions {
  49487. /**
  49488. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49489. */
  49490. customButtons?: Array<WebXREnterExitUIButton>;
  49491. /**
  49492. * A reference space type to use when creating the default button.
  49493. * Default is local-floor
  49494. */
  49495. referenceSpaceType?: XRReferenceSpaceType;
  49496. /**
  49497. * Context to enter xr with
  49498. */
  49499. renderTarget?: Nullable<WebXRRenderTarget>;
  49500. /**
  49501. * A session mode to use when creating the default button.
  49502. * Default is immersive-vr
  49503. */
  49504. sessionMode?: XRSessionMode;
  49505. /**
  49506. * A list of optional features to init the session with
  49507. */
  49508. optionalFeatures?: string[];
  49509. }
  49510. /**
  49511. * UI to allow the user to enter/exit XR mode
  49512. */
  49513. export class WebXREnterExitUI implements IDisposable {
  49514. private scene;
  49515. /** version of the options passed to this UI */
  49516. options: WebXREnterExitUIOptions;
  49517. private _activeButton;
  49518. private _buttons;
  49519. private _overlay;
  49520. /**
  49521. * Fired every time the active button is changed.
  49522. *
  49523. * When xr is entered via a button that launches xr that button will be the callback parameter
  49524. *
  49525. * When exiting xr the callback parameter will be null)
  49526. */
  49527. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49528. /**
  49529. *
  49530. * @param scene babylon scene object to use
  49531. * @param options (read-only) version of the options passed to this UI
  49532. */
  49533. private constructor();
  49534. /**
  49535. * Creates UI to allow the user to enter/exit XR mode
  49536. * @param scene the scene to add the ui to
  49537. * @param helper the xr experience helper to enter/exit xr with
  49538. * @param options options to configure the UI
  49539. * @returns the created ui
  49540. */
  49541. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49542. /**
  49543. * Disposes of the XR UI component
  49544. */
  49545. dispose(): void;
  49546. private _updateButtons;
  49547. }
  49548. }
  49549. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49550. import { Vector3 } from "babylonjs/Maths/math.vector";
  49551. import { Color4 } from "babylonjs/Maths/math.color";
  49552. import { Nullable } from "babylonjs/types";
  49553. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49554. import { Scene } from "babylonjs/scene";
  49555. /**
  49556. * Class containing static functions to help procedurally build meshes
  49557. */
  49558. export class LinesBuilder {
  49559. /**
  49560. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49561. * * 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
  49562. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49563. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49564. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49565. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49566. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49567. * * 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
  49568. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49570. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49571. * @param name defines the name of the new line system
  49572. * @param options defines the options used to create the line system
  49573. * @param scene defines the hosting scene
  49574. * @returns a new line system mesh
  49575. */
  49576. static CreateLineSystem(name: string, options: {
  49577. lines: Vector3[][];
  49578. updatable?: boolean;
  49579. instance?: Nullable<LinesMesh>;
  49580. colors?: Nullable<Color4[][]>;
  49581. useVertexAlpha?: boolean;
  49582. }, scene: Nullable<Scene>): LinesMesh;
  49583. /**
  49584. * Creates a line mesh
  49585. * 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
  49586. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49587. * * The parameter `points` is an array successive Vector3
  49588. * * 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
  49589. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49590. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49591. * * When updating an instance, remember that only point positions can change, not the number of points
  49592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49594. * @param name defines the name of the new line system
  49595. * @param options defines the options used to create the line system
  49596. * @param scene defines the hosting scene
  49597. * @returns a new line mesh
  49598. */
  49599. static CreateLines(name: string, options: {
  49600. points: Vector3[];
  49601. updatable?: boolean;
  49602. instance?: Nullable<LinesMesh>;
  49603. colors?: Color4[];
  49604. useVertexAlpha?: boolean;
  49605. }, scene?: Nullable<Scene>): LinesMesh;
  49606. /**
  49607. * Creates a dashed line mesh
  49608. * * 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
  49609. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49610. * * The parameter `points` is an array successive Vector3
  49611. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49612. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49613. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49614. * * 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
  49615. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49616. * * When updating an instance, remember that only point positions can change, not the number of points
  49617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49618. * @param name defines the name of the mesh
  49619. * @param options defines the options used to create the mesh
  49620. * @param scene defines the hosting scene
  49621. * @returns the dashed line mesh
  49622. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49623. */
  49624. static CreateDashedLines(name: string, options: {
  49625. points: Vector3[];
  49626. dashSize?: number;
  49627. gapSize?: number;
  49628. dashNb?: number;
  49629. updatable?: boolean;
  49630. instance?: LinesMesh;
  49631. useVertexAlpha?: boolean;
  49632. }, scene?: Nullable<Scene>): LinesMesh;
  49633. }
  49634. }
  49635. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  49636. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49637. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49638. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49640. import { Vector3 } from "babylonjs/Maths/math.vector";
  49641. import { Material } from "babylonjs/Materials/material";
  49642. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49643. import { Scene } from "babylonjs/scene";
  49644. /**
  49645. * The options container for the teleportation module
  49646. */
  49647. export interface IWebXRTeleportationOptions {
  49648. /**
  49649. * if provided, this scene will be used to render meshes.
  49650. */
  49651. customUtilityLayerScene?: Scene;
  49652. /**
  49653. * Values to configure the default target mesh
  49654. */
  49655. defaultTargetMeshOptions?: {
  49656. /**
  49657. * Fill color of the teleportation area
  49658. */
  49659. teleportationFillColor?: string;
  49660. /**
  49661. * Border color for the teleportation area
  49662. */
  49663. teleportationBorderColor?: string;
  49664. /**
  49665. * Disable the mesh's animation sequence
  49666. */
  49667. disableAnimation?: boolean;
  49668. /**
  49669. * Disable lighting on the material or the ring and arrow
  49670. */
  49671. disableLighting?: boolean;
  49672. /**
  49673. * Override the default material of the torus and arrow
  49674. */
  49675. torusArrowMaterial?: Material;
  49676. };
  49677. /**
  49678. * A list of meshes to use as floor meshes.
  49679. * Meshes can be added and removed after initializing the feature using the
  49680. * addFloorMesh and removeFloorMesh functions
  49681. * If empty, rotation will still work
  49682. */
  49683. floorMeshes?: AbstractMesh[];
  49684. /**
  49685. * use this rendering group id for the meshes (optional)
  49686. */
  49687. renderingGroupId?: number;
  49688. /**
  49689. * Should teleportation move only to snap points
  49690. */
  49691. snapPointsOnly?: boolean;
  49692. /**
  49693. * An array of points to which the teleportation will snap to.
  49694. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49695. */
  49696. snapPositions?: Vector3[];
  49697. /**
  49698. * How close should the teleportation ray be in order to snap to position.
  49699. * Default to 0.8 units (meters)
  49700. */
  49701. snapToPositionRadius?: number;
  49702. /**
  49703. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49704. * If you want to support rotation, make sure your mesh has a direction indicator.
  49705. *
  49706. * When left untouched, the default mesh will be initialized.
  49707. */
  49708. teleportationTargetMesh?: AbstractMesh;
  49709. /**
  49710. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49711. */
  49712. timeToTeleport?: number;
  49713. /**
  49714. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49715. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49716. */
  49717. useMainComponentOnly?: boolean;
  49718. /**
  49719. * Should meshes created here be added to a utility layer or the main scene
  49720. */
  49721. useUtilityLayer?: boolean;
  49722. /**
  49723. * Babylon XR Input class for controller
  49724. */
  49725. xrInput: WebXRInput;
  49726. }
  49727. /**
  49728. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49729. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49730. * the input of the attached controllers.
  49731. */
  49732. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49733. private _options;
  49734. private _controllers;
  49735. private _currentTeleportationControllerId;
  49736. private _floorMeshes;
  49737. private _quadraticBezierCurve;
  49738. private _selectionFeature;
  49739. private _snapToPositions;
  49740. private _snappedToPoint;
  49741. private _teleportationRingMaterial?;
  49742. private _tmpRay;
  49743. private _tmpVector;
  49744. /**
  49745. * The module's name
  49746. */
  49747. static readonly Name: string;
  49748. /**
  49749. * The (Babylon) version of this module.
  49750. * This is an integer representing the implementation version.
  49751. * This number does not correspond to the webxr specs version
  49752. */
  49753. static readonly Version: number;
  49754. /**
  49755. * Is movement backwards enabled
  49756. */
  49757. backwardsMovementEnabled: boolean;
  49758. /**
  49759. * Distance to travel when moving backwards
  49760. */
  49761. backwardsTeleportationDistance: number;
  49762. /**
  49763. * The distance from the user to the inspection point in the direction of the controller
  49764. * A higher number will allow the user to move further
  49765. * defaults to 5 (meters, in xr units)
  49766. */
  49767. parabolicCheckRadius: number;
  49768. /**
  49769. * Should the module support parabolic ray on top of direct ray
  49770. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49771. * Very helpful when moving between floors / different heights
  49772. */
  49773. parabolicRayEnabled: boolean;
  49774. /**
  49775. * How much rotation should be applied when rotating right and left
  49776. */
  49777. rotationAngle: number;
  49778. /**
  49779. * Is rotation enabled when moving forward?
  49780. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49781. */
  49782. rotationEnabled: boolean;
  49783. /**
  49784. * constructs a new anchor system
  49785. * @param _xrSessionManager an instance of WebXRSessionManager
  49786. * @param _options configuration object for this feature
  49787. */
  49788. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49789. /**
  49790. * Get the snapPointsOnly flag
  49791. */
  49792. get snapPointsOnly(): boolean;
  49793. /**
  49794. * Sets the snapPointsOnly flag
  49795. * @param snapToPoints should teleportation be exclusively to snap points
  49796. */
  49797. set snapPointsOnly(snapToPoints: boolean);
  49798. /**
  49799. * Add a new mesh to the floor meshes array
  49800. * @param mesh the mesh to use as floor mesh
  49801. */
  49802. addFloorMesh(mesh: AbstractMesh): void;
  49803. /**
  49804. * Add a new snap-to point to fix teleportation to this position
  49805. * @param newSnapPoint The new Snap-To point
  49806. */
  49807. addSnapPoint(newSnapPoint: Vector3): void;
  49808. attach(): boolean;
  49809. detach(): boolean;
  49810. dispose(): void;
  49811. /**
  49812. * Remove a mesh from the floor meshes array
  49813. * @param mesh the mesh to remove
  49814. */
  49815. removeFloorMesh(mesh: AbstractMesh): void;
  49816. /**
  49817. * Remove a mesh from the floor meshes array using its name
  49818. * @param name the mesh name to remove
  49819. */
  49820. removeFloorMeshByName(name: string): void;
  49821. /**
  49822. * 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
  49823. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49824. * @returns was the point found and removed or not
  49825. */
  49826. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49827. /**
  49828. * This function sets a selection feature that will be disabled when
  49829. * the forward ray is shown and will be reattached when hidden.
  49830. * This is used to remove the selection rays when moving.
  49831. * @param selectionFeature the feature to disable when forward movement is enabled
  49832. */
  49833. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49834. protected _onXRFrame(_xrFrame: XRFrame): void;
  49835. private _attachController;
  49836. private _createDefaultTargetMesh;
  49837. private _detachController;
  49838. private _findClosestSnapPointWithRadius;
  49839. private _setTargetMeshPosition;
  49840. private _setTargetMeshVisibility;
  49841. private _showParabolicPath;
  49842. private _teleportForward;
  49843. }
  49844. }
  49845. declare module "babylonjs/XR/webXRDefaultExperience" {
  49846. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49847. import { Scene } from "babylonjs/scene";
  49848. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  49849. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  49850. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49851. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  49852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49853. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  49854. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  49855. /**
  49856. * Options for the default xr helper
  49857. */
  49858. export class WebXRDefaultExperienceOptions {
  49859. /**
  49860. * Enable or disable default UI to enter XR
  49861. */
  49862. disableDefaultUI?: boolean;
  49863. /**
  49864. * Should teleportation not initialize. defaults to false.
  49865. */
  49866. disableTeleportation?: boolean;
  49867. /**
  49868. * Floor meshes that will be used for teleport
  49869. */
  49870. floorMeshes?: Array<AbstractMesh>;
  49871. /**
  49872. * If set to true, the first frame will not be used to reset position
  49873. * The first frame is mainly used when copying transformation from the old camera
  49874. * Mainly used in AR
  49875. */
  49876. ignoreNativeCameraTransformation?: boolean;
  49877. /**
  49878. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49879. */
  49880. inputOptions?: IWebXRInputOptions;
  49881. /**
  49882. * optional configuration for the output canvas
  49883. */
  49884. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49885. /**
  49886. * optional UI options. This can be used among other to change session mode and reference space type
  49887. */
  49888. uiOptions?: WebXREnterExitUIOptions;
  49889. /**
  49890. * When loading teleportation and pointer select, use stable versions instead of latest.
  49891. */
  49892. useStablePlugins?: boolean;
  49893. /**
  49894. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49895. */
  49896. renderingGroupId?: number;
  49897. /**
  49898. * A list of optional features to init the session with
  49899. * If set to true, all features we support will be added
  49900. */
  49901. optionalFeatures?: boolean | string[];
  49902. }
  49903. /**
  49904. * Default experience which provides a similar setup to the previous webVRExperience
  49905. */
  49906. export class WebXRDefaultExperience {
  49907. /**
  49908. * Base experience
  49909. */
  49910. baseExperience: WebXRExperienceHelper;
  49911. /**
  49912. * Enables ui for entering/exiting xr
  49913. */
  49914. enterExitUI: WebXREnterExitUI;
  49915. /**
  49916. * Input experience extension
  49917. */
  49918. input: WebXRInput;
  49919. /**
  49920. * Enables laser pointer and selection
  49921. */
  49922. pointerSelection: WebXRControllerPointerSelection;
  49923. /**
  49924. * Default target xr should render to
  49925. */
  49926. renderTarget: WebXRRenderTarget;
  49927. /**
  49928. * Enables teleportation
  49929. */
  49930. teleportation: WebXRMotionControllerTeleportation;
  49931. private constructor();
  49932. /**
  49933. * Creates the default xr experience
  49934. * @param scene scene
  49935. * @param options options for basic configuration
  49936. * @returns resulting WebXRDefaultExperience
  49937. */
  49938. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49939. /**
  49940. * DIsposes of the experience helper
  49941. */
  49942. dispose(): void;
  49943. }
  49944. }
  49945. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  49946. import { Observable } from "babylonjs/Misc/observable";
  49947. import { Nullable } from "babylonjs/types";
  49948. import { Camera } from "babylonjs/Cameras/camera";
  49949. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  49950. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  49951. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  49952. import { Scene } from "babylonjs/scene";
  49953. import { Vector3 } from "babylonjs/Maths/math.vector";
  49954. import { Color3 } from "babylonjs/Maths/math.color";
  49955. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49957. import { Mesh } from "babylonjs/Meshes/mesh";
  49958. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  49959. import { EasingFunction } from "babylonjs/Animations/easing";
  49960. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  49961. import "babylonjs/Meshes/Builders/groundBuilder";
  49962. import "babylonjs/Meshes/Builders/torusBuilder";
  49963. import "babylonjs/Meshes/Builders/cylinderBuilder";
  49964. import "babylonjs/Gamepads/gamepadSceneComponent";
  49965. import "babylonjs/Animations/animatable";
  49966. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  49967. /**
  49968. * Options to modify the vr teleportation behavior.
  49969. */
  49970. export interface VRTeleportationOptions {
  49971. /**
  49972. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49973. */
  49974. floorMeshName?: string;
  49975. /**
  49976. * A list of meshes to be used as the teleportation floor. (default: empty)
  49977. */
  49978. floorMeshes?: Mesh[];
  49979. /**
  49980. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49981. */
  49982. teleportationMode?: number;
  49983. /**
  49984. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49985. */
  49986. teleportationTime?: number;
  49987. /**
  49988. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49989. */
  49990. teleportationSpeed?: number;
  49991. /**
  49992. * The easing function used in the animation or null for Linear. (default CircleEase)
  49993. */
  49994. easingFunction?: EasingFunction;
  49995. }
  49996. /**
  49997. * Options to modify the vr experience helper's behavior.
  49998. */
  49999. export interface VRExperienceHelperOptions extends WebVROptions {
  50000. /**
  50001. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50002. */
  50003. createDeviceOrientationCamera?: boolean;
  50004. /**
  50005. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50006. */
  50007. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50008. /**
  50009. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50010. */
  50011. laserToggle?: boolean;
  50012. /**
  50013. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50014. */
  50015. floorMeshes?: Mesh[];
  50016. /**
  50017. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50018. */
  50019. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50020. /**
  50021. * Defines if WebXR should be used instead of WebVR (if available)
  50022. */
  50023. useXR?: boolean;
  50024. }
  50025. /**
  50026. * Event containing information after VR has been entered
  50027. */
  50028. export class OnAfterEnteringVRObservableEvent {
  50029. /**
  50030. * If entering vr was successful
  50031. */
  50032. success: boolean;
  50033. }
  50034. /**
  50035. * Helps to quickly add VR support to an existing scene.
  50036. * See http://doc.babylonjs.com/how_to/webvr_helper
  50037. */
  50038. export class VRExperienceHelper {
  50039. /** Options to modify the vr experience helper's behavior. */
  50040. webVROptions: VRExperienceHelperOptions;
  50041. private _scene;
  50042. private _position;
  50043. private _btnVR;
  50044. private _btnVRDisplayed;
  50045. private _webVRsupported;
  50046. private _webVRready;
  50047. private _webVRrequesting;
  50048. private _webVRpresenting;
  50049. private _hasEnteredVR;
  50050. private _fullscreenVRpresenting;
  50051. private _inputElement;
  50052. private _webVRCamera;
  50053. private _vrDeviceOrientationCamera;
  50054. private _deviceOrientationCamera;
  50055. private _existingCamera;
  50056. private _onKeyDown;
  50057. private _onVrDisplayPresentChange;
  50058. private _onVRDisplayChanged;
  50059. private _onVRRequestPresentStart;
  50060. private _onVRRequestPresentComplete;
  50061. /**
  50062. * 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)
  50063. */
  50064. enableGazeEvenWhenNoPointerLock: boolean;
  50065. /**
  50066. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50067. */
  50068. exitVROnDoubleTap: boolean;
  50069. /**
  50070. * Observable raised right before entering VR.
  50071. */
  50072. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50073. /**
  50074. * Observable raised when entering VR has completed.
  50075. */
  50076. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50077. /**
  50078. * Observable raised when exiting VR.
  50079. */
  50080. onExitingVRObservable: Observable<VRExperienceHelper>;
  50081. /**
  50082. * Observable raised when controller mesh is loaded.
  50083. */
  50084. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50085. /** Return this.onEnteringVRObservable
  50086. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50087. */
  50088. get onEnteringVR(): Observable<VRExperienceHelper>;
  50089. /** Return this.onExitingVRObservable
  50090. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50091. */
  50092. get onExitingVR(): Observable<VRExperienceHelper>;
  50093. /** Return this.onControllerMeshLoadedObservable
  50094. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50095. */
  50096. get onControllerMeshLoaded(): Observable<WebVRController>;
  50097. private _rayLength;
  50098. private _useCustomVRButton;
  50099. private _teleportationRequested;
  50100. private _teleportActive;
  50101. private _floorMeshName;
  50102. private _floorMeshesCollection;
  50103. private _teleportationMode;
  50104. private _teleportationTime;
  50105. private _teleportationSpeed;
  50106. private _teleportationEasing;
  50107. private _rotationAllowed;
  50108. private _teleportBackwardsVector;
  50109. private _teleportationTarget;
  50110. private _isDefaultTeleportationTarget;
  50111. private _postProcessMove;
  50112. private _teleportationFillColor;
  50113. private _teleportationBorderColor;
  50114. private _rotationAngle;
  50115. private _haloCenter;
  50116. private _cameraGazer;
  50117. private _padSensibilityUp;
  50118. private _padSensibilityDown;
  50119. private _leftController;
  50120. private _rightController;
  50121. private _gazeColor;
  50122. private _laserColor;
  50123. private _pickedLaserColor;
  50124. private _pickedGazeColor;
  50125. /**
  50126. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50127. */
  50128. onNewMeshSelected: Observable<AbstractMesh>;
  50129. /**
  50130. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50131. * This observable will provide the mesh and the controller used to select the mesh
  50132. */
  50133. onMeshSelectedWithController: Observable<{
  50134. mesh: AbstractMesh;
  50135. controller: WebVRController;
  50136. }>;
  50137. /**
  50138. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50139. */
  50140. onNewMeshPicked: Observable<PickingInfo>;
  50141. private _circleEase;
  50142. /**
  50143. * Observable raised before camera teleportation
  50144. */
  50145. onBeforeCameraTeleport: Observable<Vector3>;
  50146. /**
  50147. * Observable raised after camera teleportation
  50148. */
  50149. onAfterCameraTeleport: Observable<Vector3>;
  50150. /**
  50151. * Observable raised when current selected mesh gets unselected
  50152. */
  50153. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50154. private _raySelectionPredicate;
  50155. /**
  50156. * To be optionaly changed by user to define custom ray selection
  50157. */
  50158. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50159. /**
  50160. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50161. */
  50162. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50163. /**
  50164. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50165. */
  50166. teleportationEnabled: boolean;
  50167. private _defaultHeight;
  50168. private _teleportationInitialized;
  50169. private _interactionsEnabled;
  50170. private _interactionsRequested;
  50171. private _displayGaze;
  50172. private _displayLaserPointer;
  50173. /**
  50174. * The mesh used to display where the user is going to teleport.
  50175. */
  50176. get teleportationTarget(): Mesh;
  50177. /**
  50178. * Sets the mesh to be used to display where the user is going to teleport.
  50179. */
  50180. set teleportationTarget(value: Mesh);
  50181. /**
  50182. * 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
  50183. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50184. * See http://doc.babylonjs.com/resources/baking_transformations
  50185. */
  50186. get gazeTrackerMesh(): Mesh;
  50187. set gazeTrackerMesh(value: Mesh);
  50188. /**
  50189. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50190. */
  50191. updateGazeTrackerScale: boolean;
  50192. /**
  50193. * If the gaze trackers color should be updated when selecting meshes
  50194. */
  50195. updateGazeTrackerColor: boolean;
  50196. /**
  50197. * If the controller laser color should be updated when selecting meshes
  50198. */
  50199. updateControllerLaserColor: boolean;
  50200. /**
  50201. * The gaze tracking mesh corresponding to the left controller
  50202. */
  50203. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50204. /**
  50205. * The gaze tracking mesh corresponding to the right controller
  50206. */
  50207. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50208. /**
  50209. * If the ray of the gaze should be displayed.
  50210. */
  50211. get displayGaze(): boolean;
  50212. /**
  50213. * Sets if the ray of the gaze should be displayed.
  50214. */
  50215. set displayGaze(value: boolean);
  50216. /**
  50217. * If the ray of the LaserPointer should be displayed.
  50218. */
  50219. get displayLaserPointer(): boolean;
  50220. /**
  50221. * Sets if the ray of the LaserPointer should be displayed.
  50222. */
  50223. set displayLaserPointer(value: boolean);
  50224. /**
  50225. * The deviceOrientationCamera used as the camera when not in VR.
  50226. */
  50227. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50228. /**
  50229. * Based on the current WebVR support, returns the current VR camera used.
  50230. */
  50231. get currentVRCamera(): Nullable<Camera>;
  50232. /**
  50233. * The webVRCamera which is used when in VR.
  50234. */
  50235. get webVRCamera(): WebVRFreeCamera;
  50236. /**
  50237. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50238. */
  50239. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50240. /**
  50241. * The html button that is used to trigger entering into VR.
  50242. */
  50243. get vrButton(): Nullable<HTMLButtonElement>;
  50244. private get _teleportationRequestInitiated();
  50245. /**
  50246. * Defines whether or not Pointer lock should be requested when switching to
  50247. * full screen.
  50248. */
  50249. requestPointerLockOnFullScreen: boolean;
  50250. /**
  50251. * If asking to force XR, this will be populated with the default xr experience
  50252. */
  50253. xr: WebXRDefaultExperience;
  50254. /**
  50255. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50256. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50257. */
  50258. xrTestDone: boolean;
  50259. /**
  50260. * Instantiates a VRExperienceHelper.
  50261. * Helps to quickly add VR support to an existing scene.
  50262. * @param scene The scene the VRExperienceHelper belongs to.
  50263. * @param webVROptions Options to modify the vr experience helper's behavior.
  50264. */
  50265. constructor(scene: Scene,
  50266. /** Options to modify the vr experience helper's behavior. */
  50267. webVROptions?: VRExperienceHelperOptions);
  50268. private completeVRInit;
  50269. private _onDefaultMeshLoaded;
  50270. private _onResize;
  50271. private _onFullscreenChange;
  50272. /**
  50273. * Gets a value indicating if we are currently in VR mode.
  50274. */
  50275. get isInVRMode(): boolean;
  50276. private onVrDisplayPresentChange;
  50277. private onVRDisplayChanged;
  50278. private moveButtonToBottomRight;
  50279. private displayVRButton;
  50280. private updateButtonVisibility;
  50281. private _cachedAngularSensibility;
  50282. /**
  50283. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50284. * Otherwise, will use the fullscreen API.
  50285. */
  50286. enterVR(): void;
  50287. /**
  50288. * Attempt to exit VR, or fullscreen.
  50289. */
  50290. exitVR(): void;
  50291. /**
  50292. * The position of the vr experience helper.
  50293. */
  50294. get position(): Vector3;
  50295. /**
  50296. * Sets the position of the vr experience helper.
  50297. */
  50298. set position(value: Vector3);
  50299. /**
  50300. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50301. */
  50302. enableInteractions(): void;
  50303. private get _noControllerIsActive();
  50304. private beforeRender;
  50305. private _isTeleportationFloor;
  50306. /**
  50307. * Adds a floor mesh to be used for teleportation.
  50308. * @param floorMesh the mesh to be used for teleportation.
  50309. */
  50310. addFloorMesh(floorMesh: Mesh): void;
  50311. /**
  50312. * Removes a floor mesh from being used for teleportation.
  50313. * @param floorMesh the mesh to be removed.
  50314. */
  50315. removeFloorMesh(floorMesh: Mesh): void;
  50316. /**
  50317. * Enables interactions and teleportation using the VR controllers and gaze.
  50318. * @param vrTeleportationOptions options to modify teleportation behavior.
  50319. */
  50320. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50321. private _onNewGamepadConnected;
  50322. private _tryEnableInteractionOnController;
  50323. private _onNewGamepadDisconnected;
  50324. private _enableInteractionOnController;
  50325. private _checkTeleportWithRay;
  50326. private _checkRotate;
  50327. private _checkTeleportBackwards;
  50328. private _enableTeleportationOnController;
  50329. private _createTeleportationCircles;
  50330. private _displayTeleportationTarget;
  50331. private _hideTeleportationTarget;
  50332. private _rotateCamera;
  50333. private _moveTeleportationSelectorTo;
  50334. private _workingVector;
  50335. private _workingQuaternion;
  50336. private _workingMatrix;
  50337. /**
  50338. * Time Constant Teleportation Mode
  50339. */
  50340. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50341. /**
  50342. * Speed Constant Teleportation Mode
  50343. */
  50344. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50345. /**
  50346. * Teleports the users feet to the desired location
  50347. * @param location The location where the user's feet should be placed
  50348. */
  50349. teleportCamera(location: Vector3): void;
  50350. private _convertNormalToDirectionOfRay;
  50351. private _castRayAndSelectObject;
  50352. private _notifySelectedMeshUnselected;
  50353. /**
  50354. * Permanently set new colors for the laser pointer
  50355. * @param color the new laser color
  50356. * @param pickedColor the new laser color when picked mesh detected
  50357. */
  50358. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50359. /**
  50360. * Set lighting enabled / disabled on the laser pointer of both controllers
  50361. * @param enabled should the lighting be enabled on the laser pointer
  50362. */
  50363. setLaserLightingState(enabled?: boolean): void;
  50364. /**
  50365. * Permanently set new colors for the gaze pointer
  50366. * @param color the new gaze color
  50367. * @param pickedColor the new gaze color when picked mesh detected
  50368. */
  50369. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50370. /**
  50371. * Sets the color of the laser ray from the vr controllers.
  50372. * @param color new color for the ray.
  50373. */
  50374. changeLaserColor(color: Color3): void;
  50375. /**
  50376. * Sets the color of the ray from the vr headsets gaze.
  50377. * @param color new color for the ray.
  50378. */
  50379. changeGazeColor(color: Color3): void;
  50380. /**
  50381. * Exits VR and disposes of the vr experience helper
  50382. */
  50383. dispose(): void;
  50384. /**
  50385. * Gets the name of the VRExperienceHelper class
  50386. * @returns "VRExperienceHelper"
  50387. */
  50388. getClassName(): string;
  50389. }
  50390. }
  50391. declare module "babylonjs/Cameras/VR/index" {
  50392. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50393. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50394. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50395. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50396. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50397. export * from "babylonjs/Cameras/VR/webVRCamera";
  50398. }
  50399. declare module "babylonjs/Cameras/RigModes/index" {
  50400. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50401. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50402. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50403. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50404. }
  50405. declare module "babylonjs/Cameras/index" {
  50406. export * from "babylonjs/Cameras/Inputs/index";
  50407. export * from "babylonjs/Cameras/cameraInputsManager";
  50408. export * from "babylonjs/Cameras/camera";
  50409. export * from "babylonjs/Cameras/targetCamera";
  50410. export * from "babylonjs/Cameras/freeCamera";
  50411. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50412. export * from "babylonjs/Cameras/touchCamera";
  50413. export * from "babylonjs/Cameras/arcRotateCamera";
  50414. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50415. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50416. export * from "babylonjs/Cameras/flyCamera";
  50417. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50418. export * from "babylonjs/Cameras/followCamera";
  50419. export * from "babylonjs/Cameras/followCameraInputsManager";
  50420. export * from "babylonjs/Cameras/gamepadCamera";
  50421. export * from "babylonjs/Cameras/Stereoscopic/index";
  50422. export * from "babylonjs/Cameras/universalCamera";
  50423. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50424. export * from "babylonjs/Cameras/VR/index";
  50425. export * from "babylonjs/Cameras/RigModes/index";
  50426. }
  50427. declare module "babylonjs/Collisions/index" {
  50428. export * from "babylonjs/Collisions/collider";
  50429. export * from "babylonjs/Collisions/collisionCoordinator";
  50430. export * from "babylonjs/Collisions/pickingInfo";
  50431. export * from "babylonjs/Collisions/intersectionInfo";
  50432. export * from "babylonjs/Collisions/meshCollisionData";
  50433. }
  50434. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50435. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50436. import { Vector3 } from "babylonjs/Maths/math.vector";
  50437. import { Ray } from "babylonjs/Culling/ray";
  50438. import { Plane } from "babylonjs/Maths/math.plane";
  50439. /**
  50440. * Contains an array of blocks representing the octree
  50441. */
  50442. export interface IOctreeContainer<T> {
  50443. /**
  50444. * Blocks within the octree
  50445. */
  50446. blocks: Array<OctreeBlock<T>>;
  50447. }
  50448. /**
  50449. * Class used to store a cell in an octree
  50450. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50451. */
  50452. export class OctreeBlock<T> {
  50453. /**
  50454. * Gets the content of the current block
  50455. */
  50456. entries: T[];
  50457. /**
  50458. * Gets the list of block children
  50459. */
  50460. blocks: Array<OctreeBlock<T>>;
  50461. private _depth;
  50462. private _maxDepth;
  50463. private _capacity;
  50464. private _minPoint;
  50465. private _maxPoint;
  50466. private _boundingVectors;
  50467. private _creationFunc;
  50468. /**
  50469. * Creates a new block
  50470. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50471. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50472. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50473. * @param depth defines the current depth of this block in the octree
  50474. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50475. * @param creationFunc defines a callback to call when an element is added to the block
  50476. */
  50477. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50478. /**
  50479. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50480. */
  50481. get capacity(): number;
  50482. /**
  50483. * Gets the minimum vector (in world space) of the block's bounding box
  50484. */
  50485. get minPoint(): Vector3;
  50486. /**
  50487. * Gets the maximum vector (in world space) of the block's bounding box
  50488. */
  50489. get maxPoint(): Vector3;
  50490. /**
  50491. * Add a new element to this block
  50492. * @param entry defines the element to add
  50493. */
  50494. addEntry(entry: T): void;
  50495. /**
  50496. * Remove an element from this block
  50497. * @param entry defines the element to remove
  50498. */
  50499. removeEntry(entry: T): void;
  50500. /**
  50501. * Add an array of elements to this block
  50502. * @param entries defines the array of elements to add
  50503. */
  50504. addEntries(entries: T[]): void;
  50505. /**
  50506. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50507. * @param frustumPlanes defines the frustum planes to test
  50508. * @param selection defines the array to store current content if selection is positive
  50509. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50510. */
  50511. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50512. /**
  50513. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50514. * @param sphereCenter defines the bounding sphere center
  50515. * @param sphereRadius defines the bounding sphere radius
  50516. * @param selection defines the array to store current content if selection is positive
  50517. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50518. */
  50519. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50520. /**
  50521. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50522. * @param ray defines the ray to test with
  50523. * @param selection defines the array to store current content if selection is positive
  50524. */
  50525. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50526. /**
  50527. * Subdivide the content into child blocks (this block will then be empty)
  50528. */
  50529. createInnerBlocks(): void;
  50530. /**
  50531. * @hidden
  50532. */
  50533. 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;
  50534. }
  50535. }
  50536. declare module "babylonjs/Culling/Octrees/octree" {
  50537. import { SmartArray } from "babylonjs/Misc/smartArray";
  50538. import { Vector3 } from "babylonjs/Maths/math.vector";
  50539. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50541. import { Ray } from "babylonjs/Culling/ray";
  50542. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  50543. import { Plane } from "babylonjs/Maths/math.plane";
  50544. /**
  50545. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50546. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50547. */
  50548. export class Octree<T> {
  50549. /** 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.) */
  50550. maxDepth: number;
  50551. /**
  50552. * Blocks within the octree containing objects
  50553. */
  50554. blocks: Array<OctreeBlock<T>>;
  50555. /**
  50556. * Content stored in the octree
  50557. */
  50558. dynamicContent: T[];
  50559. private _maxBlockCapacity;
  50560. private _selectionContent;
  50561. private _creationFunc;
  50562. /**
  50563. * Creates a octree
  50564. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50565. * @param creationFunc function to be used to instatiate the octree
  50566. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50567. * @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.)
  50568. */
  50569. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50570. /** 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.) */
  50571. maxDepth?: number);
  50572. /**
  50573. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50574. * @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);
  50575. * @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);
  50576. * @param entries meshes to be added to the octree blocks
  50577. */
  50578. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50579. /**
  50580. * Adds a mesh to the octree
  50581. * @param entry Mesh to add to the octree
  50582. */
  50583. addMesh(entry: T): void;
  50584. /**
  50585. * Remove an element from the octree
  50586. * @param entry defines the element to remove
  50587. */
  50588. removeMesh(entry: T): void;
  50589. /**
  50590. * Selects an array of meshes within the frustum
  50591. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50592. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50593. * @returns array of meshes within the frustum
  50594. */
  50595. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50596. /**
  50597. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50598. * @param sphereCenter defines the bounding sphere center
  50599. * @param sphereRadius defines the bounding sphere radius
  50600. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50601. * @returns an array of objects that intersect the sphere
  50602. */
  50603. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50604. /**
  50605. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50606. * @param ray defines the ray to test with
  50607. * @returns array of intersected objects
  50608. */
  50609. intersectsRay(ray: Ray): SmartArray<T>;
  50610. /**
  50611. * Adds a mesh into the octree block if it intersects the block
  50612. */
  50613. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50614. /**
  50615. * Adds a submesh into the octree block if it intersects the block
  50616. */
  50617. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50618. }
  50619. }
  50620. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  50621. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  50622. import { Scene } from "babylonjs/scene";
  50623. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50625. import { Ray } from "babylonjs/Culling/ray";
  50626. import { Octree } from "babylonjs/Culling/Octrees/octree";
  50627. import { Collider } from "babylonjs/Collisions/collider";
  50628. module "babylonjs/scene" {
  50629. interface Scene {
  50630. /**
  50631. * @hidden
  50632. * Backing Filed
  50633. */
  50634. _selectionOctree: Octree<AbstractMesh>;
  50635. /**
  50636. * Gets the octree used to boost mesh selection (picking)
  50637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50638. */
  50639. selectionOctree: Octree<AbstractMesh>;
  50640. /**
  50641. * Creates or updates the octree used to boost selection (picking)
  50642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50643. * @param maxCapacity defines the maximum capacity per leaf
  50644. * @param maxDepth defines the maximum depth of the octree
  50645. * @returns an octree of AbstractMesh
  50646. */
  50647. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50648. }
  50649. }
  50650. module "babylonjs/Meshes/abstractMesh" {
  50651. interface AbstractMesh {
  50652. /**
  50653. * @hidden
  50654. * Backing Field
  50655. */
  50656. _submeshesOctree: Octree<SubMesh>;
  50657. /**
  50658. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50659. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50660. * @param maxCapacity defines the maximum size of each block (64 by default)
  50661. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50662. * @returns the new octree
  50663. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50665. */
  50666. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50667. }
  50668. }
  50669. /**
  50670. * Defines the octree scene component responsible to manage any octrees
  50671. * in a given scene.
  50672. */
  50673. export class OctreeSceneComponent {
  50674. /**
  50675. * The component name help to identify the component in the list of scene components.
  50676. */
  50677. readonly name: string;
  50678. /**
  50679. * The scene the component belongs to.
  50680. */
  50681. scene: Scene;
  50682. /**
  50683. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50684. */
  50685. readonly checksIsEnabled: boolean;
  50686. /**
  50687. * Creates a new instance of the component for the given scene
  50688. * @param scene Defines the scene to register the component in
  50689. */
  50690. constructor(scene: Scene);
  50691. /**
  50692. * Registers the component in a given scene
  50693. */
  50694. register(): void;
  50695. /**
  50696. * Return the list of active meshes
  50697. * @returns the list of active meshes
  50698. */
  50699. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50700. /**
  50701. * Return the list of active sub meshes
  50702. * @param mesh The mesh to get the candidates sub meshes from
  50703. * @returns the list of active sub meshes
  50704. */
  50705. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50706. private _tempRay;
  50707. /**
  50708. * Return the list of sub meshes intersecting with a given local ray
  50709. * @param mesh defines the mesh to find the submesh for
  50710. * @param localRay defines the ray in local space
  50711. * @returns the list of intersecting sub meshes
  50712. */
  50713. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50714. /**
  50715. * Return the list of sub meshes colliding with a collider
  50716. * @param mesh defines the mesh to find the submesh for
  50717. * @param collider defines the collider to evaluate the collision against
  50718. * @returns the list of colliding sub meshes
  50719. */
  50720. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50721. /**
  50722. * Rebuilds the elements related to this component in case of
  50723. * context lost for instance.
  50724. */
  50725. rebuild(): void;
  50726. /**
  50727. * Disposes the component and the associated ressources.
  50728. */
  50729. dispose(): void;
  50730. }
  50731. }
  50732. declare module "babylonjs/Culling/Octrees/index" {
  50733. export * from "babylonjs/Culling/Octrees/octree";
  50734. export * from "babylonjs/Culling/Octrees/octreeBlock";
  50735. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  50736. }
  50737. declare module "babylonjs/Culling/index" {
  50738. export * from "babylonjs/Culling/boundingBox";
  50739. export * from "babylonjs/Culling/boundingInfo";
  50740. export * from "babylonjs/Culling/boundingSphere";
  50741. export * from "babylonjs/Culling/Octrees/index";
  50742. export * from "babylonjs/Culling/ray";
  50743. }
  50744. declare module "babylonjs/Gizmos/gizmo" {
  50745. import { Nullable } from "babylonjs/types";
  50746. import { IDisposable } from "babylonjs/scene";
  50747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50748. import { Mesh } from "babylonjs/Meshes/mesh";
  50749. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50750. /**
  50751. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50752. */
  50753. export class Gizmo implements IDisposable {
  50754. /** The utility layer the gizmo will be added to */
  50755. gizmoLayer: UtilityLayerRenderer;
  50756. /**
  50757. * The root mesh of the gizmo
  50758. */
  50759. _rootMesh: Mesh;
  50760. private _attachedMesh;
  50761. /**
  50762. * Ratio for the scale of the gizmo (Default: 1)
  50763. */
  50764. scaleRatio: number;
  50765. /**
  50766. * If a custom mesh has been set (Default: false)
  50767. */
  50768. protected _customMeshSet: boolean;
  50769. /**
  50770. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50771. * * When set, interactions will be enabled
  50772. */
  50773. get attachedMesh(): Nullable<AbstractMesh>;
  50774. set attachedMesh(value: Nullable<AbstractMesh>);
  50775. /**
  50776. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50777. * @param mesh The mesh to replace the default mesh of the gizmo
  50778. */
  50779. setCustomMesh(mesh: Mesh): void;
  50780. /**
  50781. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50782. */
  50783. updateGizmoRotationToMatchAttachedMesh: boolean;
  50784. /**
  50785. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50786. */
  50787. updateGizmoPositionToMatchAttachedMesh: boolean;
  50788. /**
  50789. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50790. */
  50791. updateScale: boolean;
  50792. protected _interactionsEnabled: boolean;
  50793. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50794. private _beforeRenderObserver;
  50795. private _tempVector;
  50796. /**
  50797. * Creates a gizmo
  50798. * @param gizmoLayer The utility layer the gizmo will be added to
  50799. */
  50800. constructor(
  50801. /** The utility layer the gizmo will be added to */
  50802. gizmoLayer?: UtilityLayerRenderer);
  50803. /**
  50804. * Updates the gizmo to match the attached mesh's position/rotation
  50805. */
  50806. protected _update(): void;
  50807. /**
  50808. * Disposes of the gizmo
  50809. */
  50810. dispose(): void;
  50811. }
  50812. }
  50813. declare module "babylonjs/Gizmos/planeDragGizmo" {
  50814. import { Observable } from "babylonjs/Misc/observable";
  50815. import { Nullable } from "babylonjs/types";
  50816. import { Vector3 } from "babylonjs/Maths/math.vector";
  50817. import { Color3 } from "babylonjs/Maths/math.color";
  50818. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50820. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50821. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50822. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50823. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50824. import { Scene } from "babylonjs/scene";
  50825. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50826. /**
  50827. * Single plane drag gizmo
  50828. */
  50829. export class PlaneDragGizmo extends Gizmo {
  50830. /**
  50831. * Drag behavior responsible for the gizmos dragging interactions
  50832. */
  50833. dragBehavior: PointerDragBehavior;
  50834. private _pointerObserver;
  50835. /**
  50836. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50837. */
  50838. snapDistance: number;
  50839. /**
  50840. * Event that fires each time the gizmo snaps to a new location.
  50841. * * snapDistance is the the change in distance
  50842. */
  50843. onSnapObservable: Observable<{
  50844. snapDistance: number;
  50845. }>;
  50846. private _plane;
  50847. private _coloredMaterial;
  50848. private _hoverMaterial;
  50849. private _isEnabled;
  50850. private _parent;
  50851. /** @hidden */
  50852. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50853. /** @hidden */
  50854. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50855. /**
  50856. * Creates a PlaneDragGizmo
  50857. * @param gizmoLayer The utility layer the gizmo will be added to
  50858. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50859. * @param color The color of the gizmo
  50860. */
  50861. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50862. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50863. /**
  50864. * If the gizmo is enabled
  50865. */
  50866. set isEnabled(value: boolean);
  50867. get isEnabled(): boolean;
  50868. /**
  50869. * Disposes of the gizmo
  50870. */
  50871. dispose(): void;
  50872. }
  50873. }
  50874. declare module "babylonjs/Gizmos/positionGizmo" {
  50875. import { Observable } from "babylonjs/Misc/observable";
  50876. import { Nullable } from "babylonjs/types";
  50877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50878. import { Mesh } from "babylonjs/Meshes/mesh";
  50879. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50880. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  50881. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  50882. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50883. /**
  50884. * Gizmo that enables dragging a mesh along 3 axis
  50885. */
  50886. export class PositionGizmo extends Gizmo {
  50887. /**
  50888. * Internal gizmo used for interactions on the x axis
  50889. */
  50890. xGizmo: AxisDragGizmo;
  50891. /**
  50892. * Internal gizmo used for interactions on the y axis
  50893. */
  50894. yGizmo: AxisDragGizmo;
  50895. /**
  50896. * Internal gizmo used for interactions on the z axis
  50897. */
  50898. zGizmo: AxisDragGizmo;
  50899. /**
  50900. * Internal gizmo used for interactions on the yz plane
  50901. */
  50902. xPlaneGizmo: PlaneDragGizmo;
  50903. /**
  50904. * Internal gizmo used for interactions on the xz plane
  50905. */
  50906. yPlaneGizmo: PlaneDragGizmo;
  50907. /**
  50908. * Internal gizmo used for interactions on the xy plane
  50909. */
  50910. zPlaneGizmo: PlaneDragGizmo;
  50911. /**
  50912. * private variables
  50913. */
  50914. private _meshAttached;
  50915. private _updateGizmoRotationToMatchAttachedMesh;
  50916. private _snapDistance;
  50917. private _scaleRatio;
  50918. /** Fires an event when any of it's sub gizmos are dragged */
  50919. onDragStartObservable: Observable<unknown>;
  50920. /** Fires an event when any of it's sub gizmos are released from dragging */
  50921. onDragEndObservable: Observable<unknown>;
  50922. /**
  50923. * If set to true, planar drag is enabled
  50924. */
  50925. private _planarGizmoEnabled;
  50926. get attachedMesh(): Nullable<AbstractMesh>;
  50927. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50928. /**
  50929. * Creates a PositionGizmo
  50930. * @param gizmoLayer The utility layer the gizmo will be added to
  50931. */
  50932. constructor(gizmoLayer?: UtilityLayerRenderer);
  50933. /**
  50934. * If the planar drag gizmo is enabled
  50935. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50936. */
  50937. set planarGizmoEnabled(value: boolean);
  50938. get planarGizmoEnabled(): boolean;
  50939. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50940. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50941. /**
  50942. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50943. */
  50944. set snapDistance(value: number);
  50945. get snapDistance(): number;
  50946. /**
  50947. * Ratio for the scale of the gizmo (Default: 1)
  50948. */
  50949. set scaleRatio(value: number);
  50950. get scaleRatio(): number;
  50951. /**
  50952. * Disposes of the gizmo
  50953. */
  50954. dispose(): void;
  50955. /**
  50956. * CustomMeshes are not supported by this gizmo
  50957. * @param mesh The mesh to replace the default mesh of the gizmo
  50958. */
  50959. setCustomMesh(mesh: Mesh): void;
  50960. }
  50961. }
  50962. declare module "babylonjs/Gizmos/axisDragGizmo" {
  50963. import { Observable } from "babylonjs/Misc/observable";
  50964. import { Nullable } from "babylonjs/types";
  50965. import { Vector3 } from "babylonjs/Maths/math.vector";
  50966. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50968. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50969. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50970. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50971. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50972. import { Scene } from "babylonjs/scene";
  50973. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50974. import { Color3 } from "babylonjs/Maths/math.color";
  50975. /**
  50976. * Single axis drag gizmo
  50977. */
  50978. export class AxisDragGizmo extends Gizmo {
  50979. /**
  50980. * Drag behavior responsible for the gizmos dragging interactions
  50981. */
  50982. dragBehavior: PointerDragBehavior;
  50983. private _pointerObserver;
  50984. /**
  50985. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50986. */
  50987. snapDistance: number;
  50988. /**
  50989. * Event that fires each time the gizmo snaps to a new location.
  50990. * * snapDistance is the the change in distance
  50991. */
  50992. onSnapObservable: Observable<{
  50993. snapDistance: number;
  50994. }>;
  50995. private _isEnabled;
  50996. private _parent;
  50997. private _arrow;
  50998. private _coloredMaterial;
  50999. private _hoverMaterial;
  51000. /** @hidden */
  51001. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51002. /** @hidden */
  51003. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51004. /**
  51005. * Creates an AxisDragGizmo
  51006. * @param gizmoLayer The utility layer the gizmo will be added to
  51007. * @param dragAxis The axis which the gizmo will be able to drag on
  51008. * @param color The color of the gizmo
  51009. */
  51010. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51011. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51012. /**
  51013. * If the gizmo is enabled
  51014. */
  51015. set isEnabled(value: boolean);
  51016. get isEnabled(): boolean;
  51017. /**
  51018. * Disposes of the gizmo
  51019. */
  51020. dispose(): void;
  51021. }
  51022. }
  51023. declare module "babylonjs/Debug/axesViewer" {
  51024. import { Vector3 } from "babylonjs/Maths/math.vector";
  51025. import { Nullable } from "babylonjs/types";
  51026. import { Scene } from "babylonjs/scene";
  51027. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51028. /**
  51029. * The Axes viewer will show 3 axes in a specific point in space
  51030. */
  51031. export class AxesViewer {
  51032. private _xAxis;
  51033. private _yAxis;
  51034. private _zAxis;
  51035. private _scaleLinesFactor;
  51036. private _instanced;
  51037. /**
  51038. * Gets the hosting scene
  51039. */
  51040. scene: Scene;
  51041. /**
  51042. * Gets or sets a number used to scale line length
  51043. */
  51044. scaleLines: number;
  51045. /** Gets the node hierarchy used to render x-axis */
  51046. get xAxis(): TransformNode;
  51047. /** Gets the node hierarchy used to render y-axis */
  51048. get yAxis(): TransformNode;
  51049. /** Gets the node hierarchy used to render z-axis */
  51050. get zAxis(): TransformNode;
  51051. /**
  51052. * Creates a new AxesViewer
  51053. * @param scene defines the hosting scene
  51054. * @param scaleLines defines a number used to scale line length (1 by default)
  51055. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51056. * @param xAxis defines the node hierarchy used to render the x-axis
  51057. * @param yAxis defines the node hierarchy used to render the y-axis
  51058. * @param zAxis defines the node hierarchy used to render the z-axis
  51059. */
  51060. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51061. /**
  51062. * Force the viewer to update
  51063. * @param position defines the position of the viewer
  51064. * @param xaxis defines the x axis of the viewer
  51065. * @param yaxis defines the y axis of the viewer
  51066. * @param zaxis defines the z axis of the viewer
  51067. */
  51068. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51069. /**
  51070. * Creates an instance of this axes viewer.
  51071. * @returns a new axes viewer with instanced meshes
  51072. */
  51073. createInstance(): AxesViewer;
  51074. /** Releases resources */
  51075. dispose(): void;
  51076. private static _SetRenderingGroupId;
  51077. }
  51078. }
  51079. declare module "babylonjs/Debug/boneAxesViewer" {
  51080. import { Nullable } from "babylonjs/types";
  51081. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51082. import { Vector3 } from "babylonjs/Maths/math.vector";
  51083. import { Mesh } from "babylonjs/Meshes/mesh";
  51084. import { Bone } from "babylonjs/Bones/bone";
  51085. import { Scene } from "babylonjs/scene";
  51086. /**
  51087. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51088. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51089. */
  51090. export class BoneAxesViewer extends AxesViewer {
  51091. /**
  51092. * Gets or sets the target mesh where to display the axes viewer
  51093. */
  51094. mesh: Nullable<Mesh>;
  51095. /**
  51096. * Gets or sets the target bone where to display the axes viewer
  51097. */
  51098. bone: Nullable<Bone>;
  51099. /** Gets current position */
  51100. pos: Vector3;
  51101. /** Gets direction of X axis */
  51102. xaxis: Vector3;
  51103. /** Gets direction of Y axis */
  51104. yaxis: Vector3;
  51105. /** Gets direction of Z axis */
  51106. zaxis: Vector3;
  51107. /**
  51108. * Creates a new BoneAxesViewer
  51109. * @param scene defines the hosting scene
  51110. * @param bone defines the target bone
  51111. * @param mesh defines the target mesh
  51112. * @param scaleLines defines a scaling factor for line length (1 by default)
  51113. */
  51114. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51115. /**
  51116. * Force the viewer to update
  51117. */
  51118. update(): void;
  51119. /** Releases resources */
  51120. dispose(): void;
  51121. }
  51122. }
  51123. declare module "babylonjs/Debug/debugLayer" {
  51124. import { Scene } from "babylonjs/scene";
  51125. /**
  51126. * Interface used to define scene explorer extensibility option
  51127. */
  51128. export interface IExplorerExtensibilityOption {
  51129. /**
  51130. * Define the option label
  51131. */
  51132. label: string;
  51133. /**
  51134. * Defines the action to execute on click
  51135. */
  51136. action: (entity: any) => void;
  51137. }
  51138. /**
  51139. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51140. */
  51141. export interface IExplorerExtensibilityGroup {
  51142. /**
  51143. * Defines a predicate to test if a given type mut be extended
  51144. */
  51145. predicate: (entity: any) => boolean;
  51146. /**
  51147. * Gets the list of options added to a type
  51148. */
  51149. entries: IExplorerExtensibilityOption[];
  51150. }
  51151. /**
  51152. * Interface used to define the options to use to create the Inspector
  51153. */
  51154. export interface IInspectorOptions {
  51155. /**
  51156. * Display in overlay mode (default: false)
  51157. */
  51158. overlay?: boolean;
  51159. /**
  51160. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51161. */
  51162. globalRoot?: HTMLElement;
  51163. /**
  51164. * Display the Scene explorer
  51165. */
  51166. showExplorer?: boolean;
  51167. /**
  51168. * Display the property inspector
  51169. */
  51170. showInspector?: boolean;
  51171. /**
  51172. * Display in embed mode (both panes on the right)
  51173. */
  51174. embedMode?: boolean;
  51175. /**
  51176. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51177. */
  51178. handleResize?: boolean;
  51179. /**
  51180. * Allow the panes to popup (default: true)
  51181. */
  51182. enablePopup?: boolean;
  51183. /**
  51184. * Allow the panes to be closed by users (default: true)
  51185. */
  51186. enableClose?: boolean;
  51187. /**
  51188. * Optional list of extensibility entries
  51189. */
  51190. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51191. /**
  51192. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51193. */
  51194. inspectorURL?: string;
  51195. /**
  51196. * Optional initial tab (default to DebugLayerTab.Properties)
  51197. */
  51198. initialTab?: DebugLayerTab;
  51199. }
  51200. module "babylonjs/scene" {
  51201. interface Scene {
  51202. /**
  51203. * @hidden
  51204. * Backing field
  51205. */
  51206. _debugLayer: DebugLayer;
  51207. /**
  51208. * Gets the debug layer (aka Inspector) associated with the scene
  51209. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51210. */
  51211. debugLayer: DebugLayer;
  51212. }
  51213. }
  51214. /**
  51215. * Enum of inspector action tab
  51216. */
  51217. export enum DebugLayerTab {
  51218. /**
  51219. * Properties tag (default)
  51220. */
  51221. Properties = 0,
  51222. /**
  51223. * Debug tab
  51224. */
  51225. Debug = 1,
  51226. /**
  51227. * Statistics tab
  51228. */
  51229. Statistics = 2,
  51230. /**
  51231. * Tools tab
  51232. */
  51233. Tools = 3,
  51234. /**
  51235. * Settings tab
  51236. */
  51237. Settings = 4
  51238. }
  51239. /**
  51240. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51241. * what is happening in your scene
  51242. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51243. */
  51244. export class DebugLayer {
  51245. /**
  51246. * Define the url to get the inspector script from.
  51247. * By default it uses the babylonjs CDN.
  51248. * @ignoreNaming
  51249. */
  51250. static InspectorURL: string;
  51251. private _scene;
  51252. private BJSINSPECTOR;
  51253. private _onPropertyChangedObservable?;
  51254. /**
  51255. * Observable triggered when a property is changed through the inspector.
  51256. */
  51257. get onPropertyChangedObservable(): any;
  51258. /**
  51259. * Instantiates a new debug layer.
  51260. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51261. * what is happening in your scene
  51262. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51263. * @param scene Defines the scene to inspect
  51264. */
  51265. constructor(scene: Scene);
  51266. /** Creates the inspector window. */
  51267. private _createInspector;
  51268. /**
  51269. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51270. * @param entity defines the entity to select
  51271. * @param lineContainerTitle defines the specific block to highlight
  51272. */
  51273. select(entity: any, lineContainerTitle?: string): void;
  51274. /** Get the inspector from bundle or global */
  51275. private _getGlobalInspector;
  51276. /**
  51277. * Get if the inspector is visible or not.
  51278. * @returns true if visible otherwise, false
  51279. */
  51280. isVisible(): boolean;
  51281. /**
  51282. * Hide the inspector and close its window.
  51283. */
  51284. hide(): void;
  51285. /**
  51286. * Update the scene in the inspector
  51287. */
  51288. setAsActiveScene(): void;
  51289. /**
  51290. * Launch the debugLayer.
  51291. * @param config Define the configuration of the inspector
  51292. * @return a promise fulfilled when the debug layer is visible
  51293. */
  51294. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51295. }
  51296. }
  51297. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51298. import { Nullable } from "babylonjs/types";
  51299. import { Scene } from "babylonjs/scene";
  51300. import { Vector4 } from "babylonjs/Maths/math.vector";
  51301. import { Color4 } from "babylonjs/Maths/math.color";
  51302. import { Mesh } from "babylonjs/Meshes/mesh";
  51303. /**
  51304. * Class containing static functions to help procedurally build meshes
  51305. */
  51306. export class BoxBuilder {
  51307. /**
  51308. * Creates a box mesh
  51309. * * The parameter `size` sets the size (float) of each box side (default 1)
  51310. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51311. * * 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)
  51312. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51316. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51317. * @param name defines the name of the mesh
  51318. * @param options defines the options used to create the mesh
  51319. * @param scene defines the hosting scene
  51320. * @returns the box mesh
  51321. */
  51322. static CreateBox(name: string, options: {
  51323. size?: number;
  51324. width?: number;
  51325. height?: number;
  51326. depth?: number;
  51327. faceUV?: Vector4[];
  51328. faceColors?: Color4[];
  51329. sideOrientation?: number;
  51330. frontUVs?: Vector4;
  51331. backUVs?: Vector4;
  51332. wrap?: boolean;
  51333. topBaseAt?: number;
  51334. bottomBaseAt?: number;
  51335. updatable?: boolean;
  51336. }, scene?: Nullable<Scene>): Mesh;
  51337. }
  51338. }
  51339. declare module "babylonjs/Debug/physicsViewer" {
  51340. import { Nullable } from "babylonjs/types";
  51341. import { Scene } from "babylonjs/scene";
  51342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51343. import { Mesh } from "babylonjs/Meshes/mesh";
  51344. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51345. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51346. /**
  51347. * Used to show the physics impostor around the specific mesh
  51348. */
  51349. export class PhysicsViewer {
  51350. /** @hidden */
  51351. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51352. /** @hidden */
  51353. protected _meshes: Array<Nullable<AbstractMesh>>;
  51354. /** @hidden */
  51355. protected _scene: Nullable<Scene>;
  51356. /** @hidden */
  51357. protected _numMeshes: number;
  51358. /** @hidden */
  51359. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51360. private _renderFunction;
  51361. private _utilityLayer;
  51362. private _debugBoxMesh;
  51363. private _debugSphereMesh;
  51364. private _debugCylinderMesh;
  51365. private _debugMaterial;
  51366. private _debugMeshMeshes;
  51367. /**
  51368. * Creates a new PhysicsViewer
  51369. * @param scene defines the hosting scene
  51370. */
  51371. constructor(scene: Scene);
  51372. /** @hidden */
  51373. protected _updateDebugMeshes(): void;
  51374. /**
  51375. * Renders a specified physic impostor
  51376. * @param impostor defines the impostor to render
  51377. * @param targetMesh defines the mesh represented by the impostor
  51378. * @returns the new debug mesh used to render the impostor
  51379. */
  51380. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51381. /**
  51382. * Hides a specified physic impostor
  51383. * @param impostor defines the impostor to hide
  51384. */
  51385. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51386. private _getDebugMaterial;
  51387. private _getDebugBoxMesh;
  51388. private _getDebugSphereMesh;
  51389. private _getDebugCylinderMesh;
  51390. private _getDebugMeshMesh;
  51391. private _getDebugMesh;
  51392. /** Releases all resources */
  51393. dispose(): void;
  51394. }
  51395. }
  51396. declare module "babylonjs/Debug/rayHelper" {
  51397. import { Nullable } from "babylonjs/types";
  51398. import { Ray } from "babylonjs/Culling/ray";
  51399. import { Vector3 } from "babylonjs/Maths/math.vector";
  51400. import { Color3 } from "babylonjs/Maths/math.color";
  51401. import { Scene } from "babylonjs/scene";
  51402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51403. import "babylonjs/Meshes/Builders/linesBuilder";
  51404. /**
  51405. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51406. * in order to better appreciate the issue one might have.
  51407. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51408. */
  51409. export class RayHelper {
  51410. /**
  51411. * Defines the ray we are currently tryin to visualize.
  51412. */
  51413. ray: Nullable<Ray>;
  51414. private _renderPoints;
  51415. private _renderLine;
  51416. private _renderFunction;
  51417. private _scene;
  51418. private _updateToMeshFunction;
  51419. private _attachedToMesh;
  51420. private _meshSpaceDirection;
  51421. private _meshSpaceOrigin;
  51422. /**
  51423. * Helper function to create a colored helper in a scene in one line.
  51424. * @param ray Defines the ray we are currently tryin to visualize
  51425. * @param scene Defines the scene the ray is used in
  51426. * @param color Defines the color we want to see the ray in
  51427. * @returns The newly created ray helper.
  51428. */
  51429. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51430. /**
  51431. * Instantiate a new ray helper.
  51432. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51433. * in order to better appreciate the issue one might have.
  51434. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51435. * @param ray Defines the ray we are currently tryin to visualize
  51436. */
  51437. constructor(ray: Ray);
  51438. /**
  51439. * Shows the ray we are willing to debug.
  51440. * @param scene Defines the scene the ray needs to be rendered in
  51441. * @param color Defines the color the ray needs to be rendered in
  51442. */
  51443. show(scene: Scene, color?: Color3): void;
  51444. /**
  51445. * Hides the ray we are debugging.
  51446. */
  51447. hide(): void;
  51448. private _render;
  51449. /**
  51450. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51451. * @param mesh Defines the mesh we want the helper attached to
  51452. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51453. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51454. * @param length Defines the length of the ray
  51455. */
  51456. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51457. /**
  51458. * Detach the ray helper from the mesh it has previously been attached to.
  51459. */
  51460. detachFromMesh(): void;
  51461. private _updateToMesh;
  51462. /**
  51463. * Dispose the helper and release its associated resources.
  51464. */
  51465. dispose(): void;
  51466. }
  51467. }
  51468. declare module "babylonjs/Debug/skeletonViewer" {
  51469. import { Color3 } from "babylonjs/Maths/math.color";
  51470. import { Scene } from "babylonjs/scene";
  51471. import { Nullable } from "babylonjs/types";
  51472. import { Skeleton } from "babylonjs/Bones/skeleton";
  51473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51474. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51475. /**
  51476. * Class used to render a debug view of a given skeleton
  51477. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51478. */
  51479. export class SkeletonViewer {
  51480. /** defines the skeleton to render */
  51481. skeleton: Skeleton;
  51482. /** defines the mesh attached to the skeleton */
  51483. mesh: AbstractMesh;
  51484. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51485. autoUpdateBonesMatrices: boolean;
  51486. /** defines the rendering group id to use with the viewer */
  51487. renderingGroupId: number;
  51488. /** Gets or sets the color used to render the skeleton */
  51489. color: Color3;
  51490. private _scene;
  51491. private _debugLines;
  51492. private _debugMesh;
  51493. private _isEnabled;
  51494. private _renderFunction;
  51495. private _utilityLayer;
  51496. /**
  51497. * Returns the mesh used to render the bones
  51498. */
  51499. get debugMesh(): Nullable<LinesMesh>;
  51500. /**
  51501. * Creates a new SkeletonViewer
  51502. * @param skeleton defines the skeleton to render
  51503. * @param mesh defines the mesh attached to the skeleton
  51504. * @param scene defines the hosting scene
  51505. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51506. * @param renderingGroupId defines the rendering group id to use with the viewer
  51507. */
  51508. constructor(
  51509. /** defines the skeleton to render */
  51510. skeleton: Skeleton,
  51511. /** defines the mesh attached to the skeleton */
  51512. mesh: AbstractMesh, scene: Scene,
  51513. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51514. autoUpdateBonesMatrices?: boolean,
  51515. /** defines the rendering group id to use with the viewer */
  51516. renderingGroupId?: number);
  51517. /** Gets or sets a boolean indicating if the viewer is enabled */
  51518. set isEnabled(value: boolean);
  51519. get isEnabled(): boolean;
  51520. private _getBonePosition;
  51521. private _getLinesForBonesWithLength;
  51522. private _getLinesForBonesNoLength;
  51523. /** Update the viewer to sync with current skeleton state */
  51524. update(): void;
  51525. /** Release associated resources */
  51526. dispose(): void;
  51527. }
  51528. }
  51529. declare module "babylonjs/Debug/index" {
  51530. export * from "babylonjs/Debug/axesViewer";
  51531. export * from "babylonjs/Debug/boneAxesViewer";
  51532. export * from "babylonjs/Debug/debugLayer";
  51533. export * from "babylonjs/Debug/physicsViewer";
  51534. export * from "babylonjs/Debug/rayHelper";
  51535. export * from "babylonjs/Debug/skeletonViewer";
  51536. }
  51537. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  51538. /**
  51539. * Enum for Device Types
  51540. */
  51541. export enum DeviceType {
  51542. /** Generic */
  51543. Generic = 0,
  51544. /** Keyboard */
  51545. Keyboard = 1,
  51546. /** Mouse */
  51547. Mouse = 2,
  51548. /** Touch Pointers */
  51549. Touch = 3,
  51550. /** PS4 Dual Shock */
  51551. DualShock = 4,
  51552. /** Xbox */
  51553. Xbox = 5,
  51554. /** Switch Controller */
  51555. Switch = 6
  51556. }
  51557. /**
  51558. * Enum for All Pointers (Touch/Mouse)
  51559. */
  51560. export enum PointerInput {
  51561. /** Horizontal Axis */
  51562. Horizontal = 0,
  51563. /** Vertical Axis */
  51564. Vertical = 1,
  51565. /** Left Click or Touch */
  51566. LeftClick = 2,
  51567. /** Middle Click */
  51568. MiddleClick = 3,
  51569. /** Right Click */
  51570. RightClick = 4,
  51571. /** Browser Back */
  51572. BrowserBack = 5,
  51573. /** Browser Forward */
  51574. BrowserForward = 6
  51575. }
  51576. /**
  51577. * Enum for Dual Shock Gamepad
  51578. */
  51579. export enum DualShockInput {
  51580. /** Cross */
  51581. Cross = 0,
  51582. /** Circle */
  51583. Circle = 1,
  51584. /** Square */
  51585. Square = 2,
  51586. /** Triangle */
  51587. Triangle = 3,
  51588. /** L1 */
  51589. L1 = 4,
  51590. /** R1 */
  51591. R1 = 5,
  51592. /** L2 */
  51593. L2 = 6,
  51594. /** R2 */
  51595. R2 = 7,
  51596. /** Share */
  51597. Share = 8,
  51598. /** Options */
  51599. Options = 9,
  51600. /** L3 */
  51601. L3 = 10,
  51602. /** R3 */
  51603. R3 = 11,
  51604. /** DPadUp */
  51605. DPadUp = 12,
  51606. /** DPadDown */
  51607. DPadDown = 13,
  51608. /** DPadLeft */
  51609. DPadLeft = 14,
  51610. /** DRight */
  51611. DPadRight = 15,
  51612. /** Home */
  51613. Home = 16,
  51614. /** TouchPad */
  51615. TouchPad = 17,
  51616. /** LStickXAxis */
  51617. LStickXAxis = 18,
  51618. /** LStickYAxis */
  51619. LStickYAxis = 19,
  51620. /** RStickXAxis */
  51621. RStickXAxis = 20,
  51622. /** RStickYAxis */
  51623. RStickYAxis = 21
  51624. }
  51625. /**
  51626. * Enum for Xbox Gamepad
  51627. */
  51628. export enum XboxInput {
  51629. /** A */
  51630. A = 0,
  51631. /** B */
  51632. B = 1,
  51633. /** X */
  51634. X = 2,
  51635. /** Y */
  51636. Y = 3,
  51637. /** LB */
  51638. LB = 4,
  51639. /** RB */
  51640. RB = 5,
  51641. /** LT */
  51642. LT = 6,
  51643. /** RT */
  51644. RT = 7,
  51645. /** Back */
  51646. Back = 8,
  51647. /** Start */
  51648. Start = 9,
  51649. /** LS */
  51650. LS = 10,
  51651. /** RS */
  51652. RS = 11,
  51653. /** DPadUp */
  51654. DPadUp = 12,
  51655. /** DPadDown */
  51656. DPadDown = 13,
  51657. /** DPadLeft */
  51658. DPadLeft = 14,
  51659. /** DRight */
  51660. DPadRight = 15,
  51661. /** Home */
  51662. Home = 16,
  51663. /** LStickXAxis */
  51664. LStickXAxis = 17,
  51665. /** LStickYAxis */
  51666. LStickYAxis = 18,
  51667. /** RStickXAxis */
  51668. RStickXAxis = 19,
  51669. /** RStickYAxis */
  51670. RStickYAxis = 20
  51671. }
  51672. /**
  51673. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51674. */
  51675. export enum SwitchInput {
  51676. /** B */
  51677. B = 0,
  51678. /** A */
  51679. A = 1,
  51680. /** Y */
  51681. Y = 2,
  51682. /** X */
  51683. X = 3,
  51684. /** L */
  51685. L = 4,
  51686. /** R */
  51687. R = 5,
  51688. /** ZL */
  51689. ZL = 6,
  51690. /** ZR */
  51691. ZR = 7,
  51692. /** Minus */
  51693. Minus = 8,
  51694. /** Plus */
  51695. Plus = 9,
  51696. /** LS */
  51697. LS = 10,
  51698. /** RS */
  51699. RS = 11,
  51700. /** DPadUp */
  51701. DPadUp = 12,
  51702. /** DPadDown */
  51703. DPadDown = 13,
  51704. /** DPadLeft */
  51705. DPadLeft = 14,
  51706. /** DRight */
  51707. DPadRight = 15,
  51708. /** Home */
  51709. Home = 16,
  51710. /** Capture */
  51711. Capture = 17,
  51712. /** LStickXAxis */
  51713. LStickXAxis = 18,
  51714. /** LStickYAxis */
  51715. LStickYAxis = 19,
  51716. /** RStickXAxis */
  51717. RStickXAxis = 20,
  51718. /** RStickYAxis */
  51719. RStickYAxis = 21
  51720. }
  51721. }
  51722. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  51723. import { Engine } from "babylonjs/Engines/engine";
  51724. import { IDisposable } from "babylonjs/scene";
  51725. import { Nullable } from "babylonjs/types";
  51726. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51727. /**
  51728. * This class will take all inputs from Keyboard, Pointer, and
  51729. * any Gamepads and provide a polling system that all devices
  51730. * will use. This class assumes that there will only be one
  51731. * pointer device and one keyboard.
  51732. */
  51733. export class DeviceInputSystem implements IDisposable {
  51734. /**
  51735. * Callback to be triggered when a device is connected
  51736. */
  51737. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51738. /**
  51739. * Callback to be triggered when a device is disconnected
  51740. */
  51741. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51742. /**
  51743. * Callback to be triggered when event driven input is updated
  51744. */
  51745. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51746. private _inputs;
  51747. private _gamepads;
  51748. private _keyboardActive;
  51749. private _pointerActive;
  51750. private _elementToAttachTo;
  51751. private _keyboardDownEvent;
  51752. private _keyboardUpEvent;
  51753. private _pointerMoveEvent;
  51754. private _pointerDownEvent;
  51755. private _pointerUpEvent;
  51756. private _gamepadConnectedEvent;
  51757. private _gamepadDisconnectedEvent;
  51758. private static _MAX_KEYCODES;
  51759. private static _MAX_POINTER_INPUTS;
  51760. /**
  51761. * Default Constructor
  51762. * @param engine - engine to pull input element from
  51763. */
  51764. constructor(engine: Engine);
  51765. /**
  51766. * Checks for current device input value, given an id and input index
  51767. * @param deviceName Id of connected device
  51768. * @param inputIndex Index of device input
  51769. * @returns Current value of input
  51770. */
  51771. /**
  51772. * Checks for current device input value, given an id and input index
  51773. * @param deviceType Enum specifiying device type
  51774. * @param deviceSlot "Slot" or index that device is referenced in
  51775. * @param inputIndex Id of input to be checked
  51776. * @returns Current value of input
  51777. */
  51778. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51779. /**
  51780. * Dispose of all the eventlisteners
  51781. */
  51782. dispose(): void;
  51783. /**
  51784. * Add device and inputs to device array
  51785. * @param deviceType Enum specifiying device type
  51786. * @param deviceSlot "Slot" or index that device is referenced in
  51787. * @param numberOfInputs Number of input entries to create for given device
  51788. */
  51789. private _registerDevice;
  51790. /**
  51791. * Given a specific device name, remove that device from the device map
  51792. * @param deviceType Enum specifiying device type
  51793. * @param deviceSlot "Slot" or index that device is referenced in
  51794. */
  51795. private _unregisterDevice;
  51796. /**
  51797. * Handle all actions that come from keyboard interaction
  51798. */
  51799. private _handleKeyActions;
  51800. /**
  51801. * Handle all actions that come from pointer interaction
  51802. */
  51803. private _handlePointerActions;
  51804. /**
  51805. * Handle all actions that come from gamepad interaction
  51806. */
  51807. private _handleGamepadActions;
  51808. /**
  51809. * Update all non-event based devices with each frame
  51810. * @param deviceType Enum specifiying device type
  51811. * @param deviceSlot "Slot" or index that device is referenced in
  51812. * @param inputIndex Id of input to be checked
  51813. */
  51814. private _updateDevice;
  51815. /**
  51816. * Gets DeviceType from the device name
  51817. * @param deviceName Name of Device from DeviceInputSystem
  51818. * @returns DeviceType enum value
  51819. */
  51820. private _getGamepadDeviceType;
  51821. }
  51822. }
  51823. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  51824. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51825. /**
  51826. * Type to handle enforcement of inputs
  51827. */
  51828. 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;
  51829. }
  51830. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  51831. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  51832. import { Engine } from "babylonjs/Engines/engine";
  51833. import { IDisposable } from "babylonjs/scene";
  51834. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51835. import { Nullable } from "babylonjs/types";
  51836. import { Observable } from "babylonjs/Misc/observable";
  51837. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51838. /**
  51839. * Class that handles all input for a specific device
  51840. */
  51841. export class DeviceSource<T extends DeviceType> {
  51842. /** Type of device */
  51843. readonly deviceType: DeviceType;
  51844. /** "Slot" or index that device is referenced in */
  51845. readonly deviceSlot: number;
  51846. /**
  51847. * Observable to handle device input changes per device
  51848. */
  51849. readonly onInputChangedObservable: Observable<{
  51850. inputIndex: DeviceInput<T>;
  51851. previousState: Nullable<number>;
  51852. currentState: Nullable<number>;
  51853. }>;
  51854. private readonly _deviceInputSystem;
  51855. /**
  51856. * Default Constructor
  51857. * @param deviceInputSystem Reference to DeviceInputSystem
  51858. * @param deviceType Type of device
  51859. * @param deviceSlot "Slot" or index that device is referenced in
  51860. */
  51861. constructor(deviceInputSystem: DeviceInputSystem,
  51862. /** Type of device */
  51863. deviceType: DeviceType,
  51864. /** "Slot" or index that device is referenced in */
  51865. deviceSlot?: number);
  51866. /**
  51867. * Get input for specific input
  51868. * @param inputIndex index of specific input on device
  51869. * @returns Input value from DeviceInputSystem
  51870. */
  51871. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51872. }
  51873. /**
  51874. * Class to keep track of devices
  51875. */
  51876. export class DeviceSourceManager implements IDisposable {
  51877. /**
  51878. * Observable to be triggered when before a device is connected
  51879. */
  51880. readonly onBeforeDeviceConnectedObservable: Observable<{
  51881. deviceType: DeviceType;
  51882. deviceSlot: number;
  51883. }>;
  51884. /**
  51885. * Observable to be triggered when before a device is disconnected
  51886. */
  51887. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51888. deviceType: DeviceType;
  51889. deviceSlot: number;
  51890. }>;
  51891. /**
  51892. * Observable to be triggered when after a device is connected
  51893. */
  51894. readonly onAfterDeviceConnectedObservable: Observable<{
  51895. deviceType: DeviceType;
  51896. deviceSlot: number;
  51897. }>;
  51898. /**
  51899. * Observable to be triggered when after a device is disconnected
  51900. */
  51901. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51902. deviceType: DeviceType;
  51903. deviceSlot: number;
  51904. }>;
  51905. private readonly _devices;
  51906. private readonly _firstDevice;
  51907. private readonly _deviceInputSystem;
  51908. /**
  51909. * Default Constructor
  51910. * @param engine engine to pull input element from
  51911. */
  51912. constructor(engine: Engine);
  51913. /**
  51914. * Gets a DeviceSource, given a type and slot
  51915. * @param deviceType Enum specifying device type
  51916. * @param deviceSlot "Slot" or index that device is referenced in
  51917. * @returns DeviceSource object
  51918. */
  51919. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51920. /**
  51921. * Gets an array of DeviceSource objects for a given device type
  51922. * @param deviceType Enum specifying device type
  51923. * @returns Array of DeviceSource objects
  51924. */
  51925. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51926. /**
  51927. * Dispose of DeviceInputSystem and other parts
  51928. */
  51929. dispose(): void;
  51930. /**
  51931. * Function to add device name to device list
  51932. * @param deviceType Enum specifying device type
  51933. * @param deviceSlot "Slot" or index that device is referenced in
  51934. */
  51935. private _addDevice;
  51936. /**
  51937. * Function to remove device name to device list
  51938. * @param deviceType Enum specifying device type
  51939. * @param deviceSlot "Slot" or index that device is referenced in
  51940. */
  51941. private _removeDevice;
  51942. /**
  51943. * Updates array storing first connected device of each type
  51944. * @param type Type of Device
  51945. */
  51946. private _updateFirstDevices;
  51947. }
  51948. }
  51949. declare module "babylonjs/DeviceInput/index" {
  51950. export * from "babylonjs/DeviceInput/deviceInputSystem";
  51951. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51952. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51953. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51954. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51955. }
  51956. declare module "babylonjs/Engines/nullEngine" {
  51957. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  51958. import { Engine } from "babylonjs/Engines/engine";
  51959. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  51960. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  51961. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51962. import { Effect } from "babylonjs/Materials/effect";
  51963. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  51964. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  51965. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  51966. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  51967. /**
  51968. * Options to create the null engine
  51969. */
  51970. export class NullEngineOptions {
  51971. /**
  51972. * Render width (Default: 512)
  51973. */
  51974. renderWidth: number;
  51975. /**
  51976. * Render height (Default: 256)
  51977. */
  51978. renderHeight: number;
  51979. /**
  51980. * Texture size (Default: 512)
  51981. */
  51982. textureSize: number;
  51983. /**
  51984. * If delta time between frames should be constant
  51985. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51986. */
  51987. deterministicLockstep: boolean;
  51988. /**
  51989. * Maximum about of steps between frames (Default: 4)
  51990. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51991. */
  51992. lockstepMaxSteps: number;
  51993. }
  51994. /**
  51995. * The null engine class provides support for headless version of babylon.js.
  51996. * This can be used in server side scenario or for testing purposes
  51997. */
  51998. export class NullEngine extends Engine {
  51999. private _options;
  52000. /**
  52001. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52002. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52003. * @returns true if engine is in deterministic lock step mode
  52004. */
  52005. isDeterministicLockStep(): boolean;
  52006. /**
  52007. * Gets the max steps when engine is running in deterministic lock step
  52008. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52009. * @returns the max steps
  52010. */
  52011. getLockstepMaxSteps(): number;
  52012. /**
  52013. * Gets the current hardware scaling level.
  52014. * By default the hardware scaling level is computed from the window device ratio.
  52015. * 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.
  52016. * @returns a number indicating the current hardware scaling level
  52017. */
  52018. getHardwareScalingLevel(): number;
  52019. constructor(options?: NullEngineOptions);
  52020. /**
  52021. * Creates a vertex buffer
  52022. * @param vertices the data for the vertex buffer
  52023. * @returns the new WebGL static buffer
  52024. */
  52025. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52026. /**
  52027. * Creates a new index buffer
  52028. * @param indices defines the content of the index buffer
  52029. * @param updatable defines if the index buffer must be updatable
  52030. * @returns a new webGL buffer
  52031. */
  52032. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52033. /**
  52034. * Clear the current render buffer or the current render target (if any is set up)
  52035. * @param color defines the color to use
  52036. * @param backBuffer defines if the back buffer must be cleared
  52037. * @param depth defines if the depth buffer must be cleared
  52038. * @param stencil defines if the stencil buffer must be cleared
  52039. */
  52040. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52041. /**
  52042. * Gets the current render width
  52043. * @param useScreen defines if screen size must be used (or the current render target if any)
  52044. * @returns a number defining the current render width
  52045. */
  52046. getRenderWidth(useScreen?: boolean): number;
  52047. /**
  52048. * Gets the current render height
  52049. * @param useScreen defines if screen size must be used (or the current render target if any)
  52050. * @returns a number defining the current render height
  52051. */
  52052. getRenderHeight(useScreen?: boolean): number;
  52053. /**
  52054. * Set the WebGL's viewport
  52055. * @param viewport defines the viewport element to be used
  52056. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52057. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52058. */
  52059. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52060. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52061. /**
  52062. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52063. * @param pipelineContext defines the pipeline context to use
  52064. * @param uniformsNames defines the list of uniform names
  52065. * @returns an array of webGL uniform locations
  52066. */
  52067. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52068. /**
  52069. * Gets the lsit of active attributes for a given webGL program
  52070. * @param pipelineContext defines the pipeline context to use
  52071. * @param attributesNames defines the list of attribute names to get
  52072. * @returns an array of indices indicating the offset of each attribute
  52073. */
  52074. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52075. /**
  52076. * Binds an effect to the webGL context
  52077. * @param effect defines the effect to bind
  52078. */
  52079. bindSamplers(effect: Effect): void;
  52080. /**
  52081. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52082. * @param effect defines the effect to activate
  52083. */
  52084. enableEffect(effect: Effect): void;
  52085. /**
  52086. * Set various states to the webGL context
  52087. * @param culling defines backface culling state
  52088. * @param zOffset defines the value to apply to zOffset (0 by default)
  52089. * @param force defines if states must be applied even if cache is up to date
  52090. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52091. */
  52092. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52093. /**
  52094. * Set the value of an uniform to an array of int32
  52095. * @param uniform defines the webGL uniform location where to store the value
  52096. * @param array defines the array of int32 to store
  52097. */
  52098. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52099. /**
  52100. * Set the value of an uniform to an array of int32 (stored as vec2)
  52101. * @param uniform defines the webGL uniform location where to store the value
  52102. * @param array defines the array of int32 to store
  52103. */
  52104. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52105. /**
  52106. * Set the value of an uniform to an array of int32 (stored as vec3)
  52107. * @param uniform defines the webGL uniform location where to store the value
  52108. * @param array defines the array of int32 to store
  52109. */
  52110. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52111. /**
  52112. * Set the value of an uniform to an array of int32 (stored as vec4)
  52113. * @param uniform defines the webGL uniform location where to store the value
  52114. * @param array defines the array of int32 to store
  52115. */
  52116. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52117. /**
  52118. * Set the value of an uniform to an array of float32
  52119. * @param uniform defines the webGL uniform location where to store the value
  52120. * @param array defines the array of float32 to store
  52121. */
  52122. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52123. /**
  52124. * Set the value of an uniform to an array of float32 (stored as vec2)
  52125. * @param uniform defines the webGL uniform location where to store the value
  52126. * @param array defines the array of float32 to store
  52127. */
  52128. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52129. /**
  52130. * Set the value of an uniform to an array of float32 (stored as vec3)
  52131. * @param uniform defines the webGL uniform location where to store the value
  52132. * @param array defines the array of float32 to store
  52133. */
  52134. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52135. /**
  52136. * Set the value of an uniform to an array of float32 (stored as vec4)
  52137. * @param uniform defines the webGL uniform location where to store the value
  52138. * @param array defines the array of float32 to store
  52139. */
  52140. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52141. /**
  52142. * Set the value of an uniform to an array of number
  52143. * @param uniform defines the webGL uniform location where to store the value
  52144. * @param array defines the array of number to store
  52145. */
  52146. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52147. /**
  52148. * Set the value of an uniform to an array of number (stored as vec2)
  52149. * @param uniform defines the webGL uniform location where to store the value
  52150. * @param array defines the array of number to store
  52151. */
  52152. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52153. /**
  52154. * Set the value of an uniform to an array of number (stored as vec3)
  52155. * @param uniform defines the webGL uniform location where to store the value
  52156. * @param array defines the array of number to store
  52157. */
  52158. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52159. /**
  52160. * Set the value of an uniform to an array of number (stored as vec4)
  52161. * @param uniform defines the webGL uniform location where to store the value
  52162. * @param array defines the array of number to store
  52163. */
  52164. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52165. /**
  52166. * Set the value of an uniform to an array of float32 (stored as matrices)
  52167. * @param uniform defines the webGL uniform location where to store the value
  52168. * @param matrices defines the array of float32 to store
  52169. */
  52170. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52171. /**
  52172. * Set the value of an uniform to a matrix (3x3)
  52173. * @param uniform defines the webGL uniform location where to store the value
  52174. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52175. */
  52176. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52177. /**
  52178. * Set the value of an uniform to a matrix (2x2)
  52179. * @param uniform defines the webGL uniform location where to store the value
  52180. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52181. */
  52182. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52183. /**
  52184. * Set the value of an uniform to a number (float)
  52185. * @param uniform defines the webGL uniform location where to store the value
  52186. * @param value defines the float number to store
  52187. */
  52188. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52189. /**
  52190. * Set the value of an uniform to a vec2
  52191. * @param uniform defines the webGL uniform location where to store the value
  52192. * @param x defines the 1st component of the value
  52193. * @param y defines the 2nd component of the value
  52194. */
  52195. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52196. /**
  52197. * Set the value of an uniform to a vec3
  52198. * @param uniform defines the webGL uniform location where to store the value
  52199. * @param x defines the 1st component of the value
  52200. * @param y defines the 2nd component of the value
  52201. * @param z defines the 3rd component of the value
  52202. */
  52203. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52204. /**
  52205. * Set the value of an uniform to a boolean
  52206. * @param uniform defines the webGL uniform location where to store the value
  52207. * @param bool defines the boolean to store
  52208. */
  52209. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52210. /**
  52211. * Set the value of an uniform to a vec4
  52212. * @param uniform defines the webGL uniform location where to store the value
  52213. * @param x defines the 1st component of the value
  52214. * @param y defines the 2nd component of the value
  52215. * @param z defines the 3rd component of the value
  52216. * @param w defines the 4th component of the value
  52217. */
  52218. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52219. /**
  52220. * Sets the current alpha mode
  52221. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52222. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52223. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52224. */
  52225. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52226. /**
  52227. * Bind webGl buffers directly to the webGL context
  52228. * @param vertexBuffers defines the vertex buffer to bind
  52229. * @param indexBuffer defines the index buffer to bind
  52230. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52231. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52232. * @param effect defines the effect associated with the vertex buffer
  52233. */
  52234. bindBuffers(vertexBuffers: {
  52235. [key: string]: VertexBuffer;
  52236. }, indexBuffer: DataBuffer, effect: Effect): void;
  52237. /**
  52238. * Force the entire cache to be cleared
  52239. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52240. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52241. */
  52242. wipeCaches(bruteForce?: boolean): void;
  52243. /**
  52244. * Send a draw order
  52245. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52246. * @param indexStart defines the starting index
  52247. * @param indexCount defines the number of index to draw
  52248. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52249. */
  52250. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52251. /**
  52252. * Draw a list of indexed primitives
  52253. * @param fillMode defines the primitive to use
  52254. * @param indexStart defines the starting index
  52255. * @param indexCount defines the number of index to draw
  52256. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52257. */
  52258. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52259. /**
  52260. * Draw a list of unindexed primitives
  52261. * @param fillMode defines the primitive to use
  52262. * @param verticesStart defines the index of first vertex to draw
  52263. * @param verticesCount defines the count of vertices to draw
  52264. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52265. */
  52266. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52267. /** @hidden */
  52268. _createTexture(): WebGLTexture;
  52269. /** @hidden */
  52270. _releaseTexture(texture: InternalTexture): void;
  52271. /**
  52272. * Usually called from Texture.ts.
  52273. * Passed information to create a WebGLTexture
  52274. * @param urlArg defines a value which contains one of the following:
  52275. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52276. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52277. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52278. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52279. * @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)
  52280. * @param scene needed for loading to the correct scene
  52281. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52282. * @param onLoad optional callback to be called upon successful completion
  52283. * @param onError optional callback to be called upon failure
  52284. * @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
  52285. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52286. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52287. * @param forcedExtension defines the extension to use to pick the right loader
  52288. * @param mimeType defines an optional mime type
  52289. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52290. */
  52291. 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;
  52292. /**
  52293. * Creates a new render target texture
  52294. * @param size defines the size of the texture
  52295. * @param options defines the options used to create the texture
  52296. * @returns a new render target texture stored in an InternalTexture
  52297. */
  52298. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52299. /**
  52300. * Update the sampling mode of a given texture
  52301. * @param samplingMode defines the required sampling mode
  52302. * @param texture defines the texture to update
  52303. */
  52304. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52305. /**
  52306. * Binds the frame buffer to the specified texture.
  52307. * @param texture The texture to render to or null for the default canvas
  52308. * @param faceIndex The face of the texture to render to in case of cube texture
  52309. * @param requiredWidth The width of the target to render to
  52310. * @param requiredHeight The height of the target to render to
  52311. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52312. * @param lodLevel defines le lod level to bind to the frame buffer
  52313. */
  52314. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52315. /**
  52316. * Unbind the current render target texture from the webGL context
  52317. * @param texture defines the render target texture to unbind
  52318. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52319. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52320. */
  52321. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52322. /**
  52323. * Creates a dynamic vertex buffer
  52324. * @param vertices the data for the dynamic vertex buffer
  52325. * @returns the new WebGL dynamic buffer
  52326. */
  52327. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52328. /**
  52329. * Update the content of a dynamic texture
  52330. * @param texture defines the texture to update
  52331. * @param canvas defines the canvas containing the source
  52332. * @param invertY defines if data must be stored with Y axis inverted
  52333. * @param premulAlpha defines if alpha is stored as premultiplied
  52334. * @param format defines the format of the data
  52335. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52336. */
  52337. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52338. /**
  52339. * Gets a boolean indicating if all created effects are ready
  52340. * @returns true if all effects are ready
  52341. */
  52342. areAllEffectsReady(): boolean;
  52343. /**
  52344. * @hidden
  52345. * Get the current error code of the webGL context
  52346. * @returns the error code
  52347. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52348. */
  52349. getError(): number;
  52350. /** @hidden */
  52351. _getUnpackAlignement(): number;
  52352. /** @hidden */
  52353. _unpackFlipY(value: boolean): void;
  52354. /**
  52355. * Update a dynamic index buffer
  52356. * @param indexBuffer defines the target index buffer
  52357. * @param indices defines the data to update
  52358. * @param offset defines the offset in the target index buffer where update should start
  52359. */
  52360. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52361. /**
  52362. * Updates a dynamic vertex buffer.
  52363. * @param vertexBuffer the vertex buffer to update
  52364. * @param vertices the data used to update the vertex buffer
  52365. * @param byteOffset the byte offset of the data (optional)
  52366. * @param byteLength the byte length of the data (optional)
  52367. */
  52368. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52369. /** @hidden */
  52370. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52371. /** @hidden */
  52372. _bindTexture(channel: number, texture: InternalTexture): void;
  52373. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52374. /**
  52375. * 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
  52376. */
  52377. releaseEffects(): void;
  52378. displayLoadingUI(): void;
  52379. hideLoadingUI(): void;
  52380. /** @hidden */
  52381. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52382. /** @hidden */
  52383. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52384. /** @hidden */
  52385. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52386. /** @hidden */
  52387. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52388. }
  52389. }
  52390. declare module "babylonjs/Instrumentation/timeToken" {
  52391. import { Nullable } from "babylonjs/types";
  52392. /**
  52393. * @hidden
  52394. **/
  52395. export class _TimeToken {
  52396. _startTimeQuery: Nullable<WebGLQuery>;
  52397. _endTimeQuery: Nullable<WebGLQuery>;
  52398. _timeElapsedQuery: Nullable<WebGLQuery>;
  52399. _timeElapsedQueryEnded: boolean;
  52400. }
  52401. }
  52402. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52403. import { Nullable, int } from "babylonjs/types";
  52404. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52405. /** @hidden */
  52406. export class _OcclusionDataStorage {
  52407. /** @hidden */
  52408. occlusionInternalRetryCounter: number;
  52409. /** @hidden */
  52410. isOcclusionQueryInProgress: boolean;
  52411. /** @hidden */
  52412. isOccluded: boolean;
  52413. /** @hidden */
  52414. occlusionRetryCount: number;
  52415. /** @hidden */
  52416. occlusionType: number;
  52417. /** @hidden */
  52418. occlusionQueryAlgorithmType: number;
  52419. }
  52420. module "babylonjs/Engines/engine" {
  52421. interface Engine {
  52422. /**
  52423. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52424. * @return the new query
  52425. */
  52426. createQuery(): WebGLQuery;
  52427. /**
  52428. * Delete and release a webGL query
  52429. * @param query defines the query to delete
  52430. * @return the current engine
  52431. */
  52432. deleteQuery(query: WebGLQuery): Engine;
  52433. /**
  52434. * Check if a given query has resolved and got its value
  52435. * @param query defines the query to check
  52436. * @returns true if the query got its value
  52437. */
  52438. isQueryResultAvailable(query: WebGLQuery): boolean;
  52439. /**
  52440. * Gets the value of a given query
  52441. * @param query defines the query to check
  52442. * @returns the value of the query
  52443. */
  52444. getQueryResult(query: WebGLQuery): number;
  52445. /**
  52446. * Initiates an occlusion query
  52447. * @param algorithmType defines the algorithm to use
  52448. * @param query defines the query to use
  52449. * @returns the current engine
  52450. * @see http://doc.babylonjs.com/features/occlusionquery
  52451. */
  52452. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52453. /**
  52454. * Ends an occlusion query
  52455. * @see http://doc.babylonjs.com/features/occlusionquery
  52456. * @param algorithmType defines the algorithm to use
  52457. * @returns the current engine
  52458. */
  52459. endOcclusionQuery(algorithmType: number): Engine;
  52460. /**
  52461. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52462. * Please note that only one query can be issued at a time
  52463. * @returns a time token used to track the time span
  52464. */
  52465. startTimeQuery(): Nullable<_TimeToken>;
  52466. /**
  52467. * Ends a time query
  52468. * @param token defines the token used to measure the time span
  52469. * @returns the time spent (in ns)
  52470. */
  52471. endTimeQuery(token: _TimeToken): int;
  52472. /** @hidden */
  52473. _currentNonTimestampToken: Nullable<_TimeToken>;
  52474. /** @hidden */
  52475. _createTimeQuery(): WebGLQuery;
  52476. /** @hidden */
  52477. _deleteTimeQuery(query: WebGLQuery): void;
  52478. /** @hidden */
  52479. _getGlAlgorithmType(algorithmType: number): number;
  52480. /** @hidden */
  52481. _getTimeQueryResult(query: WebGLQuery): any;
  52482. /** @hidden */
  52483. _getTimeQueryAvailability(query: WebGLQuery): any;
  52484. }
  52485. }
  52486. module "babylonjs/Meshes/abstractMesh" {
  52487. interface AbstractMesh {
  52488. /**
  52489. * Backing filed
  52490. * @hidden
  52491. */
  52492. __occlusionDataStorage: _OcclusionDataStorage;
  52493. /**
  52494. * Access property
  52495. * @hidden
  52496. */
  52497. _occlusionDataStorage: _OcclusionDataStorage;
  52498. /**
  52499. * 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.
  52500. * The default value is -1 which means don't break the query and wait till the result
  52501. * @see http://doc.babylonjs.com/features/occlusionquery
  52502. */
  52503. occlusionRetryCount: number;
  52504. /**
  52505. * 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:
  52506. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52507. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52508. * * 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.
  52509. * @see http://doc.babylonjs.com/features/occlusionquery
  52510. */
  52511. occlusionType: number;
  52512. /**
  52513. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52514. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52515. * * 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.
  52516. * @see http://doc.babylonjs.com/features/occlusionquery
  52517. */
  52518. occlusionQueryAlgorithmType: number;
  52519. /**
  52520. * 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
  52521. * @see http://doc.babylonjs.com/features/occlusionquery
  52522. */
  52523. isOccluded: boolean;
  52524. /**
  52525. * Flag to check the progress status of the query
  52526. * @see http://doc.babylonjs.com/features/occlusionquery
  52527. */
  52528. isOcclusionQueryInProgress: boolean;
  52529. }
  52530. }
  52531. }
  52532. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  52533. import { Nullable } from "babylonjs/types";
  52534. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52535. /** @hidden */
  52536. export var _forceTransformFeedbackToBundle: boolean;
  52537. module "babylonjs/Engines/engine" {
  52538. interface Engine {
  52539. /**
  52540. * Creates a webGL transform feedback object
  52541. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52542. * @returns the webGL transform feedback object
  52543. */
  52544. createTransformFeedback(): WebGLTransformFeedback;
  52545. /**
  52546. * Delete a webGL transform feedback object
  52547. * @param value defines the webGL transform feedback object to delete
  52548. */
  52549. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52550. /**
  52551. * Bind a webGL transform feedback object to the webgl context
  52552. * @param value defines the webGL transform feedback object to bind
  52553. */
  52554. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52555. /**
  52556. * Begins a transform feedback operation
  52557. * @param usePoints defines if points or triangles must be used
  52558. */
  52559. beginTransformFeedback(usePoints: boolean): void;
  52560. /**
  52561. * Ends a transform feedback operation
  52562. */
  52563. endTransformFeedback(): void;
  52564. /**
  52565. * Specify the varyings to use with transform feedback
  52566. * @param program defines the associated webGL program
  52567. * @param value defines the list of strings representing the varying names
  52568. */
  52569. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52570. /**
  52571. * Bind a webGL buffer for a transform feedback operation
  52572. * @param value defines the webGL buffer to bind
  52573. */
  52574. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52575. }
  52576. }
  52577. }
  52578. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  52579. import { Scene } from "babylonjs/scene";
  52580. import { Engine } from "babylonjs/Engines/engine";
  52581. import { Texture } from "babylonjs/Materials/Textures/texture";
  52582. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52583. import "babylonjs/Engines/Extensions/engine.multiRender";
  52584. /**
  52585. * Creation options of the multi render target texture.
  52586. */
  52587. export interface IMultiRenderTargetOptions {
  52588. /**
  52589. * Define if the texture needs to create mip maps after render.
  52590. */
  52591. generateMipMaps?: boolean;
  52592. /**
  52593. * Define the types of all the draw buffers we want to create
  52594. */
  52595. types?: number[];
  52596. /**
  52597. * Define the sampling modes of all the draw buffers we want to create
  52598. */
  52599. samplingModes?: number[];
  52600. /**
  52601. * Define if a depth buffer is required
  52602. */
  52603. generateDepthBuffer?: boolean;
  52604. /**
  52605. * Define if a stencil buffer is required
  52606. */
  52607. generateStencilBuffer?: boolean;
  52608. /**
  52609. * Define if a depth texture is required instead of a depth buffer
  52610. */
  52611. generateDepthTexture?: boolean;
  52612. /**
  52613. * Define the number of desired draw buffers
  52614. */
  52615. textureCount?: number;
  52616. /**
  52617. * Define if aspect ratio should be adapted to the texture or stay the scene one
  52618. */
  52619. doNotChangeAspectRatio?: boolean;
  52620. /**
  52621. * Define the default type of the buffers we are creating
  52622. */
  52623. defaultType?: number;
  52624. }
  52625. /**
  52626. * A multi render target, like a render target provides the ability to render to a texture.
  52627. * Unlike the render target, it can render to several draw buffers in one draw.
  52628. * This is specially interesting in deferred rendering or for any effects requiring more than
  52629. * just one color from a single pass.
  52630. */
  52631. export class MultiRenderTarget extends RenderTargetTexture {
  52632. private _internalTextures;
  52633. private _textures;
  52634. private _multiRenderTargetOptions;
  52635. /**
  52636. * Get if draw buffers are currently supported by the used hardware and browser.
  52637. */
  52638. get isSupported(): boolean;
  52639. /**
  52640. * Get the list of textures generated by the multi render target.
  52641. */
  52642. get textures(): Texture[];
  52643. /**
  52644. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  52645. */
  52646. get depthTexture(): Texture;
  52647. /**
  52648. * Set the wrapping mode on U of all the textures we are rendering to.
  52649. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52650. */
  52651. set wrapU(wrap: number);
  52652. /**
  52653. * Set the wrapping mode on V of all the textures we are rendering to.
  52654. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52655. */
  52656. set wrapV(wrap: number);
  52657. /**
  52658. * Instantiate a new multi render target texture.
  52659. * A multi render target, like a render target provides the ability to render to a texture.
  52660. * Unlike the render target, it can render to several draw buffers in one draw.
  52661. * This is specially interesting in deferred rendering or for any effects requiring more than
  52662. * just one color from a single pass.
  52663. * @param name Define the name of the texture
  52664. * @param size Define the size of the buffers to render to
  52665. * @param count Define the number of target we are rendering into
  52666. * @param scene Define the scene the texture belongs to
  52667. * @param options Define the options used to create the multi render target
  52668. */
  52669. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  52670. /** @hidden */
  52671. _rebuild(): void;
  52672. private _createInternalTextures;
  52673. private _createTextures;
  52674. /**
  52675. * Define the number of samples used if MSAA is enabled.
  52676. */
  52677. get samples(): number;
  52678. set samples(value: number);
  52679. /**
  52680. * Resize all the textures in the multi render target.
  52681. * Be carrefull as it will recreate all the data in the new texture.
  52682. * @param size Define the new size
  52683. */
  52684. resize(size: any): void;
  52685. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  52686. /**
  52687. * Dispose the render targets and their associated resources
  52688. */
  52689. dispose(): void;
  52690. /**
  52691. * Release all the underlying texture used as draw buffers.
  52692. */
  52693. releaseInternalTextures(): void;
  52694. }
  52695. }
  52696. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  52697. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52698. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  52699. import { Nullable } from "babylonjs/types";
  52700. module "babylonjs/Engines/thinEngine" {
  52701. interface ThinEngine {
  52702. /**
  52703. * Unbind a list of render target textures from the webGL context
  52704. * This is used only when drawBuffer extension or webGL2 are active
  52705. * @param textures defines the render target textures to unbind
  52706. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52707. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52708. */
  52709. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  52710. /**
  52711. * Create a multi render target texture
  52712. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  52713. * @param size defines the size of the texture
  52714. * @param options defines the creation options
  52715. * @returns the cube texture as an InternalTexture
  52716. */
  52717. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  52718. /**
  52719. * Update the sample count for a given multiple render target texture
  52720. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  52721. * @param textures defines the textures to update
  52722. * @param samples defines the sample count to set
  52723. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  52724. */
  52725. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  52726. }
  52727. }
  52728. }
  52729. declare module "babylonjs/Engines/Extensions/engine.views" {
  52730. import { Camera } from "babylonjs/Cameras/camera";
  52731. import { Nullable } from "babylonjs/types";
  52732. /**
  52733. * Class used to define an additional view for the engine
  52734. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52735. */
  52736. export class EngineView {
  52737. /** Defines the canvas where to render the view */
  52738. target: HTMLCanvasElement;
  52739. /** Defines an optional camera used to render the view (will use active camera else) */
  52740. camera?: Camera;
  52741. }
  52742. module "babylonjs/Engines/engine" {
  52743. interface Engine {
  52744. /**
  52745. * Gets or sets the HTML element to use for attaching events
  52746. */
  52747. inputElement: Nullable<HTMLElement>;
  52748. /**
  52749. * Gets the current engine view
  52750. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52751. */
  52752. activeView: Nullable<EngineView>;
  52753. /** Gets or sets the list of views */
  52754. views: EngineView[];
  52755. /**
  52756. * Register a new child canvas
  52757. * @param canvas defines the canvas to register
  52758. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52759. * @returns the associated view
  52760. */
  52761. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52762. /**
  52763. * Remove a registered child canvas
  52764. * @param canvas defines the canvas to remove
  52765. * @returns the current engine
  52766. */
  52767. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52768. }
  52769. }
  52770. }
  52771. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  52772. import { Nullable } from "babylonjs/types";
  52773. module "babylonjs/Engines/engine" {
  52774. interface Engine {
  52775. /** @hidden */
  52776. _excludedCompressedTextures: string[];
  52777. /** @hidden */
  52778. _textureFormatInUse: string;
  52779. /**
  52780. * Gets the list of texture formats supported
  52781. */
  52782. readonly texturesSupported: Array<string>;
  52783. /**
  52784. * Gets the texture format in use
  52785. */
  52786. readonly textureFormatInUse: Nullable<string>;
  52787. /**
  52788. * Set the compressed texture extensions or file names to skip.
  52789. *
  52790. * @param skippedFiles defines the list of those texture files you want to skip
  52791. * Example: [".dds", ".env", "myfile.png"]
  52792. */
  52793. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52794. /**
  52795. * Set the compressed texture format to use, based on the formats you have, and the formats
  52796. * supported by the hardware / browser.
  52797. *
  52798. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52799. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52800. * to API arguments needed to compressed textures. This puts the burden on the container
  52801. * generator to house the arcane code for determining these for current & future formats.
  52802. *
  52803. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52804. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52805. *
  52806. * Note: The result of this call is not taken into account when a texture is base64.
  52807. *
  52808. * @param formatsAvailable defines the list of those format families you have created
  52809. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52810. *
  52811. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52812. * @returns The extension selected.
  52813. */
  52814. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52815. }
  52816. }
  52817. }
  52818. declare module "babylonjs/Engines/Extensions/index" {
  52819. export * from "babylonjs/Engines/Extensions/engine.alpha";
  52820. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  52821. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  52822. export * from "babylonjs/Engines/Extensions/engine.multiview";
  52823. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  52824. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52825. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  52826. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  52827. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  52828. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  52829. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  52830. export * from "babylonjs/Engines/Extensions/engine.webVR";
  52831. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  52832. export * from "babylonjs/Engines/Extensions/engine.views";
  52833. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  52834. import "babylonjs/Engines/Extensions/engine.textureSelector";
  52835. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  52836. }
  52837. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  52838. import { Nullable } from "babylonjs/types";
  52839. /**
  52840. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52841. */
  52842. export interface CubeMapInfo {
  52843. /**
  52844. * The pixel array for the front face.
  52845. * This is stored in format, left to right, up to down format.
  52846. */
  52847. front: Nullable<ArrayBufferView>;
  52848. /**
  52849. * The pixel array for the back face.
  52850. * This is stored in format, left to right, up to down format.
  52851. */
  52852. back: Nullable<ArrayBufferView>;
  52853. /**
  52854. * The pixel array for the left face.
  52855. * This is stored in format, left to right, up to down format.
  52856. */
  52857. left: Nullable<ArrayBufferView>;
  52858. /**
  52859. * The pixel array for the right face.
  52860. * This is stored in format, left to right, up to down format.
  52861. */
  52862. right: Nullable<ArrayBufferView>;
  52863. /**
  52864. * The pixel array for the up face.
  52865. * This is stored in format, left to right, up to down format.
  52866. */
  52867. up: Nullable<ArrayBufferView>;
  52868. /**
  52869. * The pixel array for the down face.
  52870. * This is stored in format, left to right, up to down format.
  52871. */
  52872. down: Nullable<ArrayBufferView>;
  52873. /**
  52874. * The size of the cubemap stored.
  52875. *
  52876. * Each faces will be size * size pixels.
  52877. */
  52878. size: number;
  52879. /**
  52880. * The format of the texture.
  52881. *
  52882. * RGBA, RGB.
  52883. */
  52884. format: number;
  52885. /**
  52886. * The type of the texture data.
  52887. *
  52888. * UNSIGNED_INT, FLOAT.
  52889. */
  52890. type: number;
  52891. /**
  52892. * Specifies whether the texture is in gamma space.
  52893. */
  52894. gammaSpace: boolean;
  52895. }
  52896. /**
  52897. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52898. */
  52899. export class PanoramaToCubeMapTools {
  52900. private static FACE_LEFT;
  52901. private static FACE_RIGHT;
  52902. private static FACE_FRONT;
  52903. private static FACE_BACK;
  52904. private static FACE_DOWN;
  52905. private static FACE_UP;
  52906. /**
  52907. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52908. *
  52909. * @param float32Array The source data.
  52910. * @param inputWidth The width of the input panorama.
  52911. * @param inputHeight The height of the input panorama.
  52912. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52913. * @return The cubemap data
  52914. */
  52915. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52916. private static CreateCubemapTexture;
  52917. private static CalcProjectionSpherical;
  52918. }
  52919. }
  52920. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  52921. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52923. import { Nullable } from "babylonjs/types";
  52924. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52925. /**
  52926. * Helper class dealing with the extraction of spherical polynomial dataArray
  52927. * from a cube map.
  52928. */
  52929. export class CubeMapToSphericalPolynomialTools {
  52930. private static FileFaces;
  52931. /**
  52932. * Converts a texture to the according Spherical Polynomial data.
  52933. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52934. *
  52935. * @param texture The texture to extract the information from.
  52936. * @return The Spherical Polynomial data.
  52937. */
  52938. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52939. /**
  52940. * Converts a cubemap to the according Spherical Polynomial data.
  52941. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52942. *
  52943. * @param cubeInfo The Cube map to extract the information from.
  52944. * @return The Spherical Polynomial data.
  52945. */
  52946. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52947. }
  52948. }
  52949. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  52950. import { Nullable } from "babylonjs/types";
  52951. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52952. module "babylonjs/Materials/Textures/baseTexture" {
  52953. interface BaseTexture {
  52954. /**
  52955. * Get the polynomial representation of the texture data.
  52956. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52957. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52958. */
  52959. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52960. }
  52961. }
  52962. }
  52963. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  52964. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52965. /** @hidden */
  52966. export var rgbdEncodePixelShader: {
  52967. name: string;
  52968. shader: string;
  52969. };
  52970. }
  52971. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  52972. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52973. /** @hidden */
  52974. export var rgbdDecodePixelShader: {
  52975. name: string;
  52976. shader: string;
  52977. };
  52978. }
  52979. declare module "babylonjs/Misc/environmentTextureTools" {
  52980. import { Nullable } from "babylonjs/types";
  52981. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52982. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52983. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52984. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  52985. import "babylonjs/Engines/Extensions/engine.readTexture";
  52986. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52987. import "babylonjs/Shaders/rgbdEncode.fragment";
  52988. import "babylonjs/Shaders/rgbdDecode.fragment";
  52989. /**
  52990. * Raw texture data and descriptor sufficient for WebGL texture upload
  52991. */
  52992. export interface EnvironmentTextureInfo {
  52993. /**
  52994. * Version of the environment map
  52995. */
  52996. version: number;
  52997. /**
  52998. * Width of image
  52999. */
  53000. width: number;
  53001. /**
  53002. * Irradiance information stored in the file.
  53003. */
  53004. irradiance: any;
  53005. /**
  53006. * Specular information stored in the file.
  53007. */
  53008. specular: any;
  53009. }
  53010. /**
  53011. * Defines One Image in the file. It requires only the position in the file
  53012. * as well as the length.
  53013. */
  53014. interface BufferImageData {
  53015. /**
  53016. * Length of the image data.
  53017. */
  53018. length: number;
  53019. /**
  53020. * Position of the data from the null terminator delimiting the end of the JSON.
  53021. */
  53022. position: number;
  53023. }
  53024. /**
  53025. * Defines the specular data enclosed in the file.
  53026. * This corresponds to the version 1 of the data.
  53027. */
  53028. export interface EnvironmentTextureSpecularInfoV1 {
  53029. /**
  53030. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53031. */
  53032. specularDataPosition?: number;
  53033. /**
  53034. * This contains all the images data needed to reconstruct the cubemap.
  53035. */
  53036. mipmaps: Array<BufferImageData>;
  53037. /**
  53038. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53039. */
  53040. lodGenerationScale: number;
  53041. }
  53042. /**
  53043. * Sets of helpers addressing the serialization and deserialization of environment texture
  53044. * stored in a BabylonJS env file.
  53045. * Those files are usually stored as .env files.
  53046. */
  53047. export class EnvironmentTextureTools {
  53048. /**
  53049. * Magic number identifying the env file.
  53050. */
  53051. private static _MagicBytes;
  53052. /**
  53053. * Gets the environment info from an env file.
  53054. * @param data The array buffer containing the .env bytes.
  53055. * @returns the environment file info (the json header) if successfully parsed.
  53056. */
  53057. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53058. /**
  53059. * Creates an environment texture from a loaded cube texture.
  53060. * @param texture defines the cube texture to convert in env file
  53061. * @return a promise containing the environment data if succesfull.
  53062. */
  53063. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53064. /**
  53065. * Creates a JSON representation of the spherical data.
  53066. * @param texture defines the texture containing the polynomials
  53067. * @return the JSON representation of the spherical info
  53068. */
  53069. private static _CreateEnvTextureIrradiance;
  53070. /**
  53071. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53072. * @param data the image data
  53073. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53074. * @return the views described by info providing access to the underlying buffer
  53075. */
  53076. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53077. /**
  53078. * Uploads the texture info contained in the env file to the GPU.
  53079. * @param texture defines the internal texture to upload to
  53080. * @param data defines the data to load
  53081. * @param info defines the texture info retrieved through the GetEnvInfo method
  53082. * @returns a promise
  53083. */
  53084. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53085. private static _OnImageReadyAsync;
  53086. /**
  53087. * Uploads the levels of image data to the GPU.
  53088. * @param texture defines the internal texture to upload to
  53089. * @param imageData defines the array buffer views of image data [mipmap][face]
  53090. * @returns a promise
  53091. */
  53092. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53093. /**
  53094. * Uploads spherical polynomials information to the texture.
  53095. * @param texture defines the texture we are trying to upload the information to
  53096. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53097. */
  53098. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53099. /** @hidden */
  53100. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53101. }
  53102. }
  53103. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  53104. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53105. /** @hidden */
  53106. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  53107. private _genericAttributeLocation;
  53108. private _varyingLocationCount;
  53109. private _varyingLocationMap;
  53110. private _replacements;
  53111. private _textureCount;
  53112. private _uniforms;
  53113. lineProcessor(line: string): string;
  53114. attributeProcessor(attribute: string): string;
  53115. varyingProcessor(varying: string, isFragment: boolean): string;
  53116. uniformProcessor(uniform: string): string;
  53117. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  53118. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  53119. }
  53120. }
  53121. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53122. /**
  53123. * Class used to inline functions in shader code
  53124. */
  53125. export class ShaderCodeInliner {
  53126. private static readonly _RegexpFindFunctionNameAndType;
  53127. private _sourceCode;
  53128. private _functionDescr;
  53129. private _numMaxIterations;
  53130. /** Gets or sets the token used to mark the functions to inline */
  53131. inlineToken: string;
  53132. /** Gets or sets the debug mode */
  53133. debug: boolean;
  53134. /** Gets the code after the inlining process */
  53135. get code(): string;
  53136. /**
  53137. * Initializes the inliner
  53138. * @param sourceCode shader code source to inline
  53139. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53140. */
  53141. constructor(sourceCode: string, numMaxIterations?: number);
  53142. /**
  53143. * Start the processing of the shader code
  53144. */
  53145. processCode(): void;
  53146. private _collectFunctions;
  53147. private _processInlining;
  53148. private _extractBetweenMarkers;
  53149. private _skipWhitespaces;
  53150. private _removeComments;
  53151. private _replaceFunctionCallsByCode;
  53152. private _findBackward;
  53153. private _escapeRegExp;
  53154. private _replaceNames;
  53155. }
  53156. }
  53157. declare module "babylonjs/Engines/nativeEngine" {
  53158. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53159. import { Engine } from "babylonjs/Engines/engine";
  53160. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53161. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53162. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53163. import { Effect } from "babylonjs/Materials/effect";
  53164. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53165. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53166. import { IColor4Like } from "babylonjs/Maths/math.like";
  53167. import { Scene } from "babylonjs/scene";
  53168. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53169. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53170. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53171. /**
  53172. * Container for accessors for natively-stored mesh data buffers.
  53173. */
  53174. class NativeDataBuffer extends DataBuffer {
  53175. /**
  53176. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53177. */
  53178. nativeIndexBuffer?: any;
  53179. /**
  53180. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53181. */
  53182. nativeVertexBuffer?: any;
  53183. }
  53184. /** @hidden */
  53185. class NativeTexture extends InternalTexture {
  53186. getInternalTexture(): InternalTexture;
  53187. getViewCount(): number;
  53188. }
  53189. /** @hidden */
  53190. export class NativeEngine extends Engine {
  53191. private readonly _native;
  53192. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53193. private readonly INVALID_HANDLE;
  53194. getHardwareScalingLevel(): number;
  53195. constructor();
  53196. dispose(): void;
  53197. /**
  53198. * Can be used to override the current requestAnimationFrame requester.
  53199. * @hidden
  53200. */
  53201. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53202. /**
  53203. * Override default engine behavior.
  53204. * @param color
  53205. * @param backBuffer
  53206. * @param depth
  53207. * @param stencil
  53208. */
  53209. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53210. /**
  53211. * Gets host document
  53212. * @returns the host document object
  53213. */
  53214. getHostDocument(): Nullable<Document>;
  53215. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53216. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53217. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53218. recordVertexArrayObject(vertexBuffers: {
  53219. [key: string]: VertexBuffer;
  53220. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53221. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53222. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53223. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53224. /**
  53225. * Draw a list of indexed primitives
  53226. * @param fillMode defines the primitive to use
  53227. * @param indexStart defines the starting index
  53228. * @param indexCount defines the number of index to draw
  53229. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53230. */
  53231. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53232. /**
  53233. * Draw a list of unindexed primitives
  53234. * @param fillMode defines the primitive to use
  53235. * @param verticesStart defines the index of first vertex to draw
  53236. * @param verticesCount defines the count of vertices to draw
  53237. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53238. */
  53239. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53240. createPipelineContext(): IPipelineContext;
  53241. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53242. /** @hidden */
  53243. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53244. /** @hidden */
  53245. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53246. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53247. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53248. protected _setProgram(program: WebGLProgram): void;
  53249. _releaseEffect(effect: Effect): void;
  53250. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53251. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53252. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53253. bindSamplers(effect: Effect): void;
  53254. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53255. getRenderWidth(useScreen?: boolean): number;
  53256. getRenderHeight(useScreen?: boolean): number;
  53257. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53258. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53259. /**
  53260. * Set the z offset to apply to current rendering
  53261. * @param value defines the offset to apply
  53262. */
  53263. setZOffset(value: number): void;
  53264. /**
  53265. * Gets the current value of the zOffset
  53266. * @returns the current zOffset state
  53267. */
  53268. getZOffset(): number;
  53269. /**
  53270. * Enable or disable depth buffering
  53271. * @param enable defines the state to set
  53272. */
  53273. setDepthBuffer(enable: boolean): void;
  53274. /**
  53275. * Gets a boolean indicating if depth writing is enabled
  53276. * @returns the current depth writing state
  53277. */
  53278. getDepthWrite(): boolean;
  53279. /**
  53280. * Enable or disable depth writing
  53281. * @param enable defines the state to set
  53282. */
  53283. setDepthWrite(enable: boolean): void;
  53284. /**
  53285. * Enable or disable color writing
  53286. * @param enable defines the state to set
  53287. */
  53288. setColorWrite(enable: boolean): void;
  53289. /**
  53290. * Gets a boolean indicating if color writing is enabled
  53291. * @returns the current color writing state
  53292. */
  53293. getColorWrite(): boolean;
  53294. /**
  53295. * Sets alpha constants used by some alpha blending modes
  53296. * @param r defines the red component
  53297. * @param g defines the green component
  53298. * @param b defines the blue component
  53299. * @param a defines the alpha component
  53300. */
  53301. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53302. /**
  53303. * Sets the current alpha mode
  53304. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53305. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53306. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53307. */
  53308. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53309. /**
  53310. * Gets the current alpha mode
  53311. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53312. * @returns the current alpha mode
  53313. */
  53314. getAlphaMode(): number;
  53315. setInt(uniform: WebGLUniformLocation, int: number): void;
  53316. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53317. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53318. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53319. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53320. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53321. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53322. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53323. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53324. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53325. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53326. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53327. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53328. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53329. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53330. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53331. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53332. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53333. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53334. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53335. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53336. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53337. wipeCaches(bruteForce?: boolean): void;
  53338. _createTexture(): WebGLTexture;
  53339. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53340. /**
  53341. * Usually called from Texture.ts.
  53342. * Passed information to create a WebGLTexture
  53343. * @param url defines a value which contains one of the following:
  53344. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53345. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53346. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53347. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53348. * @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)
  53349. * @param scene needed for loading to the correct scene
  53350. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53351. * @param onLoad optional callback to be called upon successful completion
  53352. * @param onError optional callback to be called upon failure
  53353. * @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
  53354. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53355. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53356. * @param forcedExtension defines the extension to use to pick the right loader
  53357. * @param mimeType defines an optional mime type
  53358. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53359. */
  53360. 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;
  53361. /**
  53362. * Creates a cube texture
  53363. * @param rootUrl defines the url where the files to load is located
  53364. * @param scene defines the current scene
  53365. * @param files defines the list of files to load (1 per face)
  53366. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53367. * @param onLoad defines an optional callback raised when the texture is loaded
  53368. * @param onError defines an optional callback raised if there is an issue to load the texture
  53369. * @param format defines the format of the data
  53370. * @param forcedExtension defines the extension to use to pick the right loader
  53371. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53372. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53373. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53374. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53375. * @returns the cube texture as an InternalTexture
  53376. */
  53377. 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;
  53378. private _getSamplingFilter;
  53379. private static _GetNativeTextureFormat;
  53380. createRenderTargetTexture(size: number | {
  53381. width: number;
  53382. height: number;
  53383. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53384. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53385. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53386. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53387. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53388. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53389. /**
  53390. * Updates a dynamic vertex buffer.
  53391. * @param vertexBuffer the vertex buffer to update
  53392. * @param data the data used to update the vertex buffer
  53393. * @param byteOffset the byte offset of the data (optional)
  53394. * @param byteLength the byte length of the data (optional)
  53395. */
  53396. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53397. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53398. private _updateAnisotropicLevel;
  53399. private _getAddressMode;
  53400. /** @hidden */
  53401. _bindTexture(channel: number, texture: InternalTexture): void;
  53402. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53403. releaseEffects(): void;
  53404. /** @hidden */
  53405. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53406. /** @hidden */
  53407. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53408. /** @hidden */
  53409. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53410. /** @hidden */
  53411. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53412. }
  53413. }
  53414. declare module "babylonjs/Engines/index" {
  53415. export * from "babylonjs/Engines/constants";
  53416. export * from "babylonjs/Engines/engineCapabilities";
  53417. export * from "babylonjs/Engines/instancingAttributeInfo";
  53418. export * from "babylonjs/Engines/thinEngine";
  53419. export * from "babylonjs/Engines/engine";
  53420. export * from "babylonjs/Engines/engineStore";
  53421. export * from "babylonjs/Engines/nullEngine";
  53422. export * from "babylonjs/Engines/Extensions/index";
  53423. export * from "babylonjs/Engines/IPipelineContext";
  53424. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53425. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53426. export * from "babylonjs/Engines/nativeEngine";
  53427. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  53428. }
  53429. declare module "babylonjs/Events/clipboardEvents" {
  53430. /**
  53431. * Gather the list of clipboard event types as constants.
  53432. */
  53433. export class ClipboardEventTypes {
  53434. /**
  53435. * The clipboard event is fired when a copy command is active (pressed).
  53436. */
  53437. static readonly COPY: number;
  53438. /**
  53439. * The clipboard event is fired when a cut command is active (pressed).
  53440. */
  53441. static readonly CUT: number;
  53442. /**
  53443. * The clipboard event is fired when a paste command is active (pressed).
  53444. */
  53445. static readonly PASTE: number;
  53446. }
  53447. /**
  53448. * This class is used to store clipboard related info for the onClipboardObservable event.
  53449. */
  53450. export class ClipboardInfo {
  53451. /**
  53452. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53453. */
  53454. type: number;
  53455. /**
  53456. * Defines the related dom event
  53457. */
  53458. event: ClipboardEvent;
  53459. /**
  53460. *Creates an instance of ClipboardInfo.
  53461. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53462. * @param event Defines the related dom event
  53463. */
  53464. constructor(
  53465. /**
  53466. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53467. */
  53468. type: number,
  53469. /**
  53470. * Defines the related dom event
  53471. */
  53472. event: ClipboardEvent);
  53473. /**
  53474. * Get the clipboard event's type from the keycode.
  53475. * @param keyCode Defines the keyCode for the current keyboard event.
  53476. * @return {number}
  53477. */
  53478. static GetTypeFromCharacter(keyCode: number): number;
  53479. }
  53480. }
  53481. declare module "babylonjs/Events/index" {
  53482. export * from "babylonjs/Events/keyboardEvents";
  53483. export * from "babylonjs/Events/pointerEvents";
  53484. export * from "babylonjs/Events/clipboardEvents";
  53485. }
  53486. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  53487. import { Scene } from "babylonjs/scene";
  53488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53489. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53490. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53491. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53492. /**
  53493. * Google Daydream controller
  53494. */
  53495. export class DaydreamController extends WebVRController {
  53496. /**
  53497. * Base Url for the controller model.
  53498. */
  53499. static MODEL_BASE_URL: string;
  53500. /**
  53501. * File name for the controller model.
  53502. */
  53503. static MODEL_FILENAME: string;
  53504. /**
  53505. * Gamepad Id prefix used to identify Daydream Controller.
  53506. */
  53507. static readonly GAMEPAD_ID_PREFIX: string;
  53508. /**
  53509. * Creates a new DaydreamController from a gamepad
  53510. * @param vrGamepad the gamepad that the controller should be created from
  53511. */
  53512. constructor(vrGamepad: any);
  53513. /**
  53514. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53515. * @param scene scene in which to add meshes
  53516. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53517. */
  53518. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53519. /**
  53520. * Called once for each button that changed state since the last frame
  53521. * @param buttonIdx Which button index changed
  53522. * @param state New state of the button
  53523. * @param changes Which properties on the state changed since last frame
  53524. */
  53525. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53526. }
  53527. }
  53528. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  53529. import { Scene } from "babylonjs/scene";
  53530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53531. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53532. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53533. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53534. /**
  53535. * Gear VR Controller
  53536. */
  53537. export class GearVRController extends WebVRController {
  53538. /**
  53539. * Base Url for the controller model.
  53540. */
  53541. static MODEL_BASE_URL: string;
  53542. /**
  53543. * File name for the controller model.
  53544. */
  53545. static MODEL_FILENAME: string;
  53546. /**
  53547. * Gamepad Id prefix used to identify this controller.
  53548. */
  53549. static readonly GAMEPAD_ID_PREFIX: string;
  53550. private readonly _buttonIndexToObservableNameMap;
  53551. /**
  53552. * Creates a new GearVRController from a gamepad
  53553. * @param vrGamepad the gamepad that the controller should be created from
  53554. */
  53555. constructor(vrGamepad: any);
  53556. /**
  53557. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53558. * @param scene scene in which to add meshes
  53559. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53560. */
  53561. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53562. /**
  53563. * Called once for each button that changed state since the last frame
  53564. * @param buttonIdx Which button index changed
  53565. * @param state New state of the button
  53566. * @param changes Which properties on the state changed since last frame
  53567. */
  53568. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53569. }
  53570. }
  53571. declare module "babylonjs/Gamepads/Controllers/genericController" {
  53572. import { Scene } from "babylonjs/scene";
  53573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53574. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53575. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53576. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53577. /**
  53578. * Generic Controller
  53579. */
  53580. export class GenericController extends WebVRController {
  53581. /**
  53582. * Base Url for the controller model.
  53583. */
  53584. static readonly MODEL_BASE_URL: string;
  53585. /**
  53586. * File name for the controller model.
  53587. */
  53588. static readonly MODEL_FILENAME: string;
  53589. /**
  53590. * Creates a new GenericController from a gamepad
  53591. * @param vrGamepad the gamepad that the controller should be created from
  53592. */
  53593. constructor(vrGamepad: any);
  53594. /**
  53595. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53596. * @param scene scene in which to add meshes
  53597. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53598. */
  53599. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53600. /**
  53601. * Called once for each button that changed state since the last frame
  53602. * @param buttonIdx Which button index changed
  53603. * @param state New state of the button
  53604. * @param changes Which properties on the state changed since last frame
  53605. */
  53606. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53607. }
  53608. }
  53609. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  53610. import { Observable } from "babylonjs/Misc/observable";
  53611. import { Scene } from "babylonjs/scene";
  53612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53613. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53614. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53615. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53616. /**
  53617. * Oculus Touch Controller
  53618. */
  53619. export class OculusTouchController extends WebVRController {
  53620. /**
  53621. * Base Url for the controller model.
  53622. */
  53623. static MODEL_BASE_URL: string;
  53624. /**
  53625. * File name for the left controller model.
  53626. */
  53627. static MODEL_LEFT_FILENAME: string;
  53628. /**
  53629. * File name for the right controller model.
  53630. */
  53631. static MODEL_RIGHT_FILENAME: string;
  53632. /**
  53633. * Base Url for the Quest controller model.
  53634. */
  53635. static QUEST_MODEL_BASE_URL: string;
  53636. /**
  53637. * @hidden
  53638. * If the controllers are running on a device that needs the updated Quest controller models
  53639. */
  53640. static _IsQuest: boolean;
  53641. /**
  53642. * Fired when the secondary trigger on this controller is modified
  53643. */
  53644. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53645. /**
  53646. * Fired when the thumb rest on this controller is modified
  53647. */
  53648. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53649. /**
  53650. * Creates a new OculusTouchController from a gamepad
  53651. * @param vrGamepad the gamepad that the controller should be created from
  53652. */
  53653. constructor(vrGamepad: any);
  53654. /**
  53655. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53656. * @param scene scene in which to add meshes
  53657. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53658. */
  53659. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53660. /**
  53661. * Fired when the A button on this controller is modified
  53662. */
  53663. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53664. /**
  53665. * Fired when the B button on this controller is modified
  53666. */
  53667. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53668. /**
  53669. * Fired when the X button on this controller is modified
  53670. */
  53671. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53672. /**
  53673. * Fired when the Y button on this controller is modified
  53674. */
  53675. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53676. /**
  53677. * Called once for each button that changed state since the last frame
  53678. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53679. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53680. * 2) secondary trigger (same)
  53681. * 3) A (right) X (left), touch, pressed = value
  53682. * 4) B / Y
  53683. * 5) thumb rest
  53684. * @param buttonIdx Which button index changed
  53685. * @param state New state of the button
  53686. * @param changes Which properties on the state changed since last frame
  53687. */
  53688. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53689. }
  53690. }
  53691. declare module "babylonjs/Gamepads/Controllers/viveController" {
  53692. import { Scene } from "babylonjs/scene";
  53693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53694. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53695. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53696. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53697. import { Observable } from "babylonjs/Misc/observable";
  53698. /**
  53699. * Vive Controller
  53700. */
  53701. export class ViveController extends WebVRController {
  53702. /**
  53703. * Base Url for the controller model.
  53704. */
  53705. static MODEL_BASE_URL: string;
  53706. /**
  53707. * File name for the controller model.
  53708. */
  53709. static MODEL_FILENAME: string;
  53710. /**
  53711. * Creates a new ViveController from a gamepad
  53712. * @param vrGamepad the gamepad that the controller should be created from
  53713. */
  53714. constructor(vrGamepad: any);
  53715. /**
  53716. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53717. * @param scene scene in which to add meshes
  53718. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53719. */
  53720. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53721. /**
  53722. * Fired when the left button on this controller is modified
  53723. */
  53724. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53725. /**
  53726. * Fired when the right button on this controller is modified
  53727. */
  53728. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53729. /**
  53730. * Fired when the menu button on this controller is modified
  53731. */
  53732. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53733. /**
  53734. * Called once for each button that changed state since the last frame
  53735. * Vive mapping:
  53736. * 0: touchpad
  53737. * 1: trigger
  53738. * 2: left AND right buttons
  53739. * 3: menu button
  53740. * @param buttonIdx Which button index changed
  53741. * @param state New state of the button
  53742. * @param changes Which properties on the state changed since last frame
  53743. */
  53744. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53745. }
  53746. }
  53747. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  53748. import { Observable } from "babylonjs/Misc/observable";
  53749. import { Scene } from "babylonjs/scene";
  53750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53751. import { Ray } from "babylonjs/Culling/ray";
  53752. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53753. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53754. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53755. /**
  53756. * Defines the WindowsMotionController object that the state of the windows motion controller
  53757. */
  53758. export class WindowsMotionController extends WebVRController {
  53759. /**
  53760. * The base url used to load the left and right controller models
  53761. */
  53762. static MODEL_BASE_URL: string;
  53763. /**
  53764. * The name of the left controller model file
  53765. */
  53766. static MODEL_LEFT_FILENAME: string;
  53767. /**
  53768. * The name of the right controller model file
  53769. */
  53770. static MODEL_RIGHT_FILENAME: string;
  53771. /**
  53772. * The controller name prefix for this controller type
  53773. */
  53774. static readonly GAMEPAD_ID_PREFIX: string;
  53775. /**
  53776. * The controller id pattern for this controller type
  53777. */
  53778. private static readonly GAMEPAD_ID_PATTERN;
  53779. private _loadedMeshInfo;
  53780. protected readonly _mapping: {
  53781. buttons: string[];
  53782. buttonMeshNames: {
  53783. trigger: string;
  53784. menu: string;
  53785. grip: string;
  53786. thumbstick: string;
  53787. trackpad: string;
  53788. };
  53789. buttonObservableNames: {
  53790. trigger: string;
  53791. menu: string;
  53792. grip: string;
  53793. thumbstick: string;
  53794. trackpad: string;
  53795. };
  53796. axisMeshNames: string[];
  53797. pointingPoseMeshName: string;
  53798. };
  53799. /**
  53800. * Fired when the trackpad on this controller is clicked
  53801. */
  53802. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53803. /**
  53804. * Fired when the trackpad on this controller is modified
  53805. */
  53806. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53807. /**
  53808. * The current x and y values of this controller's trackpad
  53809. */
  53810. trackpad: StickValues;
  53811. /**
  53812. * Creates a new WindowsMotionController from a gamepad
  53813. * @param vrGamepad the gamepad that the controller should be created from
  53814. */
  53815. constructor(vrGamepad: any);
  53816. /**
  53817. * Fired when the trigger on this controller is modified
  53818. */
  53819. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53820. /**
  53821. * Fired when the menu button on this controller is modified
  53822. */
  53823. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53824. /**
  53825. * Fired when the grip button on this controller is modified
  53826. */
  53827. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53828. /**
  53829. * Fired when the thumbstick button on this controller is modified
  53830. */
  53831. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53832. /**
  53833. * Fired when the touchpad button on this controller is modified
  53834. */
  53835. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53836. /**
  53837. * Fired when the touchpad values on this controller are modified
  53838. */
  53839. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53840. protected _updateTrackpad(): void;
  53841. /**
  53842. * Called once per frame by the engine.
  53843. */
  53844. update(): void;
  53845. /**
  53846. * Called once for each button that changed state since the last frame
  53847. * @param buttonIdx Which button index changed
  53848. * @param state New state of the button
  53849. * @param changes Which properties on the state changed since last frame
  53850. */
  53851. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53852. /**
  53853. * Moves the buttons on the controller mesh based on their current state
  53854. * @param buttonName the name of the button to move
  53855. * @param buttonValue the value of the button which determines the buttons new position
  53856. */
  53857. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53858. /**
  53859. * Moves the axis on the controller mesh based on its current state
  53860. * @param axis the index of the axis
  53861. * @param axisValue the value of the axis which determines the meshes new position
  53862. * @hidden
  53863. */
  53864. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53865. /**
  53866. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53867. * @param scene scene in which to add meshes
  53868. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53869. */
  53870. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53871. /**
  53872. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53873. * can be transformed by button presses and axes values, based on this._mapping.
  53874. *
  53875. * @param scene scene in which the meshes exist
  53876. * @param meshes list of meshes that make up the controller model to process
  53877. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53878. */
  53879. private processModel;
  53880. private createMeshInfo;
  53881. /**
  53882. * Gets the ray of the controller in the direction the controller is pointing
  53883. * @param length the length the resulting ray should be
  53884. * @returns a ray in the direction the controller is pointing
  53885. */
  53886. getForwardRay(length?: number): Ray;
  53887. /**
  53888. * Disposes of the controller
  53889. */
  53890. dispose(): void;
  53891. }
  53892. /**
  53893. * This class represents a new windows motion controller in XR.
  53894. */
  53895. export class XRWindowsMotionController extends WindowsMotionController {
  53896. /**
  53897. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53898. */
  53899. protected readonly _mapping: {
  53900. buttons: string[];
  53901. buttonMeshNames: {
  53902. trigger: string;
  53903. menu: string;
  53904. grip: string;
  53905. thumbstick: string;
  53906. trackpad: string;
  53907. };
  53908. buttonObservableNames: {
  53909. trigger: string;
  53910. menu: string;
  53911. grip: string;
  53912. thumbstick: string;
  53913. trackpad: string;
  53914. };
  53915. axisMeshNames: string[];
  53916. pointingPoseMeshName: string;
  53917. };
  53918. /**
  53919. * Construct a new XR-Based windows motion controller
  53920. *
  53921. * @param gamepadInfo the gamepad object from the browser
  53922. */
  53923. constructor(gamepadInfo: any);
  53924. /**
  53925. * holds the thumbstick values (X,Y)
  53926. */
  53927. thumbstickValues: StickValues;
  53928. /**
  53929. * Fired when the thumbstick on this controller is clicked
  53930. */
  53931. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53932. /**
  53933. * Fired when the thumbstick on this controller is modified
  53934. */
  53935. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53936. /**
  53937. * Fired when the touchpad button on this controller is modified
  53938. */
  53939. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53940. /**
  53941. * Fired when the touchpad values on this controller are modified
  53942. */
  53943. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53944. /**
  53945. * Fired when the thumbstick button on this controller is modified
  53946. * here to prevent breaking changes
  53947. */
  53948. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53949. /**
  53950. * updating the thumbstick(!) and not the trackpad.
  53951. * This is named this way due to the difference between WebVR and XR and to avoid
  53952. * changing the parent class.
  53953. */
  53954. protected _updateTrackpad(): void;
  53955. /**
  53956. * Disposes the class with joy
  53957. */
  53958. dispose(): void;
  53959. }
  53960. }
  53961. declare module "babylonjs/Gamepads/Controllers/index" {
  53962. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  53963. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  53964. export * from "babylonjs/Gamepads/Controllers/genericController";
  53965. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  53966. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53967. export * from "babylonjs/Gamepads/Controllers/viveController";
  53968. export * from "babylonjs/Gamepads/Controllers/webVRController";
  53969. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  53970. }
  53971. declare module "babylonjs/Gamepads/index" {
  53972. export * from "babylonjs/Gamepads/Controllers/index";
  53973. export * from "babylonjs/Gamepads/gamepad";
  53974. export * from "babylonjs/Gamepads/gamepadManager";
  53975. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  53976. export * from "babylonjs/Gamepads/xboxGamepad";
  53977. export * from "babylonjs/Gamepads/dualShockGamepad";
  53978. }
  53979. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  53980. import { Scene } from "babylonjs/scene";
  53981. import { Vector4 } from "babylonjs/Maths/math.vector";
  53982. import { Color4 } from "babylonjs/Maths/math.color";
  53983. import { Mesh } from "babylonjs/Meshes/mesh";
  53984. import { Nullable } from "babylonjs/types";
  53985. /**
  53986. * Class containing static functions to help procedurally build meshes
  53987. */
  53988. export class PolyhedronBuilder {
  53989. /**
  53990. * Creates a polyhedron mesh
  53991. * * 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
  53992. * * The parameter `size` (positive float, default 1) sets the polygon size
  53993. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53994. * * 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`
  53995. * * 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
  53996. * * 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)`)
  53997. * * 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
  53998. * * 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
  53999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54002. * @param name defines the name of the mesh
  54003. * @param options defines the options used to create the mesh
  54004. * @param scene defines the hosting scene
  54005. * @returns the polyhedron mesh
  54006. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54007. */
  54008. static CreatePolyhedron(name: string, options: {
  54009. type?: number;
  54010. size?: number;
  54011. sizeX?: number;
  54012. sizeY?: number;
  54013. sizeZ?: number;
  54014. custom?: any;
  54015. faceUV?: Vector4[];
  54016. faceColors?: Color4[];
  54017. flat?: boolean;
  54018. updatable?: boolean;
  54019. sideOrientation?: number;
  54020. frontUVs?: Vector4;
  54021. backUVs?: Vector4;
  54022. }, scene?: Nullable<Scene>): Mesh;
  54023. }
  54024. }
  54025. declare module "babylonjs/Gizmos/scaleGizmo" {
  54026. import { Observable } from "babylonjs/Misc/observable";
  54027. import { Nullable } from "babylonjs/types";
  54028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54029. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54030. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54031. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54032. /**
  54033. * Gizmo that enables scaling a mesh along 3 axis
  54034. */
  54035. export class ScaleGizmo extends Gizmo {
  54036. /**
  54037. * Internal gizmo used for interactions on the x axis
  54038. */
  54039. xGizmo: AxisScaleGizmo;
  54040. /**
  54041. * Internal gizmo used for interactions on the y axis
  54042. */
  54043. yGizmo: AxisScaleGizmo;
  54044. /**
  54045. * Internal gizmo used for interactions on the z axis
  54046. */
  54047. zGizmo: AxisScaleGizmo;
  54048. /**
  54049. * Internal gizmo used to scale all axis equally
  54050. */
  54051. uniformScaleGizmo: AxisScaleGizmo;
  54052. private _meshAttached;
  54053. private _updateGizmoRotationToMatchAttachedMesh;
  54054. private _snapDistance;
  54055. private _scaleRatio;
  54056. private _uniformScalingMesh;
  54057. private _octahedron;
  54058. private _sensitivity;
  54059. /** Fires an event when any of it's sub gizmos are dragged */
  54060. onDragStartObservable: Observable<unknown>;
  54061. /** Fires an event when any of it's sub gizmos are released from dragging */
  54062. onDragEndObservable: Observable<unknown>;
  54063. get attachedMesh(): Nullable<AbstractMesh>;
  54064. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54065. /**
  54066. * Creates a ScaleGizmo
  54067. * @param gizmoLayer The utility layer the gizmo will be added to
  54068. */
  54069. constructor(gizmoLayer?: UtilityLayerRenderer);
  54070. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54071. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54072. /**
  54073. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54074. */
  54075. set snapDistance(value: number);
  54076. get snapDistance(): number;
  54077. /**
  54078. * Ratio for the scale of the gizmo (Default: 1)
  54079. */
  54080. set scaleRatio(value: number);
  54081. get scaleRatio(): number;
  54082. /**
  54083. * Sensitivity factor for dragging (Default: 1)
  54084. */
  54085. set sensitivity(value: number);
  54086. get sensitivity(): number;
  54087. /**
  54088. * Disposes of the gizmo
  54089. */
  54090. dispose(): void;
  54091. }
  54092. }
  54093. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54094. import { Observable } from "babylonjs/Misc/observable";
  54095. import { Nullable } from "babylonjs/types";
  54096. import { Vector3 } from "babylonjs/Maths/math.vector";
  54097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54098. import { Mesh } from "babylonjs/Meshes/mesh";
  54099. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54100. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54101. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54102. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54103. import { Color3 } from "babylonjs/Maths/math.color";
  54104. /**
  54105. * Single axis scale gizmo
  54106. */
  54107. export class AxisScaleGizmo extends Gizmo {
  54108. /**
  54109. * Drag behavior responsible for the gizmos dragging interactions
  54110. */
  54111. dragBehavior: PointerDragBehavior;
  54112. private _pointerObserver;
  54113. /**
  54114. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54115. */
  54116. snapDistance: number;
  54117. /**
  54118. * Event that fires each time the gizmo snaps to a new location.
  54119. * * snapDistance is the the change in distance
  54120. */
  54121. onSnapObservable: Observable<{
  54122. snapDistance: number;
  54123. }>;
  54124. /**
  54125. * If the scaling operation should be done on all axis (default: false)
  54126. */
  54127. uniformScaling: boolean;
  54128. /**
  54129. * Custom sensitivity value for the drag strength
  54130. */
  54131. sensitivity: number;
  54132. private _isEnabled;
  54133. private _parent;
  54134. private _arrow;
  54135. private _coloredMaterial;
  54136. private _hoverMaterial;
  54137. /**
  54138. * Creates an AxisScaleGizmo
  54139. * @param gizmoLayer The utility layer the gizmo will be added to
  54140. * @param dragAxis The axis which the gizmo will be able to scale on
  54141. * @param color The color of the gizmo
  54142. */
  54143. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54144. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54145. /**
  54146. * If the gizmo is enabled
  54147. */
  54148. set isEnabled(value: boolean);
  54149. get isEnabled(): boolean;
  54150. /**
  54151. * Disposes of the gizmo
  54152. */
  54153. dispose(): void;
  54154. /**
  54155. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54156. * @param mesh The mesh to replace the default mesh of the gizmo
  54157. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54158. */
  54159. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54160. }
  54161. }
  54162. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54163. import { Observable } from "babylonjs/Misc/observable";
  54164. import { Nullable } from "babylonjs/types";
  54165. import { Vector3 } from "babylonjs/Maths/math.vector";
  54166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54167. import { Mesh } from "babylonjs/Meshes/mesh";
  54168. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54169. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54170. import { Color3 } from "babylonjs/Maths/math.color";
  54171. import "babylonjs/Meshes/Builders/boxBuilder";
  54172. /**
  54173. * Bounding box gizmo
  54174. */
  54175. export class BoundingBoxGizmo extends Gizmo {
  54176. private _lineBoundingBox;
  54177. private _rotateSpheresParent;
  54178. private _scaleBoxesParent;
  54179. private _boundingDimensions;
  54180. private _renderObserver;
  54181. private _pointerObserver;
  54182. private _scaleDragSpeed;
  54183. private _tmpQuaternion;
  54184. private _tmpVector;
  54185. private _tmpRotationMatrix;
  54186. /**
  54187. * 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)
  54188. */
  54189. ignoreChildren: boolean;
  54190. /**
  54191. * 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)
  54192. */
  54193. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54194. /**
  54195. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54196. */
  54197. rotationSphereSize: number;
  54198. /**
  54199. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54200. */
  54201. scaleBoxSize: number;
  54202. /**
  54203. * 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)
  54204. */
  54205. fixedDragMeshScreenSize: boolean;
  54206. /**
  54207. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54208. */
  54209. fixedDragMeshScreenSizeDistanceFactor: number;
  54210. /**
  54211. * Fired when a rotation sphere or scale box is dragged
  54212. */
  54213. onDragStartObservable: Observable<{}>;
  54214. /**
  54215. * Fired when a scale box is dragged
  54216. */
  54217. onScaleBoxDragObservable: Observable<{}>;
  54218. /**
  54219. * Fired when a scale box drag is ended
  54220. */
  54221. onScaleBoxDragEndObservable: Observable<{}>;
  54222. /**
  54223. * Fired when a rotation sphere is dragged
  54224. */
  54225. onRotationSphereDragObservable: Observable<{}>;
  54226. /**
  54227. * Fired when a rotation sphere drag is ended
  54228. */
  54229. onRotationSphereDragEndObservable: Observable<{}>;
  54230. /**
  54231. * 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)
  54232. */
  54233. scalePivot: Nullable<Vector3>;
  54234. /**
  54235. * Mesh used as a pivot to rotate the attached mesh
  54236. */
  54237. private _anchorMesh;
  54238. private _existingMeshScale;
  54239. private _dragMesh;
  54240. private pointerDragBehavior;
  54241. private coloredMaterial;
  54242. private hoverColoredMaterial;
  54243. /**
  54244. * Sets the color of the bounding box gizmo
  54245. * @param color the color to set
  54246. */
  54247. setColor(color: Color3): void;
  54248. /**
  54249. * Creates an BoundingBoxGizmo
  54250. * @param gizmoLayer The utility layer the gizmo will be added to
  54251. * @param color The color of the gizmo
  54252. */
  54253. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54254. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54255. private _selectNode;
  54256. /**
  54257. * Updates the bounding box information for the Gizmo
  54258. */
  54259. updateBoundingBox(): void;
  54260. private _updateRotationSpheres;
  54261. private _updateScaleBoxes;
  54262. /**
  54263. * Enables rotation on the specified axis and disables rotation on the others
  54264. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54265. */
  54266. setEnabledRotationAxis(axis: string): void;
  54267. /**
  54268. * Enables/disables scaling
  54269. * @param enable if scaling should be enabled
  54270. * @param homogeneousScaling defines if scaling should only be homogeneous
  54271. */
  54272. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54273. private _updateDummy;
  54274. /**
  54275. * Enables a pointer drag behavior on the bounding box of the gizmo
  54276. */
  54277. enableDragBehavior(): void;
  54278. /**
  54279. * Disposes of the gizmo
  54280. */
  54281. dispose(): void;
  54282. /**
  54283. * 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)
  54284. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54285. * @returns the bounding box mesh with the passed in mesh as a child
  54286. */
  54287. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54288. /**
  54289. * CustomMeshes are not supported by this gizmo
  54290. * @param mesh The mesh to replace the default mesh of the gizmo
  54291. */
  54292. setCustomMesh(mesh: Mesh): void;
  54293. }
  54294. }
  54295. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54296. import { Observable } from "babylonjs/Misc/observable";
  54297. import { Nullable } from "babylonjs/types";
  54298. import { Vector3 } from "babylonjs/Maths/math.vector";
  54299. import { Color3 } from "babylonjs/Maths/math.color";
  54300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54301. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54302. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54303. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54304. import "babylonjs/Meshes/Builders/linesBuilder";
  54305. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54306. /**
  54307. * Single plane rotation gizmo
  54308. */
  54309. export class PlaneRotationGizmo extends Gizmo {
  54310. /**
  54311. * Drag behavior responsible for the gizmos dragging interactions
  54312. */
  54313. dragBehavior: PointerDragBehavior;
  54314. private _pointerObserver;
  54315. /**
  54316. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54317. */
  54318. snapDistance: number;
  54319. /**
  54320. * Event that fires each time the gizmo snaps to a new location.
  54321. * * snapDistance is the the change in distance
  54322. */
  54323. onSnapObservable: Observable<{
  54324. snapDistance: number;
  54325. }>;
  54326. private _isEnabled;
  54327. private _parent;
  54328. /**
  54329. * Creates a PlaneRotationGizmo
  54330. * @param gizmoLayer The utility layer the gizmo will be added to
  54331. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54332. * @param color The color of the gizmo
  54333. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54334. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54335. */
  54336. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54337. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54338. /**
  54339. * If the gizmo is enabled
  54340. */
  54341. set isEnabled(value: boolean);
  54342. get isEnabled(): boolean;
  54343. /**
  54344. * Disposes of the gizmo
  54345. */
  54346. dispose(): void;
  54347. }
  54348. }
  54349. declare module "babylonjs/Gizmos/rotationGizmo" {
  54350. import { Observable } from "babylonjs/Misc/observable";
  54351. import { Nullable } from "babylonjs/types";
  54352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54353. import { Mesh } from "babylonjs/Meshes/mesh";
  54354. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54355. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54356. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54357. /**
  54358. * Gizmo that enables rotating a mesh along 3 axis
  54359. */
  54360. export class RotationGizmo extends Gizmo {
  54361. /**
  54362. * Internal gizmo used for interactions on the x axis
  54363. */
  54364. xGizmo: PlaneRotationGizmo;
  54365. /**
  54366. * Internal gizmo used for interactions on the y axis
  54367. */
  54368. yGizmo: PlaneRotationGizmo;
  54369. /**
  54370. * Internal gizmo used for interactions on the z axis
  54371. */
  54372. zGizmo: PlaneRotationGizmo;
  54373. /** Fires an event when any of it's sub gizmos are dragged */
  54374. onDragStartObservable: Observable<unknown>;
  54375. /** Fires an event when any of it's sub gizmos are released from dragging */
  54376. onDragEndObservable: Observable<unknown>;
  54377. private _meshAttached;
  54378. get attachedMesh(): Nullable<AbstractMesh>;
  54379. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54380. /**
  54381. * Creates a RotationGizmo
  54382. * @param gizmoLayer The utility layer the gizmo will be added to
  54383. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54384. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54385. */
  54386. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54387. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54388. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54389. /**
  54390. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54391. */
  54392. set snapDistance(value: number);
  54393. get snapDistance(): number;
  54394. /**
  54395. * Ratio for the scale of the gizmo (Default: 1)
  54396. */
  54397. set scaleRatio(value: number);
  54398. get scaleRatio(): number;
  54399. /**
  54400. * Disposes of the gizmo
  54401. */
  54402. dispose(): void;
  54403. /**
  54404. * CustomMeshes are not supported by this gizmo
  54405. * @param mesh The mesh to replace the default mesh of the gizmo
  54406. */
  54407. setCustomMesh(mesh: Mesh): void;
  54408. }
  54409. }
  54410. declare module "babylonjs/Gizmos/gizmoManager" {
  54411. import { Observable } from "babylonjs/Misc/observable";
  54412. import { Nullable } from "babylonjs/types";
  54413. import { Scene, IDisposable } from "babylonjs/scene";
  54414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54415. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54416. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54417. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54418. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54419. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54420. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54421. /**
  54422. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54423. */
  54424. export class GizmoManager implements IDisposable {
  54425. private scene;
  54426. /**
  54427. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54428. */
  54429. gizmos: {
  54430. positionGizmo: Nullable<PositionGizmo>;
  54431. rotationGizmo: Nullable<RotationGizmo>;
  54432. scaleGizmo: Nullable<ScaleGizmo>;
  54433. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54434. };
  54435. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54436. clearGizmoOnEmptyPointerEvent: boolean;
  54437. /** Fires an event when the manager is attached to a mesh */
  54438. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54439. private _gizmosEnabled;
  54440. private _pointerObserver;
  54441. private _attachedMesh;
  54442. private _boundingBoxColor;
  54443. private _defaultUtilityLayer;
  54444. private _defaultKeepDepthUtilityLayer;
  54445. /**
  54446. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54447. */
  54448. boundingBoxDragBehavior: SixDofDragBehavior;
  54449. /**
  54450. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54451. */
  54452. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54453. /**
  54454. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54455. */
  54456. usePointerToAttachGizmos: boolean;
  54457. /**
  54458. * Utility layer that the bounding box gizmo belongs to
  54459. */
  54460. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54461. /**
  54462. * Utility layer that all gizmos besides bounding box belong to
  54463. */
  54464. get utilityLayer(): UtilityLayerRenderer;
  54465. /**
  54466. * Instatiates a gizmo manager
  54467. * @param scene the scene to overlay the gizmos on top of
  54468. */
  54469. constructor(scene: Scene);
  54470. /**
  54471. * Attaches a set of gizmos to the specified mesh
  54472. * @param mesh The mesh the gizmo's should be attached to
  54473. */
  54474. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54475. /**
  54476. * If the position gizmo is enabled
  54477. */
  54478. set positionGizmoEnabled(value: boolean);
  54479. get positionGizmoEnabled(): boolean;
  54480. /**
  54481. * If the rotation gizmo is enabled
  54482. */
  54483. set rotationGizmoEnabled(value: boolean);
  54484. get rotationGizmoEnabled(): boolean;
  54485. /**
  54486. * If the scale gizmo is enabled
  54487. */
  54488. set scaleGizmoEnabled(value: boolean);
  54489. get scaleGizmoEnabled(): boolean;
  54490. /**
  54491. * If the boundingBox gizmo is enabled
  54492. */
  54493. set boundingBoxGizmoEnabled(value: boolean);
  54494. get boundingBoxGizmoEnabled(): boolean;
  54495. /**
  54496. * Disposes of the gizmo manager
  54497. */
  54498. dispose(): void;
  54499. }
  54500. }
  54501. declare module "babylonjs/Lights/directionalLight" {
  54502. import { Camera } from "babylonjs/Cameras/camera";
  54503. import { Scene } from "babylonjs/scene";
  54504. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54506. import { Light } from "babylonjs/Lights/light";
  54507. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54508. import { Effect } from "babylonjs/Materials/effect";
  54509. /**
  54510. * A directional light is defined by a direction (what a surprise!).
  54511. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54512. * 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.
  54513. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54514. */
  54515. export class DirectionalLight extends ShadowLight {
  54516. private _shadowFrustumSize;
  54517. /**
  54518. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54519. */
  54520. get shadowFrustumSize(): number;
  54521. /**
  54522. * Specifies a fix frustum size for the shadow generation.
  54523. */
  54524. set shadowFrustumSize(value: number);
  54525. private _shadowOrthoScale;
  54526. /**
  54527. * Gets the shadow projection scale against the optimal computed one.
  54528. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54529. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54530. */
  54531. get shadowOrthoScale(): number;
  54532. /**
  54533. * Sets the shadow projection scale against the optimal computed one.
  54534. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54535. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54536. */
  54537. set shadowOrthoScale(value: number);
  54538. /**
  54539. * Automatically compute the projection matrix to best fit (including all the casters)
  54540. * on each frame.
  54541. */
  54542. autoUpdateExtends: boolean;
  54543. /**
  54544. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54545. * on each frame. autoUpdateExtends must be set to true for this to work
  54546. */
  54547. autoCalcShadowZBounds: boolean;
  54548. private _orthoLeft;
  54549. private _orthoRight;
  54550. private _orthoTop;
  54551. private _orthoBottom;
  54552. /**
  54553. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54554. * The directional light is emitted from everywhere in the given direction.
  54555. * It can cast shadows.
  54556. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54557. * @param name The friendly name of the light
  54558. * @param direction The direction of the light
  54559. * @param scene The scene the light belongs to
  54560. */
  54561. constructor(name: string, direction: Vector3, scene: Scene);
  54562. /**
  54563. * Returns the string "DirectionalLight".
  54564. * @return The class name
  54565. */
  54566. getClassName(): string;
  54567. /**
  54568. * Returns the integer 1.
  54569. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54570. */
  54571. getTypeID(): number;
  54572. /**
  54573. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54574. * Returns the DirectionalLight Shadow projection matrix.
  54575. */
  54576. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54577. /**
  54578. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54579. * Returns the DirectionalLight Shadow projection matrix.
  54580. */
  54581. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54582. /**
  54583. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54584. * Returns the DirectionalLight Shadow projection matrix.
  54585. */
  54586. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54587. protected _buildUniformLayout(): void;
  54588. /**
  54589. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54590. * @param effect The effect to update
  54591. * @param lightIndex The index of the light in the effect to update
  54592. * @returns The directional light
  54593. */
  54594. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54595. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54596. /**
  54597. * Gets the minZ used for shadow according to both the scene and the light.
  54598. *
  54599. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54600. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54601. * @param activeCamera The camera we are returning the min for
  54602. * @returns the depth min z
  54603. */
  54604. getDepthMinZ(activeCamera: Camera): number;
  54605. /**
  54606. * Gets the maxZ used for shadow according to both the scene and the light.
  54607. *
  54608. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54609. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54610. * @param activeCamera The camera we are returning the max for
  54611. * @returns the depth max z
  54612. */
  54613. getDepthMaxZ(activeCamera: Camera): number;
  54614. /**
  54615. * Prepares the list of defines specific to the light type.
  54616. * @param defines the list of defines
  54617. * @param lightIndex defines the index of the light for the effect
  54618. */
  54619. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54620. }
  54621. }
  54622. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  54623. import { Mesh } from "babylonjs/Meshes/mesh";
  54624. /**
  54625. * Class containing static functions to help procedurally build meshes
  54626. */
  54627. export class HemisphereBuilder {
  54628. /**
  54629. * Creates a hemisphere mesh
  54630. * @param name defines the name of the mesh
  54631. * @param options defines the options used to create the mesh
  54632. * @param scene defines the hosting scene
  54633. * @returns the hemisphere mesh
  54634. */
  54635. static CreateHemisphere(name: string, options: {
  54636. segments?: number;
  54637. diameter?: number;
  54638. sideOrientation?: number;
  54639. }, scene: any): Mesh;
  54640. }
  54641. }
  54642. declare module "babylonjs/Lights/spotLight" {
  54643. import { Nullable } from "babylonjs/types";
  54644. import { Scene } from "babylonjs/scene";
  54645. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54647. import { Effect } from "babylonjs/Materials/effect";
  54648. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54649. import { Light } from "babylonjs/Lights/light";
  54650. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54651. /**
  54652. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54653. * These values define a cone of light starting from the position, emitting toward the direction.
  54654. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54655. * and the exponent defines the speed of the decay of the light with distance (reach).
  54656. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54657. */
  54658. export class SpotLight extends ShadowLight {
  54659. private _angle;
  54660. private _innerAngle;
  54661. private _cosHalfAngle;
  54662. private _lightAngleScale;
  54663. private _lightAngleOffset;
  54664. /**
  54665. * Gets the cone angle of the spot light in Radians.
  54666. */
  54667. get angle(): number;
  54668. /**
  54669. * Sets the cone angle of the spot light in Radians.
  54670. */
  54671. set angle(value: number);
  54672. /**
  54673. * Only used in gltf falloff mode, this defines the angle where
  54674. * the directional falloff will start before cutting at angle which could be seen
  54675. * as outer angle.
  54676. */
  54677. get innerAngle(): number;
  54678. /**
  54679. * Only used in gltf falloff mode, this defines the angle where
  54680. * the directional falloff will start before cutting at angle which could be seen
  54681. * as outer angle.
  54682. */
  54683. set innerAngle(value: number);
  54684. private _shadowAngleScale;
  54685. /**
  54686. * Allows scaling the angle of the light for shadow generation only.
  54687. */
  54688. get shadowAngleScale(): number;
  54689. /**
  54690. * Allows scaling the angle of the light for shadow generation only.
  54691. */
  54692. set shadowAngleScale(value: number);
  54693. /**
  54694. * The light decay speed with the distance from the emission spot.
  54695. */
  54696. exponent: number;
  54697. private _projectionTextureMatrix;
  54698. /**
  54699. * Allows reading the projecton texture
  54700. */
  54701. get projectionTextureMatrix(): Matrix;
  54702. protected _projectionTextureLightNear: number;
  54703. /**
  54704. * Gets the near clip of the Spotlight for texture projection.
  54705. */
  54706. get projectionTextureLightNear(): number;
  54707. /**
  54708. * Sets the near clip of the Spotlight for texture projection.
  54709. */
  54710. set projectionTextureLightNear(value: number);
  54711. protected _projectionTextureLightFar: number;
  54712. /**
  54713. * Gets the far clip of the Spotlight for texture projection.
  54714. */
  54715. get projectionTextureLightFar(): number;
  54716. /**
  54717. * Sets the far clip of the Spotlight for texture projection.
  54718. */
  54719. set projectionTextureLightFar(value: number);
  54720. protected _projectionTextureUpDirection: Vector3;
  54721. /**
  54722. * Gets the Up vector of the Spotlight for texture projection.
  54723. */
  54724. get projectionTextureUpDirection(): Vector3;
  54725. /**
  54726. * Sets the Up vector of the Spotlight for texture projection.
  54727. */
  54728. set projectionTextureUpDirection(value: Vector3);
  54729. private _projectionTexture;
  54730. /**
  54731. * Gets the projection texture of the light.
  54732. */
  54733. get projectionTexture(): Nullable<BaseTexture>;
  54734. /**
  54735. * Sets the projection texture of the light.
  54736. */
  54737. set projectionTexture(value: Nullable<BaseTexture>);
  54738. private _projectionTextureViewLightDirty;
  54739. private _projectionTextureProjectionLightDirty;
  54740. private _projectionTextureDirty;
  54741. private _projectionTextureViewTargetVector;
  54742. private _projectionTextureViewLightMatrix;
  54743. private _projectionTextureProjectionLightMatrix;
  54744. private _projectionTextureScalingMatrix;
  54745. /**
  54746. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54747. * It can cast shadows.
  54748. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54749. * @param name The light friendly name
  54750. * @param position The position of the spot light in the scene
  54751. * @param direction The direction of the light in the scene
  54752. * @param angle The cone angle of the light in Radians
  54753. * @param exponent The light decay speed with the distance from the emission spot
  54754. * @param scene The scene the lights belongs to
  54755. */
  54756. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54757. /**
  54758. * Returns the string "SpotLight".
  54759. * @returns the class name
  54760. */
  54761. getClassName(): string;
  54762. /**
  54763. * Returns the integer 2.
  54764. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54765. */
  54766. getTypeID(): number;
  54767. /**
  54768. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54769. */
  54770. protected _setDirection(value: Vector3): void;
  54771. /**
  54772. * Overrides the position setter to recompute the projection texture view light Matrix.
  54773. */
  54774. protected _setPosition(value: Vector3): void;
  54775. /**
  54776. * 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.
  54777. * Returns the SpotLight.
  54778. */
  54779. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54780. protected _computeProjectionTextureViewLightMatrix(): void;
  54781. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54782. /**
  54783. * Main function for light texture projection matrix computing.
  54784. */
  54785. protected _computeProjectionTextureMatrix(): void;
  54786. protected _buildUniformLayout(): void;
  54787. private _computeAngleValues;
  54788. /**
  54789. * Sets the passed Effect "effect" with the Light textures.
  54790. * @param effect The effect to update
  54791. * @param lightIndex The index of the light in the effect to update
  54792. * @returns The light
  54793. */
  54794. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54795. /**
  54796. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54797. * @param effect The effect to update
  54798. * @param lightIndex The index of the light in the effect to update
  54799. * @returns The spot light
  54800. */
  54801. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54802. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54803. /**
  54804. * Disposes the light and the associated resources.
  54805. */
  54806. dispose(): void;
  54807. /**
  54808. * Prepares the list of defines specific to the light type.
  54809. * @param defines the list of defines
  54810. * @param lightIndex defines the index of the light for the effect
  54811. */
  54812. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54813. }
  54814. }
  54815. declare module "babylonjs/Gizmos/lightGizmo" {
  54816. import { Nullable } from "babylonjs/types";
  54817. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54818. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54819. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  54820. import { Light } from "babylonjs/Lights/light";
  54821. /**
  54822. * Gizmo that enables viewing a light
  54823. */
  54824. export class LightGizmo extends Gizmo {
  54825. private _lightMesh;
  54826. private _material;
  54827. private _cachedPosition;
  54828. private _cachedForward;
  54829. private _attachedMeshParent;
  54830. /**
  54831. * Creates a LightGizmo
  54832. * @param gizmoLayer The utility layer the gizmo will be added to
  54833. */
  54834. constructor(gizmoLayer?: UtilityLayerRenderer);
  54835. private _light;
  54836. /**
  54837. * The light that the gizmo is attached to
  54838. */
  54839. set light(light: Nullable<Light>);
  54840. get light(): Nullable<Light>;
  54841. /**
  54842. * Gets the material used to render the light gizmo
  54843. */
  54844. get material(): StandardMaterial;
  54845. /**
  54846. * @hidden
  54847. * Updates the gizmo to match the attached mesh's position/rotation
  54848. */
  54849. protected _update(): void;
  54850. private static _Scale;
  54851. /**
  54852. * Creates the lines for a light mesh
  54853. */
  54854. private static _CreateLightLines;
  54855. /**
  54856. * Disposes of the light gizmo
  54857. */
  54858. dispose(): void;
  54859. private static _CreateHemisphericLightMesh;
  54860. private static _CreatePointLightMesh;
  54861. private static _CreateSpotLightMesh;
  54862. private static _CreateDirectionalLightMesh;
  54863. }
  54864. }
  54865. declare module "babylonjs/Gizmos/index" {
  54866. export * from "babylonjs/Gizmos/axisDragGizmo";
  54867. export * from "babylonjs/Gizmos/axisScaleGizmo";
  54868. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  54869. export * from "babylonjs/Gizmos/gizmo";
  54870. export * from "babylonjs/Gizmos/gizmoManager";
  54871. export * from "babylonjs/Gizmos/planeRotationGizmo";
  54872. export * from "babylonjs/Gizmos/positionGizmo";
  54873. export * from "babylonjs/Gizmos/rotationGizmo";
  54874. export * from "babylonjs/Gizmos/scaleGizmo";
  54875. export * from "babylonjs/Gizmos/lightGizmo";
  54876. export * from "babylonjs/Gizmos/planeDragGizmo";
  54877. }
  54878. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  54879. /** @hidden */
  54880. export var backgroundFragmentDeclaration: {
  54881. name: string;
  54882. shader: string;
  54883. };
  54884. }
  54885. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  54886. /** @hidden */
  54887. export var backgroundUboDeclaration: {
  54888. name: string;
  54889. shader: string;
  54890. };
  54891. }
  54892. declare module "babylonjs/Shaders/background.fragment" {
  54893. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  54894. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54895. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54896. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  54897. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54898. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54899. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54900. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  54901. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  54902. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  54903. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  54904. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  54905. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  54906. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  54907. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  54908. /** @hidden */
  54909. export var backgroundPixelShader: {
  54910. name: string;
  54911. shader: string;
  54912. };
  54913. }
  54914. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  54915. /** @hidden */
  54916. export var backgroundVertexDeclaration: {
  54917. name: string;
  54918. shader: string;
  54919. };
  54920. }
  54921. declare module "babylonjs/Shaders/background.vertex" {
  54922. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  54923. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54924. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54925. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54926. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54927. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  54928. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  54929. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54930. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54931. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54932. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54933. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  54934. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  54935. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  54936. /** @hidden */
  54937. export var backgroundVertexShader: {
  54938. name: string;
  54939. shader: string;
  54940. };
  54941. }
  54942. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  54943. import { Nullable, int, float } from "babylonjs/types";
  54944. import { Scene } from "babylonjs/scene";
  54945. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54946. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54948. import { Mesh } from "babylonjs/Meshes/mesh";
  54949. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54950. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54951. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54952. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54953. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  54954. import { Color3 } from "babylonjs/Maths/math.color";
  54955. import "babylonjs/Shaders/background.fragment";
  54956. import "babylonjs/Shaders/background.vertex";
  54957. /**
  54958. * Background material used to create an efficient environement around your scene.
  54959. */
  54960. export class BackgroundMaterial extends PushMaterial {
  54961. /**
  54962. * Standard reflectance value at parallel view angle.
  54963. */
  54964. static StandardReflectance0: number;
  54965. /**
  54966. * Standard reflectance value at grazing angle.
  54967. */
  54968. static StandardReflectance90: number;
  54969. protected _primaryColor: Color3;
  54970. /**
  54971. * Key light Color (multiply against the environement texture)
  54972. */
  54973. primaryColor: Color3;
  54974. protected __perceptualColor: Nullable<Color3>;
  54975. /**
  54976. * Experimental Internal Use Only.
  54977. *
  54978. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54979. * This acts as a helper to set the primary color to a more "human friendly" value.
  54980. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54981. * output color as close as possible from the chosen value.
  54982. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54983. * part of lighting setup.)
  54984. */
  54985. get _perceptualColor(): Nullable<Color3>;
  54986. set _perceptualColor(value: Nullable<Color3>);
  54987. protected _primaryColorShadowLevel: float;
  54988. /**
  54989. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54990. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54991. */
  54992. get primaryColorShadowLevel(): float;
  54993. set primaryColorShadowLevel(value: float);
  54994. protected _primaryColorHighlightLevel: float;
  54995. /**
  54996. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54997. * The primary color is used at the level chosen to define what the white area would look.
  54998. */
  54999. get primaryColorHighlightLevel(): float;
  55000. set primaryColorHighlightLevel(value: float);
  55001. protected _reflectionTexture: Nullable<BaseTexture>;
  55002. /**
  55003. * Reflection Texture used in the material.
  55004. * Should be author in a specific way for the best result (refer to the documentation).
  55005. */
  55006. reflectionTexture: Nullable<BaseTexture>;
  55007. protected _reflectionBlur: float;
  55008. /**
  55009. * Reflection Texture level of blur.
  55010. *
  55011. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55012. * texture twice.
  55013. */
  55014. reflectionBlur: float;
  55015. protected _diffuseTexture: Nullable<BaseTexture>;
  55016. /**
  55017. * Diffuse Texture used in the material.
  55018. * Should be author in a specific way for the best result (refer to the documentation).
  55019. */
  55020. diffuseTexture: Nullable<BaseTexture>;
  55021. protected _shadowLights: Nullable<IShadowLight[]>;
  55022. /**
  55023. * Specify the list of lights casting shadow on the material.
  55024. * All scene shadow lights will be included if null.
  55025. */
  55026. shadowLights: Nullable<IShadowLight[]>;
  55027. protected _shadowLevel: float;
  55028. /**
  55029. * Helps adjusting the shadow to a softer level if required.
  55030. * 0 means black shadows and 1 means no shadows.
  55031. */
  55032. shadowLevel: float;
  55033. protected _sceneCenter: Vector3;
  55034. /**
  55035. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55036. * It is usually zero but might be interesting to modify according to your setup.
  55037. */
  55038. sceneCenter: Vector3;
  55039. protected _opacityFresnel: boolean;
  55040. /**
  55041. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55042. * This helps ensuring a nice transition when the camera goes under the ground.
  55043. */
  55044. opacityFresnel: boolean;
  55045. protected _reflectionFresnel: boolean;
  55046. /**
  55047. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55048. * This helps adding a mirror texture on the ground.
  55049. */
  55050. reflectionFresnel: boolean;
  55051. protected _reflectionFalloffDistance: number;
  55052. /**
  55053. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55054. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55055. */
  55056. reflectionFalloffDistance: number;
  55057. protected _reflectionAmount: number;
  55058. /**
  55059. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55060. */
  55061. reflectionAmount: number;
  55062. protected _reflectionReflectance0: number;
  55063. /**
  55064. * This specifies the weight of the reflection at grazing angle.
  55065. */
  55066. reflectionReflectance0: number;
  55067. protected _reflectionReflectance90: number;
  55068. /**
  55069. * This specifies the weight of the reflection at a perpendicular point of view.
  55070. */
  55071. reflectionReflectance90: number;
  55072. /**
  55073. * Sets the reflection reflectance fresnel values according to the default standard
  55074. * empirically know to work well :-)
  55075. */
  55076. set reflectionStandardFresnelWeight(value: number);
  55077. protected _useRGBColor: boolean;
  55078. /**
  55079. * Helps to directly use the maps channels instead of their level.
  55080. */
  55081. useRGBColor: boolean;
  55082. protected _enableNoise: boolean;
  55083. /**
  55084. * This helps reducing the banding effect that could occur on the background.
  55085. */
  55086. enableNoise: boolean;
  55087. /**
  55088. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55089. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55090. * Recommended to be keep at 1.0 except for special cases.
  55091. */
  55092. get fovMultiplier(): number;
  55093. set fovMultiplier(value: number);
  55094. private _fovMultiplier;
  55095. /**
  55096. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55097. */
  55098. useEquirectangularFOV: boolean;
  55099. private _maxSimultaneousLights;
  55100. /**
  55101. * Number of Simultaneous lights allowed on the material.
  55102. */
  55103. maxSimultaneousLights: int;
  55104. /**
  55105. * Default configuration related to image processing available in the Background Material.
  55106. */
  55107. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55108. /**
  55109. * Keep track of the image processing observer to allow dispose and replace.
  55110. */
  55111. private _imageProcessingObserver;
  55112. /**
  55113. * Attaches a new image processing configuration to the PBR Material.
  55114. * @param configuration (if null the scene configuration will be use)
  55115. */
  55116. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55117. /**
  55118. * Gets the image processing configuration used either in this material.
  55119. */
  55120. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55121. /**
  55122. * Sets the Default image processing configuration used either in the this material.
  55123. *
  55124. * If sets to null, the scene one is in use.
  55125. */
  55126. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55127. /**
  55128. * Gets wether the color curves effect is enabled.
  55129. */
  55130. get cameraColorCurvesEnabled(): boolean;
  55131. /**
  55132. * Sets wether the color curves effect is enabled.
  55133. */
  55134. set cameraColorCurvesEnabled(value: boolean);
  55135. /**
  55136. * Gets wether the color grading effect is enabled.
  55137. */
  55138. get cameraColorGradingEnabled(): boolean;
  55139. /**
  55140. * Gets wether the color grading effect is enabled.
  55141. */
  55142. set cameraColorGradingEnabled(value: boolean);
  55143. /**
  55144. * Gets wether tonemapping is enabled or not.
  55145. */
  55146. get cameraToneMappingEnabled(): boolean;
  55147. /**
  55148. * Sets wether tonemapping is enabled or not
  55149. */
  55150. set cameraToneMappingEnabled(value: boolean);
  55151. /**
  55152. * The camera exposure used on this material.
  55153. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55154. * This corresponds to a photographic exposure.
  55155. */
  55156. get cameraExposure(): float;
  55157. /**
  55158. * The camera exposure used on this material.
  55159. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55160. * This corresponds to a photographic exposure.
  55161. */
  55162. set cameraExposure(value: float);
  55163. /**
  55164. * Gets The camera contrast used on this material.
  55165. */
  55166. get cameraContrast(): float;
  55167. /**
  55168. * Sets The camera contrast used on this material.
  55169. */
  55170. set cameraContrast(value: float);
  55171. /**
  55172. * Gets the Color Grading 2D Lookup Texture.
  55173. */
  55174. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55175. /**
  55176. * Sets the Color Grading 2D Lookup Texture.
  55177. */
  55178. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55179. /**
  55180. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55181. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55182. * 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;
  55183. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55184. */
  55185. get cameraColorCurves(): Nullable<ColorCurves>;
  55186. /**
  55187. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55188. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55189. * 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;
  55190. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55191. */
  55192. set cameraColorCurves(value: Nullable<ColorCurves>);
  55193. /**
  55194. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55195. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55196. */
  55197. switchToBGR: boolean;
  55198. private _renderTargets;
  55199. private _reflectionControls;
  55200. private _white;
  55201. private _primaryShadowColor;
  55202. private _primaryHighlightColor;
  55203. /**
  55204. * Instantiates a Background Material in the given scene
  55205. * @param name The friendly name of the material
  55206. * @param scene The scene to add the material to
  55207. */
  55208. constructor(name: string, scene: Scene);
  55209. /**
  55210. * Gets a boolean indicating that current material needs to register RTT
  55211. */
  55212. get hasRenderTargetTextures(): boolean;
  55213. /**
  55214. * The entire material has been created in order to prevent overdraw.
  55215. * @returns false
  55216. */
  55217. needAlphaTesting(): boolean;
  55218. /**
  55219. * The entire material has been created in order to prevent overdraw.
  55220. * @returns true if blending is enable
  55221. */
  55222. needAlphaBlending(): boolean;
  55223. /**
  55224. * Checks wether the material is ready to be rendered for a given mesh.
  55225. * @param mesh The mesh to render
  55226. * @param subMesh The submesh to check against
  55227. * @param useInstances Specify wether or not the material is used with instances
  55228. * @returns true if all the dependencies are ready (Textures, Effects...)
  55229. */
  55230. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55231. /**
  55232. * Compute the primary color according to the chosen perceptual color.
  55233. */
  55234. private _computePrimaryColorFromPerceptualColor;
  55235. /**
  55236. * Compute the highlights and shadow colors according to their chosen levels.
  55237. */
  55238. private _computePrimaryColors;
  55239. /**
  55240. * Build the uniform buffer used in the material.
  55241. */
  55242. buildUniformLayout(): void;
  55243. /**
  55244. * Unbind the material.
  55245. */
  55246. unbind(): void;
  55247. /**
  55248. * Bind only the world matrix to the material.
  55249. * @param world The world matrix to bind.
  55250. */
  55251. bindOnlyWorldMatrix(world: Matrix): void;
  55252. /**
  55253. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55254. * @param world The world matrix to bind.
  55255. * @param subMesh The submesh to bind for.
  55256. */
  55257. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55258. /**
  55259. * Checks to see if a texture is used in the material.
  55260. * @param texture - Base texture to use.
  55261. * @returns - Boolean specifying if a texture is used in the material.
  55262. */
  55263. hasTexture(texture: BaseTexture): boolean;
  55264. /**
  55265. * Dispose the material.
  55266. * @param forceDisposeEffect Force disposal of the associated effect.
  55267. * @param forceDisposeTextures Force disposal of the associated textures.
  55268. */
  55269. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55270. /**
  55271. * Clones the material.
  55272. * @param name The cloned name.
  55273. * @returns The cloned material.
  55274. */
  55275. clone(name: string): BackgroundMaterial;
  55276. /**
  55277. * Serializes the current material to its JSON representation.
  55278. * @returns The JSON representation.
  55279. */
  55280. serialize(): any;
  55281. /**
  55282. * Gets the class name of the material
  55283. * @returns "BackgroundMaterial"
  55284. */
  55285. getClassName(): string;
  55286. /**
  55287. * Parse a JSON input to create back a background material.
  55288. * @param source The JSON data to parse
  55289. * @param scene The scene to create the parsed material in
  55290. * @param rootUrl The root url of the assets the material depends upon
  55291. * @returns the instantiated BackgroundMaterial.
  55292. */
  55293. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55294. }
  55295. }
  55296. declare module "babylonjs/Helpers/environmentHelper" {
  55297. import { Observable } from "babylonjs/Misc/observable";
  55298. import { Nullable } from "babylonjs/types";
  55299. import { Scene } from "babylonjs/scene";
  55300. import { Vector3 } from "babylonjs/Maths/math.vector";
  55301. import { Color3 } from "babylonjs/Maths/math.color";
  55302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55303. import { Mesh } from "babylonjs/Meshes/mesh";
  55304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55305. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55306. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55307. import "babylonjs/Meshes/Builders/planeBuilder";
  55308. import "babylonjs/Meshes/Builders/boxBuilder";
  55309. /**
  55310. * Represents the different options available during the creation of
  55311. * a Environment helper.
  55312. *
  55313. * This can control the default ground, skybox and image processing setup of your scene.
  55314. */
  55315. export interface IEnvironmentHelperOptions {
  55316. /**
  55317. * Specifies whether or not to create a ground.
  55318. * True by default.
  55319. */
  55320. createGround: boolean;
  55321. /**
  55322. * Specifies the ground size.
  55323. * 15 by default.
  55324. */
  55325. groundSize: number;
  55326. /**
  55327. * The texture used on the ground for the main color.
  55328. * Comes from the BabylonJS CDN by default.
  55329. *
  55330. * Remarks: Can be either a texture or a url.
  55331. */
  55332. groundTexture: string | BaseTexture;
  55333. /**
  55334. * The color mixed in the ground texture by default.
  55335. * BabylonJS clearColor by default.
  55336. */
  55337. groundColor: Color3;
  55338. /**
  55339. * Specifies the ground opacity.
  55340. * 1 by default.
  55341. */
  55342. groundOpacity: number;
  55343. /**
  55344. * Enables the ground to receive shadows.
  55345. * True by default.
  55346. */
  55347. enableGroundShadow: boolean;
  55348. /**
  55349. * Helps preventing the shadow to be fully black on the ground.
  55350. * 0.5 by default.
  55351. */
  55352. groundShadowLevel: number;
  55353. /**
  55354. * Creates a mirror texture attach to the ground.
  55355. * false by default.
  55356. */
  55357. enableGroundMirror: boolean;
  55358. /**
  55359. * Specifies the ground mirror size ratio.
  55360. * 0.3 by default as the default kernel is 64.
  55361. */
  55362. groundMirrorSizeRatio: number;
  55363. /**
  55364. * Specifies the ground mirror blur kernel size.
  55365. * 64 by default.
  55366. */
  55367. groundMirrorBlurKernel: number;
  55368. /**
  55369. * Specifies the ground mirror visibility amount.
  55370. * 1 by default
  55371. */
  55372. groundMirrorAmount: number;
  55373. /**
  55374. * Specifies the ground mirror reflectance weight.
  55375. * This uses the standard weight of the background material to setup the fresnel effect
  55376. * of the mirror.
  55377. * 1 by default.
  55378. */
  55379. groundMirrorFresnelWeight: number;
  55380. /**
  55381. * Specifies the ground mirror Falloff distance.
  55382. * This can helps reducing the size of the reflection.
  55383. * 0 by Default.
  55384. */
  55385. groundMirrorFallOffDistance: number;
  55386. /**
  55387. * Specifies the ground mirror texture type.
  55388. * Unsigned Int by Default.
  55389. */
  55390. groundMirrorTextureType: number;
  55391. /**
  55392. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55393. * the shown objects.
  55394. */
  55395. groundYBias: number;
  55396. /**
  55397. * Specifies whether or not to create a skybox.
  55398. * True by default.
  55399. */
  55400. createSkybox: boolean;
  55401. /**
  55402. * Specifies the skybox size.
  55403. * 20 by default.
  55404. */
  55405. skyboxSize: number;
  55406. /**
  55407. * The texture used on the skybox for the main color.
  55408. * Comes from the BabylonJS CDN by default.
  55409. *
  55410. * Remarks: Can be either a texture or a url.
  55411. */
  55412. skyboxTexture: string | BaseTexture;
  55413. /**
  55414. * The color mixed in the skybox texture by default.
  55415. * BabylonJS clearColor by default.
  55416. */
  55417. skyboxColor: Color3;
  55418. /**
  55419. * The background rotation around the Y axis of the scene.
  55420. * This helps aligning the key lights of your scene with the background.
  55421. * 0 by default.
  55422. */
  55423. backgroundYRotation: number;
  55424. /**
  55425. * Compute automatically the size of the elements to best fit with the scene.
  55426. */
  55427. sizeAuto: boolean;
  55428. /**
  55429. * Default position of the rootMesh if autoSize is not true.
  55430. */
  55431. rootPosition: Vector3;
  55432. /**
  55433. * Sets up the image processing in the scene.
  55434. * true by default.
  55435. */
  55436. setupImageProcessing: boolean;
  55437. /**
  55438. * The texture used as your environment texture in the scene.
  55439. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55440. *
  55441. * Remarks: Can be either a texture or a url.
  55442. */
  55443. environmentTexture: string | BaseTexture;
  55444. /**
  55445. * The value of the exposure to apply to the scene.
  55446. * 0.6 by default if setupImageProcessing is true.
  55447. */
  55448. cameraExposure: number;
  55449. /**
  55450. * The value of the contrast to apply to the scene.
  55451. * 1.6 by default if setupImageProcessing is true.
  55452. */
  55453. cameraContrast: number;
  55454. /**
  55455. * Specifies whether or not tonemapping should be enabled in the scene.
  55456. * true by default if setupImageProcessing is true.
  55457. */
  55458. toneMappingEnabled: boolean;
  55459. }
  55460. /**
  55461. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55462. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55463. * It also helps with the default setup of your imageProcessing configuration.
  55464. */
  55465. export class EnvironmentHelper {
  55466. /**
  55467. * Default ground texture URL.
  55468. */
  55469. private static _groundTextureCDNUrl;
  55470. /**
  55471. * Default skybox texture URL.
  55472. */
  55473. private static _skyboxTextureCDNUrl;
  55474. /**
  55475. * Default environment texture URL.
  55476. */
  55477. private static _environmentTextureCDNUrl;
  55478. /**
  55479. * Creates the default options for the helper.
  55480. */
  55481. private static _getDefaultOptions;
  55482. private _rootMesh;
  55483. /**
  55484. * Gets the root mesh created by the helper.
  55485. */
  55486. get rootMesh(): Mesh;
  55487. private _skybox;
  55488. /**
  55489. * Gets the skybox created by the helper.
  55490. */
  55491. get skybox(): Nullable<Mesh>;
  55492. private _skyboxTexture;
  55493. /**
  55494. * Gets the skybox texture created by the helper.
  55495. */
  55496. get skyboxTexture(): Nullable<BaseTexture>;
  55497. private _skyboxMaterial;
  55498. /**
  55499. * Gets the skybox material created by the helper.
  55500. */
  55501. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55502. private _ground;
  55503. /**
  55504. * Gets the ground mesh created by the helper.
  55505. */
  55506. get ground(): Nullable<Mesh>;
  55507. private _groundTexture;
  55508. /**
  55509. * Gets the ground texture created by the helper.
  55510. */
  55511. get groundTexture(): Nullable<BaseTexture>;
  55512. private _groundMirror;
  55513. /**
  55514. * Gets the ground mirror created by the helper.
  55515. */
  55516. get groundMirror(): Nullable<MirrorTexture>;
  55517. /**
  55518. * Gets the ground mirror render list to helps pushing the meshes
  55519. * you wish in the ground reflection.
  55520. */
  55521. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55522. private _groundMaterial;
  55523. /**
  55524. * Gets the ground material created by the helper.
  55525. */
  55526. get groundMaterial(): Nullable<BackgroundMaterial>;
  55527. /**
  55528. * Stores the creation options.
  55529. */
  55530. private readonly _scene;
  55531. private _options;
  55532. /**
  55533. * This observable will be notified with any error during the creation of the environment,
  55534. * mainly texture creation errors.
  55535. */
  55536. onErrorObservable: Observable<{
  55537. message?: string;
  55538. exception?: any;
  55539. }>;
  55540. /**
  55541. * constructor
  55542. * @param options Defines the options we want to customize the helper
  55543. * @param scene The scene to add the material to
  55544. */
  55545. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55546. /**
  55547. * Updates the background according to the new options
  55548. * @param options
  55549. */
  55550. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55551. /**
  55552. * Sets the primary color of all the available elements.
  55553. * @param color the main color to affect to the ground and the background
  55554. */
  55555. setMainColor(color: Color3): void;
  55556. /**
  55557. * Setup the image processing according to the specified options.
  55558. */
  55559. private _setupImageProcessing;
  55560. /**
  55561. * Setup the environment texture according to the specified options.
  55562. */
  55563. private _setupEnvironmentTexture;
  55564. /**
  55565. * Setup the background according to the specified options.
  55566. */
  55567. private _setupBackground;
  55568. /**
  55569. * Get the scene sizes according to the setup.
  55570. */
  55571. private _getSceneSize;
  55572. /**
  55573. * Setup the ground according to the specified options.
  55574. */
  55575. private _setupGround;
  55576. /**
  55577. * Setup the ground material according to the specified options.
  55578. */
  55579. private _setupGroundMaterial;
  55580. /**
  55581. * Setup the ground diffuse texture according to the specified options.
  55582. */
  55583. private _setupGroundDiffuseTexture;
  55584. /**
  55585. * Setup the ground mirror texture according to the specified options.
  55586. */
  55587. private _setupGroundMirrorTexture;
  55588. /**
  55589. * Setup the ground to receive the mirror texture.
  55590. */
  55591. private _setupMirrorInGroundMaterial;
  55592. /**
  55593. * Setup the skybox according to the specified options.
  55594. */
  55595. private _setupSkybox;
  55596. /**
  55597. * Setup the skybox material according to the specified options.
  55598. */
  55599. private _setupSkyboxMaterial;
  55600. /**
  55601. * Setup the skybox reflection texture according to the specified options.
  55602. */
  55603. private _setupSkyboxReflectionTexture;
  55604. private _errorHandler;
  55605. /**
  55606. * Dispose all the elements created by the Helper.
  55607. */
  55608. dispose(): void;
  55609. }
  55610. }
  55611. declare module "babylonjs/Helpers/photoDome" {
  55612. import { Observable } from "babylonjs/Misc/observable";
  55613. import { Nullable } from "babylonjs/types";
  55614. import { Scene } from "babylonjs/scene";
  55615. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55616. import { Mesh } from "babylonjs/Meshes/mesh";
  55617. import { Texture } from "babylonjs/Materials/Textures/texture";
  55618. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55619. import "babylonjs/Meshes/Builders/sphereBuilder";
  55620. /**
  55621. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55622. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55623. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55624. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55625. */
  55626. export class PhotoDome extends TransformNode {
  55627. /**
  55628. * Define the image as a Monoscopic panoramic 360 image.
  55629. */
  55630. static readonly MODE_MONOSCOPIC: number;
  55631. /**
  55632. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55633. */
  55634. static readonly MODE_TOPBOTTOM: number;
  55635. /**
  55636. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55637. */
  55638. static readonly MODE_SIDEBYSIDE: number;
  55639. private _useDirectMapping;
  55640. /**
  55641. * The texture being displayed on the sphere
  55642. */
  55643. protected _photoTexture: Texture;
  55644. /**
  55645. * Gets or sets the texture being displayed on the sphere
  55646. */
  55647. get photoTexture(): Texture;
  55648. set photoTexture(value: Texture);
  55649. /**
  55650. * Observable raised when an error occured while loading the 360 image
  55651. */
  55652. onLoadErrorObservable: Observable<string>;
  55653. /**
  55654. * The skybox material
  55655. */
  55656. protected _material: BackgroundMaterial;
  55657. /**
  55658. * The surface used for the skybox
  55659. */
  55660. protected _mesh: Mesh;
  55661. /**
  55662. * Gets the mesh used for the skybox.
  55663. */
  55664. get mesh(): Mesh;
  55665. /**
  55666. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55667. * Also see the options.resolution property.
  55668. */
  55669. get fovMultiplier(): number;
  55670. set fovMultiplier(value: number);
  55671. private _imageMode;
  55672. /**
  55673. * Gets or set the current video mode for the video. It can be:
  55674. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  55675. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55676. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55677. */
  55678. get imageMode(): number;
  55679. set imageMode(value: number);
  55680. /**
  55681. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  55682. * @param name Element's name, child elements will append suffixes for their own names.
  55683. * @param urlsOfPhoto defines the url of the photo to display
  55684. * @param options defines an object containing optional or exposed sub element properties
  55685. * @param onError defines a callback called when an error occured while loading the texture
  55686. */
  55687. constructor(name: string, urlOfPhoto: string, options: {
  55688. resolution?: number;
  55689. size?: number;
  55690. useDirectMapping?: boolean;
  55691. faceForward?: boolean;
  55692. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55693. private _onBeforeCameraRenderObserver;
  55694. private _changeImageMode;
  55695. /**
  55696. * Releases resources associated with this node.
  55697. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55698. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55699. */
  55700. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55701. }
  55702. }
  55703. declare module "babylonjs/Misc/rgbdTextureTools" {
  55704. import "babylonjs/Shaders/rgbdDecode.fragment";
  55705. import "babylonjs/Engines/Extensions/engine.renderTarget";
  55706. import { Texture } from "babylonjs/Materials/Textures/texture";
  55707. /**
  55708. * Class used to host RGBD texture specific utilities
  55709. */
  55710. export class RGBDTextureTools {
  55711. /**
  55712. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55713. * @param texture the texture to expand.
  55714. */
  55715. static ExpandRGBDTexture(texture: Texture): void;
  55716. }
  55717. }
  55718. declare module "babylonjs/Misc/brdfTextureTools" {
  55719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55720. import { Scene } from "babylonjs/scene";
  55721. /**
  55722. * Class used to host texture specific utilities
  55723. */
  55724. export class BRDFTextureTools {
  55725. /**
  55726. * Prevents texture cache collision
  55727. */
  55728. private static _instanceNumber;
  55729. /**
  55730. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55731. * @param scene defines the hosting scene
  55732. * @returns the environment BRDF texture
  55733. */
  55734. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55735. private static _environmentBRDFBase64Texture;
  55736. }
  55737. }
  55738. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  55739. import { Nullable } from "babylonjs/types";
  55740. import { Color3 } from "babylonjs/Maths/math.color";
  55741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55742. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55743. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55744. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55745. import { Engine } from "babylonjs/Engines/engine";
  55746. import { Scene } from "babylonjs/scene";
  55747. /**
  55748. * @hidden
  55749. */
  55750. export interface IMaterialClearCoatDefines {
  55751. CLEARCOAT: boolean;
  55752. CLEARCOAT_DEFAULTIOR: boolean;
  55753. CLEARCOAT_TEXTURE: boolean;
  55754. CLEARCOAT_TEXTUREDIRECTUV: number;
  55755. CLEARCOAT_BUMP: boolean;
  55756. CLEARCOAT_BUMPDIRECTUV: number;
  55757. CLEARCOAT_TINT: boolean;
  55758. CLEARCOAT_TINT_TEXTURE: boolean;
  55759. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55760. /** @hidden */
  55761. _areTexturesDirty: boolean;
  55762. }
  55763. /**
  55764. * Define the code related to the clear coat parameters of the pbr material.
  55765. */
  55766. export class PBRClearCoatConfiguration {
  55767. /**
  55768. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55769. * The default fits with a polyurethane material.
  55770. */
  55771. private static readonly _DefaultIndexOfRefraction;
  55772. private _isEnabled;
  55773. /**
  55774. * Defines if the clear coat is enabled in the material.
  55775. */
  55776. isEnabled: boolean;
  55777. /**
  55778. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55779. */
  55780. intensity: number;
  55781. /**
  55782. * Defines the clear coat layer roughness.
  55783. */
  55784. roughness: number;
  55785. private _indexOfRefraction;
  55786. /**
  55787. * Defines the index of refraction of the clear coat.
  55788. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55789. * The default fits with a polyurethane material.
  55790. * Changing the default value is more performance intensive.
  55791. */
  55792. indexOfRefraction: number;
  55793. private _texture;
  55794. /**
  55795. * Stores the clear coat values in a texture.
  55796. */
  55797. texture: Nullable<BaseTexture>;
  55798. private _bumpTexture;
  55799. /**
  55800. * Define the clear coat specific bump texture.
  55801. */
  55802. bumpTexture: Nullable<BaseTexture>;
  55803. private _isTintEnabled;
  55804. /**
  55805. * Defines if the clear coat tint is enabled in the material.
  55806. */
  55807. isTintEnabled: boolean;
  55808. /**
  55809. * Defines the clear coat tint of the material.
  55810. * This is only use if tint is enabled
  55811. */
  55812. tintColor: Color3;
  55813. /**
  55814. * Defines the distance at which the tint color should be found in the
  55815. * clear coat media.
  55816. * This is only use if tint is enabled
  55817. */
  55818. tintColorAtDistance: number;
  55819. /**
  55820. * Defines the clear coat layer thickness.
  55821. * This is only use if tint is enabled
  55822. */
  55823. tintThickness: number;
  55824. private _tintTexture;
  55825. /**
  55826. * Stores the clear tint values in a texture.
  55827. * rgb is tint
  55828. * a is a thickness factor
  55829. */
  55830. tintTexture: Nullable<BaseTexture>;
  55831. /** @hidden */
  55832. private _internalMarkAllSubMeshesAsTexturesDirty;
  55833. /** @hidden */
  55834. _markAllSubMeshesAsTexturesDirty(): void;
  55835. /**
  55836. * Instantiate a new istance of clear coat configuration.
  55837. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55838. */
  55839. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55840. /**
  55841. * Gets wehter the submesh is ready to be used or not.
  55842. * @param defines the list of "defines" to update.
  55843. * @param scene defines the scene the material belongs to.
  55844. * @param engine defines the engine the material belongs to.
  55845. * @param disableBumpMap defines wether the material disables bump or not.
  55846. * @returns - boolean indicating that the submesh is ready or not.
  55847. */
  55848. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55849. /**
  55850. * Checks to see if a texture is used in the material.
  55851. * @param defines the list of "defines" to update.
  55852. * @param scene defines the scene to the material belongs to.
  55853. */
  55854. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55855. /**
  55856. * Binds the material data.
  55857. * @param uniformBuffer defines the Uniform buffer to fill in.
  55858. * @param scene defines the scene the material belongs to.
  55859. * @param engine defines the engine the material belongs to.
  55860. * @param disableBumpMap defines wether the material disables bump or not.
  55861. * @param isFrozen defines wether the material is frozen or not.
  55862. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55863. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55864. */
  55865. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55866. /**
  55867. * Checks to see if a texture is used in the material.
  55868. * @param texture - Base texture to use.
  55869. * @returns - Boolean specifying if a texture is used in the material.
  55870. */
  55871. hasTexture(texture: BaseTexture): boolean;
  55872. /**
  55873. * Returns an array of the actively used textures.
  55874. * @param activeTextures Array of BaseTextures
  55875. */
  55876. getActiveTextures(activeTextures: BaseTexture[]): void;
  55877. /**
  55878. * Returns the animatable textures.
  55879. * @param animatables Array of animatable textures.
  55880. */
  55881. getAnimatables(animatables: IAnimatable[]): void;
  55882. /**
  55883. * Disposes the resources of the material.
  55884. * @param forceDisposeTextures - Forces the disposal of all textures.
  55885. */
  55886. dispose(forceDisposeTextures?: boolean): void;
  55887. /**
  55888. * Get the current class name of the texture useful for serialization or dynamic coding.
  55889. * @returns "PBRClearCoatConfiguration"
  55890. */
  55891. getClassName(): string;
  55892. /**
  55893. * Add fallbacks to the effect fallbacks list.
  55894. * @param defines defines the Base texture to use.
  55895. * @param fallbacks defines the current fallback list.
  55896. * @param currentRank defines the current fallback rank.
  55897. * @returns the new fallback rank.
  55898. */
  55899. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55900. /**
  55901. * Add the required uniforms to the current list.
  55902. * @param uniforms defines the current uniform list.
  55903. */
  55904. static AddUniforms(uniforms: string[]): void;
  55905. /**
  55906. * Add the required samplers to the current list.
  55907. * @param samplers defines the current sampler list.
  55908. */
  55909. static AddSamplers(samplers: string[]): void;
  55910. /**
  55911. * Add the required uniforms to the current buffer.
  55912. * @param uniformBuffer defines the current uniform buffer.
  55913. */
  55914. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55915. /**
  55916. * Makes a duplicate of the current configuration into another one.
  55917. * @param clearCoatConfiguration define the config where to copy the info
  55918. */
  55919. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55920. /**
  55921. * Serializes this clear coat configuration.
  55922. * @returns - An object with the serialized config.
  55923. */
  55924. serialize(): any;
  55925. /**
  55926. * Parses a anisotropy Configuration from a serialized object.
  55927. * @param source - Serialized object.
  55928. * @param scene Defines the scene we are parsing for
  55929. * @param rootUrl Defines the rootUrl to load from
  55930. */
  55931. parse(source: any, scene: Scene, rootUrl: string): void;
  55932. }
  55933. }
  55934. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  55935. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55937. import { Vector2 } from "babylonjs/Maths/math.vector";
  55938. import { Scene } from "babylonjs/scene";
  55939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55940. import { Nullable } from "babylonjs/types";
  55941. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55942. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55943. /**
  55944. * @hidden
  55945. */
  55946. export interface IMaterialAnisotropicDefines {
  55947. ANISOTROPIC: boolean;
  55948. ANISOTROPIC_TEXTURE: boolean;
  55949. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55950. MAINUV1: boolean;
  55951. _areTexturesDirty: boolean;
  55952. _needUVs: boolean;
  55953. }
  55954. /**
  55955. * Define the code related to the anisotropic parameters of the pbr material.
  55956. */
  55957. export class PBRAnisotropicConfiguration {
  55958. private _isEnabled;
  55959. /**
  55960. * Defines if the anisotropy is enabled in the material.
  55961. */
  55962. isEnabled: boolean;
  55963. /**
  55964. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55965. */
  55966. intensity: number;
  55967. /**
  55968. * Defines if the effect is along the tangents, bitangents or in between.
  55969. * By default, the effect is "strectching" the highlights along the tangents.
  55970. */
  55971. direction: Vector2;
  55972. private _texture;
  55973. /**
  55974. * Stores the anisotropy values in a texture.
  55975. * rg is direction (like normal from -1 to 1)
  55976. * b is a intensity
  55977. */
  55978. texture: Nullable<BaseTexture>;
  55979. /** @hidden */
  55980. private _internalMarkAllSubMeshesAsTexturesDirty;
  55981. /** @hidden */
  55982. _markAllSubMeshesAsTexturesDirty(): void;
  55983. /**
  55984. * Instantiate a new istance of anisotropy configuration.
  55985. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55986. */
  55987. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55988. /**
  55989. * Specifies that the submesh is ready to be used.
  55990. * @param defines the list of "defines" to update.
  55991. * @param scene defines the scene the material belongs to.
  55992. * @returns - boolean indicating that the submesh is ready or not.
  55993. */
  55994. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55995. /**
  55996. * Checks to see if a texture is used in the material.
  55997. * @param defines the list of "defines" to update.
  55998. * @param mesh the mesh we are preparing the defines for.
  55999. * @param scene defines the scene the material belongs to.
  56000. */
  56001. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56002. /**
  56003. * Binds the material data.
  56004. * @param uniformBuffer defines the Uniform buffer to fill in.
  56005. * @param scene defines the scene the material belongs to.
  56006. * @param isFrozen defines wether the material is frozen or not.
  56007. */
  56008. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56009. /**
  56010. * Checks to see if a texture is used in the material.
  56011. * @param texture - Base texture to use.
  56012. * @returns - Boolean specifying if a texture is used in the material.
  56013. */
  56014. hasTexture(texture: BaseTexture): boolean;
  56015. /**
  56016. * Returns an array of the actively used textures.
  56017. * @param activeTextures Array of BaseTextures
  56018. */
  56019. getActiveTextures(activeTextures: BaseTexture[]): void;
  56020. /**
  56021. * Returns the animatable textures.
  56022. * @param animatables Array of animatable textures.
  56023. */
  56024. getAnimatables(animatables: IAnimatable[]): void;
  56025. /**
  56026. * Disposes the resources of the material.
  56027. * @param forceDisposeTextures - Forces the disposal of all textures.
  56028. */
  56029. dispose(forceDisposeTextures?: boolean): void;
  56030. /**
  56031. * Get the current class name of the texture useful for serialization or dynamic coding.
  56032. * @returns "PBRAnisotropicConfiguration"
  56033. */
  56034. getClassName(): string;
  56035. /**
  56036. * Add fallbacks to the effect fallbacks list.
  56037. * @param defines defines the Base texture to use.
  56038. * @param fallbacks defines the current fallback list.
  56039. * @param currentRank defines the current fallback rank.
  56040. * @returns the new fallback rank.
  56041. */
  56042. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56043. /**
  56044. * Add the required uniforms to the current list.
  56045. * @param uniforms defines the current uniform list.
  56046. */
  56047. static AddUniforms(uniforms: string[]): void;
  56048. /**
  56049. * Add the required uniforms to the current buffer.
  56050. * @param uniformBuffer defines the current uniform buffer.
  56051. */
  56052. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56053. /**
  56054. * Add the required samplers to the current list.
  56055. * @param samplers defines the current sampler list.
  56056. */
  56057. static AddSamplers(samplers: string[]): void;
  56058. /**
  56059. * Makes a duplicate of the current configuration into another one.
  56060. * @param anisotropicConfiguration define the config where to copy the info
  56061. */
  56062. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56063. /**
  56064. * Serializes this anisotropy configuration.
  56065. * @returns - An object with the serialized config.
  56066. */
  56067. serialize(): any;
  56068. /**
  56069. * Parses a anisotropy Configuration from a serialized object.
  56070. * @param source - Serialized object.
  56071. * @param scene Defines the scene we are parsing for
  56072. * @param rootUrl Defines the rootUrl to load from
  56073. */
  56074. parse(source: any, scene: Scene, rootUrl: string): void;
  56075. }
  56076. }
  56077. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56078. import { Scene } from "babylonjs/scene";
  56079. /**
  56080. * @hidden
  56081. */
  56082. export interface IMaterialBRDFDefines {
  56083. BRDF_V_HEIGHT_CORRELATED: boolean;
  56084. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56085. SPHERICAL_HARMONICS: boolean;
  56086. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56087. /** @hidden */
  56088. _areMiscDirty: boolean;
  56089. }
  56090. /**
  56091. * Define the code related to the BRDF parameters of the pbr material.
  56092. */
  56093. export class PBRBRDFConfiguration {
  56094. /**
  56095. * Default value used for the energy conservation.
  56096. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56097. */
  56098. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56099. /**
  56100. * Default value used for the Smith Visibility Height Correlated mode.
  56101. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56102. */
  56103. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56104. /**
  56105. * Default value used for the IBL diffuse part.
  56106. * This can help switching back to the polynomials mode globally which is a tiny bit
  56107. * less GPU intensive at the drawback of a lower quality.
  56108. */
  56109. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56110. /**
  56111. * Default value used for activating energy conservation for the specular workflow.
  56112. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56113. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56114. */
  56115. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56116. private _useEnergyConservation;
  56117. /**
  56118. * Defines if the material uses energy conservation.
  56119. */
  56120. useEnergyConservation: boolean;
  56121. private _useSmithVisibilityHeightCorrelated;
  56122. /**
  56123. * LEGACY Mode set to false
  56124. * Defines if the material uses height smith correlated visibility term.
  56125. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56126. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56127. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56128. * Not relying on height correlated will also disable energy conservation.
  56129. */
  56130. useSmithVisibilityHeightCorrelated: boolean;
  56131. private _useSphericalHarmonics;
  56132. /**
  56133. * LEGACY Mode set to false
  56134. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56135. * diffuse part of the IBL.
  56136. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56137. * to the ground truth.
  56138. */
  56139. useSphericalHarmonics: boolean;
  56140. private _useSpecularGlossinessInputEnergyConservation;
  56141. /**
  56142. * Defines if the material uses energy conservation, when the specular workflow is active.
  56143. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56144. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56145. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56146. */
  56147. useSpecularGlossinessInputEnergyConservation: boolean;
  56148. /** @hidden */
  56149. private _internalMarkAllSubMeshesAsMiscDirty;
  56150. /** @hidden */
  56151. _markAllSubMeshesAsMiscDirty(): void;
  56152. /**
  56153. * Instantiate a new istance of clear coat configuration.
  56154. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56155. */
  56156. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56157. /**
  56158. * Checks to see if a texture is used in the material.
  56159. * @param defines the list of "defines" to update.
  56160. */
  56161. prepareDefines(defines: IMaterialBRDFDefines): void;
  56162. /**
  56163. * Get the current class name of the texture useful for serialization or dynamic coding.
  56164. * @returns "PBRClearCoatConfiguration"
  56165. */
  56166. getClassName(): string;
  56167. /**
  56168. * Makes a duplicate of the current configuration into another one.
  56169. * @param brdfConfiguration define the config where to copy the info
  56170. */
  56171. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56172. /**
  56173. * Serializes this BRDF configuration.
  56174. * @returns - An object with the serialized config.
  56175. */
  56176. serialize(): any;
  56177. /**
  56178. * Parses a anisotropy Configuration from a serialized object.
  56179. * @param source - Serialized object.
  56180. * @param scene Defines the scene we are parsing for
  56181. * @param rootUrl Defines the rootUrl to load from
  56182. */
  56183. parse(source: any, scene: Scene, rootUrl: string): void;
  56184. }
  56185. }
  56186. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56187. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56188. import { Color3 } from "babylonjs/Maths/math.color";
  56189. import { Scene } from "babylonjs/scene";
  56190. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56191. import { Nullable } from "babylonjs/types";
  56192. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56193. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56194. /**
  56195. * @hidden
  56196. */
  56197. export interface IMaterialSheenDefines {
  56198. SHEEN: boolean;
  56199. SHEEN_TEXTURE: boolean;
  56200. SHEEN_TEXTUREDIRECTUV: number;
  56201. SHEEN_LINKWITHALBEDO: boolean;
  56202. SHEEN_ROUGHNESS: boolean;
  56203. SHEEN_ALBEDOSCALING: boolean;
  56204. /** @hidden */
  56205. _areTexturesDirty: boolean;
  56206. }
  56207. /**
  56208. * Define the code related to the Sheen parameters of the pbr material.
  56209. */
  56210. export class PBRSheenConfiguration {
  56211. private _isEnabled;
  56212. /**
  56213. * Defines if the material uses sheen.
  56214. */
  56215. isEnabled: boolean;
  56216. private _linkSheenWithAlbedo;
  56217. /**
  56218. * Defines if the sheen is linked to the sheen color.
  56219. */
  56220. linkSheenWithAlbedo: boolean;
  56221. /**
  56222. * Defines the sheen intensity.
  56223. */
  56224. intensity: number;
  56225. /**
  56226. * Defines the sheen color.
  56227. */
  56228. color: Color3;
  56229. private _texture;
  56230. /**
  56231. * Stores the sheen tint values in a texture.
  56232. * rgb is tint
  56233. * a is a intensity
  56234. */
  56235. texture: Nullable<BaseTexture>;
  56236. private _roughness;
  56237. /**
  56238. * Defines the sheen roughness.
  56239. * It is not taken into account if linkSheenWithAlbedo is true.
  56240. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56241. */
  56242. roughness: Nullable<number>;
  56243. private _albedoScaling;
  56244. /**
  56245. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56246. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56247. * making it easier to setup and tweak the effect
  56248. */
  56249. albedoScaling: boolean;
  56250. /** @hidden */
  56251. private _internalMarkAllSubMeshesAsTexturesDirty;
  56252. /** @hidden */
  56253. _markAllSubMeshesAsTexturesDirty(): void;
  56254. /**
  56255. * Instantiate a new istance of clear coat configuration.
  56256. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56257. */
  56258. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56259. /**
  56260. * Specifies that the submesh is ready to be used.
  56261. * @param defines the list of "defines" to update.
  56262. * @param scene defines the scene the material belongs to.
  56263. * @returns - boolean indicating that the submesh is ready or not.
  56264. */
  56265. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56266. /**
  56267. * Checks to see if a texture is used in the material.
  56268. * @param defines the list of "defines" to update.
  56269. * @param scene defines the scene the material belongs to.
  56270. */
  56271. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56272. /**
  56273. * Binds the material data.
  56274. * @param uniformBuffer defines the Uniform buffer to fill in.
  56275. * @param scene defines the scene the material belongs to.
  56276. * @param isFrozen defines wether the material is frozen or not.
  56277. */
  56278. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56279. /**
  56280. * Checks to see if a texture is used in the material.
  56281. * @param texture - Base texture to use.
  56282. * @returns - Boolean specifying if a texture is used in the material.
  56283. */
  56284. hasTexture(texture: BaseTexture): boolean;
  56285. /**
  56286. * Returns an array of the actively used textures.
  56287. * @param activeTextures Array of BaseTextures
  56288. */
  56289. getActiveTextures(activeTextures: BaseTexture[]): void;
  56290. /**
  56291. * Returns the animatable textures.
  56292. * @param animatables Array of animatable textures.
  56293. */
  56294. getAnimatables(animatables: IAnimatable[]): void;
  56295. /**
  56296. * Disposes the resources of the material.
  56297. * @param forceDisposeTextures - Forces the disposal of all textures.
  56298. */
  56299. dispose(forceDisposeTextures?: boolean): void;
  56300. /**
  56301. * Get the current class name of the texture useful for serialization or dynamic coding.
  56302. * @returns "PBRSheenConfiguration"
  56303. */
  56304. getClassName(): string;
  56305. /**
  56306. * Add fallbacks to the effect fallbacks list.
  56307. * @param defines defines the Base texture to use.
  56308. * @param fallbacks defines the current fallback list.
  56309. * @param currentRank defines the current fallback rank.
  56310. * @returns the new fallback rank.
  56311. */
  56312. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56313. /**
  56314. * Add the required uniforms to the current list.
  56315. * @param uniforms defines the current uniform list.
  56316. */
  56317. static AddUniforms(uniforms: string[]): void;
  56318. /**
  56319. * Add the required uniforms to the current buffer.
  56320. * @param uniformBuffer defines the current uniform buffer.
  56321. */
  56322. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56323. /**
  56324. * Add the required samplers to the current list.
  56325. * @param samplers defines the current sampler list.
  56326. */
  56327. static AddSamplers(samplers: string[]): void;
  56328. /**
  56329. * Makes a duplicate of the current configuration into another one.
  56330. * @param sheenConfiguration define the config where to copy the info
  56331. */
  56332. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56333. /**
  56334. * Serializes this BRDF configuration.
  56335. * @returns - An object with the serialized config.
  56336. */
  56337. serialize(): any;
  56338. /**
  56339. * Parses a anisotropy Configuration from a serialized object.
  56340. * @param source - Serialized object.
  56341. * @param scene Defines the scene we are parsing for
  56342. * @param rootUrl Defines the rootUrl to load from
  56343. */
  56344. parse(source: any, scene: Scene, rootUrl: string): void;
  56345. }
  56346. }
  56347. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56348. import { Nullable } from "babylonjs/types";
  56349. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56350. import { Color3 } from "babylonjs/Maths/math.color";
  56351. import { SmartArray } from "babylonjs/Misc/smartArray";
  56352. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56353. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56354. import { Effect } from "babylonjs/Materials/effect";
  56355. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56356. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56357. import { Engine } from "babylonjs/Engines/engine";
  56358. import { Scene } from "babylonjs/scene";
  56359. /**
  56360. * @hidden
  56361. */
  56362. export interface IMaterialSubSurfaceDefines {
  56363. SUBSURFACE: boolean;
  56364. SS_REFRACTION: boolean;
  56365. SS_TRANSLUCENCY: boolean;
  56366. SS_SCATERRING: boolean;
  56367. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56368. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56369. SS_REFRACTIONMAP_3D: boolean;
  56370. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56371. SS_LODINREFRACTIONALPHA: boolean;
  56372. SS_GAMMAREFRACTION: boolean;
  56373. SS_RGBDREFRACTION: boolean;
  56374. SS_LINEARSPECULARREFRACTION: boolean;
  56375. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56376. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56377. /** @hidden */
  56378. _areTexturesDirty: boolean;
  56379. }
  56380. /**
  56381. * Define the code related to the sub surface parameters of the pbr material.
  56382. */
  56383. export class PBRSubSurfaceConfiguration {
  56384. private _isRefractionEnabled;
  56385. /**
  56386. * Defines if the refraction is enabled in the material.
  56387. */
  56388. isRefractionEnabled: boolean;
  56389. private _isTranslucencyEnabled;
  56390. /**
  56391. * Defines if the translucency is enabled in the material.
  56392. */
  56393. isTranslucencyEnabled: boolean;
  56394. private _isScatteringEnabled;
  56395. /**
  56396. * Defines the refraction intensity of the material.
  56397. * The refraction when enabled replaces the Diffuse part of the material.
  56398. * The intensity helps transitionning between diffuse and refraction.
  56399. */
  56400. refractionIntensity: number;
  56401. /**
  56402. * Defines the translucency intensity of the material.
  56403. * When translucency has been enabled, this defines how much of the "translucency"
  56404. * is addded to the diffuse part of the material.
  56405. */
  56406. translucencyIntensity: number;
  56407. /**
  56408. * Defines the scattering intensity of the material.
  56409. * When scattering has been enabled, this defines how much of the "scattered light"
  56410. * is addded to the diffuse part of the material.
  56411. */
  56412. scatteringIntensity: number;
  56413. private _thicknessTexture;
  56414. /**
  56415. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56416. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56417. * 0 would mean minimumThickness
  56418. * 1 would mean maximumThickness
  56419. * The other channels might be use as a mask to vary the different effects intensity.
  56420. */
  56421. thicknessTexture: Nullable<BaseTexture>;
  56422. private _refractionTexture;
  56423. /**
  56424. * Defines the texture to use for refraction.
  56425. */
  56426. refractionTexture: Nullable<BaseTexture>;
  56427. private _indexOfRefraction;
  56428. /**
  56429. * Index of refraction of the material base layer.
  56430. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56431. *
  56432. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56433. *
  56434. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56435. */
  56436. indexOfRefraction: number;
  56437. private _invertRefractionY;
  56438. /**
  56439. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56440. */
  56441. invertRefractionY: boolean;
  56442. private _linkRefractionWithTransparency;
  56443. /**
  56444. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56445. * Materials half opaque for instance using refraction could benefit from this control.
  56446. */
  56447. linkRefractionWithTransparency: boolean;
  56448. /**
  56449. * Defines the minimum thickness stored in the thickness map.
  56450. * If no thickness map is defined, this value will be used to simulate thickness.
  56451. */
  56452. minimumThickness: number;
  56453. /**
  56454. * Defines the maximum thickness stored in the thickness map.
  56455. */
  56456. maximumThickness: number;
  56457. /**
  56458. * Defines the volume tint of the material.
  56459. * This is used for both translucency and scattering.
  56460. */
  56461. tintColor: Color3;
  56462. /**
  56463. * Defines the distance at which the tint color should be found in the media.
  56464. * This is used for refraction only.
  56465. */
  56466. tintColorAtDistance: number;
  56467. /**
  56468. * Defines how far each channel transmit through the media.
  56469. * It is defined as a color to simplify it selection.
  56470. */
  56471. diffusionDistance: Color3;
  56472. private _useMaskFromThicknessTexture;
  56473. /**
  56474. * Stores the intensity of the different subsurface effects in the thickness texture.
  56475. * * the green channel is the translucency intensity.
  56476. * * the blue channel is the scattering intensity.
  56477. * * the alpha channel is the refraction intensity.
  56478. */
  56479. useMaskFromThicknessTexture: boolean;
  56480. /** @hidden */
  56481. private _internalMarkAllSubMeshesAsTexturesDirty;
  56482. /** @hidden */
  56483. _markAllSubMeshesAsTexturesDirty(): void;
  56484. /**
  56485. * Instantiate a new istance of sub surface configuration.
  56486. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56487. */
  56488. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56489. /**
  56490. * Gets wehter the submesh is ready to be used or not.
  56491. * @param defines the list of "defines" to update.
  56492. * @param scene defines the scene the material belongs to.
  56493. * @returns - boolean indicating that the submesh is ready or not.
  56494. */
  56495. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56496. /**
  56497. * Checks to see if a texture is used in the material.
  56498. * @param defines the list of "defines" to update.
  56499. * @param scene defines the scene to the material belongs to.
  56500. */
  56501. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56502. /**
  56503. * Binds the material data.
  56504. * @param uniformBuffer defines the Uniform buffer to fill in.
  56505. * @param scene defines the scene the material belongs to.
  56506. * @param engine defines the engine the material belongs to.
  56507. * @param isFrozen defines whether the material is frozen or not.
  56508. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56509. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56510. */
  56511. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56512. /**
  56513. * Unbinds the material from the mesh.
  56514. * @param activeEffect defines the effect that should be unbound from.
  56515. * @returns true if unbound, otherwise false
  56516. */
  56517. unbind(activeEffect: Effect): boolean;
  56518. /**
  56519. * Returns the texture used for refraction or null if none is used.
  56520. * @param scene defines the scene the material belongs to.
  56521. * @returns - Refraction texture if present. If no refraction texture and refraction
  56522. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56523. */
  56524. private _getRefractionTexture;
  56525. /**
  56526. * Returns true if alpha blending should be disabled.
  56527. */
  56528. get disableAlphaBlending(): boolean;
  56529. /**
  56530. * Fills the list of render target textures.
  56531. * @param renderTargets the list of render targets to update
  56532. */
  56533. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56534. /**
  56535. * Checks to see if a texture is used in the material.
  56536. * @param texture - Base texture to use.
  56537. * @returns - Boolean specifying if a texture is used in the material.
  56538. */
  56539. hasTexture(texture: BaseTexture): boolean;
  56540. /**
  56541. * Gets a boolean indicating that current material needs to register RTT
  56542. * @returns true if this uses a render target otherwise false.
  56543. */
  56544. hasRenderTargetTextures(): boolean;
  56545. /**
  56546. * Returns an array of the actively used textures.
  56547. * @param activeTextures Array of BaseTextures
  56548. */
  56549. getActiveTextures(activeTextures: BaseTexture[]): void;
  56550. /**
  56551. * Returns the animatable textures.
  56552. * @param animatables Array of animatable textures.
  56553. */
  56554. getAnimatables(animatables: IAnimatable[]): void;
  56555. /**
  56556. * Disposes the resources of the material.
  56557. * @param forceDisposeTextures - Forces the disposal of all textures.
  56558. */
  56559. dispose(forceDisposeTextures?: boolean): void;
  56560. /**
  56561. * Get the current class name of the texture useful for serialization or dynamic coding.
  56562. * @returns "PBRSubSurfaceConfiguration"
  56563. */
  56564. getClassName(): string;
  56565. /**
  56566. * Add fallbacks to the effect fallbacks list.
  56567. * @param defines defines the Base texture to use.
  56568. * @param fallbacks defines the current fallback list.
  56569. * @param currentRank defines the current fallback rank.
  56570. * @returns the new fallback rank.
  56571. */
  56572. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56573. /**
  56574. * Add the required uniforms to the current list.
  56575. * @param uniforms defines the current uniform list.
  56576. */
  56577. static AddUniforms(uniforms: string[]): void;
  56578. /**
  56579. * Add the required samplers to the current list.
  56580. * @param samplers defines the current sampler list.
  56581. */
  56582. static AddSamplers(samplers: string[]): void;
  56583. /**
  56584. * Add the required uniforms to the current buffer.
  56585. * @param uniformBuffer defines the current uniform buffer.
  56586. */
  56587. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56588. /**
  56589. * Makes a duplicate of the current configuration into another one.
  56590. * @param configuration define the config where to copy the info
  56591. */
  56592. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56593. /**
  56594. * Serializes this Sub Surface configuration.
  56595. * @returns - An object with the serialized config.
  56596. */
  56597. serialize(): any;
  56598. /**
  56599. * Parses a anisotropy Configuration from a serialized object.
  56600. * @param source - Serialized object.
  56601. * @param scene Defines the scene we are parsing for
  56602. * @param rootUrl Defines the rootUrl to load from
  56603. */
  56604. parse(source: any, scene: Scene, rootUrl: string): void;
  56605. }
  56606. }
  56607. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  56608. /** @hidden */
  56609. export var pbrFragmentDeclaration: {
  56610. name: string;
  56611. shader: string;
  56612. };
  56613. }
  56614. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  56615. /** @hidden */
  56616. export var pbrUboDeclaration: {
  56617. name: string;
  56618. shader: string;
  56619. };
  56620. }
  56621. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  56622. /** @hidden */
  56623. export var pbrFragmentExtraDeclaration: {
  56624. name: string;
  56625. shader: string;
  56626. };
  56627. }
  56628. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  56629. /** @hidden */
  56630. export var pbrFragmentSamplersDeclaration: {
  56631. name: string;
  56632. shader: string;
  56633. };
  56634. }
  56635. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  56636. /** @hidden */
  56637. export var importanceSampling: {
  56638. name: string;
  56639. shader: string;
  56640. };
  56641. }
  56642. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  56643. /** @hidden */
  56644. export var pbrHelperFunctions: {
  56645. name: string;
  56646. shader: string;
  56647. };
  56648. }
  56649. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  56650. /** @hidden */
  56651. export var harmonicsFunctions: {
  56652. name: string;
  56653. shader: string;
  56654. };
  56655. }
  56656. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  56657. /** @hidden */
  56658. export var pbrDirectLightingSetupFunctions: {
  56659. name: string;
  56660. shader: string;
  56661. };
  56662. }
  56663. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  56664. /** @hidden */
  56665. export var pbrDirectLightingFalloffFunctions: {
  56666. name: string;
  56667. shader: string;
  56668. };
  56669. }
  56670. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  56671. /** @hidden */
  56672. export var pbrBRDFFunctions: {
  56673. name: string;
  56674. shader: string;
  56675. };
  56676. }
  56677. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  56678. /** @hidden */
  56679. export var hdrFilteringFunctions: {
  56680. name: string;
  56681. shader: string;
  56682. };
  56683. }
  56684. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  56685. /** @hidden */
  56686. export var pbrDirectLightingFunctions: {
  56687. name: string;
  56688. shader: string;
  56689. };
  56690. }
  56691. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  56692. /** @hidden */
  56693. export var pbrIBLFunctions: {
  56694. name: string;
  56695. shader: string;
  56696. };
  56697. }
  56698. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  56699. /** @hidden */
  56700. export var pbrBlockAlbedoOpacity: {
  56701. name: string;
  56702. shader: string;
  56703. };
  56704. }
  56705. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  56706. /** @hidden */
  56707. export var pbrBlockReflectivity: {
  56708. name: string;
  56709. shader: string;
  56710. };
  56711. }
  56712. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  56713. /** @hidden */
  56714. export var pbrBlockAmbientOcclusion: {
  56715. name: string;
  56716. shader: string;
  56717. };
  56718. }
  56719. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  56720. /** @hidden */
  56721. export var pbrBlockAlphaFresnel: {
  56722. name: string;
  56723. shader: string;
  56724. };
  56725. }
  56726. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  56727. /** @hidden */
  56728. export var pbrBlockAnisotropic: {
  56729. name: string;
  56730. shader: string;
  56731. };
  56732. }
  56733. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  56734. /** @hidden */
  56735. export var pbrBlockReflection: {
  56736. name: string;
  56737. shader: string;
  56738. };
  56739. }
  56740. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  56741. /** @hidden */
  56742. export var pbrBlockSheen: {
  56743. name: string;
  56744. shader: string;
  56745. };
  56746. }
  56747. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  56748. /** @hidden */
  56749. export var pbrBlockClearcoat: {
  56750. name: string;
  56751. shader: string;
  56752. };
  56753. }
  56754. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  56755. /** @hidden */
  56756. export var pbrBlockSubSurface: {
  56757. name: string;
  56758. shader: string;
  56759. };
  56760. }
  56761. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  56762. /** @hidden */
  56763. export var pbrBlockNormalGeometric: {
  56764. name: string;
  56765. shader: string;
  56766. };
  56767. }
  56768. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  56769. /** @hidden */
  56770. export var pbrBlockNormalFinal: {
  56771. name: string;
  56772. shader: string;
  56773. };
  56774. }
  56775. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  56776. /** @hidden */
  56777. export var pbrBlockGeometryInfo: {
  56778. name: string;
  56779. shader: string;
  56780. };
  56781. }
  56782. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  56783. /** @hidden */
  56784. export var pbrBlockReflectance0: {
  56785. name: string;
  56786. shader: string;
  56787. };
  56788. }
  56789. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  56790. /** @hidden */
  56791. export var pbrBlockReflectance: {
  56792. name: string;
  56793. shader: string;
  56794. };
  56795. }
  56796. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  56797. /** @hidden */
  56798. export var pbrBlockDirectLighting: {
  56799. name: string;
  56800. shader: string;
  56801. };
  56802. }
  56803. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  56804. /** @hidden */
  56805. export var pbrBlockFinalLitComponents: {
  56806. name: string;
  56807. shader: string;
  56808. };
  56809. }
  56810. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  56811. /** @hidden */
  56812. export var pbrBlockFinalUnlitComponents: {
  56813. name: string;
  56814. shader: string;
  56815. };
  56816. }
  56817. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  56818. /** @hidden */
  56819. export var pbrBlockFinalColorComposition: {
  56820. name: string;
  56821. shader: string;
  56822. };
  56823. }
  56824. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  56825. /** @hidden */
  56826. export var pbrBlockImageProcessing: {
  56827. name: string;
  56828. shader: string;
  56829. };
  56830. }
  56831. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  56832. /** @hidden */
  56833. export var pbrDebug: {
  56834. name: string;
  56835. shader: string;
  56836. };
  56837. }
  56838. declare module "babylonjs/Shaders/pbr.fragment" {
  56839. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  56840. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56841. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  56842. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56843. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56844. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  56845. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56846. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56847. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56848. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56849. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56850. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  56851. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  56852. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56853. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56854. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56855. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  56856. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  56857. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  56858. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  56859. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  56860. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  56861. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  56862. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56863. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56864. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  56865. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  56866. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  56867. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  56868. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  56869. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  56870. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  56871. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  56872. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  56873. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56874. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  56875. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56876. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  56877. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  56878. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  56879. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  56880. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  56881. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  56882. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56883. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  56884. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  56885. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  56886. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56887. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56888. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  56889. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  56890. /** @hidden */
  56891. export var pbrPixelShader: {
  56892. name: string;
  56893. shader: string;
  56894. };
  56895. }
  56896. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  56897. /** @hidden */
  56898. export var pbrVertexDeclaration: {
  56899. name: string;
  56900. shader: string;
  56901. };
  56902. }
  56903. declare module "babylonjs/Shaders/pbr.vertex" {
  56904. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  56905. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56906. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56907. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56908. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56909. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56910. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  56911. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56912. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56913. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56914. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56915. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56916. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56917. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56918. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56919. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56920. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56921. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  56922. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56923. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56924. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56925. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56926. /** @hidden */
  56927. export var pbrVertexShader: {
  56928. name: string;
  56929. shader: string;
  56930. };
  56931. }
  56932. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  56933. import { Nullable } from "babylonjs/types";
  56934. import { Scene } from "babylonjs/scene";
  56935. import { Matrix } from "babylonjs/Maths/math.vector";
  56936. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56938. import { Mesh } from "babylonjs/Meshes/mesh";
  56939. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  56940. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  56941. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  56942. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  56943. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  56944. import { Color3 } from "babylonjs/Maths/math.color";
  56945. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56946. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  56947. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56948. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56950. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56951. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  56952. import "babylonjs/Shaders/pbr.fragment";
  56953. import "babylonjs/Shaders/pbr.vertex";
  56954. /**
  56955. * Manages the defines for the PBR Material.
  56956. * @hidden
  56957. */
  56958. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  56959. PBR: boolean;
  56960. NUM_SAMPLES: string;
  56961. REALTIME_FILTERING: boolean;
  56962. MAINUV1: boolean;
  56963. MAINUV2: boolean;
  56964. UV1: boolean;
  56965. UV2: boolean;
  56966. ALBEDO: boolean;
  56967. GAMMAALBEDO: boolean;
  56968. ALBEDODIRECTUV: number;
  56969. VERTEXCOLOR: boolean;
  56970. AMBIENT: boolean;
  56971. AMBIENTDIRECTUV: number;
  56972. AMBIENTINGRAYSCALE: boolean;
  56973. OPACITY: boolean;
  56974. VERTEXALPHA: boolean;
  56975. OPACITYDIRECTUV: number;
  56976. OPACITYRGB: boolean;
  56977. ALPHATEST: boolean;
  56978. DEPTHPREPASS: boolean;
  56979. ALPHABLEND: boolean;
  56980. ALPHAFROMALBEDO: boolean;
  56981. ALPHATESTVALUE: string;
  56982. SPECULAROVERALPHA: boolean;
  56983. RADIANCEOVERALPHA: boolean;
  56984. ALPHAFRESNEL: boolean;
  56985. LINEARALPHAFRESNEL: boolean;
  56986. PREMULTIPLYALPHA: boolean;
  56987. EMISSIVE: boolean;
  56988. EMISSIVEDIRECTUV: number;
  56989. REFLECTIVITY: boolean;
  56990. REFLECTIVITYDIRECTUV: number;
  56991. SPECULARTERM: boolean;
  56992. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56993. MICROSURFACEAUTOMATIC: boolean;
  56994. LODBASEDMICROSFURACE: boolean;
  56995. MICROSURFACEMAP: boolean;
  56996. MICROSURFACEMAPDIRECTUV: number;
  56997. METALLICWORKFLOW: boolean;
  56998. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56999. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57000. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57001. AOSTOREINMETALMAPRED: boolean;
  57002. METALLIC_REFLECTANCE: boolean;
  57003. METALLIC_REFLECTANCEDIRECTUV: number;
  57004. ENVIRONMENTBRDF: boolean;
  57005. ENVIRONMENTBRDF_RGBD: boolean;
  57006. NORMAL: boolean;
  57007. TANGENT: boolean;
  57008. BUMP: boolean;
  57009. BUMPDIRECTUV: number;
  57010. OBJECTSPACE_NORMALMAP: boolean;
  57011. PARALLAX: boolean;
  57012. PARALLAXOCCLUSION: boolean;
  57013. NORMALXYSCALE: boolean;
  57014. LIGHTMAP: boolean;
  57015. LIGHTMAPDIRECTUV: number;
  57016. USELIGHTMAPASSHADOWMAP: boolean;
  57017. GAMMALIGHTMAP: boolean;
  57018. RGBDLIGHTMAP: boolean;
  57019. REFLECTION: boolean;
  57020. REFLECTIONMAP_3D: boolean;
  57021. REFLECTIONMAP_SPHERICAL: boolean;
  57022. REFLECTIONMAP_PLANAR: boolean;
  57023. REFLECTIONMAP_CUBIC: boolean;
  57024. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57025. REFLECTIONMAP_PROJECTION: boolean;
  57026. REFLECTIONMAP_SKYBOX: boolean;
  57027. REFLECTIONMAP_EXPLICIT: boolean;
  57028. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57029. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57030. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57031. INVERTCUBICMAP: boolean;
  57032. USESPHERICALFROMREFLECTIONMAP: boolean;
  57033. USEIRRADIANCEMAP: boolean;
  57034. SPHERICAL_HARMONICS: boolean;
  57035. USESPHERICALINVERTEX: boolean;
  57036. REFLECTIONMAP_OPPOSITEZ: boolean;
  57037. LODINREFLECTIONALPHA: boolean;
  57038. GAMMAREFLECTION: boolean;
  57039. RGBDREFLECTION: boolean;
  57040. LINEARSPECULARREFLECTION: boolean;
  57041. RADIANCEOCCLUSION: boolean;
  57042. HORIZONOCCLUSION: boolean;
  57043. INSTANCES: boolean;
  57044. THIN_INSTANCES: boolean;
  57045. NUM_BONE_INFLUENCERS: number;
  57046. BonesPerMesh: number;
  57047. BONETEXTURE: boolean;
  57048. NONUNIFORMSCALING: boolean;
  57049. MORPHTARGETS: boolean;
  57050. MORPHTARGETS_NORMAL: boolean;
  57051. MORPHTARGETS_TANGENT: boolean;
  57052. MORPHTARGETS_UV: boolean;
  57053. NUM_MORPH_INFLUENCERS: number;
  57054. IMAGEPROCESSING: boolean;
  57055. VIGNETTE: boolean;
  57056. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57057. VIGNETTEBLENDMODEOPAQUE: boolean;
  57058. TONEMAPPING: boolean;
  57059. TONEMAPPING_ACES: boolean;
  57060. CONTRAST: boolean;
  57061. COLORCURVES: boolean;
  57062. COLORGRADING: boolean;
  57063. COLORGRADING3D: boolean;
  57064. SAMPLER3DGREENDEPTH: boolean;
  57065. SAMPLER3DBGRMAP: boolean;
  57066. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57067. EXPOSURE: boolean;
  57068. MULTIVIEW: boolean;
  57069. USEPHYSICALLIGHTFALLOFF: boolean;
  57070. USEGLTFLIGHTFALLOFF: boolean;
  57071. TWOSIDEDLIGHTING: boolean;
  57072. SHADOWFLOAT: boolean;
  57073. CLIPPLANE: boolean;
  57074. CLIPPLANE2: boolean;
  57075. CLIPPLANE3: boolean;
  57076. CLIPPLANE4: boolean;
  57077. CLIPPLANE5: boolean;
  57078. CLIPPLANE6: boolean;
  57079. POINTSIZE: boolean;
  57080. FOG: boolean;
  57081. LOGARITHMICDEPTH: boolean;
  57082. FORCENORMALFORWARD: boolean;
  57083. SPECULARAA: boolean;
  57084. CLEARCOAT: boolean;
  57085. CLEARCOAT_DEFAULTIOR: boolean;
  57086. CLEARCOAT_TEXTURE: boolean;
  57087. CLEARCOAT_TEXTUREDIRECTUV: number;
  57088. CLEARCOAT_BUMP: boolean;
  57089. CLEARCOAT_BUMPDIRECTUV: number;
  57090. CLEARCOAT_TINT: boolean;
  57091. CLEARCOAT_TINT_TEXTURE: boolean;
  57092. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57093. ANISOTROPIC: boolean;
  57094. ANISOTROPIC_TEXTURE: boolean;
  57095. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57096. BRDF_V_HEIGHT_CORRELATED: boolean;
  57097. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57098. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57099. SHEEN: boolean;
  57100. SHEEN_TEXTURE: boolean;
  57101. SHEEN_TEXTUREDIRECTUV: number;
  57102. SHEEN_LINKWITHALBEDO: boolean;
  57103. SHEEN_ROUGHNESS: boolean;
  57104. SHEEN_ALBEDOSCALING: boolean;
  57105. SUBSURFACE: boolean;
  57106. SS_REFRACTION: boolean;
  57107. SS_TRANSLUCENCY: boolean;
  57108. SS_SCATERRING: boolean;
  57109. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57110. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57111. SS_REFRACTIONMAP_3D: boolean;
  57112. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57113. SS_LODINREFRACTIONALPHA: boolean;
  57114. SS_GAMMAREFRACTION: boolean;
  57115. SS_RGBDREFRACTION: boolean;
  57116. SS_LINEARSPECULARREFRACTION: boolean;
  57117. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57118. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57119. UNLIT: boolean;
  57120. DEBUGMODE: number;
  57121. /**
  57122. * Initializes the PBR Material defines.
  57123. */
  57124. constructor();
  57125. /**
  57126. * Resets the PBR Material defines.
  57127. */
  57128. reset(): void;
  57129. }
  57130. /**
  57131. * The Physically based material base class of BJS.
  57132. *
  57133. * This offers the main features of a standard PBR material.
  57134. * For more information, please refer to the documentation :
  57135. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57136. */
  57137. export abstract class PBRBaseMaterial extends PushMaterial {
  57138. /**
  57139. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57140. */
  57141. static readonly PBRMATERIAL_OPAQUE: number;
  57142. /**
  57143. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57144. */
  57145. static readonly PBRMATERIAL_ALPHATEST: number;
  57146. /**
  57147. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57148. */
  57149. static readonly PBRMATERIAL_ALPHABLEND: number;
  57150. /**
  57151. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57152. * They are also discarded below the alpha cutoff threshold to improve performances.
  57153. */
  57154. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57155. /**
  57156. * Defines the default value of how much AO map is occluding the analytical lights
  57157. * (point spot...).
  57158. */
  57159. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57160. /**
  57161. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57162. */
  57163. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57164. /**
  57165. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57166. * to enhance interoperability with other engines.
  57167. */
  57168. static readonly LIGHTFALLOFF_GLTF: number;
  57169. /**
  57170. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57171. * to enhance interoperability with other materials.
  57172. */
  57173. static readonly LIGHTFALLOFF_STANDARD: number;
  57174. /**
  57175. * Intensity of the direct lights e.g. the four lights available in your scene.
  57176. * This impacts both the direct diffuse and specular highlights.
  57177. */
  57178. protected _directIntensity: number;
  57179. /**
  57180. * Intensity of the emissive part of the material.
  57181. * This helps controlling the emissive effect without modifying the emissive color.
  57182. */
  57183. protected _emissiveIntensity: number;
  57184. /**
  57185. * Intensity of the environment e.g. how much the environment will light the object
  57186. * either through harmonics for rough material or through the refelction for shiny ones.
  57187. */
  57188. protected _environmentIntensity: number;
  57189. /**
  57190. * This is a special control allowing the reduction of the specular highlights coming from the
  57191. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57192. */
  57193. protected _specularIntensity: number;
  57194. /**
  57195. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57196. */
  57197. private _lightingInfos;
  57198. /**
  57199. * Debug Control allowing disabling the bump map on this material.
  57200. */
  57201. protected _disableBumpMap: boolean;
  57202. /**
  57203. * AKA Diffuse Texture in standard nomenclature.
  57204. */
  57205. protected _albedoTexture: Nullable<BaseTexture>;
  57206. /**
  57207. * AKA Occlusion Texture in other nomenclature.
  57208. */
  57209. protected _ambientTexture: Nullable<BaseTexture>;
  57210. /**
  57211. * AKA Occlusion Texture Intensity in other nomenclature.
  57212. */
  57213. protected _ambientTextureStrength: number;
  57214. /**
  57215. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57216. * 1 means it completely occludes it
  57217. * 0 mean it has no impact
  57218. */
  57219. protected _ambientTextureImpactOnAnalyticalLights: number;
  57220. /**
  57221. * Stores the alpha values in a texture.
  57222. */
  57223. protected _opacityTexture: Nullable<BaseTexture>;
  57224. /**
  57225. * Stores the reflection values in a texture.
  57226. */
  57227. protected _reflectionTexture: Nullable<BaseTexture>;
  57228. /**
  57229. * Stores the emissive values in a texture.
  57230. */
  57231. protected _emissiveTexture: Nullable<BaseTexture>;
  57232. /**
  57233. * AKA Specular texture in other nomenclature.
  57234. */
  57235. protected _reflectivityTexture: Nullable<BaseTexture>;
  57236. /**
  57237. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57238. */
  57239. protected _metallicTexture: Nullable<BaseTexture>;
  57240. /**
  57241. * Specifies the metallic scalar of the metallic/roughness workflow.
  57242. * Can also be used to scale the metalness values of the metallic texture.
  57243. */
  57244. protected _metallic: Nullable<number>;
  57245. /**
  57246. * Specifies the roughness scalar of the metallic/roughness workflow.
  57247. * Can also be used to scale the roughness values of the metallic texture.
  57248. */
  57249. protected _roughness: Nullable<number>;
  57250. /**
  57251. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57252. * By default the indexOfrefraction is used to compute F0;
  57253. *
  57254. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57255. *
  57256. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57257. * F90 = metallicReflectanceColor;
  57258. */
  57259. protected _metallicF0Factor: number;
  57260. /**
  57261. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57262. * By default the F90 is always 1;
  57263. *
  57264. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57265. *
  57266. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57267. * F90 = metallicReflectanceColor;
  57268. */
  57269. protected _metallicReflectanceColor: Color3;
  57270. /**
  57271. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57272. * This is multiply against the scalar values defined in the material.
  57273. */
  57274. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57275. /**
  57276. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57277. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57278. */
  57279. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57280. /**
  57281. * Stores surface normal data used to displace a mesh in a texture.
  57282. */
  57283. protected _bumpTexture: Nullable<BaseTexture>;
  57284. /**
  57285. * Stores the pre-calculated light information of a mesh in a texture.
  57286. */
  57287. protected _lightmapTexture: Nullable<BaseTexture>;
  57288. /**
  57289. * The color of a material in ambient lighting.
  57290. */
  57291. protected _ambientColor: Color3;
  57292. /**
  57293. * AKA Diffuse Color in other nomenclature.
  57294. */
  57295. protected _albedoColor: Color3;
  57296. /**
  57297. * AKA Specular Color in other nomenclature.
  57298. */
  57299. protected _reflectivityColor: Color3;
  57300. /**
  57301. * The color applied when light is reflected from a material.
  57302. */
  57303. protected _reflectionColor: Color3;
  57304. /**
  57305. * The color applied when light is emitted from a material.
  57306. */
  57307. protected _emissiveColor: Color3;
  57308. /**
  57309. * AKA Glossiness in other nomenclature.
  57310. */
  57311. protected _microSurface: number;
  57312. /**
  57313. * Specifies that the material will use the light map as a show map.
  57314. */
  57315. protected _useLightmapAsShadowmap: boolean;
  57316. /**
  57317. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57318. * makes the reflect vector face the model (under horizon).
  57319. */
  57320. protected _useHorizonOcclusion: boolean;
  57321. /**
  57322. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57323. * too much the area relying on ambient texture to define their ambient occlusion.
  57324. */
  57325. protected _useRadianceOcclusion: boolean;
  57326. /**
  57327. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57328. */
  57329. protected _useAlphaFromAlbedoTexture: boolean;
  57330. /**
  57331. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57332. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57333. */
  57334. protected _useSpecularOverAlpha: boolean;
  57335. /**
  57336. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57337. */
  57338. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57339. /**
  57340. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57341. */
  57342. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57343. /**
  57344. * Specifies if the metallic texture contains the roughness information in its green channel.
  57345. */
  57346. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57347. /**
  57348. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57349. */
  57350. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57351. /**
  57352. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57353. */
  57354. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57355. /**
  57356. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57357. */
  57358. protected _useAmbientInGrayScale: boolean;
  57359. /**
  57360. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57361. * The material will try to infer what glossiness each pixel should be.
  57362. */
  57363. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57364. /**
  57365. * Defines the falloff type used in this material.
  57366. * It by default is Physical.
  57367. */
  57368. protected _lightFalloff: number;
  57369. /**
  57370. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57371. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57372. */
  57373. protected _useRadianceOverAlpha: boolean;
  57374. /**
  57375. * Allows using an object space normal map (instead of tangent space).
  57376. */
  57377. protected _useObjectSpaceNormalMap: boolean;
  57378. /**
  57379. * Allows using the bump map in parallax mode.
  57380. */
  57381. protected _useParallax: boolean;
  57382. /**
  57383. * Allows using the bump map in parallax occlusion mode.
  57384. */
  57385. protected _useParallaxOcclusion: boolean;
  57386. /**
  57387. * Controls the scale bias of the parallax mode.
  57388. */
  57389. protected _parallaxScaleBias: number;
  57390. /**
  57391. * If sets to true, disables all the lights affecting the material.
  57392. */
  57393. protected _disableLighting: boolean;
  57394. /**
  57395. * Number of Simultaneous lights allowed on the material.
  57396. */
  57397. protected _maxSimultaneousLights: number;
  57398. /**
  57399. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57400. */
  57401. protected _invertNormalMapX: boolean;
  57402. /**
  57403. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57404. */
  57405. protected _invertNormalMapY: boolean;
  57406. /**
  57407. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57408. */
  57409. protected _twoSidedLighting: boolean;
  57410. /**
  57411. * Defines the alpha limits in alpha test mode.
  57412. */
  57413. protected _alphaCutOff: number;
  57414. /**
  57415. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57416. */
  57417. protected _forceAlphaTest: boolean;
  57418. /**
  57419. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57420. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57421. */
  57422. protected _useAlphaFresnel: boolean;
  57423. /**
  57424. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57425. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57426. */
  57427. protected _useLinearAlphaFresnel: boolean;
  57428. /**
  57429. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57430. * from cos thetav and roughness:
  57431. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57432. */
  57433. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57434. /**
  57435. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57436. */
  57437. protected _forceIrradianceInFragment: boolean;
  57438. private _realTimeFiltering;
  57439. /**
  57440. * Enables realtime filtering on the texture.
  57441. */
  57442. get realTimeFiltering(): boolean;
  57443. set realTimeFiltering(b: boolean);
  57444. private _realTimeFilteringQuality;
  57445. /**
  57446. * Quality switch for realtime filtering
  57447. */
  57448. get realTimeFilteringQuality(): number;
  57449. set realTimeFilteringQuality(n: number);
  57450. /**
  57451. * Force normal to face away from face.
  57452. */
  57453. protected _forceNormalForward: boolean;
  57454. /**
  57455. * Enables specular anti aliasing in the PBR shader.
  57456. * It will both interacts on the Geometry for analytical and IBL lighting.
  57457. * It also prefilter the roughness map based on the bump values.
  57458. */
  57459. protected _enableSpecularAntiAliasing: boolean;
  57460. /**
  57461. * Default configuration related to image processing available in the PBR Material.
  57462. */
  57463. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57464. /**
  57465. * Keep track of the image processing observer to allow dispose and replace.
  57466. */
  57467. private _imageProcessingObserver;
  57468. /**
  57469. * Attaches a new image processing configuration to the PBR Material.
  57470. * @param configuration
  57471. */
  57472. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57473. /**
  57474. * Stores the available render targets.
  57475. */
  57476. private _renderTargets;
  57477. /**
  57478. * Sets the global ambient color for the material used in lighting calculations.
  57479. */
  57480. private _globalAmbientColor;
  57481. /**
  57482. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57483. */
  57484. private _useLogarithmicDepth;
  57485. /**
  57486. * If set to true, no lighting calculations will be applied.
  57487. */
  57488. private _unlit;
  57489. private _debugMode;
  57490. /**
  57491. * @hidden
  57492. * This is reserved for the inspector.
  57493. * Defines the material debug mode.
  57494. * It helps seeing only some components of the material while troubleshooting.
  57495. */
  57496. debugMode: number;
  57497. /**
  57498. * @hidden
  57499. * This is reserved for the inspector.
  57500. * Specify from where on screen the debug mode should start.
  57501. * The value goes from -1 (full screen) to 1 (not visible)
  57502. * It helps with side by side comparison against the final render
  57503. * This defaults to -1
  57504. */
  57505. private debugLimit;
  57506. /**
  57507. * @hidden
  57508. * This is reserved for the inspector.
  57509. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57510. * You can use the factor to better multiply the final value.
  57511. */
  57512. private debugFactor;
  57513. /**
  57514. * Defines the clear coat layer parameters for the material.
  57515. */
  57516. readonly clearCoat: PBRClearCoatConfiguration;
  57517. /**
  57518. * Defines the anisotropic parameters for the material.
  57519. */
  57520. readonly anisotropy: PBRAnisotropicConfiguration;
  57521. /**
  57522. * Defines the BRDF parameters for the material.
  57523. */
  57524. readonly brdf: PBRBRDFConfiguration;
  57525. /**
  57526. * Defines the Sheen parameters for the material.
  57527. */
  57528. readonly sheen: PBRSheenConfiguration;
  57529. /**
  57530. * Defines the SubSurface parameters for the material.
  57531. */
  57532. readonly subSurface: PBRSubSurfaceConfiguration;
  57533. protected _rebuildInParallel: boolean;
  57534. /**
  57535. * Instantiates a new PBRMaterial instance.
  57536. *
  57537. * @param name The material name
  57538. * @param scene The scene the material will be use in.
  57539. */
  57540. constructor(name: string, scene: Scene);
  57541. /**
  57542. * Gets a boolean indicating that current material needs to register RTT
  57543. */
  57544. get hasRenderTargetTextures(): boolean;
  57545. /**
  57546. * Gets the name of the material class.
  57547. */
  57548. getClassName(): string;
  57549. /**
  57550. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57551. */
  57552. get useLogarithmicDepth(): boolean;
  57553. /**
  57554. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57555. */
  57556. set useLogarithmicDepth(value: boolean);
  57557. /**
  57558. * Returns true if alpha blending should be disabled.
  57559. */
  57560. protected get _disableAlphaBlending(): boolean;
  57561. /**
  57562. * Specifies whether or not this material should be rendered in alpha blend mode.
  57563. */
  57564. needAlphaBlending(): boolean;
  57565. /**
  57566. * Specifies whether or not this material should be rendered in alpha test mode.
  57567. */
  57568. needAlphaTesting(): boolean;
  57569. /**
  57570. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57571. */
  57572. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57573. /**
  57574. * Gets the texture used for the alpha test.
  57575. */
  57576. getAlphaTestTexture(): Nullable<BaseTexture>;
  57577. /**
  57578. * Specifies that the submesh is ready to be used.
  57579. * @param mesh - BJS mesh.
  57580. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57581. * @param useInstances - Specifies that instances should be used.
  57582. * @returns - boolean indicating that the submesh is ready or not.
  57583. */
  57584. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57585. /**
  57586. * Specifies if the material uses metallic roughness workflow.
  57587. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57588. */
  57589. isMetallicWorkflow(): boolean;
  57590. private _prepareEffect;
  57591. private _prepareDefines;
  57592. /**
  57593. * Force shader compilation
  57594. */
  57595. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57596. /**
  57597. * Initializes the uniform buffer layout for the shader.
  57598. */
  57599. buildUniformLayout(): void;
  57600. /**
  57601. * Unbinds the material from the mesh
  57602. */
  57603. unbind(): void;
  57604. /**
  57605. * Binds the submesh data.
  57606. * @param world - The world matrix.
  57607. * @param mesh - The BJS mesh.
  57608. * @param subMesh - A submesh of the BJS mesh.
  57609. */
  57610. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57611. /**
  57612. * Returns the animatable textures.
  57613. * @returns - Array of animatable textures.
  57614. */
  57615. getAnimatables(): IAnimatable[];
  57616. /**
  57617. * Returns the texture used for reflections.
  57618. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57619. */
  57620. private _getReflectionTexture;
  57621. /**
  57622. * Returns an array of the actively used textures.
  57623. * @returns - Array of BaseTextures
  57624. */
  57625. getActiveTextures(): BaseTexture[];
  57626. /**
  57627. * Checks to see if a texture is used in the material.
  57628. * @param texture - Base texture to use.
  57629. * @returns - Boolean specifying if a texture is used in the material.
  57630. */
  57631. hasTexture(texture: BaseTexture): boolean;
  57632. /**
  57633. * Disposes the resources of the material.
  57634. * @param forceDisposeEffect - Forces the disposal of effects.
  57635. * @param forceDisposeTextures - Forces the disposal of all textures.
  57636. */
  57637. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57638. }
  57639. }
  57640. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  57641. import { Nullable } from "babylonjs/types";
  57642. import { Scene } from "babylonjs/scene";
  57643. import { Color3 } from "babylonjs/Maths/math.color";
  57644. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  57645. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  57646. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57647. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57648. /**
  57649. * The Physically based material of BJS.
  57650. *
  57651. * This offers the main features of a standard PBR material.
  57652. * For more information, please refer to the documentation :
  57653. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57654. */
  57655. export class PBRMaterial extends PBRBaseMaterial {
  57656. /**
  57657. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57658. */
  57659. static readonly PBRMATERIAL_OPAQUE: number;
  57660. /**
  57661. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57662. */
  57663. static readonly PBRMATERIAL_ALPHATEST: number;
  57664. /**
  57665. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57666. */
  57667. static readonly PBRMATERIAL_ALPHABLEND: number;
  57668. /**
  57669. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57670. * They are also discarded below the alpha cutoff threshold to improve performances.
  57671. */
  57672. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57673. /**
  57674. * Defines the default value of how much AO map is occluding the analytical lights
  57675. * (point spot...).
  57676. */
  57677. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57678. /**
  57679. * Intensity of the direct lights e.g. the four lights available in your scene.
  57680. * This impacts both the direct diffuse and specular highlights.
  57681. */
  57682. directIntensity: number;
  57683. /**
  57684. * Intensity of the emissive part of the material.
  57685. * This helps controlling the emissive effect without modifying the emissive color.
  57686. */
  57687. emissiveIntensity: number;
  57688. /**
  57689. * Intensity of the environment e.g. how much the environment will light the object
  57690. * either through harmonics for rough material or through the refelction for shiny ones.
  57691. */
  57692. environmentIntensity: number;
  57693. /**
  57694. * This is a special control allowing the reduction of the specular highlights coming from the
  57695. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57696. */
  57697. specularIntensity: number;
  57698. /**
  57699. * Debug Control allowing disabling the bump map on this material.
  57700. */
  57701. disableBumpMap: boolean;
  57702. /**
  57703. * AKA Diffuse Texture in standard nomenclature.
  57704. */
  57705. albedoTexture: BaseTexture;
  57706. /**
  57707. * AKA Occlusion Texture in other nomenclature.
  57708. */
  57709. ambientTexture: BaseTexture;
  57710. /**
  57711. * AKA Occlusion Texture Intensity in other nomenclature.
  57712. */
  57713. ambientTextureStrength: number;
  57714. /**
  57715. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57716. * 1 means it completely occludes it
  57717. * 0 mean it has no impact
  57718. */
  57719. ambientTextureImpactOnAnalyticalLights: number;
  57720. /**
  57721. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57722. */
  57723. opacityTexture: BaseTexture;
  57724. /**
  57725. * Stores the reflection values in a texture.
  57726. */
  57727. reflectionTexture: Nullable<BaseTexture>;
  57728. /**
  57729. * Stores the emissive values in a texture.
  57730. */
  57731. emissiveTexture: BaseTexture;
  57732. /**
  57733. * AKA Specular texture in other nomenclature.
  57734. */
  57735. reflectivityTexture: BaseTexture;
  57736. /**
  57737. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57738. */
  57739. metallicTexture: BaseTexture;
  57740. /**
  57741. * Specifies the metallic scalar of the metallic/roughness workflow.
  57742. * Can also be used to scale the metalness values of the metallic texture.
  57743. */
  57744. metallic: Nullable<number>;
  57745. /**
  57746. * Specifies the roughness scalar of the metallic/roughness workflow.
  57747. * Can also be used to scale the roughness values of the metallic texture.
  57748. */
  57749. roughness: Nullable<number>;
  57750. /**
  57751. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57752. * By default the indexOfrefraction is used to compute F0;
  57753. *
  57754. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57755. *
  57756. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57757. * F90 = metallicReflectanceColor;
  57758. */
  57759. metallicF0Factor: number;
  57760. /**
  57761. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57762. * By default the F90 is always 1;
  57763. *
  57764. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57765. *
  57766. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57767. * F90 = metallicReflectanceColor;
  57768. */
  57769. metallicReflectanceColor: Color3;
  57770. /**
  57771. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57772. * This is multiply against the scalar values defined in the material.
  57773. */
  57774. metallicReflectanceTexture: Nullable<BaseTexture>;
  57775. /**
  57776. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57777. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57778. */
  57779. microSurfaceTexture: BaseTexture;
  57780. /**
  57781. * Stores surface normal data used to displace a mesh in a texture.
  57782. */
  57783. bumpTexture: BaseTexture;
  57784. /**
  57785. * Stores the pre-calculated light information of a mesh in a texture.
  57786. */
  57787. lightmapTexture: BaseTexture;
  57788. /**
  57789. * Stores the refracted light information in a texture.
  57790. */
  57791. get refractionTexture(): Nullable<BaseTexture>;
  57792. set refractionTexture(value: Nullable<BaseTexture>);
  57793. /**
  57794. * The color of a material in ambient lighting.
  57795. */
  57796. ambientColor: Color3;
  57797. /**
  57798. * AKA Diffuse Color in other nomenclature.
  57799. */
  57800. albedoColor: Color3;
  57801. /**
  57802. * AKA Specular Color in other nomenclature.
  57803. */
  57804. reflectivityColor: Color3;
  57805. /**
  57806. * The color reflected from the material.
  57807. */
  57808. reflectionColor: Color3;
  57809. /**
  57810. * The color emitted from the material.
  57811. */
  57812. emissiveColor: Color3;
  57813. /**
  57814. * AKA Glossiness in other nomenclature.
  57815. */
  57816. microSurface: number;
  57817. /**
  57818. * Index of refraction of the material base layer.
  57819. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57820. *
  57821. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57822. *
  57823. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57824. */
  57825. get indexOfRefraction(): number;
  57826. set indexOfRefraction(value: number);
  57827. /**
  57828. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57829. */
  57830. get invertRefractionY(): boolean;
  57831. set invertRefractionY(value: boolean);
  57832. /**
  57833. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57834. * Materials half opaque for instance using refraction could benefit from this control.
  57835. */
  57836. get linkRefractionWithTransparency(): boolean;
  57837. set linkRefractionWithTransparency(value: boolean);
  57838. /**
  57839. * If true, the light map contains occlusion information instead of lighting info.
  57840. */
  57841. useLightmapAsShadowmap: boolean;
  57842. /**
  57843. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57844. */
  57845. useAlphaFromAlbedoTexture: boolean;
  57846. /**
  57847. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57848. */
  57849. forceAlphaTest: boolean;
  57850. /**
  57851. * Defines the alpha limits in alpha test mode.
  57852. */
  57853. alphaCutOff: number;
  57854. /**
  57855. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57856. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57857. */
  57858. useSpecularOverAlpha: boolean;
  57859. /**
  57860. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57861. */
  57862. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57863. /**
  57864. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57865. */
  57866. useRoughnessFromMetallicTextureAlpha: boolean;
  57867. /**
  57868. * Specifies if the metallic texture contains the roughness information in its green channel.
  57869. */
  57870. useRoughnessFromMetallicTextureGreen: boolean;
  57871. /**
  57872. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57873. */
  57874. useMetallnessFromMetallicTextureBlue: boolean;
  57875. /**
  57876. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57877. */
  57878. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57879. /**
  57880. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57881. */
  57882. useAmbientInGrayScale: boolean;
  57883. /**
  57884. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57885. * The material will try to infer what glossiness each pixel should be.
  57886. */
  57887. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57888. /**
  57889. * BJS is using an harcoded light falloff based on a manually sets up range.
  57890. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57891. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57892. */
  57893. get usePhysicalLightFalloff(): boolean;
  57894. /**
  57895. * BJS is using an harcoded light falloff based on a manually sets up range.
  57896. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57897. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57898. */
  57899. set usePhysicalLightFalloff(value: boolean);
  57900. /**
  57901. * In order to support the falloff compatibility with gltf, a special mode has been added
  57902. * to reproduce the gltf light falloff.
  57903. */
  57904. get useGLTFLightFalloff(): boolean;
  57905. /**
  57906. * In order to support the falloff compatibility with gltf, a special mode has been added
  57907. * to reproduce the gltf light falloff.
  57908. */
  57909. set useGLTFLightFalloff(value: boolean);
  57910. /**
  57911. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57912. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57913. */
  57914. useRadianceOverAlpha: boolean;
  57915. /**
  57916. * Allows using an object space normal map (instead of tangent space).
  57917. */
  57918. useObjectSpaceNormalMap: boolean;
  57919. /**
  57920. * Allows using the bump map in parallax mode.
  57921. */
  57922. useParallax: boolean;
  57923. /**
  57924. * Allows using the bump map in parallax occlusion mode.
  57925. */
  57926. useParallaxOcclusion: boolean;
  57927. /**
  57928. * Controls the scale bias of the parallax mode.
  57929. */
  57930. parallaxScaleBias: number;
  57931. /**
  57932. * If sets to true, disables all the lights affecting the material.
  57933. */
  57934. disableLighting: boolean;
  57935. /**
  57936. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57937. */
  57938. forceIrradianceInFragment: boolean;
  57939. /**
  57940. * Number of Simultaneous lights allowed on the material.
  57941. */
  57942. maxSimultaneousLights: number;
  57943. /**
  57944. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57945. */
  57946. invertNormalMapX: boolean;
  57947. /**
  57948. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57949. */
  57950. invertNormalMapY: boolean;
  57951. /**
  57952. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57953. */
  57954. twoSidedLighting: boolean;
  57955. /**
  57956. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57957. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57958. */
  57959. useAlphaFresnel: boolean;
  57960. /**
  57961. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57962. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57963. */
  57964. useLinearAlphaFresnel: boolean;
  57965. /**
  57966. * Let user defines the brdf lookup texture used for IBL.
  57967. * A default 8bit version is embedded but you could point at :
  57968. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57969. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57970. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57971. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57972. */
  57973. environmentBRDFTexture: Nullable<BaseTexture>;
  57974. /**
  57975. * Force normal to face away from face.
  57976. */
  57977. forceNormalForward: boolean;
  57978. /**
  57979. * Enables specular anti aliasing in the PBR shader.
  57980. * It will both interacts on the Geometry for analytical and IBL lighting.
  57981. * It also prefilter the roughness map based on the bump values.
  57982. */
  57983. enableSpecularAntiAliasing: boolean;
  57984. /**
  57985. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57986. * makes the reflect vector face the model (under horizon).
  57987. */
  57988. useHorizonOcclusion: boolean;
  57989. /**
  57990. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57991. * too much the area relying on ambient texture to define their ambient occlusion.
  57992. */
  57993. useRadianceOcclusion: boolean;
  57994. /**
  57995. * If set to true, no lighting calculations will be applied.
  57996. */
  57997. unlit: boolean;
  57998. /**
  57999. * Gets the image processing configuration used either in this material.
  58000. */
  58001. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58002. /**
  58003. * Sets the Default image processing configuration used either in the this material.
  58004. *
  58005. * If sets to null, the scene one is in use.
  58006. */
  58007. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58008. /**
  58009. * Gets wether the color curves effect is enabled.
  58010. */
  58011. get cameraColorCurvesEnabled(): boolean;
  58012. /**
  58013. * Sets wether the color curves effect is enabled.
  58014. */
  58015. set cameraColorCurvesEnabled(value: boolean);
  58016. /**
  58017. * Gets wether the color grading effect is enabled.
  58018. */
  58019. get cameraColorGradingEnabled(): boolean;
  58020. /**
  58021. * Gets wether the color grading effect is enabled.
  58022. */
  58023. set cameraColorGradingEnabled(value: boolean);
  58024. /**
  58025. * Gets wether tonemapping is enabled or not.
  58026. */
  58027. get cameraToneMappingEnabled(): boolean;
  58028. /**
  58029. * Sets wether tonemapping is enabled or not
  58030. */
  58031. set cameraToneMappingEnabled(value: boolean);
  58032. /**
  58033. * The camera exposure used on this material.
  58034. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58035. * This corresponds to a photographic exposure.
  58036. */
  58037. get cameraExposure(): number;
  58038. /**
  58039. * The camera exposure used on this material.
  58040. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58041. * This corresponds to a photographic exposure.
  58042. */
  58043. set cameraExposure(value: number);
  58044. /**
  58045. * Gets The camera contrast used on this material.
  58046. */
  58047. get cameraContrast(): number;
  58048. /**
  58049. * Sets The camera contrast used on this material.
  58050. */
  58051. set cameraContrast(value: number);
  58052. /**
  58053. * Gets the Color Grading 2D Lookup Texture.
  58054. */
  58055. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58056. /**
  58057. * Sets the Color Grading 2D Lookup Texture.
  58058. */
  58059. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58060. /**
  58061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58063. * 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;
  58064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58065. */
  58066. get cameraColorCurves(): Nullable<ColorCurves>;
  58067. /**
  58068. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58069. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58070. * 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;
  58071. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58072. */
  58073. set cameraColorCurves(value: Nullable<ColorCurves>);
  58074. /**
  58075. * Instantiates a new PBRMaterial instance.
  58076. *
  58077. * @param name The material name
  58078. * @param scene The scene the material will be use in.
  58079. */
  58080. constructor(name: string, scene: Scene);
  58081. /**
  58082. * Returns the name of this material class.
  58083. */
  58084. getClassName(): string;
  58085. /**
  58086. * Makes a duplicate of the current material.
  58087. * @param name - name to use for the new material.
  58088. */
  58089. clone(name: string): PBRMaterial;
  58090. /**
  58091. * Serializes this PBR Material.
  58092. * @returns - An object with the serialized material.
  58093. */
  58094. serialize(): any;
  58095. /**
  58096. * Parses a PBR Material from a serialized object.
  58097. * @param source - Serialized object.
  58098. * @param scene - BJS scene instance.
  58099. * @param rootUrl - url for the scene object
  58100. * @returns - PBRMaterial
  58101. */
  58102. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58103. }
  58104. }
  58105. declare module "babylonjs/Misc/dds" {
  58106. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58107. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58108. import { Nullable } from "babylonjs/types";
  58109. import { Scene } from "babylonjs/scene";
  58110. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58111. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58112. /**
  58113. * Direct draw surface info
  58114. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58115. */
  58116. export interface DDSInfo {
  58117. /**
  58118. * Width of the texture
  58119. */
  58120. width: number;
  58121. /**
  58122. * Width of the texture
  58123. */
  58124. height: number;
  58125. /**
  58126. * Number of Mipmaps for the texture
  58127. * @see https://en.wikipedia.org/wiki/Mipmap
  58128. */
  58129. mipmapCount: number;
  58130. /**
  58131. * If the textures format is a known fourCC format
  58132. * @see https://www.fourcc.org/
  58133. */
  58134. isFourCC: boolean;
  58135. /**
  58136. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58137. */
  58138. isRGB: boolean;
  58139. /**
  58140. * If the texture is a lumincance format
  58141. */
  58142. isLuminance: boolean;
  58143. /**
  58144. * If this is a cube texture
  58145. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58146. */
  58147. isCube: boolean;
  58148. /**
  58149. * If the texture is a compressed format eg. FOURCC_DXT1
  58150. */
  58151. isCompressed: boolean;
  58152. /**
  58153. * The dxgiFormat of the texture
  58154. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58155. */
  58156. dxgiFormat: number;
  58157. /**
  58158. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58159. */
  58160. textureType: number;
  58161. /**
  58162. * Sphericle polynomial created for the dds texture
  58163. */
  58164. sphericalPolynomial?: SphericalPolynomial;
  58165. }
  58166. /**
  58167. * Class used to provide DDS decompression tools
  58168. */
  58169. export class DDSTools {
  58170. /**
  58171. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58172. */
  58173. static StoreLODInAlphaChannel: boolean;
  58174. /**
  58175. * Gets DDS information from an array buffer
  58176. * @param data defines the array buffer view to read data from
  58177. * @returns the DDS information
  58178. */
  58179. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58180. private static _FloatView;
  58181. private static _Int32View;
  58182. private static _ToHalfFloat;
  58183. private static _FromHalfFloat;
  58184. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58185. private static _GetHalfFloatRGBAArrayBuffer;
  58186. private static _GetFloatRGBAArrayBuffer;
  58187. private static _GetFloatAsUIntRGBAArrayBuffer;
  58188. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58189. private static _GetRGBAArrayBuffer;
  58190. private static _ExtractLongWordOrder;
  58191. private static _GetRGBArrayBuffer;
  58192. private static _GetLuminanceArrayBuffer;
  58193. /**
  58194. * Uploads DDS Levels to a Babylon Texture
  58195. * @hidden
  58196. */
  58197. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58198. }
  58199. module "babylonjs/Engines/thinEngine" {
  58200. interface ThinEngine {
  58201. /**
  58202. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58203. * @param rootUrl defines the url where the file to load is located
  58204. * @param scene defines the current scene
  58205. * @param lodScale defines scale to apply to the mip map selection
  58206. * @param lodOffset defines offset to apply to the mip map selection
  58207. * @param onLoad defines an optional callback raised when the texture is loaded
  58208. * @param onError defines an optional callback raised if there is an issue to load the texture
  58209. * @param format defines the format of the data
  58210. * @param forcedExtension defines the extension to use to pick the right loader
  58211. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58212. * @returns the cube texture as an InternalTexture
  58213. */
  58214. 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;
  58215. }
  58216. }
  58217. }
  58218. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58219. import { Nullable } from "babylonjs/types";
  58220. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58221. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58222. /**
  58223. * Implementation of the DDS Texture Loader.
  58224. * @hidden
  58225. */
  58226. export class _DDSTextureLoader implements IInternalTextureLoader {
  58227. /**
  58228. * Defines wether the loader supports cascade loading the different faces.
  58229. */
  58230. readonly supportCascades: boolean;
  58231. /**
  58232. * This returns if the loader support the current file information.
  58233. * @param extension defines the file extension of the file being loaded
  58234. * @returns true if the loader can load the specified file
  58235. */
  58236. canLoad(extension: string): boolean;
  58237. /**
  58238. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58239. * @param data contains the texture data
  58240. * @param texture defines the BabylonJS internal texture
  58241. * @param createPolynomials will be true if polynomials have been requested
  58242. * @param onLoad defines the callback to trigger once the texture is ready
  58243. * @param onError defines the callback to trigger in case of error
  58244. */
  58245. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58246. /**
  58247. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58248. * @param data contains the texture data
  58249. * @param texture defines the BabylonJS internal texture
  58250. * @param callback defines the method to call once ready to upload
  58251. */
  58252. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58253. }
  58254. }
  58255. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58256. import { Nullable } from "babylonjs/types";
  58257. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58258. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58259. /**
  58260. * Implementation of the ENV Texture Loader.
  58261. * @hidden
  58262. */
  58263. export class _ENVTextureLoader implements IInternalTextureLoader {
  58264. /**
  58265. * Defines wether the loader supports cascade loading the different faces.
  58266. */
  58267. readonly supportCascades: boolean;
  58268. /**
  58269. * This returns if the loader support the current file information.
  58270. * @param extension defines the file extension of the file being loaded
  58271. * @returns true if the loader can load the specified file
  58272. */
  58273. canLoad(extension: string): boolean;
  58274. /**
  58275. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58276. * @param data contains the texture data
  58277. * @param texture defines the BabylonJS internal texture
  58278. * @param createPolynomials will be true if polynomials have been requested
  58279. * @param onLoad defines the callback to trigger once the texture is ready
  58280. * @param onError defines the callback to trigger in case of error
  58281. */
  58282. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58283. /**
  58284. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58285. * @param data contains the texture data
  58286. * @param texture defines the BabylonJS internal texture
  58287. * @param callback defines the method to call once ready to upload
  58288. */
  58289. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58290. }
  58291. }
  58292. declare module "babylonjs/Misc/khronosTextureContainer" {
  58293. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58294. /**
  58295. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58296. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58297. */
  58298. export class KhronosTextureContainer {
  58299. /** contents of the KTX container file */
  58300. data: ArrayBufferView;
  58301. private static HEADER_LEN;
  58302. private static COMPRESSED_2D;
  58303. private static COMPRESSED_3D;
  58304. private static TEX_2D;
  58305. private static TEX_3D;
  58306. /**
  58307. * Gets the openGL type
  58308. */
  58309. glType: number;
  58310. /**
  58311. * Gets the openGL type size
  58312. */
  58313. glTypeSize: number;
  58314. /**
  58315. * Gets the openGL format
  58316. */
  58317. glFormat: number;
  58318. /**
  58319. * Gets the openGL internal format
  58320. */
  58321. glInternalFormat: number;
  58322. /**
  58323. * Gets the base internal format
  58324. */
  58325. glBaseInternalFormat: number;
  58326. /**
  58327. * Gets image width in pixel
  58328. */
  58329. pixelWidth: number;
  58330. /**
  58331. * Gets image height in pixel
  58332. */
  58333. pixelHeight: number;
  58334. /**
  58335. * Gets image depth in pixels
  58336. */
  58337. pixelDepth: number;
  58338. /**
  58339. * Gets the number of array elements
  58340. */
  58341. numberOfArrayElements: number;
  58342. /**
  58343. * Gets the number of faces
  58344. */
  58345. numberOfFaces: number;
  58346. /**
  58347. * Gets the number of mipmap levels
  58348. */
  58349. numberOfMipmapLevels: number;
  58350. /**
  58351. * Gets the bytes of key value data
  58352. */
  58353. bytesOfKeyValueData: number;
  58354. /**
  58355. * Gets the load type
  58356. */
  58357. loadType: number;
  58358. /**
  58359. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58360. */
  58361. isInvalid: boolean;
  58362. /**
  58363. * Creates a new KhronosTextureContainer
  58364. * @param data contents of the KTX container file
  58365. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58366. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58367. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58368. */
  58369. constructor(
  58370. /** contents of the KTX container file */
  58371. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58372. /**
  58373. * Uploads KTX content to a Babylon Texture.
  58374. * It is assumed that the texture has already been created & is currently bound
  58375. * @hidden
  58376. */
  58377. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58378. private _upload2DCompressedLevels;
  58379. /**
  58380. * Checks if the given data starts with a KTX file identifier.
  58381. * @param data the data to check
  58382. * @returns true if the data is a KTX file or false otherwise
  58383. */
  58384. static IsValid(data: ArrayBufferView): boolean;
  58385. }
  58386. }
  58387. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58388. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58389. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58390. /**
  58391. * Class for loading KTX2 files
  58392. * !!! Experimental Extension Subject to Changes !!!
  58393. * @hidden
  58394. */
  58395. export class KhronosTextureContainer2 {
  58396. private static _ModulePromise;
  58397. private static _TranscodeFormat;
  58398. constructor(engine: ThinEngine);
  58399. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58400. private _determineTranscodeFormat;
  58401. /**
  58402. * Checks if the given data starts with a KTX2 file identifier.
  58403. * @param data the data to check
  58404. * @returns true if the data is a KTX2 file or false otherwise
  58405. */
  58406. static IsValid(data: ArrayBufferView): boolean;
  58407. }
  58408. }
  58409. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58410. import { Nullable } from "babylonjs/types";
  58411. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58412. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58413. /**
  58414. * Implementation of the KTX Texture Loader.
  58415. * @hidden
  58416. */
  58417. export class _KTXTextureLoader implements IInternalTextureLoader {
  58418. /**
  58419. * Defines wether the loader supports cascade loading the different faces.
  58420. */
  58421. readonly supportCascades: boolean;
  58422. /**
  58423. * This returns if the loader support the current file information.
  58424. * @param extension defines the file extension of the file being loaded
  58425. * @returns true if the loader can load the specified file
  58426. */
  58427. canLoad(extension: string): boolean;
  58428. /**
  58429. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58430. * @param data contains the texture data
  58431. * @param texture defines the BabylonJS internal texture
  58432. * @param createPolynomials will be true if polynomials have been requested
  58433. * @param onLoad defines the callback to trigger once the texture is ready
  58434. * @param onError defines the callback to trigger in case of error
  58435. */
  58436. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58437. /**
  58438. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58439. * @param data contains the texture data
  58440. * @param texture defines the BabylonJS internal texture
  58441. * @param callback defines the method to call once ready to upload
  58442. */
  58443. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58444. }
  58445. }
  58446. declare module "babylonjs/Helpers/sceneHelpers" {
  58447. import { Nullable } from "babylonjs/types";
  58448. import { Mesh } from "babylonjs/Meshes/mesh";
  58449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58450. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  58451. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  58452. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58453. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58454. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58455. import "babylonjs/Meshes/Builders/boxBuilder";
  58456. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  58457. /** @hidden */
  58458. export var _forceSceneHelpersToBundle: boolean;
  58459. module "babylonjs/scene" {
  58460. interface Scene {
  58461. /**
  58462. * Creates a default light for the scene.
  58463. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58464. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58465. */
  58466. createDefaultLight(replace?: boolean): void;
  58467. /**
  58468. * Creates a default camera for the scene.
  58469. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58470. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58471. * @param replace has default false, when true replaces the active camera in the scene
  58472. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58473. */
  58474. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58475. /**
  58476. * Creates a default camera and a default light.
  58477. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58478. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58479. * @param replace has the default false, when true replaces the active camera/light in the scene
  58480. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58481. */
  58482. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58483. /**
  58484. * Creates a new sky box
  58485. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58486. * @param environmentTexture defines the texture to use as environment texture
  58487. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58488. * @param scale defines the overall scale of the skybox
  58489. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58490. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58491. * @returns a new mesh holding the sky box
  58492. */
  58493. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58494. /**
  58495. * Creates a new environment
  58496. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58497. * @param options defines the options you can use to configure the environment
  58498. * @returns the new EnvironmentHelper
  58499. */
  58500. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58501. /**
  58502. * Creates a new VREXperienceHelper
  58503. * @see http://doc.babylonjs.com/how_to/webvr_helper
  58504. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58505. * @returns a new VREXperienceHelper
  58506. */
  58507. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58508. /**
  58509. * Creates a new WebXRDefaultExperience
  58510. * @see http://doc.babylonjs.com/how_to/webxr
  58511. * @param options experience options
  58512. * @returns a promise for a new WebXRDefaultExperience
  58513. */
  58514. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58515. }
  58516. }
  58517. }
  58518. declare module "babylonjs/Helpers/videoDome" {
  58519. import { Scene } from "babylonjs/scene";
  58520. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58521. import { Mesh } from "babylonjs/Meshes/mesh";
  58522. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  58523. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  58524. import "babylonjs/Meshes/Builders/sphereBuilder";
  58525. /**
  58526. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58527. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58528. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58529. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58530. */
  58531. export class VideoDome extends TransformNode {
  58532. /**
  58533. * Define the video source as a Monoscopic panoramic 360 video.
  58534. */
  58535. static readonly MODE_MONOSCOPIC: number;
  58536. /**
  58537. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58538. */
  58539. static readonly MODE_TOPBOTTOM: number;
  58540. /**
  58541. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58542. */
  58543. static readonly MODE_SIDEBYSIDE: number;
  58544. private _halfDome;
  58545. private _useDirectMapping;
  58546. /**
  58547. * The video texture being displayed on the sphere
  58548. */
  58549. protected _videoTexture: VideoTexture;
  58550. /**
  58551. * Gets the video texture being displayed on the sphere
  58552. */
  58553. get videoTexture(): VideoTexture;
  58554. /**
  58555. * The skybox material
  58556. */
  58557. protected _material: BackgroundMaterial;
  58558. /**
  58559. * The surface used for the skybox
  58560. */
  58561. protected _mesh: Mesh;
  58562. /**
  58563. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  58564. */
  58565. private _halfDomeMask;
  58566. /**
  58567. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58568. * Also see the options.resolution property.
  58569. */
  58570. get fovMultiplier(): number;
  58571. set fovMultiplier(value: number);
  58572. private _videoMode;
  58573. /**
  58574. * Gets or set the current video mode for the video. It can be:
  58575. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  58576. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58577. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58578. */
  58579. get videoMode(): number;
  58580. set videoMode(value: number);
  58581. /**
  58582. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  58583. *
  58584. */
  58585. get halfDome(): boolean;
  58586. /**
  58587. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58588. */
  58589. set halfDome(enabled: boolean);
  58590. /**
  58591. * Oberserver used in Stereoscopic VR Mode.
  58592. */
  58593. private _onBeforeCameraRenderObserver;
  58594. /**
  58595. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  58596. * @param name Element's name, child elements will append suffixes for their own names.
  58597. * @param urlsOrVideo defines the url(s) or the video element to use
  58598. * @param options An object containing optional or exposed sub element properties
  58599. */
  58600. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  58601. resolution?: number;
  58602. clickToPlay?: boolean;
  58603. autoPlay?: boolean;
  58604. loop?: boolean;
  58605. size?: number;
  58606. poster?: string;
  58607. faceForward?: boolean;
  58608. useDirectMapping?: boolean;
  58609. halfDomeMode?: boolean;
  58610. }, scene: Scene);
  58611. private _changeVideoMode;
  58612. /**
  58613. * Releases resources associated with this node.
  58614. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58615. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58616. */
  58617. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58618. }
  58619. }
  58620. declare module "babylonjs/Helpers/index" {
  58621. export * from "babylonjs/Helpers/environmentHelper";
  58622. export * from "babylonjs/Helpers/photoDome";
  58623. export * from "babylonjs/Helpers/sceneHelpers";
  58624. export * from "babylonjs/Helpers/videoDome";
  58625. }
  58626. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  58627. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58628. import { IDisposable } from "babylonjs/scene";
  58629. import { Engine } from "babylonjs/Engines/engine";
  58630. /**
  58631. * This class can be used to get instrumentation data from a Babylon engine
  58632. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58633. */
  58634. export class EngineInstrumentation implements IDisposable {
  58635. /**
  58636. * Define the instrumented engine.
  58637. */
  58638. engine: Engine;
  58639. private _captureGPUFrameTime;
  58640. private _gpuFrameTimeToken;
  58641. private _gpuFrameTime;
  58642. private _captureShaderCompilationTime;
  58643. private _shaderCompilationTime;
  58644. private _onBeginFrameObserver;
  58645. private _onEndFrameObserver;
  58646. private _onBeforeShaderCompilationObserver;
  58647. private _onAfterShaderCompilationObserver;
  58648. /**
  58649. * Gets the perf counter used for GPU frame time
  58650. */
  58651. get gpuFrameTimeCounter(): PerfCounter;
  58652. /**
  58653. * Gets the GPU frame time capture status
  58654. */
  58655. get captureGPUFrameTime(): boolean;
  58656. /**
  58657. * Enable or disable the GPU frame time capture
  58658. */
  58659. set captureGPUFrameTime(value: boolean);
  58660. /**
  58661. * Gets the perf counter used for shader compilation time
  58662. */
  58663. get shaderCompilationTimeCounter(): PerfCounter;
  58664. /**
  58665. * Gets the shader compilation time capture status
  58666. */
  58667. get captureShaderCompilationTime(): boolean;
  58668. /**
  58669. * Enable or disable the shader compilation time capture
  58670. */
  58671. set captureShaderCompilationTime(value: boolean);
  58672. /**
  58673. * Instantiates a new engine instrumentation.
  58674. * This class can be used to get instrumentation data from a Babylon engine
  58675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58676. * @param engine Defines the engine to instrument
  58677. */
  58678. constructor(
  58679. /**
  58680. * Define the instrumented engine.
  58681. */
  58682. engine: Engine);
  58683. /**
  58684. * Dispose and release associated resources.
  58685. */
  58686. dispose(): void;
  58687. }
  58688. }
  58689. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  58690. import { Scene, IDisposable } from "babylonjs/scene";
  58691. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58692. /**
  58693. * This class can be used to get instrumentation data from a Babylon engine
  58694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58695. */
  58696. export class SceneInstrumentation implements IDisposable {
  58697. /**
  58698. * Defines the scene to instrument
  58699. */
  58700. scene: Scene;
  58701. private _captureActiveMeshesEvaluationTime;
  58702. private _activeMeshesEvaluationTime;
  58703. private _captureRenderTargetsRenderTime;
  58704. private _renderTargetsRenderTime;
  58705. private _captureFrameTime;
  58706. private _frameTime;
  58707. private _captureRenderTime;
  58708. private _renderTime;
  58709. private _captureInterFrameTime;
  58710. private _interFrameTime;
  58711. private _captureParticlesRenderTime;
  58712. private _particlesRenderTime;
  58713. private _captureSpritesRenderTime;
  58714. private _spritesRenderTime;
  58715. private _capturePhysicsTime;
  58716. private _physicsTime;
  58717. private _captureAnimationsTime;
  58718. private _animationsTime;
  58719. private _captureCameraRenderTime;
  58720. private _cameraRenderTime;
  58721. private _onBeforeActiveMeshesEvaluationObserver;
  58722. private _onAfterActiveMeshesEvaluationObserver;
  58723. private _onBeforeRenderTargetsRenderObserver;
  58724. private _onAfterRenderTargetsRenderObserver;
  58725. private _onAfterRenderObserver;
  58726. private _onBeforeDrawPhaseObserver;
  58727. private _onAfterDrawPhaseObserver;
  58728. private _onBeforeAnimationsObserver;
  58729. private _onBeforeParticlesRenderingObserver;
  58730. private _onAfterParticlesRenderingObserver;
  58731. private _onBeforeSpritesRenderingObserver;
  58732. private _onAfterSpritesRenderingObserver;
  58733. private _onBeforePhysicsObserver;
  58734. private _onAfterPhysicsObserver;
  58735. private _onAfterAnimationsObserver;
  58736. private _onBeforeCameraRenderObserver;
  58737. private _onAfterCameraRenderObserver;
  58738. /**
  58739. * Gets the perf counter used for active meshes evaluation time
  58740. */
  58741. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58742. /**
  58743. * Gets the active meshes evaluation time capture status
  58744. */
  58745. get captureActiveMeshesEvaluationTime(): boolean;
  58746. /**
  58747. * Enable or disable the active meshes evaluation time capture
  58748. */
  58749. set captureActiveMeshesEvaluationTime(value: boolean);
  58750. /**
  58751. * Gets the perf counter used for render targets render time
  58752. */
  58753. get renderTargetsRenderTimeCounter(): PerfCounter;
  58754. /**
  58755. * Gets the render targets render time capture status
  58756. */
  58757. get captureRenderTargetsRenderTime(): boolean;
  58758. /**
  58759. * Enable or disable the render targets render time capture
  58760. */
  58761. set captureRenderTargetsRenderTime(value: boolean);
  58762. /**
  58763. * Gets the perf counter used for particles render time
  58764. */
  58765. get particlesRenderTimeCounter(): PerfCounter;
  58766. /**
  58767. * Gets the particles render time capture status
  58768. */
  58769. get captureParticlesRenderTime(): boolean;
  58770. /**
  58771. * Enable or disable the particles render time capture
  58772. */
  58773. set captureParticlesRenderTime(value: boolean);
  58774. /**
  58775. * Gets the perf counter used for sprites render time
  58776. */
  58777. get spritesRenderTimeCounter(): PerfCounter;
  58778. /**
  58779. * Gets the sprites render time capture status
  58780. */
  58781. get captureSpritesRenderTime(): boolean;
  58782. /**
  58783. * Enable or disable the sprites render time capture
  58784. */
  58785. set captureSpritesRenderTime(value: boolean);
  58786. /**
  58787. * Gets the perf counter used for physics time
  58788. */
  58789. get physicsTimeCounter(): PerfCounter;
  58790. /**
  58791. * Gets the physics time capture status
  58792. */
  58793. get capturePhysicsTime(): boolean;
  58794. /**
  58795. * Enable or disable the physics time capture
  58796. */
  58797. set capturePhysicsTime(value: boolean);
  58798. /**
  58799. * Gets the perf counter used for animations time
  58800. */
  58801. get animationsTimeCounter(): PerfCounter;
  58802. /**
  58803. * Gets the animations time capture status
  58804. */
  58805. get captureAnimationsTime(): boolean;
  58806. /**
  58807. * Enable or disable the animations time capture
  58808. */
  58809. set captureAnimationsTime(value: boolean);
  58810. /**
  58811. * Gets the perf counter used for frame time capture
  58812. */
  58813. get frameTimeCounter(): PerfCounter;
  58814. /**
  58815. * Gets the frame time capture status
  58816. */
  58817. get captureFrameTime(): boolean;
  58818. /**
  58819. * Enable or disable the frame time capture
  58820. */
  58821. set captureFrameTime(value: boolean);
  58822. /**
  58823. * Gets the perf counter used for inter-frames time capture
  58824. */
  58825. get interFrameTimeCounter(): PerfCounter;
  58826. /**
  58827. * Gets the inter-frames time capture status
  58828. */
  58829. get captureInterFrameTime(): boolean;
  58830. /**
  58831. * Enable or disable the inter-frames time capture
  58832. */
  58833. set captureInterFrameTime(value: boolean);
  58834. /**
  58835. * Gets the perf counter used for render time capture
  58836. */
  58837. get renderTimeCounter(): PerfCounter;
  58838. /**
  58839. * Gets the render time capture status
  58840. */
  58841. get captureRenderTime(): boolean;
  58842. /**
  58843. * Enable or disable the render time capture
  58844. */
  58845. set captureRenderTime(value: boolean);
  58846. /**
  58847. * Gets the perf counter used for camera render time capture
  58848. */
  58849. get cameraRenderTimeCounter(): PerfCounter;
  58850. /**
  58851. * Gets the camera render time capture status
  58852. */
  58853. get captureCameraRenderTime(): boolean;
  58854. /**
  58855. * Enable or disable the camera render time capture
  58856. */
  58857. set captureCameraRenderTime(value: boolean);
  58858. /**
  58859. * Gets the perf counter used for draw calls
  58860. */
  58861. get drawCallsCounter(): PerfCounter;
  58862. /**
  58863. * Instantiates a new scene instrumentation.
  58864. * This class can be used to get instrumentation data from a Babylon engine
  58865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58866. * @param scene Defines the scene to instrument
  58867. */
  58868. constructor(
  58869. /**
  58870. * Defines the scene to instrument
  58871. */
  58872. scene: Scene);
  58873. /**
  58874. * Dispose and release associated resources.
  58875. */
  58876. dispose(): void;
  58877. }
  58878. }
  58879. declare module "babylonjs/Instrumentation/index" {
  58880. export * from "babylonjs/Instrumentation/engineInstrumentation";
  58881. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  58882. export * from "babylonjs/Instrumentation/timeToken";
  58883. }
  58884. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  58885. /** @hidden */
  58886. export var glowMapGenerationPixelShader: {
  58887. name: string;
  58888. shader: string;
  58889. };
  58890. }
  58891. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  58892. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58893. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58895. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58896. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58897. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58898. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58899. /** @hidden */
  58900. export var glowMapGenerationVertexShader: {
  58901. name: string;
  58902. shader: string;
  58903. };
  58904. }
  58905. declare module "babylonjs/Layers/effectLayer" {
  58906. import { Observable } from "babylonjs/Misc/observable";
  58907. import { Nullable } from "babylonjs/types";
  58908. import { Camera } from "babylonjs/Cameras/camera";
  58909. import { Scene } from "babylonjs/scene";
  58910. import { ISize } from "babylonjs/Maths/math.size";
  58911. import { Color4 } from "babylonjs/Maths/math.color";
  58912. import { Engine } from "babylonjs/Engines/engine";
  58913. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58915. import { Mesh } from "babylonjs/Meshes/mesh";
  58916. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58918. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58919. import { Effect } from "babylonjs/Materials/effect";
  58920. import { Material } from "babylonjs/Materials/material";
  58921. import "babylonjs/Shaders/glowMapGeneration.fragment";
  58922. import "babylonjs/Shaders/glowMapGeneration.vertex";
  58923. /**
  58924. * Effect layer options. This helps customizing the behaviour
  58925. * of the effect layer.
  58926. */
  58927. export interface IEffectLayerOptions {
  58928. /**
  58929. * Multiplication factor apply to the canvas size to compute the render target size
  58930. * used to generated the objects (the smaller the faster).
  58931. */
  58932. mainTextureRatio: number;
  58933. /**
  58934. * Enforces a fixed size texture to ensure effect stability across devices.
  58935. */
  58936. mainTextureFixedSize?: number;
  58937. /**
  58938. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58939. */
  58940. alphaBlendingMode: number;
  58941. /**
  58942. * The camera attached to the layer.
  58943. */
  58944. camera: Nullable<Camera>;
  58945. /**
  58946. * The rendering group to draw the layer in.
  58947. */
  58948. renderingGroupId: number;
  58949. }
  58950. /**
  58951. * The effect layer Helps adding post process effect blended with the main pass.
  58952. *
  58953. * This can be for instance use to generate glow or higlight effects on the scene.
  58954. *
  58955. * The effect layer class can not be used directly and is intented to inherited from to be
  58956. * customized per effects.
  58957. */
  58958. export abstract class EffectLayer {
  58959. private _vertexBuffers;
  58960. private _indexBuffer;
  58961. private _cachedDefines;
  58962. private _effectLayerMapGenerationEffect;
  58963. private _effectLayerOptions;
  58964. private _mergeEffect;
  58965. protected _scene: Scene;
  58966. protected _engine: Engine;
  58967. protected _maxSize: number;
  58968. protected _mainTextureDesiredSize: ISize;
  58969. protected _mainTexture: RenderTargetTexture;
  58970. protected _shouldRender: boolean;
  58971. protected _postProcesses: PostProcess[];
  58972. protected _textures: BaseTexture[];
  58973. protected _emissiveTextureAndColor: {
  58974. texture: Nullable<BaseTexture>;
  58975. color: Color4;
  58976. };
  58977. /**
  58978. * The name of the layer
  58979. */
  58980. name: string;
  58981. /**
  58982. * The clear color of the texture used to generate the glow map.
  58983. */
  58984. neutralColor: Color4;
  58985. /**
  58986. * Specifies whether the highlight layer is enabled or not.
  58987. */
  58988. isEnabled: boolean;
  58989. /**
  58990. * Gets the camera attached to the layer.
  58991. */
  58992. get camera(): Nullable<Camera>;
  58993. /**
  58994. * Gets the rendering group id the layer should render in.
  58995. */
  58996. get renderingGroupId(): number;
  58997. set renderingGroupId(renderingGroupId: number);
  58998. /**
  58999. * An event triggered when the effect layer has been disposed.
  59000. */
  59001. onDisposeObservable: Observable<EffectLayer>;
  59002. /**
  59003. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59004. */
  59005. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59006. /**
  59007. * An event triggered when the generated texture is being merged in the scene.
  59008. */
  59009. onBeforeComposeObservable: Observable<EffectLayer>;
  59010. /**
  59011. * An event triggered when the mesh is rendered into the effect render target.
  59012. */
  59013. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59014. /**
  59015. * An event triggered after the mesh has been rendered into the effect render target.
  59016. */
  59017. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59018. /**
  59019. * An event triggered when the generated texture has been merged in the scene.
  59020. */
  59021. onAfterComposeObservable: Observable<EffectLayer>;
  59022. /**
  59023. * An event triggered when the efffect layer changes its size.
  59024. */
  59025. onSizeChangedObservable: Observable<EffectLayer>;
  59026. /** @hidden */
  59027. static _SceneComponentInitialization: (scene: Scene) => void;
  59028. /**
  59029. * Instantiates a new effect Layer and references it in the scene.
  59030. * @param name The name of the layer
  59031. * @param scene The scene to use the layer in
  59032. */
  59033. constructor(
  59034. /** The Friendly of the effect in the scene */
  59035. name: string, scene: Scene);
  59036. /**
  59037. * Get the effect name of the layer.
  59038. * @return The effect name
  59039. */
  59040. abstract getEffectName(): string;
  59041. /**
  59042. * Checks for the readiness of the element composing the layer.
  59043. * @param subMesh the mesh to check for
  59044. * @param useInstances specify whether or not to use instances to render the mesh
  59045. * @return true if ready otherwise, false
  59046. */
  59047. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59048. /**
  59049. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59050. * @returns true if the effect requires stencil during the main canvas render pass.
  59051. */
  59052. abstract needStencil(): boolean;
  59053. /**
  59054. * Create the merge effect. This is the shader use to blit the information back
  59055. * to the main canvas at the end of the scene rendering.
  59056. * @returns The effect containing the shader used to merge the effect on the main canvas
  59057. */
  59058. protected abstract _createMergeEffect(): Effect;
  59059. /**
  59060. * Creates the render target textures and post processes used in the effect layer.
  59061. */
  59062. protected abstract _createTextureAndPostProcesses(): void;
  59063. /**
  59064. * Implementation specific of rendering the generating effect on the main canvas.
  59065. * @param effect The effect used to render through
  59066. */
  59067. protected abstract _internalRender(effect: Effect): void;
  59068. /**
  59069. * Sets the required values for both the emissive texture and and the main color.
  59070. */
  59071. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59072. /**
  59073. * Free any resources and references associated to a mesh.
  59074. * Internal use
  59075. * @param mesh The mesh to free.
  59076. */
  59077. abstract _disposeMesh(mesh: Mesh): void;
  59078. /**
  59079. * Serializes this layer (Glow or Highlight for example)
  59080. * @returns a serialized layer object
  59081. */
  59082. abstract serialize?(): any;
  59083. /**
  59084. * Initializes the effect layer with the required options.
  59085. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59086. */
  59087. protected _init(options: Partial<IEffectLayerOptions>): void;
  59088. /**
  59089. * Generates the index buffer of the full screen quad blending to the main canvas.
  59090. */
  59091. private _generateIndexBuffer;
  59092. /**
  59093. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59094. */
  59095. private _generateVertexBuffer;
  59096. /**
  59097. * Sets the main texture desired size which is the closest power of two
  59098. * of the engine canvas size.
  59099. */
  59100. private _setMainTextureSize;
  59101. /**
  59102. * Creates the main texture for the effect layer.
  59103. */
  59104. protected _createMainTexture(): void;
  59105. /**
  59106. * Adds specific effects defines.
  59107. * @param defines The defines to add specifics to.
  59108. */
  59109. protected _addCustomEffectDefines(defines: string[]): void;
  59110. /**
  59111. * Checks for the readiness of the element composing the layer.
  59112. * @param subMesh the mesh to check for
  59113. * @param useInstances specify whether or not to use instances to render the mesh
  59114. * @param emissiveTexture the associated emissive texture used to generate the glow
  59115. * @return true if ready otherwise, false
  59116. */
  59117. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59118. /**
  59119. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59120. */
  59121. render(): void;
  59122. /**
  59123. * Determine if a given mesh will be used in the current effect.
  59124. * @param mesh mesh to test
  59125. * @returns true if the mesh will be used
  59126. */
  59127. hasMesh(mesh: AbstractMesh): boolean;
  59128. /**
  59129. * Returns true if the layer contains information to display, otherwise false.
  59130. * @returns true if the glow layer should be rendered
  59131. */
  59132. shouldRender(): boolean;
  59133. /**
  59134. * Returns true if the mesh should render, otherwise false.
  59135. * @param mesh The mesh to render
  59136. * @returns true if it should render otherwise false
  59137. */
  59138. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59139. /**
  59140. * Returns true if the mesh can be rendered, otherwise false.
  59141. * @param mesh The mesh to render
  59142. * @param material The material used on the mesh
  59143. * @returns true if it can be rendered otherwise false
  59144. */
  59145. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59146. /**
  59147. * Returns true if the mesh should render, otherwise false.
  59148. * @param mesh The mesh to render
  59149. * @returns true if it should render otherwise false
  59150. */
  59151. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59152. /**
  59153. * Renders the submesh passed in parameter to the generation map.
  59154. */
  59155. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59156. /**
  59157. * Defines whether the current material of the mesh should be use to render the effect.
  59158. * @param mesh defines the current mesh to render
  59159. */
  59160. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59161. /**
  59162. * Rebuild the required buffers.
  59163. * @hidden Internal use only.
  59164. */
  59165. _rebuild(): void;
  59166. /**
  59167. * Dispose only the render target textures and post process.
  59168. */
  59169. private _disposeTextureAndPostProcesses;
  59170. /**
  59171. * Dispose the highlight layer and free resources.
  59172. */
  59173. dispose(): void;
  59174. /**
  59175. * Gets the class name of the effect layer
  59176. * @returns the string with the class name of the effect layer
  59177. */
  59178. getClassName(): string;
  59179. /**
  59180. * Creates an effect layer from parsed effect layer data
  59181. * @param parsedEffectLayer defines effect layer data
  59182. * @param scene defines the current scene
  59183. * @param rootUrl defines the root URL containing the effect layer information
  59184. * @returns a parsed effect Layer
  59185. */
  59186. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59187. }
  59188. }
  59189. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59190. import { Scene } from "babylonjs/scene";
  59191. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59192. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59193. import { AbstractScene } from "babylonjs/abstractScene";
  59194. module "babylonjs/abstractScene" {
  59195. interface AbstractScene {
  59196. /**
  59197. * The list of effect layers (highlights/glow) added to the scene
  59198. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59199. * @see http://doc.babylonjs.com/how_to/glow_layer
  59200. */
  59201. effectLayers: Array<EffectLayer>;
  59202. /**
  59203. * Removes the given effect layer from this scene.
  59204. * @param toRemove defines the effect layer to remove
  59205. * @returns the index of the removed effect layer
  59206. */
  59207. removeEffectLayer(toRemove: EffectLayer): number;
  59208. /**
  59209. * Adds the given effect layer to this scene
  59210. * @param newEffectLayer defines the effect layer to add
  59211. */
  59212. addEffectLayer(newEffectLayer: EffectLayer): void;
  59213. }
  59214. }
  59215. /**
  59216. * Defines the layer scene component responsible to manage any effect layers
  59217. * in a given scene.
  59218. */
  59219. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59220. /**
  59221. * The component name helpfull to identify the component in the list of scene components.
  59222. */
  59223. readonly name: string;
  59224. /**
  59225. * The scene the component belongs to.
  59226. */
  59227. scene: Scene;
  59228. private _engine;
  59229. private _renderEffects;
  59230. private _needStencil;
  59231. private _previousStencilState;
  59232. /**
  59233. * Creates a new instance of the component for the given scene
  59234. * @param scene Defines the scene to register the component in
  59235. */
  59236. constructor(scene: Scene);
  59237. /**
  59238. * Registers the component in a given scene
  59239. */
  59240. register(): void;
  59241. /**
  59242. * Rebuilds the elements related to this component in case of
  59243. * context lost for instance.
  59244. */
  59245. rebuild(): void;
  59246. /**
  59247. * Serializes the component data to the specified json object
  59248. * @param serializationObject The object to serialize to
  59249. */
  59250. serialize(serializationObject: any): void;
  59251. /**
  59252. * Adds all the elements from the container to the scene
  59253. * @param container the container holding the elements
  59254. */
  59255. addFromContainer(container: AbstractScene): void;
  59256. /**
  59257. * Removes all the elements in the container from the scene
  59258. * @param container contains the elements to remove
  59259. * @param dispose if the removed element should be disposed (default: false)
  59260. */
  59261. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59262. /**
  59263. * Disposes the component and the associated ressources.
  59264. */
  59265. dispose(): void;
  59266. private _isReadyForMesh;
  59267. private _renderMainTexture;
  59268. private _setStencil;
  59269. private _setStencilBack;
  59270. private _draw;
  59271. private _drawCamera;
  59272. private _drawRenderingGroup;
  59273. }
  59274. }
  59275. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59276. /** @hidden */
  59277. export var glowMapMergePixelShader: {
  59278. name: string;
  59279. shader: string;
  59280. };
  59281. }
  59282. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59283. /** @hidden */
  59284. export var glowMapMergeVertexShader: {
  59285. name: string;
  59286. shader: string;
  59287. };
  59288. }
  59289. declare module "babylonjs/Layers/glowLayer" {
  59290. import { Nullable } from "babylonjs/types";
  59291. import { Camera } from "babylonjs/Cameras/camera";
  59292. import { Scene } from "babylonjs/scene";
  59293. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59295. import { Mesh } from "babylonjs/Meshes/mesh";
  59296. import { Texture } from "babylonjs/Materials/Textures/texture";
  59297. import { Effect } from "babylonjs/Materials/effect";
  59298. import { Material } from "babylonjs/Materials/material";
  59299. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59300. import { Color4 } from "babylonjs/Maths/math.color";
  59301. import "babylonjs/Shaders/glowMapMerge.fragment";
  59302. import "babylonjs/Shaders/glowMapMerge.vertex";
  59303. import "babylonjs/Layers/effectLayerSceneComponent";
  59304. module "babylonjs/abstractScene" {
  59305. interface AbstractScene {
  59306. /**
  59307. * Return a the first highlight layer of the scene with a given name.
  59308. * @param name The name of the highlight layer to look for.
  59309. * @return The highlight layer if found otherwise null.
  59310. */
  59311. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59312. }
  59313. }
  59314. /**
  59315. * Glow layer options. This helps customizing the behaviour
  59316. * of the glow layer.
  59317. */
  59318. export interface IGlowLayerOptions {
  59319. /**
  59320. * Multiplication factor apply to the canvas size to compute the render target size
  59321. * used to generated the glowing objects (the smaller the faster).
  59322. */
  59323. mainTextureRatio: number;
  59324. /**
  59325. * Enforces a fixed size texture to ensure resize independant blur.
  59326. */
  59327. mainTextureFixedSize?: number;
  59328. /**
  59329. * How big is the kernel of the blur texture.
  59330. */
  59331. blurKernelSize: number;
  59332. /**
  59333. * The camera attached to the layer.
  59334. */
  59335. camera: Nullable<Camera>;
  59336. /**
  59337. * Enable MSAA by chosing the number of samples.
  59338. */
  59339. mainTextureSamples?: number;
  59340. /**
  59341. * The rendering group to draw the layer in.
  59342. */
  59343. renderingGroupId: number;
  59344. }
  59345. /**
  59346. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59347. *
  59348. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59349. *
  59350. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59351. */
  59352. export class GlowLayer extends EffectLayer {
  59353. /**
  59354. * Effect Name of the layer.
  59355. */
  59356. static readonly EffectName: string;
  59357. /**
  59358. * The default blur kernel size used for the glow.
  59359. */
  59360. static DefaultBlurKernelSize: number;
  59361. /**
  59362. * The default texture size ratio used for the glow.
  59363. */
  59364. static DefaultTextureRatio: number;
  59365. /**
  59366. * Sets the kernel size of the blur.
  59367. */
  59368. set blurKernelSize(value: number);
  59369. /**
  59370. * Gets the kernel size of the blur.
  59371. */
  59372. get blurKernelSize(): number;
  59373. /**
  59374. * Sets the glow intensity.
  59375. */
  59376. set intensity(value: number);
  59377. /**
  59378. * Gets the glow intensity.
  59379. */
  59380. get intensity(): number;
  59381. private _options;
  59382. private _intensity;
  59383. private _horizontalBlurPostprocess1;
  59384. private _verticalBlurPostprocess1;
  59385. private _horizontalBlurPostprocess2;
  59386. private _verticalBlurPostprocess2;
  59387. private _blurTexture1;
  59388. private _blurTexture2;
  59389. private _postProcesses1;
  59390. private _postProcesses2;
  59391. private _includedOnlyMeshes;
  59392. private _excludedMeshes;
  59393. private _meshesUsingTheirOwnMaterials;
  59394. /**
  59395. * Callback used to let the user override the color selection on a per mesh basis
  59396. */
  59397. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59398. /**
  59399. * Callback used to let the user override the texture selection on a per mesh basis
  59400. */
  59401. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59402. /**
  59403. * Instantiates a new glow Layer and references it to the scene.
  59404. * @param name The name of the layer
  59405. * @param scene The scene to use the layer in
  59406. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59407. */
  59408. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59409. /**
  59410. * Get the effect name of the layer.
  59411. * @return The effect name
  59412. */
  59413. getEffectName(): string;
  59414. /**
  59415. * Create the merge effect. This is the shader use to blit the information back
  59416. * to the main canvas at the end of the scene rendering.
  59417. */
  59418. protected _createMergeEffect(): Effect;
  59419. /**
  59420. * Creates the render target textures and post processes used in the glow layer.
  59421. */
  59422. protected _createTextureAndPostProcesses(): void;
  59423. /**
  59424. * Checks for the readiness of the element composing the layer.
  59425. * @param subMesh the mesh to check for
  59426. * @param useInstances specify wether or not to use instances to render the mesh
  59427. * @param emissiveTexture the associated emissive texture used to generate the glow
  59428. * @return true if ready otherwise, false
  59429. */
  59430. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59431. /**
  59432. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59433. */
  59434. needStencil(): boolean;
  59435. /**
  59436. * Returns true if the mesh can be rendered, otherwise false.
  59437. * @param mesh The mesh to render
  59438. * @param material The material used on the mesh
  59439. * @returns true if it can be rendered otherwise false
  59440. */
  59441. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59442. /**
  59443. * Implementation specific of rendering the generating effect on the main canvas.
  59444. * @param effect The effect used to render through
  59445. */
  59446. protected _internalRender(effect: Effect): void;
  59447. /**
  59448. * Sets the required values for both the emissive texture and and the main color.
  59449. */
  59450. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59451. /**
  59452. * Returns true if the mesh should render, otherwise false.
  59453. * @param mesh The mesh to render
  59454. * @returns true if it should render otherwise false
  59455. */
  59456. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59457. /**
  59458. * Adds specific effects defines.
  59459. * @param defines The defines to add specifics to.
  59460. */
  59461. protected _addCustomEffectDefines(defines: string[]): void;
  59462. /**
  59463. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59464. * @param mesh The mesh to exclude from the glow layer
  59465. */
  59466. addExcludedMesh(mesh: Mesh): void;
  59467. /**
  59468. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59469. * @param mesh The mesh to remove
  59470. */
  59471. removeExcludedMesh(mesh: Mesh): void;
  59472. /**
  59473. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59474. * @param mesh The mesh to include in the glow layer
  59475. */
  59476. addIncludedOnlyMesh(mesh: Mesh): void;
  59477. /**
  59478. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59479. * @param mesh The mesh to remove
  59480. */
  59481. removeIncludedOnlyMesh(mesh: Mesh): void;
  59482. /**
  59483. * Determine if a given mesh will be used in the glow layer
  59484. * @param mesh The mesh to test
  59485. * @returns true if the mesh will be highlighted by the current glow layer
  59486. */
  59487. hasMesh(mesh: AbstractMesh): boolean;
  59488. /**
  59489. * Defines whether the current material of the mesh should be use to render the effect.
  59490. * @param mesh defines the current mesh to render
  59491. */
  59492. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59493. /**
  59494. * Add a mesh to be rendered through its own material and not with emissive only.
  59495. * @param mesh The mesh for which we need to use its material
  59496. */
  59497. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59498. /**
  59499. * Remove a mesh from being rendered through its own material and not with emissive only.
  59500. * @param mesh The mesh for which we need to not use its material
  59501. */
  59502. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59503. /**
  59504. * Free any resources and references associated to a mesh.
  59505. * Internal use
  59506. * @param mesh The mesh to free.
  59507. * @hidden
  59508. */
  59509. _disposeMesh(mesh: Mesh): void;
  59510. /**
  59511. * Gets the class name of the effect layer
  59512. * @returns the string with the class name of the effect layer
  59513. */
  59514. getClassName(): string;
  59515. /**
  59516. * Serializes this glow layer
  59517. * @returns a serialized glow layer object
  59518. */
  59519. serialize(): any;
  59520. /**
  59521. * Creates a Glow Layer from parsed glow layer data
  59522. * @param parsedGlowLayer defines glow layer data
  59523. * @param scene defines the current scene
  59524. * @param rootUrl defines the root URL containing the glow layer information
  59525. * @returns a parsed Glow Layer
  59526. */
  59527. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59528. }
  59529. }
  59530. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  59531. /** @hidden */
  59532. export var glowBlurPostProcessPixelShader: {
  59533. name: string;
  59534. shader: string;
  59535. };
  59536. }
  59537. declare module "babylonjs/Layers/highlightLayer" {
  59538. import { Observable } from "babylonjs/Misc/observable";
  59539. import { Nullable } from "babylonjs/types";
  59540. import { Camera } from "babylonjs/Cameras/camera";
  59541. import { Scene } from "babylonjs/scene";
  59542. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59544. import { Mesh } from "babylonjs/Meshes/mesh";
  59545. import { Effect } from "babylonjs/Materials/effect";
  59546. import { Material } from "babylonjs/Materials/material";
  59547. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59548. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59549. import "babylonjs/Shaders/glowMapMerge.fragment";
  59550. import "babylonjs/Shaders/glowMapMerge.vertex";
  59551. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  59552. module "babylonjs/abstractScene" {
  59553. interface AbstractScene {
  59554. /**
  59555. * Return a the first highlight layer of the scene with a given name.
  59556. * @param name The name of the highlight layer to look for.
  59557. * @return The highlight layer if found otherwise null.
  59558. */
  59559. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59560. }
  59561. }
  59562. /**
  59563. * Highlight layer options. This helps customizing the behaviour
  59564. * of the highlight layer.
  59565. */
  59566. export interface IHighlightLayerOptions {
  59567. /**
  59568. * Multiplication factor apply to the canvas size to compute the render target size
  59569. * used to generated the glowing objects (the smaller the faster).
  59570. */
  59571. mainTextureRatio: number;
  59572. /**
  59573. * Enforces a fixed size texture to ensure resize independant blur.
  59574. */
  59575. mainTextureFixedSize?: number;
  59576. /**
  59577. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59578. * of the picture to blur (the smaller the faster).
  59579. */
  59580. blurTextureSizeRatio: number;
  59581. /**
  59582. * How big in texel of the blur texture is the vertical blur.
  59583. */
  59584. blurVerticalSize: number;
  59585. /**
  59586. * How big in texel of the blur texture is the horizontal blur.
  59587. */
  59588. blurHorizontalSize: number;
  59589. /**
  59590. * Alpha blending mode used to apply the blur. Default is combine.
  59591. */
  59592. alphaBlendingMode: number;
  59593. /**
  59594. * The camera attached to the layer.
  59595. */
  59596. camera: Nullable<Camera>;
  59597. /**
  59598. * Should we display highlight as a solid stroke?
  59599. */
  59600. isStroke?: boolean;
  59601. /**
  59602. * The rendering group to draw the layer in.
  59603. */
  59604. renderingGroupId: number;
  59605. }
  59606. /**
  59607. * The highlight layer Helps adding a glow effect around a mesh.
  59608. *
  59609. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59610. * glowy meshes to your scene.
  59611. *
  59612. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59613. */
  59614. export class HighlightLayer extends EffectLayer {
  59615. name: string;
  59616. /**
  59617. * Effect Name of the highlight layer.
  59618. */
  59619. static readonly EffectName: string;
  59620. /**
  59621. * The neutral color used during the preparation of the glow effect.
  59622. * This is black by default as the blend operation is a blend operation.
  59623. */
  59624. static NeutralColor: Color4;
  59625. /**
  59626. * Stencil value used for glowing meshes.
  59627. */
  59628. static GlowingMeshStencilReference: number;
  59629. /**
  59630. * Stencil value used for the other meshes in the scene.
  59631. */
  59632. static NormalMeshStencilReference: number;
  59633. /**
  59634. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59635. */
  59636. innerGlow: boolean;
  59637. /**
  59638. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59639. */
  59640. outerGlow: boolean;
  59641. /**
  59642. * Specifies the horizontal size of the blur.
  59643. */
  59644. set blurHorizontalSize(value: number);
  59645. /**
  59646. * Specifies the vertical size of the blur.
  59647. */
  59648. set blurVerticalSize(value: number);
  59649. /**
  59650. * Gets the horizontal size of the blur.
  59651. */
  59652. get blurHorizontalSize(): number;
  59653. /**
  59654. * Gets the vertical size of the blur.
  59655. */
  59656. get blurVerticalSize(): number;
  59657. /**
  59658. * An event triggered when the highlight layer is being blurred.
  59659. */
  59660. onBeforeBlurObservable: Observable<HighlightLayer>;
  59661. /**
  59662. * An event triggered when the highlight layer has been blurred.
  59663. */
  59664. onAfterBlurObservable: Observable<HighlightLayer>;
  59665. private _instanceGlowingMeshStencilReference;
  59666. private _options;
  59667. private _downSamplePostprocess;
  59668. private _horizontalBlurPostprocess;
  59669. private _verticalBlurPostprocess;
  59670. private _blurTexture;
  59671. private _meshes;
  59672. private _excludedMeshes;
  59673. /**
  59674. * Instantiates a new highlight Layer and references it to the scene..
  59675. * @param name The name of the layer
  59676. * @param scene The scene to use the layer in
  59677. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59678. */
  59679. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59680. /**
  59681. * Get the effect name of the layer.
  59682. * @return The effect name
  59683. */
  59684. getEffectName(): string;
  59685. /**
  59686. * Create the merge effect. This is the shader use to blit the information back
  59687. * to the main canvas at the end of the scene rendering.
  59688. */
  59689. protected _createMergeEffect(): Effect;
  59690. /**
  59691. * Creates the render target textures and post processes used in the highlight layer.
  59692. */
  59693. protected _createTextureAndPostProcesses(): void;
  59694. /**
  59695. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59696. */
  59697. needStencil(): boolean;
  59698. /**
  59699. * Checks for the readiness of the element composing the layer.
  59700. * @param subMesh the mesh to check for
  59701. * @param useInstances specify wether or not to use instances to render the mesh
  59702. * @param emissiveTexture the associated emissive texture used to generate the glow
  59703. * @return true if ready otherwise, false
  59704. */
  59705. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59706. /**
  59707. * Implementation specific of rendering the generating effect on the main canvas.
  59708. * @param effect The effect used to render through
  59709. */
  59710. protected _internalRender(effect: Effect): void;
  59711. /**
  59712. * Returns true if the layer contains information to display, otherwise false.
  59713. */
  59714. shouldRender(): boolean;
  59715. /**
  59716. * Returns true if the mesh should render, otherwise false.
  59717. * @param mesh The mesh to render
  59718. * @returns true if it should render otherwise false
  59719. */
  59720. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59721. /**
  59722. * Adds specific effects defines.
  59723. * @param defines The defines to add specifics to.
  59724. */
  59725. protected _addCustomEffectDefines(defines: string[]): void;
  59726. /**
  59727. * Sets the required values for both the emissive texture and and the main color.
  59728. */
  59729. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59730. /**
  59731. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59732. * @param mesh The mesh to exclude from the highlight layer
  59733. */
  59734. addExcludedMesh(mesh: Mesh): void;
  59735. /**
  59736. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59737. * @param mesh The mesh to highlight
  59738. */
  59739. removeExcludedMesh(mesh: Mesh): void;
  59740. /**
  59741. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59742. * @param mesh mesh to test
  59743. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59744. */
  59745. hasMesh(mesh: AbstractMesh): boolean;
  59746. /**
  59747. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59748. * @param mesh The mesh to highlight
  59749. * @param color The color of the highlight
  59750. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59751. */
  59752. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59753. /**
  59754. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59755. * @param mesh The mesh to highlight
  59756. */
  59757. removeMesh(mesh: Mesh): void;
  59758. /**
  59759. * Remove all the meshes currently referenced in the highlight layer
  59760. */
  59761. removeAllMeshes(): void;
  59762. /**
  59763. * Force the stencil to the normal expected value for none glowing parts
  59764. */
  59765. private _defaultStencilReference;
  59766. /**
  59767. * Free any resources and references associated to a mesh.
  59768. * Internal use
  59769. * @param mesh The mesh to free.
  59770. * @hidden
  59771. */
  59772. _disposeMesh(mesh: Mesh): void;
  59773. /**
  59774. * Dispose the highlight layer and free resources.
  59775. */
  59776. dispose(): void;
  59777. /**
  59778. * Gets the class name of the effect layer
  59779. * @returns the string with the class name of the effect layer
  59780. */
  59781. getClassName(): string;
  59782. /**
  59783. * Serializes this Highlight layer
  59784. * @returns a serialized Highlight layer object
  59785. */
  59786. serialize(): any;
  59787. /**
  59788. * Creates a Highlight layer from parsed Highlight layer data
  59789. * @param parsedHightlightLayer defines the Highlight layer data
  59790. * @param scene defines the current scene
  59791. * @param rootUrl defines the root URL containing the Highlight layer information
  59792. * @returns a parsed Highlight layer
  59793. */
  59794. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59795. }
  59796. }
  59797. declare module "babylonjs/Layers/layerSceneComponent" {
  59798. import { Scene } from "babylonjs/scene";
  59799. import { ISceneComponent } from "babylonjs/sceneComponent";
  59800. import { Layer } from "babylonjs/Layers/layer";
  59801. import { AbstractScene } from "babylonjs/abstractScene";
  59802. module "babylonjs/abstractScene" {
  59803. interface AbstractScene {
  59804. /**
  59805. * The list of layers (background and foreground) of the scene
  59806. */
  59807. layers: Array<Layer>;
  59808. }
  59809. }
  59810. /**
  59811. * Defines the layer scene component responsible to manage any layers
  59812. * in a given scene.
  59813. */
  59814. export class LayerSceneComponent implements ISceneComponent {
  59815. /**
  59816. * The component name helpfull to identify the component in the list of scene components.
  59817. */
  59818. readonly name: string;
  59819. /**
  59820. * The scene the component belongs to.
  59821. */
  59822. scene: Scene;
  59823. private _engine;
  59824. /**
  59825. * Creates a new instance of the component for the given scene
  59826. * @param scene Defines the scene to register the component in
  59827. */
  59828. constructor(scene: Scene);
  59829. /**
  59830. * Registers the component in a given scene
  59831. */
  59832. register(): void;
  59833. /**
  59834. * Rebuilds the elements related to this component in case of
  59835. * context lost for instance.
  59836. */
  59837. rebuild(): void;
  59838. /**
  59839. * Disposes the component and the associated ressources.
  59840. */
  59841. dispose(): void;
  59842. private _draw;
  59843. private _drawCameraPredicate;
  59844. private _drawCameraBackground;
  59845. private _drawCameraForeground;
  59846. private _drawRenderTargetPredicate;
  59847. private _drawRenderTargetBackground;
  59848. private _drawRenderTargetForeground;
  59849. /**
  59850. * Adds all the elements from the container to the scene
  59851. * @param container the container holding the elements
  59852. */
  59853. addFromContainer(container: AbstractScene): void;
  59854. /**
  59855. * Removes all the elements in the container from the scene
  59856. * @param container contains the elements to remove
  59857. * @param dispose if the removed element should be disposed (default: false)
  59858. */
  59859. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59860. }
  59861. }
  59862. declare module "babylonjs/Shaders/layer.fragment" {
  59863. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59864. /** @hidden */
  59865. export var layerPixelShader: {
  59866. name: string;
  59867. shader: string;
  59868. };
  59869. }
  59870. declare module "babylonjs/Shaders/layer.vertex" {
  59871. /** @hidden */
  59872. export var layerVertexShader: {
  59873. name: string;
  59874. shader: string;
  59875. };
  59876. }
  59877. declare module "babylonjs/Layers/layer" {
  59878. import { Observable } from "babylonjs/Misc/observable";
  59879. import { Nullable } from "babylonjs/types";
  59880. import { Scene } from "babylonjs/scene";
  59881. import { Vector2 } from "babylonjs/Maths/math.vector";
  59882. import { Color4 } from "babylonjs/Maths/math.color";
  59883. import { Texture } from "babylonjs/Materials/Textures/texture";
  59884. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59885. import "babylonjs/Shaders/layer.fragment";
  59886. import "babylonjs/Shaders/layer.vertex";
  59887. /**
  59888. * This represents a full screen 2d layer.
  59889. * This can be useful to display a picture in the background of your scene for instance.
  59890. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59891. */
  59892. export class Layer {
  59893. /**
  59894. * Define the name of the layer.
  59895. */
  59896. name: string;
  59897. /**
  59898. * Define the texture the layer should display.
  59899. */
  59900. texture: Nullable<Texture>;
  59901. /**
  59902. * Is the layer in background or foreground.
  59903. */
  59904. isBackground: boolean;
  59905. /**
  59906. * Define the color of the layer (instead of texture).
  59907. */
  59908. color: Color4;
  59909. /**
  59910. * Define the scale of the layer in order to zoom in out of the texture.
  59911. */
  59912. scale: Vector2;
  59913. /**
  59914. * Define an offset for the layer in order to shift the texture.
  59915. */
  59916. offset: Vector2;
  59917. /**
  59918. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59919. */
  59920. alphaBlendingMode: number;
  59921. /**
  59922. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59923. * Alpha test will not mix with the background color in case of transparency.
  59924. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59925. */
  59926. alphaTest: boolean;
  59927. /**
  59928. * Define a mask to restrict the layer to only some of the scene cameras.
  59929. */
  59930. layerMask: number;
  59931. /**
  59932. * Define the list of render target the layer is visible into.
  59933. */
  59934. renderTargetTextures: RenderTargetTexture[];
  59935. /**
  59936. * Define if the layer is only used in renderTarget or if it also
  59937. * renders in the main frame buffer of the canvas.
  59938. */
  59939. renderOnlyInRenderTargetTextures: boolean;
  59940. private _scene;
  59941. private _vertexBuffers;
  59942. private _indexBuffer;
  59943. private _effect;
  59944. private _previousDefines;
  59945. /**
  59946. * An event triggered when the layer is disposed.
  59947. */
  59948. onDisposeObservable: Observable<Layer>;
  59949. private _onDisposeObserver;
  59950. /**
  59951. * Back compatibility with callback before the onDisposeObservable existed.
  59952. * The set callback will be triggered when the layer has been disposed.
  59953. */
  59954. set onDispose(callback: () => void);
  59955. /**
  59956. * An event triggered before rendering the scene
  59957. */
  59958. onBeforeRenderObservable: Observable<Layer>;
  59959. private _onBeforeRenderObserver;
  59960. /**
  59961. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59962. * The set callback will be triggered just before rendering the layer.
  59963. */
  59964. set onBeforeRender(callback: () => void);
  59965. /**
  59966. * An event triggered after rendering the scene
  59967. */
  59968. onAfterRenderObservable: Observable<Layer>;
  59969. private _onAfterRenderObserver;
  59970. /**
  59971. * Back compatibility with callback before the onAfterRenderObservable existed.
  59972. * The set callback will be triggered just after rendering the layer.
  59973. */
  59974. set onAfterRender(callback: () => void);
  59975. /**
  59976. * Instantiates a new layer.
  59977. * This represents a full screen 2d layer.
  59978. * This can be useful to display a picture in the background of your scene for instance.
  59979. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59980. * @param name Define the name of the layer in the scene
  59981. * @param imgUrl Define the url of the texture to display in the layer
  59982. * @param scene Define the scene the layer belongs to
  59983. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59984. * @param color Defines a color for the layer
  59985. */
  59986. constructor(
  59987. /**
  59988. * Define the name of the layer.
  59989. */
  59990. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59991. private _createIndexBuffer;
  59992. /** @hidden */
  59993. _rebuild(): void;
  59994. /**
  59995. * Renders the layer in the scene.
  59996. */
  59997. render(): void;
  59998. /**
  59999. * Disposes and releases the associated ressources.
  60000. */
  60001. dispose(): void;
  60002. }
  60003. }
  60004. declare module "babylonjs/Layers/index" {
  60005. export * from "babylonjs/Layers/effectLayer";
  60006. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60007. export * from "babylonjs/Layers/glowLayer";
  60008. export * from "babylonjs/Layers/highlightLayer";
  60009. export * from "babylonjs/Layers/layer";
  60010. export * from "babylonjs/Layers/layerSceneComponent";
  60011. }
  60012. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60013. /** @hidden */
  60014. export var lensFlarePixelShader: {
  60015. name: string;
  60016. shader: string;
  60017. };
  60018. }
  60019. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60020. /** @hidden */
  60021. export var lensFlareVertexShader: {
  60022. name: string;
  60023. shader: string;
  60024. };
  60025. }
  60026. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60027. import { Scene } from "babylonjs/scene";
  60028. import { Vector3 } from "babylonjs/Maths/math.vector";
  60029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60030. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60031. import "babylonjs/Shaders/lensFlare.fragment";
  60032. import "babylonjs/Shaders/lensFlare.vertex";
  60033. import { Viewport } from "babylonjs/Maths/math.viewport";
  60034. /**
  60035. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60036. * It is usually composed of several `lensFlare`.
  60037. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60038. */
  60039. export class LensFlareSystem {
  60040. /**
  60041. * Define the name of the lens flare system
  60042. */
  60043. name: string;
  60044. /**
  60045. * List of lens flares used in this system.
  60046. */
  60047. lensFlares: LensFlare[];
  60048. /**
  60049. * Define a limit from the border the lens flare can be visible.
  60050. */
  60051. borderLimit: number;
  60052. /**
  60053. * Define a viewport border we do not want to see the lens flare in.
  60054. */
  60055. viewportBorder: number;
  60056. /**
  60057. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60058. */
  60059. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60060. /**
  60061. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60062. */
  60063. layerMask: number;
  60064. /**
  60065. * Define the id of the lens flare system in the scene.
  60066. * (equal to name by default)
  60067. */
  60068. id: string;
  60069. private _scene;
  60070. private _emitter;
  60071. private _vertexBuffers;
  60072. private _indexBuffer;
  60073. private _effect;
  60074. private _positionX;
  60075. private _positionY;
  60076. private _isEnabled;
  60077. /** @hidden */
  60078. static _SceneComponentInitialization: (scene: Scene) => void;
  60079. /**
  60080. * Instantiates a lens flare system.
  60081. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60082. * It is usually composed of several `lensFlare`.
  60083. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60084. * @param name Define the name of the lens flare system in the scene
  60085. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60086. * @param scene Define the scene the lens flare system belongs to
  60087. */
  60088. constructor(
  60089. /**
  60090. * Define the name of the lens flare system
  60091. */
  60092. name: string, emitter: any, scene: Scene);
  60093. /**
  60094. * Define if the lens flare system is enabled.
  60095. */
  60096. get isEnabled(): boolean;
  60097. set isEnabled(value: boolean);
  60098. /**
  60099. * Get the scene the effects belongs to.
  60100. * @returns the scene holding the lens flare system
  60101. */
  60102. getScene(): Scene;
  60103. /**
  60104. * Get the emitter of the lens flare system.
  60105. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60106. * @returns the emitter of the lens flare system
  60107. */
  60108. getEmitter(): any;
  60109. /**
  60110. * Set the emitter of the lens flare system.
  60111. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60112. * @param newEmitter Define the new emitter of the system
  60113. */
  60114. setEmitter(newEmitter: any): void;
  60115. /**
  60116. * Get the lens flare system emitter position.
  60117. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60118. * @returns the position
  60119. */
  60120. getEmitterPosition(): Vector3;
  60121. /**
  60122. * @hidden
  60123. */
  60124. computeEffectivePosition(globalViewport: Viewport): boolean;
  60125. /** @hidden */
  60126. _isVisible(): boolean;
  60127. /**
  60128. * @hidden
  60129. */
  60130. render(): boolean;
  60131. /**
  60132. * Dispose and release the lens flare with its associated resources.
  60133. */
  60134. dispose(): void;
  60135. /**
  60136. * Parse a lens flare system from a JSON repressentation
  60137. * @param parsedLensFlareSystem Define the JSON to parse
  60138. * @param scene Define the scene the parsed system should be instantiated in
  60139. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60140. * @returns the parsed system
  60141. */
  60142. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60143. /**
  60144. * Serialize the current Lens Flare System into a JSON representation.
  60145. * @returns the serialized JSON
  60146. */
  60147. serialize(): any;
  60148. }
  60149. }
  60150. declare module "babylonjs/LensFlares/lensFlare" {
  60151. import { Nullable } from "babylonjs/types";
  60152. import { Color3 } from "babylonjs/Maths/math.color";
  60153. import { Texture } from "babylonjs/Materials/Textures/texture";
  60154. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60155. /**
  60156. * This represents one of the lens effect in a `lensFlareSystem`.
  60157. * It controls one of the indiviual texture used in the effect.
  60158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60159. */
  60160. export class LensFlare {
  60161. /**
  60162. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60163. */
  60164. size: number;
  60165. /**
  60166. * 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.
  60167. */
  60168. position: number;
  60169. /**
  60170. * Define the lens color.
  60171. */
  60172. color: Color3;
  60173. /**
  60174. * Define the lens texture.
  60175. */
  60176. texture: Nullable<Texture>;
  60177. /**
  60178. * Define the alpha mode to render this particular lens.
  60179. */
  60180. alphaMode: number;
  60181. private _system;
  60182. /**
  60183. * Creates a new Lens Flare.
  60184. * This represents one of the lens effect in a `lensFlareSystem`.
  60185. * It controls one of the indiviual texture used in the effect.
  60186. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60187. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60188. * @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.
  60189. * @param color Define the lens color
  60190. * @param imgUrl Define the lens texture url
  60191. * @param system Define the `lensFlareSystem` this flare is part of
  60192. * @returns The newly created Lens Flare
  60193. */
  60194. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60195. /**
  60196. * Instantiates a new Lens Flare.
  60197. * This represents one of the lens effect in a `lensFlareSystem`.
  60198. * It controls one of the indiviual texture used in the effect.
  60199. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60200. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60201. * @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.
  60202. * @param color Define the lens color
  60203. * @param imgUrl Define the lens texture url
  60204. * @param system Define the `lensFlareSystem` this flare is part of
  60205. */
  60206. constructor(
  60207. /**
  60208. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60209. */
  60210. size: number,
  60211. /**
  60212. * 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.
  60213. */
  60214. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60215. /**
  60216. * Dispose and release the lens flare with its associated resources.
  60217. */
  60218. dispose(): void;
  60219. }
  60220. }
  60221. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60222. import { Nullable } from "babylonjs/types";
  60223. import { Scene } from "babylonjs/scene";
  60224. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60225. import { AbstractScene } from "babylonjs/abstractScene";
  60226. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60227. module "babylonjs/abstractScene" {
  60228. interface AbstractScene {
  60229. /**
  60230. * The list of lens flare system added to the scene
  60231. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60232. */
  60233. lensFlareSystems: Array<LensFlareSystem>;
  60234. /**
  60235. * Removes the given lens flare system from this scene.
  60236. * @param toRemove The lens flare system to remove
  60237. * @returns The index of the removed lens flare system
  60238. */
  60239. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60240. /**
  60241. * Adds the given lens flare system to this scene
  60242. * @param newLensFlareSystem The lens flare system to add
  60243. */
  60244. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60245. /**
  60246. * Gets a lens flare system using its name
  60247. * @param name defines the name to look for
  60248. * @returns the lens flare system or null if not found
  60249. */
  60250. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60251. /**
  60252. * Gets a lens flare system using its id
  60253. * @param id defines the id to look for
  60254. * @returns the lens flare system or null if not found
  60255. */
  60256. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60257. }
  60258. }
  60259. /**
  60260. * Defines the lens flare scene component responsible to manage any lens flares
  60261. * in a given scene.
  60262. */
  60263. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60264. /**
  60265. * The component name helpfull to identify the component in the list of scene components.
  60266. */
  60267. readonly name: string;
  60268. /**
  60269. * The scene the component belongs to.
  60270. */
  60271. scene: Scene;
  60272. /**
  60273. * Creates a new instance of the component for the given scene
  60274. * @param scene Defines the scene to register the component in
  60275. */
  60276. constructor(scene: Scene);
  60277. /**
  60278. * Registers the component in a given scene
  60279. */
  60280. register(): void;
  60281. /**
  60282. * Rebuilds the elements related to this component in case of
  60283. * context lost for instance.
  60284. */
  60285. rebuild(): void;
  60286. /**
  60287. * Adds all the elements from the container to the scene
  60288. * @param container the container holding the elements
  60289. */
  60290. addFromContainer(container: AbstractScene): void;
  60291. /**
  60292. * Removes all the elements in the container from the scene
  60293. * @param container contains the elements to remove
  60294. * @param dispose if the removed element should be disposed (default: false)
  60295. */
  60296. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60297. /**
  60298. * Serializes the component data to the specified json object
  60299. * @param serializationObject The object to serialize to
  60300. */
  60301. serialize(serializationObject: any): void;
  60302. /**
  60303. * Disposes the component and the associated ressources.
  60304. */
  60305. dispose(): void;
  60306. private _draw;
  60307. }
  60308. }
  60309. declare module "babylonjs/LensFlares/index" {
  60310. export * from "babylonjs/LensFlares/lensFlare";
  60311. export * from "babylonjs/LensFlares/lensFlareSystem";
  60312. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60313. }
  60314. declare module "babylonjs/Shaders/depth.fragment" {
  60315. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60316. /** @hidden */
  60317. export var depthPixelShader: {
  60318. name: string;
  60319. shader: string;
  60320. };
  60321. }
  60322. declare module "babylonjs/Shaders/depth.vertex" {
  60323. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60324. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60325. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60326. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60328. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60329. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60330. /** @hidden */
  60331. export var depthVertexShader: {
  60332. name: string;
  60333. shader: string;
  60334. };
  60335. }
  60336. declare module "babylonjs/Rendering/depthRenderer" {
  60337. import { Nullable } from "babylonjs/types";
  60338. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60339. import { Scene } from "babylonjs/scene";
  60340. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60341. import { Camera } from "babylonjs/Cameras/camera";
  60342. import "babylonjs/Shaders/depth.fragment";
  60343. import "babylonjs/Shaders/depth.vertex";
  60344. /**
  60345. * This represents a depth renderer in Babylon.
  60346. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60347. */
  60348. export class DepthRenderer {
  60349. private _scene;
  60350. private _depthMap;
  60351. private _effect;
  60352. private readonly _storeNonLinearDepth;
  60353. private readonly _clearColor;
  60354. /** Get if the depth renderer is using packed depth or not */
  60355. readonly isPacked: boolean;
  60356. private _cachedDefines;
  60357. private _camera;
  60358. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60359. enabled: boolean;
  60360. /**
  60361. * Specifiess that the depth renderer will only be used within
  60362. * the camera it is created for.
  60363. * This can help forcing its rendering during the camera processing.
  60364. */
  60365. useOnlyInActiveCamera: boolean;
  60366. /** @hidden */
  60367. static _SceneComponentInitialization: (scene: Scene) => void;
  60368. /**
  60369. * Instantiates a depth renderer
  60370. * @param scene The scene the renderer belongs to
  60371. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60372. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60373. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60374. */
  60375. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60376. /**
  60377. * Creates the depth rendering effect and checks if the effect is ready.
  60378. * @param subMesh The submesh to be used to render the depth map of
  60379. * @param useInstances If multiple world instances should be used
  60380. * @returns if the depth renderer is ready to render the depth map
  60381. */
  60382. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60383. /**
  60384. * Gets the texture which the depth map will be written to.
  60385. * @returns The depth map texture
  60386. */
  60387. getDepthMap(): RenderTargetTexture;
  60388. /**
  60389. * Disposes of the depth renderer.
  60390. */
  60391. dispose(): void;
  60392. }
  60393. }
  60394. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60395. /** @hidden */
  60396. export var minmaxReduxPixelShader: {
  60397. name: string;
  60398. shader: string;
  60399. };
  60400. }
  60401. declare module "babylonjs/Misc/minMaxReducer" {
  60402. import { Nullable } from "babylonjs/types";
  60403. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60404. import { Camera } from "babylonjs/Cameras/camera";
  60405. import { Observer } from "babylonjs/Misc/observable";
  60406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60407. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60408. import { Observable } from "babylonjs/Misc/observable";
  60409. import "babylonjs/Shaders/minmaxRedux.fragment";
  60410. /**
  60411. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60412. * and maximum values from all values of the texture.
  60413. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60414. * The source values are read from the red channel of the texture.
  60415. */
  60416. export class MinMaxReducer {
  60417. /**
  60418. * Observable triggered when the computation has been performed
  60419. */
  60420. onAfterReductionPerformed: Observable<{
  60421. min: number;
  60422. max: number;
  60423. }>;
  60424. protected _camera: Camera;
  60425. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60426. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60427. protected _postProcessManager: PostProcessManager;
  60428. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60429. protected _forceFullscreenViewport: boolean;
  60430. /**
  60431. * Creates a min/max reducer
  60432. * @param camera The camera to use for the post processes
  60433. */
  60434. constructor(camera: Camera);
  60435. /**
  60436. * Gets the texture used to read the values from.
  60437. */
  60438. get sourceTexture(): Nullable<RenderTargetTexture>;
  60439. /**
  60440. * Sets the source texture to read the values from.
  60441. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60442. * because in such textures '1' value must not be taken into account to compute the maximum
  60443. * as this value is used to clear the texture.
  60444. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60445. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60446. * @param depthRedux Indicates if the texture is a depth texture or not
  60447. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60448. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60449. */
  60450. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60451. /**
  60452. * Defines the refresh rate of the computation.
  60453. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60454. */
  60455. get refreshRate(): number;
  60456. set refreshRate(value: number);
  60457. protected _activated: boolean;
  60458. /**
  60459. * Gets the activation status of the reducer
  60460. */
  60461. get activated(): boolean;
  60462. /**
  60463. * Activates the reduction computation.
  60464. * When activated, the observers registered in onAfterReductionPerformed are
  60465. * called after the compuation is performed
  60466. */
  60467. activate(): void;
  60468. /**
  60469. * Deactivates the reduction computation.
  60470. */
  60471. deactivate(): void;
  60472. /**
  60473. * Disposes the min/max reducer
  60474. * @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.
  60475. */
  60476. dispose(disposeAll?: boolean): void;
  60477. }
  60478. }
  60479. declare module "babylonjs/Misc/depthReducer" {
  60480. import { Nullable } from "babylonjs/types";
  60481. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60482. import { Camera } from "babylonjs/Cameras/camera";
  60483. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60484. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  60485. /**
  60486. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60487. */
  60488. export class DepthReducer extends MinMaxReducer {
  60489. private _depthRenderer;
  60490. private _depthRendererId;
  60491. /**
  60492. * Gets the depth renderer used for the computation.
  60493. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60494. */
  60495. get depthRenderer(): Nullable<DepthRenderer>;
  60496. /**
  60497. * Creates a depth reducer
  60498. * @param camera The camera used to render the depth texture
  60499. */
  60500. constructor(camera: Camera);
  60501. /**
  60502. * Sets the depth renderer to use to generate the depth map
  60503. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60504. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60505. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60506. */
  60507. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60508. /** @hidden */
  60509. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60510. /**
  60511. * Activates the reduction computation.
  60512. * When activated, the observers registered in onAfterReductionPerformed are
  60513. * called after the compuation is performed
  60514. */
  60515. activate(): void;
  60516. /**
  60517. * Deactivates the reduction computation.
  60518. */
  60519. deactivate(): void;
  60520. /**
  60521. * Disposes the depth reducer
  60522. * @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.
  60523. */
  60524. dispose(disposeAll?: boolean): void;
  60525. }
  60526. }
  60527. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  60528. import { Nullable } from "babylonjs/types";
  60529. import { Scene } from "babylonjs/scene";
  60530. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60531. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60533. import { Effect } from "babylonjs/Materials/effect";
  60534. import "babylonjs/Shaders/shadowMap.fragment";
  60535. import "babylonjs/Shaders/shadowMap.vertex";
  60536. import "babylonjs/Shaders/depthBoxBlur.fragment";
  60537. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  60538. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60539. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  60540. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60541. /**
  60542. * A CSM implementation allowing casting shadows on large scenes.
  60543. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60544. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60545. */
  60546. export class CascadedShadowGenerator extends ShadowGenerator {
  60547. private static readonly frustumCornersNDCSpace;
  60548. /**
  60549. * Name of the CSM class
  60550. */
  60551. static CLASSNAME: string;
  60552. /**
  60553. * Defines the default number of cascades used by the CSM.
  60554. */
  60555. static readonly DEFAULT_CASCADES_COUNT: number;
  60556. /**
  60557. * Defines the minimum number of cascades used by the CSM.
  60558. */
  60559. static readonly MIN_CASCADES_COUNT: number;
  60560. /**
  60561. * Defines the maximum number of cascades used by the CSM.
  60562. */
  60563. static readonly MAX_CASCADES_COUNT: number;
  60564. protected _validateFilter(filter: number): number;
  60565. /**
  60566. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60567. */
  60568. penumbraDarkness: number;
  60569. private _numCascades;
  60570. /**
  60571. * Gets or set the number of cascades used by the CSM.
  60572. */
  60573. get numCascades(): number;
  60574. set numCascades(value: number);
  60575. /**
  60576. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60577. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60578. */
  60579. stabilizeCascades: boolean;
  60580. private _freezeShadowCastersBoundingInfo;
  60581. private _freezeShadowCastersBoundingInfoObservable;
  60582. /**
  60583. * Enables or disables the shadow casters bounding info computation.
  60584. * If your shadow casters don't move, you can disable this feature.
  60585. * If it is enabled, the bounding box computation is done every frame.
  60586. */
  60587. get freezeShadowCastersBoundingInfo(): boolean;
  60588. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60589. private _scbiMin;
  60590. private _scbiMax;
  60591. protected _computeShadowCastersBoundingInfo(): void;
  60592. protected _shadowCastersBoundingInfo: BoundingInfo;
  60593. /**
  60594. * Gets or sets the shadow casters bounding info.
  60595. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60596. * so that the system won't overwrite the bounds you provide
  60597. */
  60598. get shadowCastersBoundingInfo(): BoundingInfo;
  60599. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60600. protected _breaksAreDirty: boolean;
  60601. protected _minDistance: number;
  60602. protected _maxDistance: number;
  60603. /**
  60604. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60605. *
  60606. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60607. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60608. * @param min minimal distance for the breaks (default to 0.)
  60609. * @param max maximal distance for the breaks (default to 1.)
  60610. */
  60611. setMinMaxDistance(min: number, max: number): void;
  60612. /** Gets the minimal distance used in the cascade break computation */
  60613. get minDistance(): number;
  60614. /** Gets the maximal distance used in the cascade break computation */
  60615. get maxDistance(): number;
  60616. /**
  60617. * Gets the class name of that object
  60618. * @returns "CascadedShadowGenerator"
  60619. */
  60620. getClassName(): string;
  60621. private _cascadeMinExtents;
  60622. private _cascadeMaxExtents;
  60623. /**
  60624. * Gets a cascade minimum extents
  60625. * @param cascadeIndex index of the cascade
  60626. * @returns the minimum cascade extents
  60627. */
  60628. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60629. /**
  60630. * Gets a cascade maximum extents
  60631. * @param cascadeIndex index of the cascade
  60632. * @returns the maximum cascade extents
  60633. */
  60634. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60635. private _cascades;
  60636. private _currentLayer;
  60637. private _viewSpaceFrustumsZ;
  60638. private _viewMatrices;
  60639. private _projectionMatrices;
  60640. private _transformMatrices;
  60641. private _transformMatricesAsArray;
  60642. private _frustumLengths;
  60643. private _lightSizeUVCorrection;
  60644. private _depthCorrection;
  60645. private _frustumCornersWorldSpace;
  60646. private _frustumCenter;
  60647. private _shadowCameraPos;
  60648. private _shadowMaxZ;
  60649. /**
  60650. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60651. * It defaults to camera.maxZ
  60652. */
  60653. get shadowMaxZ(): number;
  60654. /**
  60655. * Sets the shadow max z distance.
  60656. */
  60657. set shadowMaxZ(value: number);
  60658. protected _debug: boolean;
  60659. /**
  60660. * Gets or sets the debug flag.
  60661. * When enabled, the cascades are materialized by different colors on the screen.
  60662. */
  60663. get debug(): boolean;
  60664. set debug(dbg: boolean);
  60665. private _depthClamp;
  60666. /**
  60667. * Gets or sets the depth clamping value.
  60668. *
  60669. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60670. * to account for the shadow casters far away.
  60671. *
  60672. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60673. */
  60674. get depthClamp(): boolean;
  60675. set depthClamp(value: boolean);
  60676. private _cascadeBlendPercentage;
  60677. /**
  60678. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60679. * It defaults to 0.1 (10% blending).
  60680. */
  60681. get cascadeBlendPercentage(): number;
  60682. set cascadeBlendPercentage(value: number);
  60683. private _lambda;
  60684. /**
  60685. * Gets or set the lambda parameter.
  60686. * This parameter is used to split the camera frustum and create the cascades.
  60687. * 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.
  60688. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60689. */
  60690. get lambda(): number;
  60691. set lambda(value: number);
  60692. /**
  60693. * Gets the view matrix corresponding to a given cascade
  60694. * @param cascadeNum cascade to retrieve the view matrix from
  60695. * @returns the cascade view matrix
  60696. */
  60697. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60698. /**
  60699. * Gets the projection matrix corresponding to a given cascade
  60700. * @param cascadeNum cascade to retrieve the projection matrix from
  60701. * @returns the cascade projection matrix
  60702. */
  60703. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60704. /**
  60705. * Gets the transformation matrix corresponding to a given cascade
  60706. * @param cascadeNum cascade to retrieve the transformation matrix from
  60707. * @returns the cascade transformation matrix
  60708. */
  60709. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60710. private _depthRenderer;
  60711. /**
  60712. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60713. *
  60714. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60715. *
  60716. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60717. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60718. * @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
  60719. */
  60720. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60721. private _depthReducer;
  60722. private _autoCalcDepthBounds;
  60723. /**
  60724. * Gets or sets the autoCalcDepthBounds property.
  60725. *
  60726. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60727. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60728. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60729. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60730. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60731. */
  60732. get autoCalcDepthBounds(): boolean;
  60733. set autoCalcDepthBounds(value: boolean);
  60734. /**
  60735. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60736. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60737. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60738. * for setting the refresh rate on the renderer yourself!
  60739. */
  60740. get autoCalcDepthBoundsRefreshRate(): number;
  60741. set autoCalcDepthBoundsRefreshRate(value: number);
  60742. /**
  60743. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60744. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60745. * you change the camera near/far planes!
  60746. */
  60747. splitFrustum(): void;
  60748. private _splitFrustum;
  60749. private _computeMatrices;
  60750. private _computeFrustumInWorldSpace;
  60751. private _computeCascadeFrustum;
  60752. /**
  60753. * Support test.
  60754. */
  60755. static get IsSupported(): boolean;
  60756. /** @hidden */
  60757. static _SceneComponentInitialization: (scene: Scene) => void;
  60758. /**
  60759. * Creates a Cascaded Shadow Generator object.
  60760. * A ShadowGenerator is the required tool to use the shadows.
  60761. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60762. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60763. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60764. * @param light The directional light object generating the shadows.
  60765. * @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.
  60766. */
  60767. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60768. protected _initializeGenerator(): void;
  60769. protected _createTargetRenderTexture(): void;
  60770. protected _initializeShadowMap(): void;
  60771. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60772. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60773. /**
  60774. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60775. * @param defines Defines of the material we want to update
  60776. * @param lightIndex Index of the light in the enabled light list of the material
  60777. */
  60778. prepareDefines(defines: any, lightIndex: number): void;
  60779. /**
  60780. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60781. * defined in the generator but impacting the effect).
  60782. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60783. * @param effect The effect we are binfing the information for
  60784. */
  60785. bindShadowLight(lightIndex: string, effect: Effect): void;
  60786. /**
  60787. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60788. * (eq to view projection * shadow projection matrices)
  60789. * @returns The transform matrix used to create the shadow map
  60790. */
  60791. getTransformMatrix(): Matrix;
  60792. /**
  60793. * Disposes the ShadowGenerator.
  60794. * Returns nothing.
  60795. */
  60796. dispose(): void;
  60797. /**
  60798. * Serializes the shadow generator setup to a json object.
  60799. * @returns The serialized JSON object
  60800. */
  60801. serialize(): any;
  60802. /**
  60803. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60804. * @param parsedShadowGenerator The JSON object to parse
  60805. * @param scene The scene to create the shadow map for
  60806. * @returns The parsed shadow generator
  60807. */
  60808. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60809. }
  60810. }
  60811. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  60812. import { Scene } from "babylonjs/scene";
  60813. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60814. import { AbstractScene } from "babylonjs/abstractScene";
  60815. /**
  60816. * Defines the shadow generator component responsible to manage any shadow generators
  60817. * in a given scene.
  60818. */
  60819. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60820. /**
  60821. * The component name helpfull to identify the component in the list of scene components.
  60822. */
  60823. readonly name: string;
  60824. /**
  60825. * The scene the component belongs to.
  60826. */
  60827. scene: Scene;
  60828. /**
  60829. * Creates a new instance of the component for the given scene
  60830. * @param scene Defines the scene to register the component in
  60831. */
  60832. constructor(scene: Scene);
  60833. /**
  60834. * Registers the component in a given scene
  60835. */
  60836. register(): void;
  60837. /**
  60838. * Rebuilds the elements related to this component in case of
  60839. * context lost for instance.
  60840. */
  60841. rebuild(): void;
  60842. /**
  60843. * Serializes the component data to the specified json object
  60844. * @param serializationObject The object to serialize to
  60845. */
  60846. serialize(serializationObject: any): void;
  60847. /**
  60848. * Adds all the elements from the container to the scene
  60849. * @param container the container holding the elements
  60850. */
  60851. addFromContainer(container: AbstractScene): void;
  60852. /**
  60853. * Removes all the elements in the container from the scene
  60854. * @param container contains the elements to remove
  60855. * @param dispose if the removed element should be disposed (default: false)
  60856. */
  60857. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60858. /**
  60859. * Rebuilds the elements related to this component in case of
  60860. * context lost for instance.
  60861. */
  60862. dispose(): void;
  60863. private _gatherRenderTargets;
  60864. }
  60865. }
  60866. declare module "babylonjs/Lights/Shadows/index" {
  60867. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  60868. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  60869. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  60870. }
  60871. declare module "babylonjs/Lights/pointLight" {
  60872. import { Scene } from "babylonjs/scene";
  60873. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60875. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60876. import { Effect } from "babylonjs/Materials/effect";
  60877. /**
  60878. * A point light is a light defined by an unique point in world space.
  60879. * The light is emitted in every direction from this point.
  60880. * A good example of a point light is a standard light bulb.
  60881. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60882. */
  60883. export class PointLight extends ShadowLight {
  60884. private _shadowAngle;
  60885. /**
  60886. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60887. * This specifies what angle the shadow will use to be created.
  60888. *
  60889. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60890. */
  60891. get shadowAngle(): number;
  60892. /**
  60893. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60894. * This specifies what angle the shadow will use to be created.
  60895. *
  60896. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60897. */
  60898. set shadowAngle(value: number);
  60899. /**
  60900. * Gets the direction if it has been set.
  60901. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60902. */
  60903. get direction(): Vector3;
  60904. /**
  60905. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60906. */
  60907. set direction(value: Vector3);
  60908. /**
  60909. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60910. * A PointLight emits the light in every direction.
  60911. * It can cast shadows.
  60912. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60913. * ```javascript
  60914. * var pointLight = new PointLight("pl", camera.position, scene);
  60915. * ```
  60916. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60917. * @param name The light friendly name
  60918. * @param position The position of the point light in the scene
  60919. * @param scene The scene the lights belongs to
  60920. */
  60921. constructor(name: string, position: Vector3, scene: Scene);
  60922. /**
  60923. * Returns the string "PointLight"
  60924. * @returns the class name
  60925. */
  60926. getClassName(): string;
  60927. /**
  60928. * Returns the integer 0.
  60929. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60930. */
  60931. getTypeID(): number;
  60932. /**
  60933. * Specifies wether or not the shadowmap should be a cube texture.
  60934. * @returns true if the shadowmap needs to be a cube texture.
  60935. */
  60936. needCube(): boolean;
  60937. /**
  60938. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60939. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60940. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60941. */
  60942. getShadowDirection(faceIndex?: number): Vector3;
  60943. /**
  60944. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60945. * - fov = PI / 2
  60946. * - aspect ratio : 1.0
  60947. * - z-near and far equal to the active camera minZ and maxZ.
  60948. * Returns the PointLight.
  60949. */
  60950. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60951. protected _buildUniformLayout(): void;
  60952. /**
  60953. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60954. * @param effect The effect to update
  60955. * @param lightIndex The index of the light in the effect to update
  60956. * @returns The point light
  60957. */
  60958. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60959. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60960. /**
  60961. * Prepares the list of defines specific to the light type.
  60962. * @param defines the list of defines
  60963. * @param lightIndex defines the index of the light for the effect
  60964. */
  60965. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60966. }
  60967. }
  60968. declare module "babylonjs/Lights/index" {
  60969. export * from "babylonjs/Lights/light";
  60970. export * from "babylonjs/Lights/shadowLight";
  60971. export * from "babylonjs/Lights/Shadows/index";
  60972. export * from "babylonjs/Lights/directionalLight";
  60973. export * from "babylonjs/Lights/hemisphericLight";
  60974. export * from "babylonjs/Lights/pointLight";
  60975. export * from "babylonjs/Lights/spotLight";
  60976. }
  60977. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  60978. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  60979. /**
  60980. * Header information of HDR texture files.
  60981. */
  60982. export interface HDRInfo {
  60983. /**
  60984. * The height of the texture in pixels.
  60985. */
  60986. height: number;
  60987. /**
  60988. * The width of the texture in pixels.
  60989. */
  60990. width: number;
  60991. /**
  60992. * The index of the beginning of the data in the binary file.
  60993. */
  60994. dataPosition: number;
  60995. }
  60996. /**
  60997. * This groups tools to convert HDR texture to native colors array.
  60998. */
  60999. export class HDRTools {
  61000. private static Ldexp;
  61001. private static Rgbe2float;
  61002. private static readStringLine;
  61003. /**
  61004. * Reads header information from an RGBE texture stored in a native array.
  61005. * More information on this format are available here:
  61006. * https://en.wikipedia.org/wiki/RGBE_image_format
  61007. *
  61008. * @param uint8array The binary file stored in native array.
  61009. * @return The header information.
  61010. */
  61011. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61012. /**
  61013. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61014. * This RGBE texture needs to store the information as a panorama.
  61015. *
  61016. * More information on this format are available here:
  61017. * https://en.wikipedia.org/wiki/RGBE_image_format
  61018. *
  61019. * @param buffer The binary file stored in an array buffer.
  61020. * @param size The expected size of the extracted cubemap.
  61021. * @return The Cube Map information.
  61022. */
  61023. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61024. /**
  61025. * Returns the pixels data extracted from an RGBE texture.
  61026. * This pixels will be stored left to right up to down in the R G B order in one array.
  61027. *
  61028. * More information on this format are available here:
  61029. * https://en.wikipedia.org/wiki/RGBE_image_format
  61030. *
  61031. * @param uint8array The binary file stored in an array buffer.
  61032. * @param hdrInfo The header information of the file.
  61033. * @return The pixels data in RGB right to left up to down order.
  61034. */
  61035. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61036. private static RGBE_ReadPixels_RLE;
  61037. }
  61038. }
  61039. declare module "babylonjs/Materials/effectRenderer" {
  61040. import { Nullable } from "babylonjs/types";
  61041. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61042. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61043. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61044. import { Viewport } from "babylonjs/Maths/math.viewport";
  61045. import { Observable } from "babylonjs/Misc/observable";
  61046. import { Effect } from "babylonjs/Materials/effect";
  61047. import "babylonjs/Shaders/postprocess.vertex";
  61048. /**
  61049. * Effect Render Options
  61050. */
  61051. export interface IEffectRendererOptions {
  61052. /**
  61053. * Defines the vertices positions.
  61054. */
  61055. positions?: number[];
  61056. /**
  61057. * Defines the indices.
  61058. */
  61059. indices?: number[];
  61060. }
  61061. /**
  61062. * Helper class to render one or more effects.
  61063. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61064. */
  61065. export class EffectRenderer {
  61066. private engine;
  61067. private static _DefaultOptions;
  61068. private _vertexBuffers;
  61069. private _indexBuffer;
  61070. private _fullscreenViewport;
  61071. /**
  61072. * Creates an effect renderer
  61073. * @param engine the engine to use for rendering
  61074. * @param options defines the options of the effect renderer
  61075. */
  61076. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61077. /**
  61078. * Sets the current viewport in normalized coordinates 0-1
  61079. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61080. */
  61081. setViewport(viewport?: Viewport): void;
  61082. /**
  61083. * Binds the embedded attributes buffer to the effect.
  61084. * @param effect Defines the effect to bind the attributes for
  61085. */
  61086. bindBuffers(effect: Effect): void;
  61087. /**
  61088. * Sets the current effect wrapper to use during draw.
  61089. * The effect needs to be ready before calling this api.
  61090. * This also sets the default full screen position attribute.
  61091. * @param effectWrapper Defines the effect to draw with
  61092. */
  61093. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61094. /**
  61095. * Restores engine states
  61096. */
  61097. restoreStates(): void;
  61098. /**
  61099. * Draws a full screen quad.
  61100. */
  61101. draw(): void;
  61102. private isRenderTargetTexture;
  61103. /**
  61104. * renders one or more effects to a specified texture
  61105. * @param effectWrapper the effect to renderer
  61106. * @param outputTexture texture to draw to, if null it will render to the screen.
  61107. */
  61108. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61109. /**
  61110. * Disposes of the effect renderer
  61111. */
  61112. dispose(): void;
  61113. }
  61114. /**
  61115. * Options to create an EffectWrapper
  61116. */
  61117. interface EffectWrapperCreationOptions {
  61118. /**
  61119. * Engine to use to create the effect
  61120. */
  61121. engine: ThinEngine;
  61122. /**
  61123. * Fragment shader for the effect
  61124. */
  61125. fragmentShader: string;
  61126. /**
  61127. * Use the shader store instead of direct source code
  61128. */
  61129. useShaderStore?: boolean;
  61130. /**
  61131. * Vertex shader for the effect
  61132. */
  61133. vertexShader?: string;
  61134. /**
  61135. * Attributes to use in the shader
  61136. */
  61137. attributeNames?: Array<string>;
  61138. /**
  61139. * Uniforms to use in the shader
  61140. */
  61141. uniformNames?: Array<string>;
  61142. /**
  61143. * Texture sampler names to use in the shader
  61144. */
  61145. samplerNames?: Array<string>;
  61146. /**
  61147. * Defines to use in the shader
  61148. */
  61149. defines?: Array<string>;
  61150. /**
  61151. * Callback when effect is compiled
  61152. */
  61153. onCompiled?: Nullable<(effect: Effect) => void>;
  61154. /**
  61155. * The friendly name of the effect displayed in Spector.
  61156. */
  61157. name?: string;
  61158. }
  61159. /**
  61160. * Wraps an effect to be used for rendering
  61161. */
  61162. export class EffectWrapper {
  61163. /**
  61164. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61165. */
  61166. onApplyObservable: Observable<{}>;
  61167. /**
  61168. * The underlying effect
  61169. */
  61170. effect: Effect;
  61171. /**
  61172. * Creates an effect to be renderer
  61173. * @param creationOptions options to create the effect
  61174. */
  61175. constructor(creationOptions: EffectWrapperCreationOptions);
  61176. /**
  61177. * Disposes of the effect wrapper
  61178. */
  61179. dispose(): void;
  61180. }
  61181. }
  61182. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61183. /** @hidden */
  61184. export var hdrFilteringVertexShader: {
  61185. name: string;
  61186. shader: string;
  61187. };
  61188. }
  61189. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61191. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61192. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61193. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61194. /** @hidden */
  61195. export var hdrFilteringPixelShader: {
  61196. name: string;
  61197. shader: string;
  61198. };
  61199. }
  61200. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61202. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61203. import { Nullable } from "babylonjs/types";
  61204. import "babylonjs/Shaders/hdrFiltering.vertex";
  61205. import "babylonjs/Shaders/hdrFiltering.fragment";
  61206. /**
  61207. * Options for texture filtering
  61208. */
  61209. interface IHDRFilteringOptions {
  61210. /**
  61211. * Scales pixel intensity for the input HDR map.
  61212. */
  61213. hdrScale?: number;
  61214. /**
  61215. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61216. */
  61217. quality?: number;
  61218. }
  61219. /**
  61220. * Filters HDR maps to get correct renderings of PBR reflections
  61221. */
  61222. export class HDRFiltering {
  61223. private _engine;
  61224. private _effectRenderer;
  61225. private _effectWrapper;
  61226. private _lodGenerationOffset;
  61227. private _lodGenerationScale;
  61228. /**
  61229. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61230. * you care about baking speed.
  61231. */
  61232. quality: number;
  61233. /**
  61234. * Scales pixel intensity for the input HDR map.
  61235. */
  61236. hdrScale: number;
  61237. /**
  61238. * Instantiates HDR filter for reflection maps
  61239. *
  61240. * @param engine Thin engine
  61241. * @param options Options
  61242. */
  61243. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61244. private _createRenderTarget;
  61245. private _prefilterInternal;
  61246. private _createEffect;
  61247. /**
  61248. * Get a value indicating if the filter is ready to be used
  61249. * @param texture Texture to filter
  61250. * @returns true if the filter is ready
  61251. */
  61252. isReady(texture: BaseTexture): boolean;
  61253. /**
  61254. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61255. * Prefiltering will be invoked at the end of next rendering pass.
  61256. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61257. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61258. * @param texture Texture to filter
  61259. * @param onFinished Callback when filtering is done
  61260. * @return Promise called when prefiltering is done
  61261. */
  61262. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61263. }
  61264. }
  61265. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61266. import { Nullable } from "babylonjs/types";
  61267. import { Scene } from "babylonjs/scene";
  61268. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61269. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61270. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61271. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61272. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61273. /**
  61274. * This represents a texture coming from an HDR input.
  61275. *
  61276. * The only supported format is currently panorama picture stored in RGBE format.
  61277. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61278. */
  61279. export class HDRCubeTexture extends BaseTexture {
  61280. private static _facesMapping;
  61281. private _generateHarmonics;
  61282. private _noMipmap;
  61283. private _prefilterOnLoad;
  61284. private _textureMatrix;
  61285. private _size;
  61286. private _onLoad;
  61287. private _onError;
  61288. /**
  61289. * The texture URL.
  61290. */
  61291. url: string;
  61292. /**
  61293. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61294. */
  61295. coordinatesMode: number;
  61296. protected _isBlocking: boolean;
  61297. /**
  61298. * Sets wether or not the texture is blocking during loading.
  61299. */
  61300. set isBlocking(value: boolean);
  61301. /**
  61302. * Gets wether or not the texture is blocking during loading.
  61303. */
  61304. get isBlocking(): boolean;
  61305. protected _rotationY: number;
  61306. /**
  61307. * Sets texture matrix rotation angle around Y axis in radians.
  61308. */
  61309. set rotationY(value: number);
  61310. /**
  61311. * Gets texture matrix rotation angle around Y axis radians.
  61312. */
  61313. get rotationY(): number;
  61314. /**
  61315. * Gets or sets the center of the bounding box associated with the cube texture
  61316. * It must define where the camera used to render the texture was set
  61317. */
  61318. boundingBoxPosition: Vector3;
  61319. private _boundingBoxSize;
  61320. /**
  61321. * Gets or sets the size of the bounding box associated with the cube texture
  61322. * When defined, the cubemap will switch to local mode
  61323. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61324. * @example https://www.babylonjs-playground.com/#RNASML
  61325. */
  61326. set boundingBoxSize(value: Vector3);
  61327. get boundingBoxSize(): Vector3;
  61328. /**
  61329. * Instantiates an HDRTexture from the following parameters.
  61330. *
  61331. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61332. * @param sceneOrEngine The scene or engine the texture will be used in
  61333. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61334. * @param noMipmap Forces to not generate the mipmap if true
  61335. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61336. * @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)
  61337. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61338. */
  61339. 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>);
  61340. /**
  61341. * Get the current class name of the texture useful for serialization or dynamic coding.
  61342. * @returns "HDRCubeTexture"
  61343. */
  61344. getClassName(): string;
  61345. /**
  61346. * Occurs when the file is raw .hdr file.
  61347. */
  61348. private loadTexture;
  61349. clone(): HDRCubeTexture;
  61350. delayLoad(): void;
  61351. /**
  61352. * Get the texture reflection matrix used to rotate/transform the reflection.
  61353. * @returns the reflection matrix
  61354. */
  61355. getReflectionTextureMatrix(): Matrix;
  61356. /**
  61357. * Set the texture reflection matrix used to rotate/transform the reflection.
  61358. * @param value Define the reflection matrix to set
  61359. */
  61360. setReflectionTextureMatrix(value: Matrix): void;
  61361. /**
  61362. * Parses a JSON representation of an HDR Texture in order to create the texture
  61363. * @param parsedTexture Define the JSON representation
  61364. * @param scene Define the scene the texture should be created in
  61365. * @param rootUrl Define the root url in case we need to load relative dependencies
  61366. * @returns the newly created texture after parsing
  61367. */
  61368. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61369. serialize(): any;
  61370. }
  61371. }
  61372. declare module "babylonjs/Physics/physicsEngine" {
  61373. import { Nullable } from "babylonjs/types";
  61374. import { Vector3 } from "babylonjs/Maths/math.vector";
  61375. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61376. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61377. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61378. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61379. /**
  61380. * Class used to control physics engine
  61381. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61382. */
  61383. export class PhysicsEngine implements IPhysicsEngine {
  61384. private _physicsPlugin;
  61385. /**
  61386. * Global value used to control the smallest number supported by the simulation
  61387. */
  61388. static Epsilon: number;
  61389. private _impostors;
  61390. private _joints;
  61391. private _subTimeStep;
  61392. /**
  61393. * Gets the gravity vector used by the simulation
  61394. */
  61395. gravity: Vector3;
  61396. /**
  61397. * Factory used to create the default physics plugin.
  61398. * @returns The default physics plugin
  61399. */
  61400. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61401. /**
  61402. * Creates a new Physics Engine
  61403. * @param gravity defines the gravity vector used by the simulation
  61404. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61405. */
  61406. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61407. /**
  61408. * Sets the gravity vector used by the simulation
  61409. * @param gravity defines the gravity vector to use
  61410. */
  61411. setGravity(gravity: Vector3): void;
  61412. /**
  61413. * Set the time step of the physics engine.
  61414. * Default is 1/60.
  61415. * To slow it down, enter 1/600 for example.
  61416. * To speed it up, 1/30
  61417. * @param newTimeStep defines the new timestep to apply to this world.
  61418. */
  61419. setTimeStep(newTimeStep?: number): void;
  61420. /**
  61421. * Get the time step of the physics engine.
  61422. * @returns the current time step
  61423. */
  61424. getTimeStep(): number;
  61425. /**
  61426. * Set the sub time step of the physics engine.
  61427. * Default is 0 meaning there is no sub steps
  61428. * To increase physics resolution precision, set a small value (like 1 ms)
  61429. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61430. */
  61431. setSubTimeStep(subTimeStep?: number): void;
  61432. /**
  61433. * Get the sub time step of the physics engine.
  61434. * @returns the current sub time step
  61435. */
  61436. getSubTimeStep(): number;
  61437. /**
  61438. * Release all resources
  61439. */
  61440. dispose(): void;
  61441. /**
  61442. * Gets the name of the current physics plugin
  61443. * @returns the name of the plugin
  61444. */
  61445. getPhysicsPluginName(): string;
  61446. /**
  61447. * Adding a new impostor for the impostor tracking.
  61448. * This will be done by the impostor itself.
  61449. * @param impostor the impostor to add
  61450. */
  61451. addImpostor(impostor: PhysicsImpostor): void;
  61452. /**
  61453. * Remove an impostor from the engine.
  61454. * This impostor and its mesh will not longer be updated by the physics engine.
  61455. * @param impostor the impostor to remove
  61456. */
  61457. removeImpostor(impostor: PhysicsImpostor): void;
  61458. /**
  61459. * Add a joint to the physics engine
  61460. * @param mainImpostor defines the main impostor to which the joint is added.
  61461. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61462. * @param joint defines the joint that will connect both impostors.
  61463. */
  61464. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61465. /**
  61466. * Removes a joint from the simulation
  61467. * @param mainImpostor defines the impostor used with the joint
  61468. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61469. * @param joint defines the joint to remove
  61470. */
  61471. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61472. /**
  61473. * Called by the scene. No need to call it.
  61474. * @param delta defines the timespam between frames
  61475. */
  61476. _step(delta: number): void;
  61477. /**
  61478. * Gets the current plugin used to run the simulation
  61479. * @returns current plugin
  61480. */
  61481. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61482. /**
  61483. * Gets the list of physic impostors
  61484. * @returns an array of PhysicsImpostor
  61485. */
  61486. getImpostors(): Array<PhysicsImpostor>;
  61487. /**
  61488. * Gets the impostor for a physics enabled object
  61489. * @param object defines the object impersonated by the impostor
  61490. * @returns the PhysicsImpostor or null if not found
  61491. */
  61492. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61493. /**
  61494. * Gets the impostor for a physics body object
  61495. * @param body defines physics body used by the impostor
  61496. * @returns the PhysicsImpostor or null if not found
  61497. */
  61498. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61499. /**
  61500. * Does a raycast in the physics world
  61501. * @param from when should the ray start?
  61502. * @param to when should the ray end?
  61503. * @returns PhysicsRaycastResult
  61504. */
  61505. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61506. }
  61507. }
  61508. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  61509. import { Nullable } from "babylonjs/types";
  61510. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61512. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61513. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61514. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61515. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61516. /** @hidden */
  61517. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61518. private _useDeltaForWorldStep;
  61519. world: any;
  61520. name: string;
  61521. private _physicsMaterials;
  61522. private _fixedTimeStep;
  61523. private _cannonRaycastResult;
  61524. private _raycastResult;
  61525. private _physicsBodysToRemoveAfterStep;
  61526. private _firstFrame;
  61527. BJSCANNON: any;
  61528. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61529. setGravity(gravity: Vector3): void;
  61530. setTimeStep(timeStep: number): void;
  61531. getTimeStep(): number;
  61532. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61533. private _removeMarkedPhysicsBodiesFromWorld;
  61534. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61535. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61536. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61537. private _processChildMeshes;
  61538. removePhysicsBody(impostor: PhysicsImpostor): void;
  61539. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61540. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61541. private _addMaterial;
  61542. private _checkWithEpsilon;
  61543. private _createShape;
  61544. private _createHeightmap;
  61545. private _minus90X;
  61546. private _plus90X;
  61547. private _tmpPosition;
  61548. private _tmpDeltaPosition;
  61549. private _tmpUnityRotation;
  61550. private _updatePhysicsBodyTransformation;
  61551. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61552. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61553. isSupported(): boolean;
  61554. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61555. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61556. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61557. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61558. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61559. getBodyMass(impostor: PhysicsImpostor): number;
  61560. getBodyFriction(impostor: PhysicsImpostor): number;
  61561. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61562. getBodyRestitution(impostor: PhysicsImpostor): number;
  61563. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61564. sleepBody(impostor: PhysicsImpostor): void;
  61565. wakeUpBody(impostor: PhysicsImpostor): void;
  61566. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61567. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61568. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61569. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61570. getRadius(impostor: PhysicsImpostor): number;
  61571. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61572. dispose(): void;
  61573. private _extendNamespace;
  61574. /**
  61575. * Does a raycast in the physics world
  61576. * @param from when should the ray start?
  61577. * @param to when should the ray end?
  61578. * @returns PhysicsRaycastResult
  61579. */
  61580. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61581. }
  61582. }
  61583. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  61584. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61585. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61586. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61588. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61589. import { Nullable } from "babylonjs/types";
  61590. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61591. /** @hidden */
  61592. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61593. private _useDeltaForWorldStep;
  61594. world: any;
  61595. name: string;
  61596. BJSOIMO: any;
  61597. private _raycastResult;
  61598. private _fixedTimeStep;
  61599. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61600. setGravity(gravity: Vector3): void;
  61601. setTimeStep(timeStep: number): void;
  61602. getTimeStep(): number;
  61603. private _tmpImpostorsArray;
  61604. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61605. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61606. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61607. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61608. private _tmpPositionVector;
  61609. removePhysicsBody(impostor: PhysicsImpostor): void;
  61610. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61611. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61612. isSupported(): boolean;
  61613. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61614. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61615. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61616. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61617. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61618. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61619. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61620. getBodyMass(impostor: PhysicsImpostor): number;
  61621. getBodyFriction(impostor: PhysicsImpostor): number;
  61622. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61623. getBodyRestitution(impostor: PhysicsImpostor): number;
  61624. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61625. sleepBody(impostor: PhysicsImpostor): void;
  61626. wakeUpBody(impostor: PhysicsImpostor): void;
  61627. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61628. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61629. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61630. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61631. getRadius(impostor: PhysicsImpostor): number;
  61632. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61633. dispose(): void;
  61634. /**
  61635. * Does a raycast in the physics world
  61636. * @param from when should the ray start?
  61637. * @param to when should the ray end?
  61638. * @returns PhysicsRaycastResult
  61639. */
  61640. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61641. }
  61642. }
  61643. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  61644. import { Nullable } from "babylonjs/types";
  61645. import { Scene } from "babylonjs/scene";
  61646. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  61647. import { Color4 } from "babylonjs/Maths/math.color";
  61648. import { Mesh } from "babylonjs/Meshes/mesh";
  61649. /**
  61650. * Class containing static functions to help procedurally build meshes
  61651. */
  61652. export class RibbonBuilder {
  61653. /**
  61654. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61655. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61656. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61657. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61658. * * 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
  61659. * * 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
  61660. * * 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
  61661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61664. * * 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
  61665. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61666. * * 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
  61667. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61669. * @param name defines the name of the mesh
  61670. * @param options defines the options used to create the mesh
  61671. * @param scene defines the hosting scene
  61672. * @returns the ribbon mesh
  61673. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61674. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61675. */
  61676. static CreateRibbon(name: string, options: {
  61677. pathArray: Vector3[][];
  61678. closeArray?: boolean;
  61679. closePath?: boolean;
  61680. offset?: number;
  61681. updatable?: boolean;
  61682. sideOrientation?: number;
  61683. frontUVs?: Vector4;
  61684. backUVs?: Vector4;
  61685. instance?: Mesh;
  61686. invertUV?: boolean;
  61687. uvs?: Vector2[];
  61688. colors?: Color4[];
  61689. }, scene?: Nullable<Scene>): Mesh;
  61690. }
  61691. }
  61692. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  61693. import { Nullable } from "babylonjs/types";
  61694. import { Scene } from "babylonjs/scene";
  61695. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61696. import { Mesh } from "babylonjs/Meshes/mesh";
  61697. /**
  61698. * Class containing static functions to help procedurally build meshes
  61699. */
  61700. export class ShapeBuilder {
  61701. /**
  61702. * 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.
  61703. * * 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.
  61704. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61705. * * 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.
  61706. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61707. * * 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
  61708. * * 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
  61709. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61712. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61714. * @param name defines the name of the mesh
  61715. * @param options defines the options used to create the mesh
  61716. * @param scene defines the hosting scene
  61717. * @returns the extruded shape mesh
  61718. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61719. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61720. */
  61721. static ExtrudeShape(name: string, options: {
  61722. shape: Vector3[];
  61723. path: Vector3[];
  61724. scale?: number;
  61725. rotation?: number;
  61726. cap?: number;
  61727. updatable?: boolean;
  61728. sideOrientation?: number;
  61729. frontUVs?: Vector4;
  61730. backUVs?: Vector4;
  61731. instance?: Mesh;
  61732. invertUV?: boolean;
  61733. }, scene?: Nullable<Scene>): Mesh;
  61734. /**
  61735. * Creates an custom extruded shape mesh.
  61736. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61737. * * 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.
  61738. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61739. * * 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
  61740. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61741. * * 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
  61742. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61743. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61744. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61745. * * 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
  61746. * * 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
  61747. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61750. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61752. * @param name defines the name of the mesh
  61753. * @param options defines the options used to create the mesh
  61754. * @param scene defines the hosting scene
  61755. * @returns the custom extruded shape mesh
  61756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61757. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61759. */
  61760. static ExtrudeShapeCustom(name: string, options: {
  61761. shape: Vector3[];
  61762. path: Vector3[];
  61763. scaleFunction?: any;
  61764. rotationFunction?: any;
  61765. ribbonCloseArray?: boolean;
  61766. ribbonClosePath?: boolean;
  61767. cap?: number;
  61768. updatable?: boolean;
  61769. sideOrientation?: number;
  61770. frontUVs?: Vector4;
  61771. backUVs?: Vector4;
  61772. instance?: Mesh;
  61773. invertUV?: boolean;
  61774. }, scene?: Nullable<Scene>): Mesh;
  61775. private static _ExtrudeShapeGeneric;
  61776. }
  61777. }
  61778. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  61779. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  61780. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61781. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61782. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61783. import { Nullable } from "babylonjs/types";
  61784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61785. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61786. /**
  61787. * AmmoJS Physics plugin
  61788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61789. * @see https://github.com/kripken/ammo.js/
  61790. */
  61791. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61792. private _useDeltaForWorldStep;
  61793. /**
  61794. * Reference to the Ammo library
  61795. */
  61796. bjsAMMO: any;
  61797. /**
  61798. * Created ammoJS world which physics bodies are added to
  61799. */
  61800. world: any;
  61801. /**
  61802. * Name of the plugin
  61803. */
  61804. name: string;
  61805. private _timeStep;
  61806. private _fixedTimeStep;
  61807. private _maxSteps;
  61808. private _tmpQuaternion;
  61809. private _tmpAmmoTransform;
  61810. private _tmpAmmoQuaternion;
  61811. private _tmpAmmoConcreteContactResultCallback;
  61812. private _collisionConfiguration;
  61813. private _dispatcher;
  61814. private _overlappingPairCache;
  61815. private _solver;
  61816. private _softBodySolver;
  61817. private _tmpAmmoVectorA;
  61818. private _tmpAmmoVectorB;
  61819. private _tmpAmmoVectorC;
  61820. private _tmpAmmoVectorD;
  61821. private _tmpContactCallbackResult;
  61822. private _tmpAmmoVectorRCA;
  61823. private _tmpAmmoVectorRCB;
  61824. private _raycastResult;
  61825. private static readonly DISABLE_COLLISION_FLAG;
  61826. private static readonly KINEMATIC_FLAG;
  61827. private static readonly DISABLE_DEACTIVATION_FLAG;
  61828. /**
  61829. * Initializes the ammoJS plugin
  61830. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61831. * @param ammoInjection can be used to inject your own ammo reference
  61832. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61833. */
  61834. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61835. /**
  61836. * Sets the gravity of the physics world (m/(s^2))
  61837. * @param gravity Gravity to set
  61838. */
  61839. setGravity(gravity: Vector3): void;
  61840. /**
  61841. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61842. * @param timeStep timestep to use in seconds
  61843. */
  61844. setTimeStep(timeStep: number): void;
  61845. /**
  61846. * 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)
  61847. * @param fixedTimeStep fixedTimeStep to use in seconds
  61848. */
  61849. setFixedTimeStep(fixedTimeStep: number): void;
  61850. /**
  61851. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61852. * @param maxSteps the maximum number of steps by the physics engine per frame
  61853. */
  61854. setMaxSteps(maxSteps: number): void;
  61855. /**
  61856. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61857. * @returns the current timestep in seconds
  61858. */
  61859. getTimeStep(): number;
  61860. /**
  61861. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61862. */
  61863. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61864. private _isImpostorInContact;
  61865. private _isImpostorPairInContact;
  61866. private _stepSimulation;
  61867. /**
  61868. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61869. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61870. * After the step the babylon meshes are set to the position of the physics imposters
  61871. * @param delta amount of time to step forward
  61872. * @param impostors array of imposters to update before/after the step
  61873. */
  61874. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61875. /**
  61876. * Update babylon mesh to match physics world object
  61877. * @param impostor imposter to match
  61878. */
  61879. private _afterSoftStep;
  61880. /**
  61881. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61882. * @param impostor imposter to match
  61883. */
  61884. private _ropeStep;
  61885. /**
  61886. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61887. * @param impostor imposter to match
  61888. */
  61889. private _softbodyOrClothStep;
  61890. private _tmpMatrix;
  61891. /**
  61892. * Applies an impulse on the imposter
  61893. * @param impostor imposter to apply impulse to
  61894. * @param force amount of force to be applied to the imposter
  61895. * @param contactPoint the location to apply the impulse on the imposter
  61896. */
  61897. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61898. /**
  61899. * Applies a force on the imposter
  61900. * @param impostor imposter to apply force
  61901. * @param force amount of force to be applied to the imposter
  61902. * @param contactPoint the location to apply the force on the imposter
  61903. */
  61904. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61905. /**
  61906. * Creates a physics body using the plugin
  61907. * @param impostor the imposter to create the physics body on
  61908. */
  61909. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61910. /**
  61911. * Removes the physics body from the imposter and disposes of the body's memory
  61912. * @param impostor imposter to remove the physics body from
  61913. */
  61914. removePhysicsBody(impostor: PhysicsImpostor): void;
  61915. /**
  61916. * Generates a joint
  61917. * @param impostorJoint the imposter joint to create the joint with
  61918. */
  61919. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61920. /**
  61921. * Removes a joint
  61922. * @param impostorJoint the imposter joint to remove the joint from
  61923. */
  61924. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61925. private _addMeshVerts;
  61926. /**
  61927. * Initialise the soft body vertices to match its object's (mesh) vertices
  61928. * Softbody vertices (nodes) are in world space and to match this
  61929. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61930. * @param impostor to create the softbody for
  61931. */
  61932. private _softVertexData;
  61933. /**
  61934. * Create an impostor's soft body
  61935. * @param impostor to create the softbody for
  61936. */
  61937. private _createSoftbody;
  61938. /**
  61939. * Create cloth for an impostor
  61940. * @param impostor to create the softbody for
  61941. */
  61942. private _createCloth;
  61943. /**
  61944. * Create rope for an impostor
  61945. * @param impostor to create the softbody for
  61946. */
  61947. private _createRope;
  61948. /**
  61949. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61950. * @param impostor to create the custom physics shape for
  61951. */
  61952. private _createCustom;
  61953. private _addHullVerts;
  61954. private _createShape;
  61955. /**
  61956. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61957. * @param impostor imposter containing the physics body and babylon object
  61958. */
  61959. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61960. /**
  61961. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61962. * @param impostor imposter containing the physics body and babylon object
  61963. * @param newPosition new position
  61964. * @param newRotation new rotation
  61965. */
  61966. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61967. /**
  61968. * If this plugin is supported
  61969. * @returns true if its supported
  61970. */
  61971. isSupported(): boolean;
  61972. /**
  61973. * Sets the linear velocity of the physics body
  61974. * @param impostor imposter to set the velocity on
  61975. * @param velocity velocity to set
  61976. */
  61977. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61978. /**
  61979. * Sets the angular velocity of the physics body
  61980. * @param impostor imposter to set the velocity on
  61981. * @param velocity velocity to set
  61982. */
  61983. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61984. /**
  61985. * gets the linear velocity
  61986. * @param impostor imposter to get linear velocity from
  61987. * @returns linear velocity
  61988. */
  61989. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61990. /**
  61991. * gets the angular velocity
  61992. * @param impostor imposter to get angular velocity from
  61993. * @returns angular velocity
  61994. */
  61995. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61996. /**
  61997. * Sets the mass of physics body
  61998. * @param impostor imposter to set the mass on
  61999. * @param mass mass to set
  62000. */
  62001. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62002. /**
  62003. * Gets the mass of the physics body
  62004. * @param impostor imposter to get the mass from
  62005. * @returns mass
  62006. */
  62007. getBodyMass(impostor: PhysicsImpostor): number;
  62008. /**
  62009. * Gets friction of the impostor
  62010. * @param impostor impostor to get friction from
  62011. * @returns friction value
  62012. */
  62013. getBodyFriction(impostor: PhysicsImpostor): number;
  62014. /**
  62015. * Sets friction of the impostor
  62016. * @param impostor impostor to set friction on
  62017. * @param friction friction value
  62018. */
  62019. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62020. /**
  62021. * Gets restitution of the impostor
  62022. * @param impostor impostor to get restitution from
  62023. * @returns restitution value
  62024. */
  62025. getBodyRestitution(impostor: PhysicsImpostor): number;
  62026. /**
  62027. * Sets resitution of the impostor
  62028. * @param impostor impostor to set resitution on
  62029. * @param restitution resitution value
  62030. */
  62031. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62032. /**
  62033. * Gets pressure inside the impostor
  62034. * @param impostor impostor to get pressure from
  62035. * @returns pressure value
  62036. */
  62037. getBodyPressure(impostor: PhysicsImpostor): number;
  62038. /**
  62039. * Sets pressure inside a soft body impostor
  62040. * Cloth and rope must remain 0 pressure
  62041. * @param impostor impostor to set pressure on
  62042. * @param pressure pressure value
  62043. */
  62044. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62045. /**
  62046. * Gets stiffness of the impostor
  62047. * @param impostor impostor to get stiffness from
  62048. * @returns pressure value
  62049. */
  62050. getBodyStiffness(impostor: PhysicsImpostor): number;
  62051. /**
  62052. * Sets stiffness of the impostor
  62053. * @param impostor impostor to set stiffness on
  62054. * @param stiffness stiffness value from 0 to 1
  62055. */
  62056. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62057. /**
  62058. * Gets velocityIterations of the impostor
  62059. * @param impostor impostor to get velocity iterations from
  62060. * @returns velocityIterations value
  62061. */
  62062. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62063. /**
  62064. * Sets velocityIterations of the impostor
  62065. * @param impostor impostor to set velocity iterations on
  62066. * @param velocityIterations velocityIterations value
  62067. */
  62068. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62069. /**
  62070. * Gets positionIterations of the impostor
  62071. * @param impostor impostor to get position iterations from
  62072. * @returns positionIterations value
  62073. */
  62074. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62075. /**
  62076. * Sets positionIterations of the impostor
  62077. * @param impostor impostor to set position on
  62078. * @param positionIterations positionIterations value
  62079. */
  62080. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62081. /**
  62082. * Append an anchor to a cloth object
  62083. * @param impostor is the cloth impostor to add anchor to
  62084. * @param otherImpostor is the rigid impostor to anchor to
  62085. * @param width ratio across width from 0 to 1
  62086. * @param height ratio up height from 0 to 1
  62087. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62088. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62089. */
  62090. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62091. /**
  62092. * Append an hook to a rope object
  62093. * @param impostor is the rope impostor to add hook to
  62094. * @param otherImpostor is the rigid impostor to hook to
  62095. * @param length ratio along the rope from 0 to 1
  62096. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62097. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62098. */
  62099. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62100. /**
  62101. * Sleeps the physics body and stops it from being active
  62102. * @param impostor impostor to sleep
  62103. */
  62104. sleepBody(impostor: PhysicsImpostor): void;
  62105. /**
  62106. * Activates the physics body
  62107. * @param impostor impostor to activate
  62108. */
  62109. wakeUpBody(impostor: PhysicsImpostor): void;
  62110. /**
  62111. * Updates the distance parameters of the joint
  62112. * @param joint joint to update
  62113. * @param maxDistance maximum distance of the joint
  62114. * @param minDistance minimum distance of the joint
  62115. */
  62116. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62117. /**
  62118. * Sets a motor on the joint
  62119. * @param joint joint to set motor on
  62120. * @param speed speed of the motor
  62121. * @param maxForce maximum force of the motor
  62122. * @param motorIndex index of the motor
  62123. */
  62124. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62125. /**
  62126. * Sets the motors limit
  62127. * @param joint joint to set limit on
  62128. * @param upperLimit upper limit
  62129. * @param lowerLimit lower limit
  62130. */
  62131. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62132. /**
  62133. * Syncs the position and rotation of a mesh with the impostor
  62134. * @param mesh mesh to sync
  62135. * @param impostor impostor to update the mesh with
  62136. */
  62137. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62138. /**
  62139. * Gets the radius of the impostor
  62140. * @param impostor impostor to get radius from
  62141. * @returns the radius
  62142. */
  62143. getRadius(impostor: PhysicsImpostor): number;
  62144. /**
  62145. * Gets the box size of the impostor
  62146. * @param impostor impostor to get box size from
  62147. * @param result the resulting box size
  62148. */
  62149. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62150. /**
  62151. * Disposes of the impostor
  62152. */
  62153. dispose(): void;
  62154. /**
  62155. * Does a raycast in the physics world
  62156. * @param from when should the ray start?
  62157. * @param to when should the ray end?
  62158. * @returns PhysicsRaycastResult
  62159. */
  62160. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62161. }
  62162. }
  62163. declare module "babylonjs/Probes/reflectionProbe" {
  62164. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62165. import { Vector3 } from "babylonjs/Maths/math.vector";
  62166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62167. import { Nullable } from "babylonjs/types";
  62168. import { Scene } from "babylonjs/scene";
  62169. module "babylonjs/abstractScene" {
  62170. interface AbstractScene {
  62171. /**
  62172. * The list of reflection probes added to the scene
  62173. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62174. */
  62175. reflectionProbes: Array<ReflectionProbe>;
  62176. /**
  62177. * Removes the given reflection probe from this scene.
  62178. * @param toRemove The reflection probe to remove
  62179. * @returns The index of the removed reflection probe
  62180. */
  62181. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62182. /**
  62183. * Adds the given reflection probe to this scene.
  62184. * @param newReflectionProbe The reflection probe to add
  62185. */
  62186. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62187. }
  62188. }
  62189. /**
  62190. * Class used to generate realtime reflection / refraction cube textures
  62191. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62192. */
  62193. export class ReflectionProbe {
  62194. /** defines the name of the probe */
  62195. name: string;
  62196. private _scene;
  62197. private _renderTargetTexture;
  62198. private _projectionMatrix;
  62199. private _viewMatrix;
  62200. private _target;
  62201. private _add;
  62202. private _attachedMesh;
  62203. private _invertYAxis;
  62204. /** Gets or sets probe position (center of the cube map) */
  62205. position: Vector3;
  62206. /**
  62207. * Creates a new reflection probe
  62208. * @param name defines the name of the probe
  62209. * @param size defines the texture resolution (for each face)
  62210. * @param scene defines the hosting scene
  62211. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62212. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62213. */
  62214. constructor(
  62215. /** defines the name of the probe */
  62216. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62217. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62218. get samples(): number;
  62219. set samples(value: number);
  62220. /** Gets or sets the refresh rate to use (on every frame by default) */
  62221. get refreshRate(): number;
  62222. set refreshRate(value: number);
  62223. /**
  62224. * Gets the hosting scene
  62225. * @returns a Scene
  62226. */
  62227. getScene(): Scene;
  62228. /** Gets the internal CubeTexture used to render to */
  62229. get cubeTexture(): RenderTargetTexture;
  62230. /** Gets the list of meshes to render */
  62231. get renderList(): Nullable<AbstractMesh[]>;
  62232. /**
  62233. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62234. * @param mesh defines the mesh to attach to
  62235. */
  62236. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62237. /**
  62238. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62239. * @param renderingGroupId The rendering group id corresponding to its index
  62240. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62241. */
  62242. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62243. /**
  62244. * Clean all associated resources
  62245. */
  62246. dispose(): void;
  62247. /**
  62248. * Converts the reflection probe information to a readable string for debug purpose.
  62249. * @param fullDetails Supports for multiple levels of logging within scene loading
  62250. * @returns the human readable reflection probe info
  62251. */
  62252. toString(fullDetails?: boolean): string;
  62253. /**
  62254. * Get the class name of the relfection probe.
  62255. * @returns "ReflectionProbe"
  62256. */
  62257. getClassName(): string;
  62258. /**
  62259. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62260. * @returns The JSON representation of the texture
  62261. */
  62262. serialize(): any;
  62263. /**
  62264. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62265. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62266. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62267. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62268. * @returns The parsed reflection probe if successful
  62269. */
  62270. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62271. }
  62272. }
  62273. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62274. /** @hidden */
  62275. export var _BabylonLoaderRegistered: boolean;
  62276. /**
  62277. * Helps setting up some configuration for the babylon file loader.
  62278. */
  62279. export class BabylonFileLoaderConfiguration {
  62280. /**
  62281. * The loader does not allow injecting custom physix engine into the plugins.
  62282. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62283. * So you could set this variable to your engine import to make it work.
  62284. */
  62285. static LoaderInjectedPhysicsEngine: any;
  62286. }
  62287. }
  62288. declare module "babylonjs/Loading/Plugins/index" {
  62289. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62290. }
  62291. declare module "babylonjs/Loading/index" {
  62292. export * from "babylonjs/Loading/loadingScreen";
  62293. export * from "babylonjs/Loading/Plugins/index";
  62294. export * from "babylonjs/Loading/sceneLoader";
  62295. export * from "babylonjs/Loading/sceneLoaderFlags";
  62296. }
  62297. declare module "babylonjs/Materials/Background/index" {
  62298. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62299. }
  62300. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62301. import { Scene } from "babylonjs/scene";
  62302. import { Color3 } from "babylonjs/Maths/math.color";
  62303. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62305. /**
  62306. * The Physically based simple base material of BJS.
  62307. *
  62308. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62309. * It is used as the base class for both the specGloss and metalRough conventions.
  62310. */
  62311. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62312. /**
  62313. * Number of Simultaneous lights allowed on the material.
  62314. */
  62315. maxSimultaneousLights: number;
  62316. /**
  62317. * If sets to true, disables all the lights affecting the material.
  62318. */
  62319. disableLighting: boolean;
  62320. /**
  62321. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62322. */
  62323. environmentTexture: BaseTexture;
  62324. /**
  62325. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62326. */
  62327. invertNormalMapX: boolean;
  62328. /**
  62329. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62330. */
  62331. invertNormalMapY: boolean;
  62332. /**
  62333. * Normal map used in the model.
  62334. */
  62335. normalTexture: BaseTexture;
  62336. /**
  62337. * Emissivie color used to self-illuminate the model.
  62338. */
  62339. emissiveColor: Color3;
  62340. /**
  62341. * Emissivie texture used to self-illuminate the model.
  62342. */
  62343. emissiveTexture: BaseTexture;
  62344. /**
  62345. * Occlusion Channel Strenght.
  62346. */
  62347. occlusionStrength: number;
  62348. /**
  62349. * Occlusion Texture of the material (adding extra occlusion effects).
  62350. */
  62351. occlusionTexture: BaseTexture;
  62352. /**
  62353. * Defines the alpha limits in alpha test mode.
  62354. */
  62355. alphaCutOff: number;
  62356. /**
  62357. * Gets the current double sided mode.
  62358. */
  62359. get doubleSided(): boolean;
  62360. /**
  62361. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62362. */
  62363. set doubleSided(value: boolean);
  62364. /**
  62365. * Stores the pre-calculated light information of a mesh in a texture.
  62366. */
  62367. lightmapTexture: BaseTexture;
  62368. /**
  62369. * If true, the light map contains occlusion information instead of lighting info.
  62370. */
  62371. useLightmapAsShadowmap: boolean;
  62372. /**
  62373. * Instantiates a new PBRMaterial instance.
  62374. *
  62375. * @param name The material name
  62376. * @param scene The scene the material will be use in.
  62377. */
  62378. constructor(name: string, scene: Scene);
  62379. getClassName(): string;
  62380. }
  62381. }
  62382. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62383. import { Scene } from "babylonjs/scene";
  62384. import { Color3 } from "babylonjs/Maths/math.color";
  62385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62386. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62387. /**
  62388. * The PBR material of BJS following the metal roughness convention.
  62389. *
  62390. * This fits to the PBR convention in the GLTF definition:
  62391. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62392. */
  62393. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62394. /**
  62395. * The base color has two different interpretations depending on the value of metalness.
  62396. * When the material is a metal, the base color is the specific measured reflectance value
  62397. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62398. * of the material.
  62399. */
  62400. baseColor: Color3;
  62401. /**
  62402. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62403. * well as opacity information in the alpha channel.
  62404. */
  62405. baseTexture: BaseTexture;
  62406. /**
  62407. * Specifies the metallic scalar value of the material.
  62408. * Can also be used to scale the metalness values of the metallic texture.
  62409. */
  62410. metallic: number;
  62411. /**
  62412. * Specifies the roughness scalar value of the material.
  62413. * Can also be used to scale the roughness values of the metallic texture.
  62414. */
  62415. roughness: number;
  62416. /**
  62417. * Texture containing both the metallic value in the B channel and the
  62418. * roughness value in the G channel to keep better precision.
  62419. */
  62420. metallicRoughnessTexture: BaseTexture;
  62421. /**
  62422. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62423. *
  62424. * @param name The material name
  62425. * @param scene The scene the material will be use in.
  62426. */
  62427. constructor(name: string, scene: Scene);
  62428. /**
  62429. * Return the currrent class name of the material.
  62430. */
  62431. getClassName(): string;
  62432. /**
  62433. * Makes a duplicate of the current material.
  62434. * @param name - name to use for the new material.
  62435. */
  62436. clone(name: string): PBRMetallicRoughnessMaterial;
  62437. /**
  62438. * Serialize the material to a parsable JSON object.
  62439. */
  62440. serialize(): any;
  62441. /**
  62442. * Parses a JSON object correponding to the serialize function.
  62443. */
  62444. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62445. }
  62446. }
  62447. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  62448. import { Scene } from "babylonjs/scene";
  62449. import { Color3 } from "babylonjs/Maths/math.color";
  62450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62451. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62452. /**
  62453. * The PBR material of BJS following the specular glossiness convention.
  62454. *
  62455. * This fits to the PBR convention in the GLTF definition:
  62456. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62457. */
  62458. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62459. /**
  62460. * Specifies the diffuse color of the material.
  62461. */
  62462. diffuseColor: Color3;
  62463. /**
  62464. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62465. * channel.
  62466. */
  62467. diffuseTexture: BaseTexture;
  62468. /**
  62469. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62470. */
  62471. specularColor: Color3;
  62472. /**
  62473. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62474. */
  62475. glossiness: number;
  62476. /**
  62477. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62478. */
  62479. specularGlossinessTexture: BaseTexture;
  62480. /**
  62481. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62482. *
  62483. * @param name The material name
  62484. * @param scene The scene the material will be use in.
  62485. */
  62486. constructor(name: string, scene: Scene);
  62487. /**
  62488. * Return the currrent class name of the material.
  62489. */
  62490. getClassName(): string;
  62491. /**
  62492. * Makes a duplicate of the current material.
  62493. * @param name - name to use for the new material.
  62494. */
  62495. clone(name: string): PBRSpecularGlossinessMaterial;
  62496. /**
  62497. * Serialize the material to a parsable JSON object.
  62498. */
  62499. serialize(): any;
  62500. /**
  62501. * Parses a JSON object correponding to the serialize function.
  62502. */
  62503. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62504. }
  62505. }
  62506. declare module "babylonjs/Materials/PBR/index" {
  62507. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62508. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62509. export * from "babylonjs/Materials/PBR/pbrMaterial";
  62510. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  62511. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  62512. }
  62513. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  62514. import { Nullable } from "babylonjs/types";
  62515. import { Scene } from "babylonjs/scene";
  62516. import { Matrix } from "babylonjs/Maths/math.vector";
  62517. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62518. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62519. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62520. /**
  62521. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62522. * It can help converting any input color in a desired output one. This can then be used to create effects
  62523. * from sepia, black and white to sixties or futuristic rendering...
  62524. *
  62525. * The only supported format is currently 3dl.
  62526. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62527. */
  62528. export class ColorGradingTexture extends BaseTexture {
  62529. /**
  62530. * The texture URL.
  62531. */
  62532. url: string;
  62533. /**
  62534. * Empty line regex stored for GC.
  62535. */
  62536. private static _noneEmptyLineRegex;
  62537. private _textureMatrix;
  62538. private _onLoad;
  62539. /**
  62540. * Instantiates a ColorGradingTexture from the following parameters.
  62541. *
  62542. * @param url The location of the color gradind data (currently only supporting 3dl)
  62543. * @param sceneOrEngine The scene or engine the texture will be used in
  62544. * @param onLoad defines a callback triggered when the texture has been loaded
  62545. */
  62546. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62547. /**
  62548. * Fires the onload event from the constructor if requested.
  62549. */
  62550. private _triggerOnLoad;
  62551. /**
  62552. * Returns the texture matrix used in most of the material.
  62553. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62554. */
  62555. getTextureMatrix(): Matrix;
  62556. /**
  62557. * Occurs when the file being loaded is a .3dl LUT file.
  62558. */
  62559. private load3dlTexture;
  62560. /**
  62561. * Starts the loading process of the texture.
  62562. */
  62563. private loadTexture;
  62564. /**
  62565. * Clones the color gradind texture.
  62566. */
  62567. clone(): ColorGradingTexture;
  62568. /**
  62569. * Called during delayed load for textures.
  62570. */
  62571. delayLoad(): void;
  62572. /**
  62573. * Parses a color grading texture serialized by Babylon.
  62574. * @param parsedTexture The texture information being parsedTexture
  62575. * @param scene The scene to load the texture in
  62576. * @param rootUrl The root url of the data assets to load
  62577. * @return A color gradind texture
  62578. */
  62579. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62580. /**
  62581. * Serializes the LUT texture to json format.
  62582. */
  62583. serialize(): any;
  62584. }
  62585. }
  62586. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  62587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62588. import { Scene } from "babylonjs/scene";
  62589. import { Nullable } from "babylonjs/types";
  62590. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62591. /**
  62592. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62593. */
  62594. export class EquiRectangularCubeTexture extends BaseTexture {
  62595. /** The six faces of the cube. */
  62596. private static _FacesMapping;
  62597. private _noMipmap;
  62598. private _onLoad;
  62599. private _onError;
  62600. /** The size of the cubemap. */
  62601. private _size;
  62602. /** The buffer of the image. */
  62603. private _buffer;
  62604. /** The width of the input image. */
  62605. private _width;
  62606. /** The height of the input image. */
  62607. private _height;
  62608. /** The URL to the image. */
  62609. url: string;
  62610. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  62611. coordinatesMode: number;
  62612. /**
  62613. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62614. * @param url The location of the image
  62615. * @param scene The scene the texture will be used in
  62616. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62617. * @param noMipmap Forces to not generate the mipmap if true
  62618. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62619. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62620. * @param onLoad — defines a callback called when texture is loaded
  62621. * @param onError — defines a callback called if there is an error
  62622. */
  62623. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62624. /**
  62625. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62626. */
  62627. private loadImage;
  62628. /**
  62629. * Convert the image buffer into a cubemap and create a CubeTexture.
  62630. */
  62631. private loadTexture;
  62632. /**
  62633. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62634. * @param buffer The ArrayBuffer that should be converted.
  62635. * @returns The buffer as Float32Array.
  62636. */
  62637. private getFloat32ArrayFromArrayBuffer;
  62638. /**
  62639. * Get the current class name of the texture useful for serialization or dynamic coding.
  62640. * @returns "EquiRectangularCubeTexture"
  62641. */
  62642. getClassName(): string;
  62643. /**
  62644. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62645. * @returns A clone of the current EquiRectangularCubeTexture.
  62646. */
  62647. clone(): EquiRectangularCubeTexture;
  62648. }
  62649. }
  62650. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  62651. import { Nullable } from "babylonjs/types";
  62652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62653. import { Matrix } from "babylonjs/Maths/math.vector";
  62654. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62655. import "babylonjs/Engines/Extensions/engine.videoTexture";
  62656. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62657. import { Scene } from "babylonjs/scene";
  62658. /**
  62659. * Defines the options related to the creation of an HtmlElementTexture
  62660. */
  62661. export interface IHtmlElementTextureOptions {
  62662. /**
  62663. * Defines wether mip maps should be created or not.
  62664. */
  62665. generateMipMaps?: boolean;
  62666. /**
  62667. * Defines the sampling mode of the texture.
  62668. */
  62669. samplingMode?: number;
  62670. /**
  62671. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62672. */
  62673. engine: Nullable<ThinEngine>;
  62674. /**
  62675. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62676. */
  62677. scene: Nullable<Scene>;
  62678. }
  62679. /**
  62680. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62681. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62682. * is automatically managed.
  62683. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62684. * in your application.
  62685. *
  62686. * As the update is not automatic, you need to call them manually.
  62687. */
  62688. export class HtmlElementTexture extends BaseTexture {
  62689. /**
  62690. * The texture URL.
  62691. */
  62692. element: HTMLVideoElement | HTMLCanvasElement;
  62693. private static readonly DefaultOptions;
  62694. private _textureMatrix;
  62695. private _isVideo;
  62696. private _generateMipMaps;
  62697. private _samplingMode;
  62698. /**
  62699. * Instantiates a HtmlElementTexture from the following parameters.
  62700. *
  62701. * @param name Defines the name of the texture
  62702. * @param element Defines the video or canvas the texture is filled with
  62703. * @param options Defines the other none mandatory texture creation options
  62704. */
  62705. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62706. private _createInternalTexture;
  62707. /**
  62708. * Returns the texture matrix used in most of the material.
  62709. */
  62710. getTextureMatrix(): Matrix;
  62711. /**
  62712. * Updates the content of the texture.
  62713. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62714. */
  62715. update(invertY?: Nullable<boolean>): void;
  62716. }
  62717. }
  62718. declare module "babylonjs/Misc/tga" {
  62719. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62720. /**
  62721. * Based on jsTGALoader - Javascript loader for TGA file
  62722. * By Vincent Thibault
  62723. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62724. */
  62725. export class TGATools {
  62726. private static _TYPE_INDEXED;
  62727. private static _TYPE_RGB;
  62728. private static _TYPE_GREY;
  62729. private static _TYPE_RLE_INDEXED;
  62730. private static _TYPE_RLE_RGB;
  62731. private static _TYPE_RLE_GREY;
  62732. private static _ORIGIN_MASK;
  62733. private static _ORIGIN_SHIFT;
  62734. private static _ORIGIN_BL;
  62735. private static _ORIGIN_BR;
  62736. private static _ORIGIN_UL;
  62737. private static _ORIGIN_UR;
  62738. /**
  62739. * Gets the header of a TGA file
  62740. * @param data defines the TGA data
  62741. * @returns the header
  62742. */
  62743. static GetTGAHeader(data: Uint8Array): any;
  62744. /**
  62745. * Uploads TGA content to a Babylon Texture
  62746. * @hidden
  62747. */
  62748. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62749. /** @hidden */
  62750. 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;
  62751. /** @hidden */
  62752. 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;
  62753. /** @hidden */
  62754. 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;
  62755. /** @hidden */
  62756. 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;
  62757. /** @hidden */
  62758. 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;
  62759. /** @hidden */
  62760. 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;
  62761. }
  62762. }
  62763. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  62764. import { Nullable } from "babylonjs/types";
  62765. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62766. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62767. /**
  62768. * Implementation of the TGA Texture Loader.
  62769. * @hidden
  62770. */
  62771. export class _TGATextureLoader implements IInternalTextureLoader {
  62772. /**
  62773. * Defines wether the loader supports cascade loading the different faces.
  62774. */
  62775. readonly supportCascades: boolean;
  62776. /**
  62777. * This returns if the loader support the current file information.
  62778. * @param extension defines the file extension of the file being loaded
  62779. * @returns true if the loader can load the specified file
  62780. */
  62781. canLoad(extension: string): boolean;
  62782. /**
  62783. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62784. * @param data contains the texture data
  62785. * @param texture defines the BabylonJS internal texture
  62786. * @param createPolynomials will be true if polynomials have been requested
  62787. * @param onLoad defines the callback to trigger once the texture is ready
  62788. * @param onError defines the callback to trigger in case of error
  62789. */
  62790. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62791. /**
  62792. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62793. * @param data contains the texture data
  62794. * @param texture defines the BabylonJS internal texture
  62795. * @param callback defines the method to call once ready to upload
  62796. */
  62797. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62798. }
  62799. }
  62800. declare module "babylonjs/Misc/basis" {
  62801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62802. /**
  62803. * Info about the .basis files
  62804. */
  62805. class BasisFileInfo {
  62806. /**
  62807. * If the file has alpha
  62808. */
  62809. hasAlpha: boolean;
  62810. /**
  62811. * Info about each image of the basis file
  62812. */
  62813. images: Array<{
  62814. levels: Array<{
  62815. width: number;
  62816. height: number;
  62817. transcodedPixels: ArrayBufferView;
  62818. }>;
  62819. }>;
  62820. }
  62821. /**
  62822. * Result of transcoding a basis file
  62823. */
  62824. class TranscodeResult {
  62825. /**
  62826. * Info about the .basis file
  62827. */
  62828. fileInfo: BasisFileInfo;
  62829. /**
  62830. * Format to use when loading the file
  62831. */
  62832. format: number;
  62833. }
  62834. /**
  62835. * Configuration options for the Basis transcoder
  62836. */
  62837. export class BasisTranscodeConfiguration {
  62838. /**
  62839. * Supported compression formats used to determine the supported output format of the transcoder
  62840. */
  62841. supportedCompressionFormats?: {
  62842. /**
  62843. * etc1 compression format
  62844. */
  62845. etc1?: boolean;
  62846. /**
  62847. * s3tc compression format
  62848. */
  62849. s3tc?: boolean;
  62850. /**
  62851. * pvrtc compression format
  62852. */
  62853. pvrtc?: boolean;
  62854. /**
  62855. * etc2 compression format
  62856. */
  62857. etc2?: boolean;
  62858. };
  62859. /**
  62860. * If mipmap levels should be loaded for transcoded images (Default: true)
  62861. */
  62862. loadMipmapLevels?: boolean;
  62863. /**
  62864. * Index of a single image to load (Default: all images)
  62865. */
  62866. loadSingleImage?: number;
  62867. }
  62868. /**
  62869. * Used to load .Basis files
  62870. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62871. */
  62872. export class BasisTools {
  62873. private static _IgnoreSupportedFormats;
  62874. /**
  62875. * URL to use when loading the basis transcoder
  62876. */
  62877. static JSModuleURL: string;
  62878. /**
  62879. * URL to use when loading the wasm module for the transcoder
  62880. */
  62881. static WasmModuleURL: string;
  62882. /**
  62883. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62884. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62885. * @returns internal format corresponding to the Basis format
  62886. */
  62887. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62888. private static _WorkerPromise;
  62889. private static _Worker;
  62890. private static _actionId;
  62891. private static _CreateWorkerAsync;
  62892. /**
  62893. * Transcodes a loaded image file to compressed pixel data
  62894. * @param data image data to transcode
  62895. * @param config configuration options for the transcoding
  62896. * @returns a promise resulting in the transcoded image
  62897. */
  62898. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62899. /**
  62900. * Loads a texture from the transcode result
  62901. * @param texture texture load to
  62902. * @param transcodeResult the result of transcoding the basis file to load from
  62903. */
  62904. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62905. }
  62906. }
  62907. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  62908. import { Nullable } from "babylonjs/types";
  62909. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62910. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62911. /**
  62912. * Loader for .basis file format
  62913. */
  62914. export class _BasisTextureLoader implements IInternalTextureLoader {
  62915. /**
  62916. * Defines whether the loader supports cascade loading the different faces.
  62917. */
  62918. readonly supportCascades: boolean;
  62919. /**
  62920. * This returns if the loader support the current file information.
  62921. * @param extension defines the file extension of the file being loaded
  62922. * @returns true if the loader can load the specified file
  62923. */
  62924. canLoad(extension: string): boolean;
  62925. /**
  62926. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62927. * @param data contains the texture data
  62928. * @param texture defines the BabylonJS internal texture
  62929. * @param createPolynomials will be true if polynomials have been requested
  62930. * @param onLoad defines the callback to trigger once the texture is ready
  62931. * @param onError defines the callback to trigger in case of error
  62932. */
  62933. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62934. /**
  62935. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62936. * @param data contains the texture data
  62937. * @param texture defines the BabylonJS internal texture
  62938. * @param callback defines the method to call once ready to upload
  62939. */
  62940. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62941. }
  62942. }
  62943. declare module "babylonjs/Materials/Textures/Loaders/index" {
  62944. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  62945. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  62946. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  62947. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  62948. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  62949. }
  62950. declare module "babylonjs/Materials/Textures/Packer/frame" {
  62951. import { Vector2 } from "babylonjs/Maths/math.vector";
  62952. /**
  62953. * Defines the basic options interface of a TexturePacker Frame
  62954. */
  62955. export interface ITexturePackerFrame {
  62956. /**
  62957. * The frame ID
  62958. */
  62959. id: number;
  62960. /**
  62961. * The frames Scale
  62962. */
  62963. scale: Vector2;
  62964. /**
  62965. * The Frames offset
  62966. */
  62967. offset: Vector2;
  62968. }
  62969. /**
  62970. * This is a support class for frame Data on texture packer sets.
  62971. */
  62972. export class TexturePackerFrame implements ITexturePackerFrame {
  62973. /**
  62974. * The frame ID
  62975. */
  62976. id: number;
  62977. /**
  62978. * The frames Scale
  62979. */
  62980. scale: Vector2;
  62981. /**
  62982. * The Frames offset
  62983. */
  62984. offset: Vector2;
  62985. /**
  62986. * Initializes a texture package frame.
  62987. * @param id The numerical frame identifier
  62988. * @param scale Scalar Vector2 for UV frame
  62989. * @param offset Vector2 for the frame position in UV units.
  62990. * @returns TexturePackerFrame
  62991. */
  62992. constructor(id: number, scale: Vector2, offset: Vector2);
  62993. }
  62994. }
  62995. declare module "babylonjs/Materials/Textures/Packer/packer" {
  62996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62997. import { Scene } from "babylonjs/scene";
  62998. import { Nullable } from "babylonjs/types";
  62999. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63000. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63001. /**
  63002. * Defines the basic options interface of a TexturePacker
  63003. */
  63004. export interface ITexturePackerOptions {
  63005. /**
  63006. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63007. */
  63008. map?: string[];
  63009. /**
  63010. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63011. */
  63012. uvsIn?: string;
  63013. /**
  63014. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63015. */
  63016. uvsOut?: string;
  63017. /**
  63018. * number representing the layout style. Defaults to LAYOUT_STRIP
  63019. */
  63020. layout?: number;
  63021. /**
  63022. * number of columns if using custom column count layout(2). This defaults to 4.
  63023. */
  63024. colnum?: number;
  63025. /**
  63026. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63027. */
  63028. updateInputMeshes?: boolean;
  63029. /**
  63030. * boolean flag to dispose all the source textures. Defaults to true.
  63031. */
  63032. disposeSources?: boolean;
  63033. /**
  63034. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63035. */
  63036. fillBlanks?: boolean;
  63037. /**
  63038. * string value representing the context fill style color. Defaults to 'black'.
  63039. */
  63040. customFillColor?: string;
  63041. /**
  63042. * Width and Height Value of each Frame in the TexturePacker Sets
  63043. */
  63044. frameSize?: number;
  63045. /**
  63046. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63047. */
  63048. paddingRatio?: number;
  63049. /**
  63050. * Number that declares the fill method for the padding gutter.
  63051. */
  63052. paddingMode?: number;
  63053. /**
  63054. * If in SUBUV_COLOR padding mode what color to use.
  63055. */
  63056. paddingColor?: Color3 | Color4;
  63057. }
  63058. /**
  63059. * Defines the basic interface of a TexturePacker JSON File
  63060. */
  63061. export interface ITexturePackerJSON {
  63062. /**
  63063. * The frame ID
  63064. */
  63065. name: string;
  63066. /**
  63067. * The base64 channel data
  63068. */
  63069. sets: any;
  63070. /**
  63071. * The options of the Packer
  63072. */
  63073. options: ITexturePackerOptions;
  63074. /**
  63075. * The frame data of the Packer
  63076. */
  63077. frames: Array<number>;
  63078. }
  63079. /**
  63080. * This is a support class that generates a series of packed texture sets.
  63081. * @see https://doc.babylonjs.com/babylon101/materials
  63082. */
  63083. export class TexturePacker {
  63084. /** Packer Layout Constant 0 */
  63085. static readonly LAYOUT_STRIP: number;
  63086. /** Packer Layout Constant 1 */
  63087. static readonly LAYOUT_POWER2: number;
  63088. /** Packer Layout Constant 2 */
  63089. static readonly LAYOUT_COLNUM: number;
  63090. /** Packer Layout Constant 0 */
  63091. static readonly SUBUV_WRAP: number;
  63092. /** Packer Layout Constant 1 */
  63093. static readonly SUBUV_EXTEND: number;
  63094. /** Packer Layout Constant 2 */
  63095. static readonly SUBUV_COLOR: number;
  63096. /** The Name of the Texture Package */
  63097. name: string;
  63098. /** The scene scope of the TexturePacker */
  63099. scene: Scene;
  63100. /** The Meshes to target */
  63101. meshes: AbstractMesh[];
  63102. /** Arguments passed with the Constructor */
  63103. options: ITexturePackerOptions;
  63104. /** The promise that is started upon initialization */
  63105. promise: Nullable<Promise<TexturePacker | string>>;
  63106. /** The Container object for the channel sets that are generated */
  63107. sets: object;
  63108. /** The Container array for the frames that are generated */
  63109. frames: TexturePackerFrame[];
  63110. /** The expected number of textures the system is parsing. */
  63111. private _expecting;
  63112. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63113. private _paddingValue;
  63114. /**
  63115. * Initializes a texture package series from an array of meshes or a single mesh.
  63116. * @param name The name of the package
  63117. * @param meshes The target meshes to compose the package from
  63118. * @param options The arguments that texture packer should follow while building.
  63119. * @param scene The scene which the textures are scoped to.
  63120. * @returns TexturePacker
  63121. */
  63122. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63123. /**
  63124. * Starts the package process
  63125. * @param resolve The promises resolution function
  63126. * @returns TexturePacker
  63127. */
  63128. private _createFrames;
  63129. /**
  63130. * Calculates the Size of the Channel Sets
  63131. * @returns Vector2
  63132. */
  63133. private _calculateSize;
  63134. /**
  63135. * Calculates the UV data for the frames.
  63136. * @param baseSize the base frameSize
  63137. * @param padding the base frame padding
  63138. * @param dtSize size of the Dynamic Texture for that channel
  63139. * @param dtUnits is 1/dtSize
  63140. * @param update flag to update the input meshes
  63141. */
  63142. private _calculateMeshUVFrames;
  63143. /**
  63144. * Calculates the frames Offset.
  63145. * @param index of the frame
  63146. * @returns Vector2
  63147. */
  63148. private _getFrameOffset;
  63149. /**
  63150. * Updates a Mesh to the frame data
  63151. * @param mesh that is the target
  63152. * @param frameID or the frame index
  63153. */
  63154. private _updateMeshUV;
  63155. /**
  63156. * Updates a Meshes materials to use the texture packer channels
  63157. * @param m is the mesh to target
  63158. * @param force all channels on the packer to be set.
  63159. */
  63160. private _updateTextureReferences;
  63161. /**
  63162. * Public method to set a Mesh to a frame
  63163. * @param m that is the target
  63164. * @param frameID or the frame index
  63165. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63166. */
  63167. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63168. /**
  63169. * Starts the async promise to compile the texture packer.
  63170. * @returns Promise<void>
  63171. */
  63172. processAsync(): Promise<void>;
  63173. /**
  63174. * Disposes all textures associated with this packer
  63175. */
  63176. dispose(): void;
  63177. /**
  63178. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63179. * @param imageType is the image type to use.
  63180. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63181. */
  63182. download(imageType?: string, quality?: number): void;
  63183. /**
  63184. * Public method to load a texturePacker JSON file.
  63185. * @param data of the JSON file in string format.
  63186. */
  63187. updateFromJSON(data: string): void;
  63188. }
  63189. }
  63190. declare module "babylonjs/Materials/Textures/Packer/index" {
  63191. export * from "babylonjs/Materials/Textures/Packer/packer";
  63192. export * from "babylonjs/Materials/Textures/Packer/frame";
  63193. }
  63194. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63195. import { Scene } from "babylonjs/scene";
  63196. import { Texture } from "babylonjs/Materials/Textures/texture";
  63197. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63198. /**
  63199. * 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.
  63200. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63201. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63202. */
  63203. export class CustomProceduralTexture extends ProceduralTexture {
  63204. private _animate;
  63205. private _time;
  63206. private _config;
  63207. private _texturePath;
  63208. /**
  63209. * Instantiates a new Custom Procedural Texture.
  63210. * 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.
  63211. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63212. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63213. * @param name Define the name of the texture
  63214. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63215. * @param size Define the size of the texture to create
  63216. * @param scene Define the scene the texture belongs to
  63217. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63218. * @param generateMipMaps Define if the texture should creates mip maps or not
  63219. */
  63220. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63221. private _loadJson;
  63222. /**
  63223. * Is the texture ready to be used ? (rendered at least once)
  63224. * @returns true if ready, otherwise, false.
  63225. */
  63226. isReady(): boolean;
  63227. /**
  63228. * Render the texture to its associated render target.
  63229. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63230. */
  63231. render(useCameraPostProcess?: boolean): void;
  63232. /**
  63233. * Update the list of dependant textures samplers in the shader.
  63234. */
  63235. updateTextures(): void;
  63236. /**
  63237. * Update the uniform values of the procedural texture in the shader.
  63238. */
  63239. updateShaderUniforms(): void;
  63240. /**
  63241. * Define if the texture animates or not.
  63242. */
  63243. get animate(): boolean;
  63244. set animate(value: boolean);
  63245. }
  63246. }
  63247. declare module "babylonjs/Shaders/noise.fragment" {
  63248. /** @hidden */
  63249. export var noisePixelShader: {
  63250. name: string;
  63251. shader: string;
  63252. };
  63253. }
  63254. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63255. import { Nullable } from "babylonjs/types";
  63256. import { Scene } from "babylonjs/scene";
  63257. import { Texture } from "babylonjs/Materials/Textures/texture";
  63258. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63259. import "babylonjs/Shaders/noise.fragment";
  63260. /**
  63261. * Class used to generate noise procedural textures
  63262. */
  63263. export class NoiseProceduralTexture extends ProceduralTexture {
  63264. private _time;
  63265. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63266. brightness: number;
  63267. /** Defines the number of octaves to process */
  63268. octaves: number;
  63269. /** Defines the level of persistence (0.8 by default) */
  63270. persistence: number;
  63271. /** Gets or sets animation speed factor (default is 1) */
  63272. animationSpeedFactor: number;
  63273. /**
  63274. * Creates a new NoiseProceduralTexture
  63275. * @param name defines the name fo the texture
  63276. * @param size defines the size of the texture (default is 256)
  63277. * @param scene defines the hosting scene
  63278. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63279. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63280. */
  63281. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63282. private _updateShaderUniforms;
  63283. protected _getDefines(): string;
  63284. /** Generate the current state of the procedural texture */
  63285. render(useCameraPostProcess?: boolean): void;
  63286. /**
  63287. * Serializes this noise procedural texture
  63288. * @returns a serialized noise procedural texture object
  63289. */
  63290. serialize(): any;
  63291. /**
  63292. * Clone the texture.
  63293. * @returns the cloned texture
  63294. */
  63295. clone(): NoiseProceduralTexture;
  63296. /**
  63297. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63298. * @param parsedTexture defines parsed texture data
  63299. * @param scene defines the current scene
  63300. * @param rootUrl defines the root URL containing noise procedural texture information
  63301. * @returns a parsed NoiseProceduralTexture
  63302. */
  63303. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63304. }
  63305. }
  63306. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63307. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63308. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63309. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63310. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63311. }
  63312. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63313. import { Nullable } from "babylonjs/types";
  63314. import { Scene } from "babylonjs/scene";
  63315. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63316. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63317. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63318. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63319. /**
  63320. * Raw cube texture where the raw buffers are passed in
  63321. */
  63322. export class RawCubeTexture extends CubeTexture {
  63323. /**
  63324. * Creates a cube texture where the raw buffers are passed in.
  63325. * @param scene defines the scene the texture is attached to
  63326. * @param data defines the array of data to use to create each face
  63327. * @param size defines the size of the textures
  63328. * @param format defines the format of the data
  63329. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63330. * @param generateMipMaps defines if the engine should generate the mip levels
  63331. * @param invertY defines if data must be stored with Y axis inverted
  63332. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63333. * @param compression defines the compression used (null by default)
  63334. */
  63335. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63336. /**
  63337. * Updates the raw cube texture.
  63338. * @param data defines the data to store
  63339. * @param format defines the data format
  63340. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63341. * @param invertY defines if data must be stored with Y axis inverted
  63342. * @param compression defines the compression used (null by default)
  63343. * @param level defines which level of the texture to update
  63344. */
  63345. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63346. /**
  63347. * Updates a raw cube texture with RGBD encoded data.
  63348. * @param data defines the array of data [mipmap][face] to use to create each face
  63349. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63350. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63351. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63352. * @returns a promsie that resolves when the operation is complete
  63353. */
  63354. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63355. /**
  63356. * Clones the raw cube texture.
  63357. * @return a new cube texture
  63358. */
  63359. clone(): CubeTexture;
  63360. /** @hidden */
  63361. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63362. }
  63363. }
  63364. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63365. import { Scene } from "babylonjs/scene";
  63366. import { Texture } from "babylonjs/Materials/Textures/texture";
  63367. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63368. /**
  63369. * Class used to store 2D array textures containing user data
  63370. */
  63371. export class RawTexture2DArray extends Texture {
  63372. /** Gets or sets the texture format to use */
  63373. format: number;
  63374. /**
  63375. * Create a new RawTexture2DArray
  63376. * @param data defines the data of the texture
  63377. * @param width defines the width of the texture
  63378. * @param height defines the height of the texture
  63379. * @param depth defines the number of layers of the texture
  63380. * @param format defines the texture format to use
  63381. * @param scene defines the hosting scene
  63382. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63383. * @param invertY defines if texture must be stored with Y axis inverted
  63384. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63385. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63386. */
  63387. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63388. /** Gets or sets the texture format to use */
  63389. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63390. /**
  63391. * Update the texture with new data
  63392. * @param data defines the data to store in the texture
  63393. */
  63394. update(data: ArrayBufferView): void;
  63395. }
  63396. }
  63397. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63398. import { Scene } from "babylonjs/scene";
  63399. import { Texture } from "babylonjs/Materials/Textures/texture";
  63400. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63401. /**
  63402. * Class used to store 3D textures containing user data
  63403. */
  63404. export class RawTexture3D extends Texture {
  63405. /** Gets or sets the texture format to use */
  63406. format: number;
  63407. /**
  63408. * Create a new RawTexture3D
  63409. * @param data defines the data of the texture
  63410. * @param width defines the width of the texture
  63411. * @param height defines the height of the texture
  63412. * @param depth defines the depth of the texture
  63413. * @param format defines the texture format to use
  63414. * @param scene defines the hosting scene
  63415. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63416. * @param invertY defines if texture must be stored with Y axis inverted
  63417. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63418. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63419. */
  63420. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63421. /** Gets or sets the texture format to use */
  63422. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63423. /**
  63424. * Update the texture with new data
  63425. * @param data defines the data to store in the texture
  63426. */
  63427. update(data: ArrayBufferView): void;
  63428. }
  63429. }
  63430. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63431. import { Scene } from "babylonjs/scene";
  63432. import { Plane } from "babylonjs/Maths/math.plane";
  63433. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63434. /**
  63435. * Creates a refraction texture used by refraction channel of the standard material.
  63436. * It is like a mirror but to see through a material.
  63437. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63438. */
  63439. export class RefractionTexture extends RenderTargetTexture {
  63440. /**
  63441. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63442. * 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.
  63443. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63444. */
  63445. refractionPlane: Plane;
  63446. /**
  63447. * Define how deep under the surface we should see.
  63448. */
  63449. depth: number;
  63450. /**
  63451. * Creates a refraction texture used by refraction channel of the standard material.
  63452. * It is like a mirror but to see through a material.
  63453. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63454. * @param name Define the texture name
  63455. * @param size Define the size of the underlying texture
  63456. * @param scene Define the scene the refraction belongs to
  63457. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63458. */
  63459. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63460. /**
  63461. * Clone the refraction texture.
  63462. * @returns the cloned texture
  63463. */
  63464. clone(): RefractionTexture;
  63465. /**
  63466. * Serialize the texture to a JSON representation you could use in Parse later on
  63467. * @returns the serialized JSON representation
  63468. */
  63469. serialize(): any;
  63470. }
  63471. }
  63472. declare module "babylonjs/Materials/Textures/index" {
  63473. export * from "babylonjs/Materials/Textures/baseTexture";
  63474. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  63475. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  63476. export * from "babylonjs/Materials/Textures/cubeTexture";
  63477. export * from "babylonjs/Materials/Textures/dynamicTexture";
  63478. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63479. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  63480. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  63481. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  63482. export * from "babylonjs/Materials/Textures/internalTexture";
  63483. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  63484. export * from "babylonjs/Materials/Textures/Loaders/index";
  63485. export * from "babylonjs/Materials/Textures/mirrorTexture";
  63486. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  63487. export * from "babylonjs/Materials/Textures/Packer/index";
  63488. export * from "babylonjs/Materials/Textures/Procedurals/index";
  63489. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  63490. export * from "babylonjs/Materials/Textures/rawTexture";
  63491. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  63492. export * from "babylonjs/Materials/Textures/rawTexture3D";
  63493. export * from "babylonjs/Materials/Textures/refractionTexture";
  63494. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  63495. export * from "babylonjs/Materials/Textures/texture";
  63496. export * from "babylonjs/Materials/Textures/videoTexture";
  63497. }
  63498. declare module "babylonjs/Materials/Node/Enums/index" {
  63499. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  63500. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  63501. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  63502. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  63503. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  63504. }
  63505. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  63506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63507. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63509. import { Mesh } from "babylonjs/Meshes/mesh";
  63510. import { Effect } from "babylonjs/Materials/effect";
  63511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63512. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63513. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63514. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63515. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63516. /**
  63517. * Block used to add support for vertex skinning (bones)
  63518. */
  63519. export class BonesBlock extends NodeMaterialBlock {
  63520. /**
  63521. * Creates a new BonesBlock
  63522. * @param name defines the block name
  63523. */
  63524. constructor(name: string);
  63525. /**
  63526. * Initialize the block and prepare the context for build
  63527. * @param state defines the state that will be used for the build
  63528. */
  63529. initialize(state: NodeMaterialBuildState): void;
  63530. /**
  63531. * Gets the current class name
  63532. * @returns the class name
  63533. */
  63534. getClassName(): string;
  63535. /**
  63536. * Gets the matrix indices input component
  63537. */
  63538. get matricesIndices(): NodeMaterialConnectionPoint;
  63539. /**
  63540. * Gets the matrix weights input component
  63541. */
  63542. get matricesWeights(): NodeMaterialConnectionPoint;
  63543. /**
  63544. * Gets the extra matrix indices input component
  63545. */
  63546. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63547. /**
  63548. * Gets the extra matrix weights input component
  63549. */
  63550. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63551. /**
  63552. * Gets the world input component
  63553. */
  63554. get world(): NodeMaterialConnectionPoint;
  63555. /**
  63556. * Gets the output component
  63557. */
  63558. get output(): NodeMaterialConnectionPoint;
  63559. autoConfigure(material: NodeMaterial): void;
  63560. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63561. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63562. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63563. protected _buildBlock(state: NodeMaterialBuildState): this;
  63564. }
  63565. }
  63566. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  63567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63571. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63572. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63573. /**
  63574. * Block used to add support for instances
  63575. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63576. */
  63577. export class InstancesBlock extends NodeMaterialBlock {
  63578. /**
  63579. * Creates a new InstancesBlock
  63580. * @param name defines the block name
  63581. */
  63582. constructor(name: string);
  63583. /**
  63584. * Gets the current class name
  63585. * @returns the class name
  63586. */
  63587. getClassName(): string;
  63588. /**
  63589. * Gets the first world row input component
  63590. */
  63591. get world0(): NodeMaterialConnectionPoint;
  63592. /**
  63593. * Gets the second world row input component
  63594. */
  63595. get world1(): NodeMaterialConnectionPoint;
  63596. /**
  63597. * Gets the third world row input component
  63598. */
  63599. get world2(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the forth world row input component
  63602. */
  63603. get world3(): NodeMaterialConnectionPoint;
  63604. /**
  63605. * Gets the world input component
  63606. */
  63607. get world(): NodeMaterialConnectionPoint;
  63608. /**
  63609. * Gets the output component
  63610. */
  63611. get output(): NodeMaterialConnectionPoint;
  63612. /**
  63613. * Gets the isntanceID component
  63614. */
  63615. get instanceID(): NodeMaterialConnectionPoint;
  63616. autoConfigure(material: NodeMaterial): void;
  63617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63618. protected _buildBlock(state: NodeMaterialBuildState): this;
  63619. }
  63620. }
  63621. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  63622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63623. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63626. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63627. import { Effect } from "babylonjs/Materials/effect";
  63628. import { Mesh } from "babylonjs/Meshes/mesh";
  63629. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63630. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63631. /**
  63632. * Block used to add morph targets support to vertex shader
  63633. */
  63634. export class MorphTargetsBlock extends NodeMaterialBlock {
  63635. private _repeatableContentAnchor;
  63636. /**
  63637. * Create a new MorphTargetsBlock
  63638. * @param name defines the block name
  63639. */
  63640. constructor(name: string);
  63641. /**
  63642. * Gets the current class name
  63643. * @returns the class name
  63644. */
  63645. getClassName(): string;
  63646. /**
  63647. * Gets the position input component
  63648. */
  63649. get position(): NodeMaterialConnectionPoint;
  63650. /**
  63651. * Gets the normal input component
  63652. */
  63653. get normal(): NodeMaterialConnectionPoint;
  63654. /**
  63655. * Gets the tangent input component
  63656. */
  63657. get tangent(): NodeMaterialConnectionPoint;
  63658. /**
  63659. * Gets the tangent input component
  63660. */
  63661. get uv(): NodeMaterialConnectionPoint;
  63662. /**
  63663. * Gets the position output component
  63664. */
  63665. get positionOutput(): NodeMaterialConnectionPoint;
  63666. /**
  63667. * Gets the normal output component
  63668. */
  63669. get normalOutput(): NodeMaterialConnectionPoint;
  63670. /**
  63671. * Gets the tangent output component
  63672. */
  63673. get tangentOutput(): NodeMaterialConnectionPoint;
  63674. /**
  63675. * Gets the tangent output component
  63676. */
  63677. get uvOutput(): NodeMaterialConnectionPoint;
  63678. initialize(state: NodeMaterialBuildState): void;
  63679. autoConfigure(material: NodeMaterial): void;
  63680. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63681. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63682. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63683. protected _buildBlock(state: NodeMaterialBuildState): this;
  63684. }
  63685. }
  63686. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  63687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63690. import { Nullable } from "babylonjs/types";
  63691. import { Scene } from "babylonjs/scene";
  63692. import { Effect } from "babylonjs/Materials/effect";
  63693. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63694. import { Mesh } from "babylonjs/Meshes/mesh";
  63695. import { Light } from "babylonjs/Lights/light";
  63696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63697. /**
  63698. * Block used to get data information from a light
  63699. */
  63700. export class LightInformationBlock extends NodeMaterialBlock {
  63701. private _lightDataUniformName;
  63702. private _lightColorUniformName;
  63703. private _lightTypeDefineName;
  63704. /**
  63705. * Gets or sets the light associated with this block
  63706. */
  63707. light: Nullable<Light>;
  63708. /**
  63709. * Creates a new LightInformationBlock
  63710. * @param name defines the block name
  63711. */
  63712. constructor(name: string);
  63713. /**
  63714. * Gets the current class name
  63715. * @returns the class name
  63716. */
  63717. getClassName(): string;
  63718. /**
  63719. * Gets the world position input component
  63720. */
  63721. get worldPosition(): NodeMaterialConnectionPoint;
  63722. /**
  63723. * Gets the direction output component
  63724. */
  63725. get direction(): NodeMaterialConnectionPoint;
  63726. /**
  63727. * Gets the direction output component
  63728. */
  63729. get color(): NodeMaterialConnectionPoint;
  63730. /**
  63731. * Gets the direction output component
  63732. */
  63733. get intensity(): NodeMaterialConnectionPoint;
  63734. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63736. protected _buildBlock(state: NodeMaterialBuildState): this;
  63737. serialize(): any;
  63738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63739. }
  63740. }
  63741. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  63742. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  63743. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  63744. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  63745. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  63746. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  63747. }
  63748. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  63749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63750. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63751. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63753. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63754. import { Effect } from "babylonjs/Materials/effect";
  63755. import { Mesh } from "babylonjs/Meshes/mesh";
  63756. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63757. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63758. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63759. /**
  63760. * Block used to add image processing support to fragment shader
  63761. */
  63762. export class ImageProcessingBlock extends NodeMaterialBlock {
  63763. /**
  63764. * Create a new ImageProcessingBlock
  63765. * @param name defines the block name
  63766. */
  63767. constructor(name: string);
  63768. /**
  63769. * Gets the current class name
  63770. * @returns the class name
  63771. */
  63772. getClassName(): string;
  63773. /**
  63774. * Gets the color input component
  63775. */
  63776. get color(): NodeMaterialConnectionPoint;
  63777. /**
  63778. * Gets the output component
  63779. */
  63780. get output(): NodeMaterialConnectionPoint;
  63781. /**
  63782. * Initialize the block and prepare the context for build
  63783. * @param state defines the state that will be used for the build
  63784. */
  63785. initialize(state: NodeMaterialBuildState): void;
  63786. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63789. protected _buildBlock(state: NodeMaterialBuildState): this;
  63790. }
  63791. }
  63792. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  63793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63796. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63798. import { Effect } from "babylonjs/Materials/effect";
  63799. import { Mesh } from "babylonjs/Meshes/mesh";
  63800. import { Scene } from "babylonjs/scene";
  63801. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  63802. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  63803. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  63804. /**
  63805. * Block used to pertub normals based on a normal map
  63806. */
  63807. export class PerturbNormalBlock extends NodeMaterialBlock {
  63808. private _tangentSpaceParameterName;
  63809. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63810. invertX: boolean;
  63811. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63812. invertY: boolean;
  63813. /**
  63814. * Create a new PerturbNormalBlock
  63815. * @param name defines the block name
  63816. */
  63817. constructor(name: string);
  63818. /**
  63819. * Gets the current class name
  63820. * @returns the class name
  63821. */
  63822. getClassName(): string;
  63823. /**
  63824. * Gets the world position input component
  63825. */
  63826. get worldPosition(): NodeMaterialConnectionPoint;
  63827. /**
  63828. * Gets the world normal input component
  63829. */
  63830. get worldNormal(): NodeMaterialConnectionPoint;
  63831. /**
  63832. * Gets the world tangent input component
  63833. */
  63834. get worldTangent(): NodeMaterialConnectionPoint;
  63835. /**
  63836. * Gets the uv input component
  63837. */
  63838. get uv(): NodeMaterialConnectionPoint;
  63839. /**
  63840. * Gets the normal map color input component
  63841. */
  63842. get normalMapColor(): NodeMaterialConnectionPoint;
  63843. /**
  63844. * Gets the strength input component
  63845. */
  63846. get strength(): NodeMaterialConnectionPoint;
  63847. /**
  63848. * Gets the output component
  63849. */
  63850. get output(): NodeMaterialConnectionPoint;
  63851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63852. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63853. autoConfigure(material: NodeMaterial): void;
  63854. protected _buildBlock(state: NodeMaterialBuildState): this;
  63855. protected _dumpPropertiesCode(): string;
  63856. serialize(): any;
  63857. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63858. }
  63859. }
  63860. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  63861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63864. /**
  63865. * Block used to discard a pixel if a value is smaller than a cutoff
  63866. */
  63867. export class DiscardBlock extends NodeMaterialBlock {
  63868. /**
  63869. * Create a new DiscardBlock
  63870. * @param name defines the block name
  63871. */
  63872. constructor(name: string);
  63873. /**
  63874. * Gets the current class name
  63875. * @returns the class name
  63876. */
  63877. getClassName(): string;
  63878. /**
  63879. * Gets the color input component
  63880. */
  63881. get value(): NodeMaterialConnectionPoint;
  63882. /**
  63883. * Gets the cutoff input component
  63884. */
  63885. get cutoff(): NodeMaterialConnectionPoint;
  63886. protected _buildBlock(state: NodeMaterialBuildState): this;
  63887. }
  63888. }
  63889. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  63890. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63891. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63892. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63893. /**
  63894. * Block used to test if the fragment shader is front facing
  63895. */
  63896. export class FrontFacingBlock extends NodeMaterialBlock {
  63897. /**
  63898. * Creates a new FrontFacingBlock
  63899. * @param name defines the block name
  63900. */
  63901. constructor(name: string);
  63902. /**
  63903. * Gets the current class name
  63904. * @returns the class name
  63905. */
  63906. getClassName(): string;
  63907. /**
  63908. * Gets the output component
  63909. */
  63910. get output(): NodeMaterialConnectionPoint;
  63911. protected _buildBlock(state: NodeMaterialBuildState): this;
  63912. }
  63913. }
  63914. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  63915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63918. /**
  63919. * Block used to get the derivative value on x and y of a given input
  63920. */
  63921. export class DerivativeBlock extends NodeMaterialBlock {
  63922. /**
  63923. * Create a new DerivativeBlock
  63924. * @param name defines the block name
  63925. */
  63926. constructor(name: string);
  63927. /**
  63928. * Gets the current class name
  63929. * @returns the class name
  63930. */
  63931. getClassName(): string;
  63932. /**
  63933. * Gets the input component
  63934. */
  63935. get input(): NodeMaterialConnectionPoint;
  63936. /**
  63937. * Gets the derivative output on x
  63938. */
  63939. get dx(): NodeMaterialConnectionPoint;
  63940. /**
  63941. * Gets the derivative output on y
  63942. */
  63943. get dy(): NodeMaterialConnectionPoint;
  63944. protected _buildBlock(state: NodeMaterialBuildState): this;
  63945. }
  63946. }
  63947. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  63948. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  63949. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  63950. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  63951. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  63952. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  63953. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  63954. }
  63955. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  63956. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63957. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63958. import { Mesh } from "babylonjs/Meshes/mesh";
  63959. import { Effect } from "babylonjs/Materials/effect";
  63960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63962. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63963. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  63964. /**
  63965. * Block used to add support for scene fog
  63966. */
  63967. export class FogBlock extends NodeMaterialBlock {
  63968. private _fogDistanceName;
  63969. private _fogParameters;
  63970. /**
  63971. * Create a new FogBlock
  63972. * @param name defines the block name
  63973. */
  63974. constructor(name: string);
  63975. /**
  63976. * Gets the current class name
  63977. * @returns the class name
  63978. */
  63979. getClassName(): string;
  63980. /**
  63981. * Gets the world position input component
  63982. */
  63983. get worldPosition(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the view input component
  63986. */
  63987. get view(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the color input component
  63990. */
  63991. get input(): NodeMaterialConnectionPoint;
  63992. /**
  63993. * Gets the fog color input component
  63994. */
  63995. get fogColor(): NodeMaterialConnectionPoint;
  63996. /**
  63997. * Gets the output component
  63998. */
  63999. get output(): NodeMaterialConnectionPoint;
  64000. autoConfigure(material: NodeMaterial): void;
  64001. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64003. protected _buildBlock(state: NodeMaterialBuildState): this;
  64004. }
  64005. }
  64006. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64008. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64009. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64011. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64012. import { Effect } from "babylonjs/Materials/effect";
  64013. import { Mesh } from "babylonjs/Meshes/mesh";
  64014. import { Light } from "babylonjs/Lights/light";
  64015. import { Nullable } from "babylonjs/types";
  64016. import { Scene } from "babylonjs/scene";
  64017. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64018. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64019. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64020. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64021. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64022. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64023. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64024. /**
  64025. * Block used to add light in the fragment shader
  64026. */
  64027. export class LightBlock extends NodeMaterialBlock {
  64028. private _lightId;
  64029. /**
  64030. * Gets or sets the light associated with this block
  64031. */
  64032. light: Nullable<Light>;
  64033. /**
  64034. * Create a new LightBlock
  64035. * @param name defines the block name
  64036. */
  64037. constructor(name: string);
  64038. /**
  64039. * Gets the current class name
  64040. * @returns the class name
  64041. */
  64042. getClassName(): string;
  64043. /**
  64044. * Gets the world position input component
  64045. */
  64046. get worldPosition(): NodeMaterialConnectionPoint;
  64047. /**
  64048. * Gets the world normal input component
  64049. */
  64050. get worldNormal(): NodeMaterialConnectionPoint;
  64051. /**
  64052. * Gets the camera (or eye) position component
  64053. */
  64054. get cameraPosition(): NodeMaterialConnectionPoint;
  64055. /**
  64056. * Gets the glossiness component
  64057. */
  64058. get glossiness(): NodeMaterialConnectionPoint;
  64059. /**
  64060. * Gets the glossinness power component
  64061. */
  64062. get glossPower(): NodeMaterialConnectionPoint;
  64063. /**
  64064. * Gets the diffuse color component
  64065. */
  64066. get diffuseColor(): NodeMaterialConnectionPoint;
  64067. /**
  64068. * Gets the specular color component
  64069. */
  64070. get specularColor(): NodeMaterialConnectionPoint;
  64071. /**
  64072. * Gets the diffuse output component
  64073. */
  64074. get diffuseOutput(): NodeMaterialConnectionPoint;
  64075. /**
  64076. * Gets the specular output component
  64077. */
  64078. get specularOutput(): NodeMaterialConnectionPoint;
  64079. /**
  64080. * Gets the shadow output component
  64081. */
  64082. get shadow(): NodeMaterialConnectionPoint;
  64083. autoConfigure(material: NodeMaterial): void;
  64084. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64085. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64086. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64087. private _injectVertexCode;
  64088. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64089. serialize(): any;
  64090. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64091. }
  64092. }
  64093. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64096. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64097. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64098. /**
  64099. * Block used to read a reflection texture from a sampler
  64100. */
  64101. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64102. /**
  64103. * Create a new ReflectionTextureBlock
  64104. * @param name defines the block name
  64105. */
  64106. constructor(name: string);
  64107. /**
  64108. * Gets the current class name
  64109. * @returns the class name
  64110. */
  64111. getClassName(): string;
  64112. /**
  64113. * Gets the world position input component
  64114. */
  64115. get position(): NodeMaterialConnectionPoint;
  64116. /**
  64117. * Gets the world position input component
  64118. */
  64119. get worldPosition(): NodeMaterialConnectionPoint;
  64120. /**
  64121. * Gets the world normal input component
  64122. */
  64123. get worldNormal(): NodeMaterialConnectionPoint;
  64124. /**
  64125. * Gets the world input component
  64126. */
  64127. get world(): NodeMaterialConnectionPoint;
  64128. /**
  64129. * Gets the camera (or eye) position component
  64130. */
  64131. get cameraPosition(): NodeMaterialConnectionPoint;
  64132. /**
  64133. * Gets the view input component
  64134. */
  64135. get view(): NodeMaterialConnectionPoint;
  64136. /**
  64137. * Gets the rgb output component
  64138. */
  64139. get rgb(): NodeMaterialConnectionPoint;
  64140. /**
  64141. * Gets the r output component
  64142. */
  64143. get r(): NodeMaterialConnectionPoint;
  64144. /**
  64145. * Gets the g output component
  64146. */
  64147. get g(): NodeMaterialConnectionPoint;
  64148. /**
  64149. * Gets the b output component
  64150. */
  64151. get b(): NodeMaterialConnectionPoint;
  64152. autoConfigure(material: NodeMaterial): void;
  64153. protected _buildBlock(state: NodeMaterialBuildState): this;
  64154. }
  64155. }
  64156. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64157. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64158. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64159. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64160. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64161. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64162. }
  64163. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64164. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64165. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64166. }
  64167. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64171. /**
  64172. * Block used to add 2 vectors
  64173. */
  64174. export class AddBlock extends NodeMaterialBlock {
  64175. /**
  64176. * Creates a new AddBlock
  64177. * @param name defines the block name
  64178. */
  64179. constructor(name: string);
  64180. /**
  64181. * Gets the current class name
  64182. * @returns the class name
  64183. */
  64184. getClassName(): string;
  64185. /**
  64186. * Gets the left operand input component
  64187. */
  64188. get left(): NodeMaterialConnectionPoint;
  64189. /**
  64190. * Gets the right operand input component
  64191. */
  64192. get right(): NodeMaterialConnectionPoint;
  64193. /**
  64194. * Gets the output component
  64195. */
  64196. get output(): NodeMaterialConnectionPoint;
  64197. protected _buildBlock(state: NodeMaterialBuildState): this;
  64198. }
  64199. }
  64200. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64201. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64202. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64203. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64204. /**
  64205. * Block used to scale a vector by a float
  64206. */
  64207. export class ScaleBlock extends NodeMaterialBlock {
  64208. /**
  64209. * Creates a new ScaleBlock
  64210. * @param name defines the block name
  64211. */
  64212. constructor(name: string);
  64213. /**
  64214. * Gets the current class name
  64215. * @returns the class name
  64216. */
  64217. getClassName(): string;
  64218. /**
  64219. * Gets the input component
  64220. */
  64221. get input(): NodeMaterialConnectionPoint;
  64222. /**
  64223. * Gets the factor input component
  64224. */
  64225. get factor(): NodeMaterialConnectionPoint;
  64226. /**
  64227. * Gets the output component
  64228. */
  64229. get output(): NodeMaterialConnectionPoint;
  64230. protected _buildBlock(state: NodeMaterialBuildState): this;
  64231. }
  64232. }
  64233. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64237. import { Scene } from "babylonjs/scene";
  64238. /**
  64239. * Block used to clamp a float
  64240. */
  64241. export class ClampBlock extends NodeMaterialBlock {
  64242. /** Gets or sets the minimum range */
  64243. minimum: number;
  64244. /** Gets or sets the maximum range */
  64245. maximum: number;
  64246. /**
  64247. * Creates a new ClampBlock
  64248. * @param name defines the block name
  64249. */
  64250. constructor(name: string);
  64251. /**
  64252. * Gets the current class name
  64253. * @returns the class name
  64254. */
  64255. getClassName(): string;
  64256. /**
  64257. * Gets the value input component
  64258. */
  64259. get value(): NodeMaterialConnectionPoint;
  64260. /**
  64261. * Gets the output component
  64262. */
  64263. get output(): NodeMaterialConnectionPoint;
  64264. protected _buildBlock(state: NodeMaterialBuildState): this;
  64265. protected _dumpPropertiesCode(): string;
  64266. serialize(): any;
  64267. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64268. }
  64269. }
  64270. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64274. /**
  64275. * Block used to apply a cross product between 2 vectors
  64276. */
  64277. export class CrossBlock extends NodeMaterialBlock {
  64278. /**
  64279. * Creates a new CrossBlock
  64280. * @param name defines the block name
  64281. */
  64282. constructor(name: string);
  64283. /**
  64284. * Gets the current class name
  64285. * @returns the class name
  64286. */
  64287. getClassName(): string;
  64288. /**
  64289. * Gets the left operand input component
  64290. */
  64291. get left(): NodeMaterialConnectionPoint;
  64292. /**
  64293. * Gets the right operand input component
  64294. */
  64295. get right(): NodeMaterialConnectionPoint;
  64296. /**
  64297. * Gets the output component
  64298. */
  64299. get output(): NodeMaterialConnectionPoint;
  64300. protected _buildBlock(state: NodeMaterialBuildState): this;
  64301. }
  64302. }
  64303. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64304. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64305. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64306. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64307. /**
  64308. * Block used to apply a dot product between 2 vectors
  64309. */
  64310. export class DotBlock extends NodeMaterialBlock {
  64311. /**
  64312. * Creates a new DotBlock
  64313. * @param name defines the block name
  64314. */
  64315. constructor(name: string);
  64316. /**
  64317. * Gets the current class name
  64318. * @returns the class name
  64319. */
  64320. getClassName(): string;
  64321. /**
  64322. * Gets the left operand input component
  64323. */
  64324. get left(): NodeMaterialConnectionPoint;
  64325. /**
  64326. * Gets the right operand input component
  64327. */
  64328. get right(): NodeMaterialConnectionPoint;
  64329. /**
  64330. * Gets the output component
  64331. */
  64332. get output(): NodeMaterialConnectionPoint;
  64333. protected _buildBlock(state: NodeMaterialBuildState): this;
  64334. }
  64335. }
  64336. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  64337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64340. /**
  64341. * Block used to normalize a vector
  64342. */
  64343. export class NormalizeBlock extends NodeMaterialBlock {
  64344. /**
  64345. * Creates a new NormalizeBlock
  64346. * @param name defines the block name
  64347. */
  64348. constructor(name: string);
  64349. /**
  64350. * Gets the current class name
  64351. * @returns the class name
  64352. */
  64353. getClassName(): string;
  64354. /**
  64355. * Gets the input component
  64356. */
  64357. get input(): NodeMaterialConnectionPoint;
  64358. /**
  64359. * Gets the output component
  64360. */
  64361. get output(): NodeMaterialConnectionPoint;
  64362. protected _buildBlock(state: NodeMaterialBuildState): this;
  64363. }
  64364. }
  64365. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  64366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64369. import { Scene } from "babylonjs/scene";
  64370. /**
  64371. * Operations supported by the Trigonometry block
  64372. */
  64373. export enum TrigonometryBlockOperations {
  64374. /** Cos */
  64375. Cos = 0,
  64376. /** Sin */
  64377. Sin = 1,
  64378. /** Abs */
  64379. Abs = 2,
  64380. /** Exp */
  64381. Exp = 3,
  64382. /** Exp2 */
  64383. Exp2 = 4,
  64384. /** Round */
  64385. Round = 5,
  64386. /** Floor */
  64387. Floor = 6,
  64388. /** Ceiling */
  64389. Ceiling = 7,
  64390. /** Square root */
  64391. Sqrt = 8,
  64392. /** Log */
  64393. Log = 9,
  64394. /** Tangent */
  64395. Tan = 10,
  64396. /** Arc tangent */
  64397. ArcTan = 11,
  64398. /** Arc cosinus */
  64399. ArcCos = 12,
  64400. /** Arc sinus */
  64401. ArcSin = 13,
  64402. /** Fraction */
  64403. Fract = 14,
  64404. /** Sign */
  64405. Sign = 15,
  64406. /** To radians (from degrees) */
  64407. Radians = 16,
  64408. /** To degrees (from radians) */
  64409. Degrees = 17
  64410. }
  64411. /**
  64412. * Block used to apply trigonometry operation to floats
  64413. */
  64414. export class TrigonometryBlock extends NodeMaterialBlock {
  64415. /**
  64416. * Gets or sets the operation applied by the block
  64417. */
  64418. operation: TrigonometryBlockOperations;
  64419. /**
  64420. * Creates a new TrigonometryBlock
  64421. * @param name defines the block name
  64422. */
  64423. constructor(name: string);
  64424. /**
  64425. * Gets the current class name
  64426. * @returns the class name
  64427. */
  64428. getClassName(): string;
  64429. /**
  64430. * Gets the input component
  64431. */
  64432. get input(): NodeMaterialConnectionPoint;
  64433. /**
  64434. * Gets the output component
  64435. */
  64436. get output(): NodeMaterialConnectionPoint;
  64437. protected _buildBlock(state: NodeMaterialBuildState): this;
  64438. serialize(): any;
  64439. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64440. protected _dumpPropertiesCode(): string;
  64441. }
  64442. }
  64443. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  64444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64447. /**
  64448. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64449. */
  64450. export class ColorMergerBlock extends NodeMaterialBlock {
  64451. /**
  64452. * Create a new ColorMergerBlock
  64453. * @param name defines the block name
  64454. */
  64455. constructor(name: string);
  64456. /**
  64457. * Gets the current class name
  64458. * @returns the class name
  64459. */
  64460. getClassName(): string;
  64461. /**
  64462. * Gets the rgb component (input)
  64463. */
  64464. get rgbIn(): NodeMaterialConnectionPoint;
  64465. /**
  64466. * Gets the r component (input)
  64467. */
  64468. get r(): NodeMaterialConnectionPoint;
  64469. /**
  64470. * Gets the g component (input)
  64471. */
  64472. get g(): NodeMaterialConnectionPoint;
  64473. /**
  64474. * Gets the b component (input)
  64475. */
  64476. get b(): NodeMaterialConnectionPoint;
  64477. /**
  64478. * Gets the a component (input)
  64479. */
  64480. get a(): NodeMaterialConnectionPoint;
  64481. /**
  64482. * Gets the rgba component (output)
  64483. */
  64484. get rgba(): NodeMaterialConnectionPoint;
  64485. /**
  64486. * Gets the rgb component (output)
  64487. */
  64488. get rgbOut(): NodeMaterialConnectionPoint;
  64489. /**
  64490. * Gets the rgb component (output)
  64491. * @deprecated Please use rgbOut instead.
  64492. */
  64493. get rgb(): NodeMaterialConnectionPoint;
  64494. protected _buildBlock(state: NodeMaterialBuildState): this;
  64495. }
  64496. }
  64497. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  64498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64501. /**
  64502. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64503. */
  64504. export class VectorSplitterBlock extends NodeMaterialBlock {
  64505. /**
  64506. * Create a new VectorSplitterBlock
  64507. * @param name defines the block name
  64508. */
  64509. constructor(name: string);
  64510. /**
  64511. * Gets the current class name
  64512. * @returns the class name
  64513. */
  64514. getClassName(): string;
  64515. /**
  64516. * Gets the xyzw component (input)
  64517. */
  64518. get xyzw(): NodeMaterialConnectionPoint;
  64519. /**
  64520. * Gets the xyz component (input)
  64521. */
  64522. get xyzIn(): NodeMaterialConnectionPoint;
  64523. /**
  64524. * Gets the xy component (input)
  64525. */
  64526. get xyIn(): NodeMaterialConnectionPoint;
  64527. /**
  64528. * Gets the xyz component (output)
  64529. */
  64530. get xyzOut(): NodeMaterialConnectionPoint;
  64531. /**
  64532. * Gets the xy component (output)
  64533. */
  64534. get xyOut(): NodeMaterialConnectionPoint;
  64535. /**
  64536. * Gets the x component (output)
  64537. */
  64538. get x(): NodeMaterialConnectionPoint;
  64539. /**
  64540. * Gets the y component (output)
  64541. */
  64542. get y(): NodeMaterialConnectionPoint;
  64543. /**
  64544. * Gets the z component (output)
  64545. */
  64546. get z(): NodeMaterialConnectionPoint;
  64547. /**
  64548. * Gets the w component (output)
  64549. */
  64550. get w(): NodeMaterialConnectionPoint;
  64551. protected _inputRename(name: string): string;
  64552. protected _outputRename(name: string): string;
  64553. protected _buildBlock(state: NodeMaterialBuildState): this;
  64554. }
  64555. }
  64556. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  64557. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64558. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64559. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64560. /**
  64561. * Block used to lerp between 2 values
  64562. */
  64563. export class LerpBlock extends NodeMaterialBlock {
  64564. /**
  64565. * Creates a new LerpBlock
  64566. * @param name defines the block name
  64567. */
  64568. constructor(name: string);
  64569. /**
  64570. * Gets the current class name
  64571. * @returns the class name
  64572. */
  64573. getClassName(): string;
  64574. /**
  64575. * Gets the left operand input component
  64576. */
  64577. get left(): NodeMaterialConnectionPoint;
  64578. /**
  64579. * Gets the right operand input component
  64580. */
  64581. get right(): NodeMaterialConnectionPoint;
  64582. /**
  64583. * Gets the gradient operand input component
  64584. */
  64585. get gradient(): NodeMaterialConnectionPoint;
  64586. /**
  64587. * Gets the output component
  64588. */
  64589. get output(): NodeMaterialConnectionPoint;
  64590. protected _buildBlock(state: NodeMaterialBuildState): this;
  64591. }
  64592. }
  64593. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  64594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64597. /**
  64598. * Block used to divide 2 vectors
  64599. */
  64600. export class DivideBlock extends NodeMaterialBlock {
  64601. /**
  64602. * Creates a new DivideBlock
  64603. * @param name defines the block name
  64604. */
  64605. constructor(name: string);
  64606. /**
  64607. * Gets the current class name
  64608. * @returns the class name
  64609. */
  64610. getClassName(): string;
  64611. /**
  64612. * Gets the left operand input component
  64613. */
  64614. get left(): NodeMaterialConnectionPoint;
  64615. /**
  64616. * Gets the right operand input component
  64617. */
  64618. get right(): NodeMaterialConnectionPoint;
  64619. /**
  64620. * Gets the output component
  64621. */
  64622. get output(): NodeMaterialConnectionPoint;
  64623. protected _buildBlock(state: NodeMaterialBuildState): this;
  64624. }
  64625. }
  64626. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  64627. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64628. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64630. /**
  64631. * Block used to subtract 2 vectors
  64632. */
  64633. export class SubtractBlock extends NodeMaterialBlock {
  64634. /**
  64635. * Creates a new SubtractBlock
  64636. * @param name defines the block name
  64637. */
  64638. constructor(name: string);
  64639. /**
  64640. * Gets the current class name
  64641. * @returns the class name
  64642. */
  64643. getClassName(): string;
  64644. /**
  64645. * Gets the left operand input component
  64646. */
  64647. get left(): NodeMaterialConnectionPoint;
  64648. /**
  64649. * Gets the right operand input component
  64650. */
  64651. get right(): NodeMaterialConnectionPoint;
  64652. /**
  64653. * Gets the output component
  64654. */
  64655. get output(): NodeMaterialConnectionPoint;
  64656. protected _buildBlock(state: NodeMaterialBuildState): this;
  64657. }
  64658. }
  64659. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  64660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64662. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64663. /**
  64664. * Block used to step a value
  64665. */
  64666. export class StepBlock extends NodeMaterialBlock {
  64667. /**
  64668. * Creates a new StepBlock
  64669. * @param name defines the block name
  64670. */
  64671. constructor(name: string);
  64672. /**
  64673. * Gets the current class name
  64674. * @returns the class name
  64675. */
  64676. getClassName(): string;
  64677. /**
  64678. * Gets the value operand input component
  64679. */
  64680. get value(): NodeMaterialConnectionPoint;
  64681. /**
  64682. * Gets the edge operand input component
  64683. */
  64684. get edge(): NodeMaterialConnectionPoint;
  64685. /**
  64686. * Gets the output component
  64687. */
  64688. get output(): NodeMaterialConnectionPoint;
  64689. protected _buildBlock(state: NodeMaterialBuildState): this;
  64690. }
  64691. }
  64692. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  64693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64694. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64695. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64696. /**
  64697. * Block used to get the opposite (1 - x) of a value
  64698. */
  64699. export class OneMinusBlock extends NodeMaterialBlock {
  64700. /**
  64701. * Creates a new OneMinusBlock
  64702. * @param name defines the block name
  64703. */
  64704. constructor(name: string);
  64705. /**
  64706. * Gets the current class name
  64707. * @returns the class name
  64708. */
  64709. getClassName(): string;
  64710. /**
  64711. * Gets the input component
  64712. */
  64713. get input(): NodeMaterialConnectionPoint;
  64714. /**
  64715. * Gets the output component
  64716. */
  64717. get output(): NodeMaterialConnectionPoint;
  64718. protected _buildBlock(state: NodeMaterialBuildState): this;
  64719. }
  64720. }
  64721. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  64722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64724. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64725. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64726. /**
  64727. * Block used to get the view direction
  64728. */
  64729. export class ViewDirectionBlock extends NodeMaterialBlock {
  64730. /**
  64731. * Creates a new ViewDirectionBlock
  64732. * @param name defines the block name
  64733. */
  64734. constructor(name: string);
  64735. /**
  64736. * Gets the current class name
  64737. * @returns the class name
  64738. */
  64739. getClassName(): string;
  64740. /**
  64741. * Gets the world position component
  64742. */
  64743. get worldPosition(): NodeMaterialConnectionPoint;
  64744. /**
  64745. * Gets the camera position component
  64746. */
  64747. get cameraPosition(): NodeMaterialConnectionPoint;
  64748. /**
  64749. * Gets the output component
  64750. */
  64751. get output(): NodeMaterialConnectionPoint;
  64752. autoConfigure(material: NodeMaterial): void;
  64753. protected _buildBlock(state: NodeMaterialBuildState): this;
  64754. }
  64755. }
  64756. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  64757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64760. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64761. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  64762. /**
  64763. * Block used to compute fresnel value
  64764. */
  64765. export class FresnelBlock extends NodeMaterialBlock {
  64766. /**
  64767. * Create a new FresnelBlock
  64768. * @param name defines the block name
  64769. */
  64770. constructor(name: string);
  64771. /**
  64772. * Gets the current class name
  64773. * @returns the class name
  64774. */
  64775. getClassName(): string;
  64776. /**
  64777. * Gets the world normal input component
  64778. */
  64779. get worldNormal(): NodeMaterialConnectionPoint;
  64780. /**
  64781. * Gets the view direction input component
  64782. */
  64783. get viewDirection(): NodeMaterialConnectionPoint;
  64784. /**
  64785. * Gets the bias input component
  64786. */
  64787. get bias(): NodeMaterialConnectionPoint;
  64788. /**
  64789. * Gets the camera (or eye) position component
  64790. */
  64791. get power(): NodeMaterialConnectionPoint;
  64792. /**
  64793. * Gets the fresnel output component
  64794. */
  64795. get fresnel(): NodeMaterialConnectionPoint;
  64796. autoConfigure(material: NodeMaterial): void;
  64797. protected _buildBlock(state: NodeMaterialBuildState): this;
  64798. }
  64799. }
  64800. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  64801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64804. /**
  64805. * Block used to get the max of 2 values
  64806. */
  64807. export class MaxBlock extends NodeMaterialBlock {
  64808. /**
  64809. * Creates a new MaxBlock
  64810. * @param name defines the block name
  64811. */
  64812. constructor(name: string);
  64813. /**
  64814. * Gets the current class name
  64815. * @returns the class name
  64816. */
  64817. getClassName(): string;
  64818. /**
  64819. * Gets the left operand input component
  64820. */
  64821. get left(): NodeMaterialConnectionPoint;
  64822. /**
  64823. * Gets the right operand input component
  64824. */
  64825. get right(): NodeMaterialConnectionPoint;
  64826. /**
  64827. * Gets the output component
  64828. */
  64829. get output(): NodeMaterialConnectionPoint;
  64830. protected _buildBlock(state: NodeMaterialBuildState): this;
  64831. }
  64832. }
  64833. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  64834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64837. /**
  64838. * Block used to get the min of 2 values
  64839. */
  64840. export class MinBlock extends NodeMaterialBlock {
  64841. /**
  64842. * Creates a new MinBlock
  64843. * @param name defines the block name
  64844. */
  64845. constructor(name: string);
  64846. /**
  64847. * Gets the current class name
  64848. * @returns the class name
  64849. */
  64850. getClassName(): string;
  64851. /**
  64852. * Gets the left operand input component
  64853. */
  64854. get left(): NodeMaterialConnectionPoint;
  64855. /**
  64856. * Gets the right operand input component
  64857. */
  64858. get right(): NodeMaterialConnectionPoint;
  64859. /**
  64860. * Gets the output component
  64861. */
  64862. get output(): NodeMaterialConnectionPoint;
  64863. protected _buildBlock(state: NodeMaterialBuildState): this;
  64864. }
  64865. }
  64866. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  64867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64870. /**
  64871. * Block used to get the distance between 2 values
  64872. */
  64873. export class DistanceBlock extends NodeMaterialBlock {
  64874. /**
  64875. * Creates a new DistanceBlock
  64876. * @param name defines the block name
  64877. */
  64878. constructor(name: string);
  64879. /**
  64880. * Gets the current class name
  64881. * @returns the class name
  64882. */
  64883. getClassName(): string;
  64884. /**
  64885. * Gets the left operand input component
  64886. */
  64887. get left(): NodeMaterialConnectionPoint;
  64888. /**
  64889. * Gets the right operand input component
  64890. */
  64891. get right(): NodeMaterialConnectionPoint;
  64892. /**
  64893. * Gets the output component
  64894. */
  64895. get output(): NodeMaterialConnectionPoint;
  64896. protected _buildBlock(state: NodeMaterialBuildState): this;
  64897. }
  64898. }
  64899. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  64900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64903. /**
  64904. * Block used to get the length of a vector
  64905. */
  64906. export class LengthBlock extends NodeMaterialBlock {
  64907. /**
  64908. * Creates a new LengthBlock
  64909. * @param name defines the block name
  64910. */
  64911. constructor(name: string);
  64912. /**
  64913. * Gets the current class name
  64914. * @returns the class name
  64915. */
  64916. getClassName(): string;
  64917. /**
  64918. * Gets the value input component
  64919. */
  64920. get value(): NodeMaterialConnectionPoint;
  64921. /**
  64922. * Gets the output component
  64923. */
  64924. get output(): NodeMaterialConnectionPoint;
  64925. protected _buildBlock(state: NodeMaterialBuildState): this;
  64926. }
  64927. }
  64928. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  64929. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64930. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64932. /**
  64933. * Block used to get negative version of a value (i.e. x * -1)
  64934. */
  64935. export class NegateBlock extends NodeMaterialBlock {
  64936. /**
  64937. * Creates a new NegateBlock
  64938. * @param name defines the block name
  64939. */
  64940. constructor(name: string);
  64941. /**
  64942. * Gets the current class name
  64943. * @returns the class name
  64944. */
  64945. getClassName(): string;
  64946. /**
  64947. * Gets the value input component
  64948. */
  64949. get value(): NodeMaterialConnectionPoint;
  64950. /**
  64951. * Gets the output component
  64952. */
  64953. get output(): NodeMaterialConnectionPoint;
  64954. protected _buildBlock(state: NodeMaterialBuildState): this;
  64955. }
  64956. }
  64957. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  64958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64961. /**
  64962. * Block used to get the value of the first parameter raised to the power of the second
  64963. */
  64964. export class PowBlock extends NodeMaterialBlock {
  64965. /**
  64966. * Creates a new PowBlock
  64967. * @param name defines the block name
  64968. */
  64969. constructor(name: string);
  64970. /**
  64971. * Gets the current class name
  64972. * @returns the class name
  64973. */
  64974. getClassName(): string;
  64975. /**
  64976. * Gets the value operand input component
  64977. */
  64978. get value(): NodeMaterialConnectionPoint;
  64979. /**
  64980. * Gets the power operand input component
  64981. */
  64982. get power(): NodeMaterialConnectionPoint;
  64983. /**
  64984. * Gets the output component
  64985. */
  64986. get output(): NodeMaterialConnectionPoint;
  64987. protected _buildBlock(state: NodeMaterialBuildState): this;
  64988. }
  64989. }
  64990. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  64991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64994. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64995. /**
  64996. * Block used to get a random number
  64997. */
  64998. export class RandomNumberBlock extends NodeMaterialBlock {
  64999. /**
  65000. * Creates a new RandomNumberBlock
  65001. * @param name defines the block name
  65002. */
  65003. constructor(name: string);
  65004. /**
  65005. * Gets the current class name
  65006. * @returns the class name
  65007. */
  65008. getClassName(): string;
  65009. /**
  65010. * Gets the seed input component
  65011. */
  65012. get seed(): NodeMaterialConnectionPoint;
  65013. /**
  65014. * Gets the output component
  65015. */
  65016. get output(): NodeMaterialConnectionPoint;
  65017. protected _buildBlock(state: NodeMaterialBuildState): this;
  65018. }
  65019. }
  65020. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65024. /**
  65025. * Block used to compute arc tangent of 2 values
  65026. */
  65027. export class ArcTan2Block extends NodeMaterialBlock {
  65028. /**
  65029. * Creates a new ArcTan2Block
  65030. * @param name defines the block name
  65031. */
  65032. constructor(name: string);
  65033. /**
  65034. * Gets the current class name
  65035. * @returns the class name
  65036. */
  65037. getClassName(): string;
  65038. /**
  65039. * Gets the x operand input component
  65040. */
  65041. get x(): NodeMaterialConnectionPoint;
  65042. /**
  65043. * Gets the y operand input component
  65044. */
  65045. get y(): NodeMaterialConnectionPoint;
  65046. /**
  65047. * Gets the output component
  65048. */
  65049. get output(): NodeMaterialConnectionPoint;
  65050. protected _buildBlock(state: NodeMaterialBuildState): this;
  65051. }
  65052. }
  65053. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65057. /**
  65058. * Block used to smooth step a value
  65059. */
  65060. export class SmoothStepBlock extends NodeMaterialBlock {
  65061. /**
  65062. * Creates a new SmoothStepBlock
  65063. * @param name defines the block name
  65064. */
  65065. constructor(name: string);
  65066. /**
  65067. * Gets the current class name
  65068. * @returns the class name
  65069. */
  65070. getClassName(): string;
  65071. /**
  65072. * Gets the value operand input component
  65073. */
  65074. get value(): NodeMaterialConnectionPoint;
  65075. /**
  65076. * Gets the first edge operand input component
  65077. */
  65078. get edge0(): NodeMaterialConnectionPoint;
  65079. /**
  65080. * Gets the second edge operand input component
  65081. */
  65082. get edge1(): NodeMaterialConnectionPoint;
  65083. /**
  65084. * Gets the output component
  65085. */
  65086. get output(): NodeMaterialConnectionPoint;
  65087. protected _buildBlock(state: NodeMaterialBuildState): this;
  65088. }
  65089. }
  65090. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65092. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65093. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65094. /**
  65095. * Block used to get the reciprocal (1 / x) of a value
  65096. */
  65097. export class ReciprocalBlock extends NodeMaterialBlock {
  65098. /**
  65099. * Creates a new ReciprocalBlock
  65100. * @param name defines the block name
  65101. */
  65102. constructor(name: string);
  65103. /**
  65104. * Gets the current class name
  65105. * @returns the class name
  65106. */
  65107. getClassName(): string;
  65108. /**
  65109. * Gets the input component
  65110. */
  65111. get input(): NodeMaterialConnectionPoint;
  65112. /**
  65113. * Gets the output component
  65114. */
  65115. get output(): NodeMaterialConnectionPoint;
  65116. protected _buildBlock(state: NodeMaterialBuildState): this;
  65117. }
  65118. }
  65119. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65123. /**
  65124. * Block used to replace a color by another one
  65125. */
  65126. export class ReplaceColorBlock extends NodeMaterialBlock {
  65127. /**
  65128. * Creates a new ReplaceColorBlock
  65129. * @param name defines the block name
  65130. */
  65131. constructor(name: string);
  65132. /**
  65133. * Gets the current class name
  65134. * @returns the class name
  65135. */
  65136. getClassName(): string;
  65137. /**
  65138. * Gets the value input component
  65139. */
  65140. get value(): NodeMaterialConnectionPoint;
  65141. /**
  65142. * Gets the reference input component
  65143. */
  65144. get reference(): NodeMaterialConnectionPoint;
  65145. /**
  65146. * Gets the distance input component
  65147. */
  65148. get distance(): NodeMaterialConnectionPoint;
  65149. /**
  65150. * Gets the replacement input component
  65151. */
  65152. get replacement(): NodeMaterialConnectionPoint;
  65153. /**
  65154. * Gets the output component
  65155. */
  65156. get output(): NodeMaterialConnectionPoint;
  65157. protected _buildBlock(state: NodeMaterialBuildState): this;
  65158. }
  65159. }
  65160. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  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 posterize a value
  65166. * @see https://en.wikipedia.org/wiki/Posterization
  65167. */
  65168. export class PosterizeBlock extends NodeMaterialBlock {
  65169. /**
  65170. * Creates a new PosterizeBlock
  65171. * @param name defines the block name
  65172. */
  65173. constructor(name: string);
  65174. /**
  65175. * Gets the current class name
  65176. * @returns the class name
  65177. */
  65178. getClassName(): string;
  65179. /**
  65180. * Gets the value input component
  65181. */
  65182. get value(): NodeMaterialConnectionPoint;
  65183. /**
  65184. * Gets the steps input component
  65185. */
  65186. get steps(): NodeMaterialConnectionPoint;
  65187. /**
  65188. * Gets the output component
  65189. */
  65190. get output(): NodeMaterialConnectionPoint;
  65191. protected _buildBlock(state: NodeMaterialBuildState): this;
  65192. }
  65193. }
  65194. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65195. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65196. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65198. import { Scene } from "babylonjs/scene";
  65199. /**
  65200. * Operations supported by the Wave block
  65201. */
  65202. export enum WaveBlockKind {
  65203. /** SawTooth */
  65204. SawTooth = 0,
  65205. /** Square */
  65206. Square = 1,
  65207. /** Triangle */
  65208. Triangle = 2
  65209. }
  65210. /**
  65211. * Block used to apply wave operation to floats
  65212. */
  65213. export class WaveBlock extends NodeMaterialBlock {
  65214. /**
  65215. * Gets or sets the kibnd of wave to be applied by the block
  65216. */
  65217. kind: WaveBlockKind;
  65218. /**
  65219. * Creates a new WaveBlock
  65220. * @param name defines the block name
  65221. */
  65222. constructor(name: string);
  65223. /**
  65224. * Gets the current class name
  65225. * @returns the class name
  65226. */
  65227. getClassName(): string;
  65228. /**
  65229. * Gets the input component
  65230. */
  65231. get input(): NodeMaterialConnectionPoint;
  65232. /**
  65233. * Gets the output component
  65234. */
  65235. get output(): NodeMaterialConnectionPoint;
  65236. protected _buildBlock(state: NodeMaterialBuildState): this;
  65237. serialize(): any;
  65238. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65239. }
  65240. }
  65241. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65245. import { Color3 } from "babylonjs/Maths/math.color";
  65246. import { Scene } from "babylonjs/scene";
  65247. /**
  65248. * Class used to store a color step for the GradientBlock
  65249. */
  65250. export class GradientBlockColorStep {
  65251. /**
  65252. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65253. */
  65254. step: number;
  65255. /**
  65256. * Gets or sets the color associated with this step
  65257. */
  65258. color: Color3;
  65259. /**
  65260. * Creates a new GradientBlockColorStep
  65261. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65262. * @param color defines the color associated with this step
  65263. */
  65264. constructor(
  65265. /**
  65266. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65267. */
  65268. step: number,
  65269. /**
  65270. * Gets or sets the color associated with this step
  65271. */
  65272. color: Color3);
  65273. }
  65274. /**
  65275. * Block used to return a color from a gradient based on an input value between 0 and 1
  65276. */
  65277. export class GradientBlock extends NodeMaterialBlock {
  65278. /**
  65279. * Gets or sets the list of color steps
  65280. */
  65281. colorSteps: GradientBlockColorStep[];
  65282. /**
  65283. * Creates a new GradientBlock
  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 gradient input component
  65294. */
  65295. get gradient(): NodeMaterialConnectionPoint;
  65296. /**
  65297. * Gets the output component
  65298. */
  65299. get output(): NodeMaterialConnectionPoint;
  65300. private _writeColorConstant;
  65301. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65302. serialize(): any;
  65303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65304. protected _dumpPropertiesCode(): string;
  65305. }
  65306. }
  65307. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  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. /**
  65312. * Block used to normalize lerp between 2 values
  65313. */
  65314. export class NLerpBlock extends NodeMaterialBlock {
  65315. /**
  65316. * Creates a new NLerpBlock
  65317. * @param name defines the block name
  65318. */
  65319. constructor(name: string);
  65320. /**
  65321. * Gets the current class name
  65322. * @returns the class name
  65323. */
  65324. getClassName(): string;
  65325. /**
  65326. * Gets the left operand input component
  65327. */
  65328. get left(): NodeMaterialConnectionPoint;
  65329. /**
  65330. * Gets the right operand input component
  65331. */
  65332. get right(): NodeMaterialConnectionPoint;
  65333. /**
  65334. * Gets the gradient operand input component
  65335. */
  65336. get gradient(): NodeMaterialConnectionPoint;
  65337. /**
  65338. * Gets the output component
  65339. */
  65340. get output(): NodeMaterialConnectionPoint;
  65341. protected _buildBlock(state: NodeMaterialBuildState): this;
  65342. }
  65343. }
  65344. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  65345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65348. import { Scene } from "babylonjs/scene";
  65349. /**
  65350. * block used to Generate a Worley Noise 3D Noise Pattern
  65351. */
  65352. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65353. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65354. manhattanDistance: boolean;
  65355. /**
  65356. * Creates a new WorleyNoise3DBlock
  65357. * @param name defines the block name
  65358. */
  65359. constructor(name: string);
  65360. /**
  65361. * Gets the current class name
  65362. * @returns the class name
  65363. */
  65364. getClassName(): string;
  65365. /**
  65366. * Gets the seed input component
  65367. */
  65368. get seed(): NodeMaterialConnectionPoint;
  65369. /**
  65370. * Gets the jitter input component
  65371. */
  65372. get jitter(): NodeMaterialConnectionPoint;
  65373. /**
  65374. * Gets the output component
  65375. */
  65376. get output(): NodeMaterialConnectionPoint;
  65377. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65378. /**
  65379. * Exposes the properties to the UI?
  65380. */
  65381. protected _dumpPropertiesCode(): string;
  65382. /**
  65383. * Exposes the properties to the Seralize?
  65384. */
  65385. serialize(): any;
  65386. /**
  65387. * Exposes the properties to the deseralize?
  65388. */
  65389. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65390. }
  65391. }
  65392. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  65393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65396. /**
  65397. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65398. */
  65399. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65400. /**
  65401. * Creates a new SimplexPerlin3DBlock
  65402. * @param name defines the block name
  65403. */
  65404. constructor(name: string);
  65405. /**
  65406. * Gets the current class name
  65407. * @returns the class name
  65408. */
  65409. getClassName(): string;
  65410. /**
  65411. * Gets the seed operand input component
  65412. */
  65413. get seed(): NodeMaterialConnectionPoint;
  65414. /**
  65415. * Gets the output component
  65416. */
  65417. get output(): NodeMaterialConnectionPoint;
  65418. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65419. }
  65420. }
  65421. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  65422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65425. /**
  65426. * Block used to blend normals
  65427. */
  65428. export class NormalBlendBlock extends NodeMaterialBlock {
  65429. /**
  65430. * Creates a new NormalBlendBlock
  65431. * @param name defines the block name
  65432. */
  65433. constructor(name: string);
  65434. /**
  65435. * Gets the current class name
  65436. * @returns the class name
  65437. */
  65438. getClassName(): string;
  65439. /**
  65440. * Gets the first input component
  65441. */
  65442. get normalMap0(): NodeMaterialConnectionPoint;
  65443. /**
  65444. * Gets the second input component
  65445. */
  65446. get normalMap1(): NodeMaterialConnectionPoint;
  65447. /**
  65448. * Gets the output component
  65449. */
  65450. get output(): NodeMaterialConnectionPoint;
  65451. protected _buildBlock(state: NodeMaterialBuildState): this;
  65452. }
  65453. }
  65454. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  65455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65458. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65459. /**
  65460. * Block used to rotate a 2d vector by a given angle
  65461. */
  65462. export class Rotate2dBlock extends NodeMaterialBlock {
  65463. /**
  65464. * Creates a new Rotate2dBlock
  65465. * @param name defines the block name
  65466. */
  65467. constructor(name: string);
  65468. /**
  65469. * Gets the current class name
  65470. * @returns the class name
  65471. */
  65472. getClassName(): string;
  65473. /**
  65474. * Gets the input vector
  65475. */
  65476. get input(): NodeMaterialConnectionPoint;
  65477. /**
  65478. * Gets the input angle
  65479. */
  65480. get angle(): NodeMaterialConnectionPoint;
  65481. /**
  65482. * Gets the output component
  65483. */
  65484. get output(): NodeMaterialConnectionPoint;
  65485. autoConfigure(material: NodeMaterial): void;
  65486. protected _buildBlock(state: NodeMaterialBuildState): this;
  65487. }
  65488. }
  65489. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  65490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65492. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65493. /**
  65494. * Block used to get the reflected vector from a direction and a normal
  65495. */
  65496. export class ReflectBlock extends NodeMaterialBlock {
  65497. /**
  65498. * Creates a new ReflectBlock
  65499. * @param name defines the block name
  65500. */
  65501. constructor(name: string);
  65502. /**
  65503. * Gets the current class name
  65504. * @returns the class name
  65505. */
  65506. getClassName(): string;
  65507. /**
  65508. * Gets the incident component
  65509. */
  65510. get incident(): NodeMaterialConnectionPoint;
  65511. /**
  65512. * Gets the normal component
  65513. */
  65514. get normal(): NodeMaterialConnectionPoint;
  65515. /**
  65516. * Gets the output component
  65517. */
  65518. get output(): NodeMaterialConnectionPoint;
  65519. protected _buildBlock(state: NodeMaterialBuildState): this;
  65520. }
  65521. }
  65522. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  65523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65526. /**
  65527. * Block used to get the refracted vector from a direction and a normal
  65528. */
  65529. export class RefractBlock extends NodeMaterialBlock {
  65530. /**
  65531. * Creates a new RefractBlock
  65532. * @param name defines the block name
  65533. */
  65534. constructor(name: string);
  65535. /**
  65536. * Gets the current class name
  65537. * @returns the class name
  65538. */
  65539. getClassName(): string;
  65540. /**
  65541. * Gets the incident component
  65542. */
  65543. get incident(): NodeMaterialConnectionPoint;
  65544. /**
  65545. * Gets the normal component
  65546. */
  65547. get normal(): NodeMaterialConnectionPoint;
  65548. /**
  65549. * Gets the index of refraction component
  65550. */
  65551. get ior(): NodeMaterialConnectionPoint;
  65552. /**
  65553. * Gets the output component
  65554. */
  65555. get output(): NodeMaterialConnectionPoint;
  65556. protected _buildBlock(state: NodeMaterialBuildState): this;
  65557. }
  65558. }
  65559. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  65560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65563. /**
  65564. * Block used to desaturate a color
  65565. */
  65566. export class DesaturateBlock extends NodeMaterialBlock {
  65567. /**
  65568. * Creates a new DesaturateBlock
  65569. * @param name defines the block name
  65570. */
  65571. constructor(name: string);
  65572. /**
  65573. * Gets the current class name
  65574. * @returns the class name
  65575. */
  65576. getClassName(): string;
  65577. /**
  65578. * Gets the color operand input component
  65579. */
  65580. get color(): NodeMaterialConnectionPoint;
  65581. /**
  65582. * Gets the level operand input component
  65583. */
  65584. get level(): NodeMaterialConnectionPoint;
  65585. /**
  65586. * Gets the output component
  65587. */
  65588. get output(): NodeMaterialConnectionPoint;
  65589. protected _buildBlock(state: NodeMaterialBuildState): this;
  65590. }
  65591. }
  65592. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  65593. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65595. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65596. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65597. import { Nullable } from "babylonjs/types";
  65598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65599. import { Scene } from "babylonjs/scene";
  65600. /**
  65601. * Block used to implement the ambient occlusion module of the PBR material
  65602. */
  65603. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65604. /**
  65605. * Create a new AmbientOcclusionBlock
  65606. * @param name defines the block name
  65607. */
  65608. constructor(name: string);
  65609. /**
  65610. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65611. */
  65612. useAmbientInGrayScale: boolean;
  65613. /**
  65614. * Initialize the block and prepare the context for build
  65615. * @param state defines the state that will be used for the build
  65616. */
  65617. initialize(state: NodeMaterialBuildState): void;
  65618. /**
  65619. * Gets the current class name
  65620. * @returns the class name
  65621. */
  65622. getClassName(): string;
  65623. /**
  65624. * Gets the texture input component
  65625. */
  65626. get texture(): NodeMaterialConnectionPoint;
  65627. /**
  65628. * Gets the texture intensity component
  65629. */
  65630. get intensity(): NodeMaterialConnectionPoint;
  65631. /**
  65632. * Gets the direct light intensity input component
  65633. */
  65634. get directLightIntensity(): NodeMaterialConnectionPoint;
  65635. /**
  65636. * Gets the ambient occlusion object output component
  65637. */
  65638. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65639. /**
  65640. * Gets the main code of the block (fragment side)
  65641. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65642. * @returns the shader code
  65643. */
  65644. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65646. protected _buildBlock(state: NodeMaterialBuildState): this;
  65647. protected _dumpPropertiesCode(): string;
  65648. serialize(): any;
  65649. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65650. }
  65651. }
  65652. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  65653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65654. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65655. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65656. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65658. import { Nullable } from "babylonjs/types";
  65659. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65660. import { Mesh } from "babylonjs/Meshes/mesh";
  65661. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65662. import { Effect } from "babylonjs/Materials/effect";
  65663. import { Scene } from "babylonjs/scene";
  65664. /**
  65665. * Block used to implement the reflection module of the PBR material
  65666. */
  65667. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65668. /** @hidden */
  65669. _defineLODReflectionAlpha: string;
  65670. /** @hidden */
  65671. _defineLinearSpecularReflection: string;
  65672. private _vEnvironmentIrradianceName;
  65673. /** @hidden */
  65674. _vReflectionMicrosurfaceInfosName: string;
  65675. /** @hidden */
  65676. _vReflectionInfosName: string;
  65677. private _scene;
  65678. /**
  65679. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65680. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65681. * It's less burden on the user side in the editor part.
  65682. */
  65683. /** @hidden */
  65684. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65685. /** @hidden */
  65686. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65687. /** @hidden */
  65688. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65689. /**
  65690. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65691. * diffuse part of the IBL.
  65692. */
  65693. useSphericalHarmonics: boolean;
  65694. /**
  65695. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65696. */
  65697. forceIrradianceInFragment: boolean;
  65698. /**
  65699. * Create a new ReflectionBlock
  65700. * @param name defines the block name
  65701. */
  65702. constructor(name: string);
  65703. /**
  65704. * Gets the current class name
  65705. * @returns the class name
  65706. */
  65707. getClassName(): string;
  65708. /**
  65709. * Gets the position input component
  65710. */
  65711. get position(): NodeMaterialConnectionPoint;
  65712. /**
  65713. * Gets the world position input component
  65714. */
  65715. get worldPosition(): NodeMaterialConnectionPoint;
  65716. /**
  65717. * Gets the world normal input component
  65718. */
  65719. get worldNormal(): NodeMaterialConnectionPoint;
  65720. /**
  65721. * Gets the world input component
  65722. */
  65723. get world(): NodeMaterialConnectionPoint;
  65724. /**
  65725. * Gets the camera (or eye) position component
  65726. */
  65727. get cameraPosition(): NodeMaterialConnectionPoint;
  65728. /**
  65729. * Gets the view input component
  65730. */
  65731. get view(): NodeMaterialConnectionPoint;
  65732. /**
  65733. * Gets the color input component
  65734. */
  65735. get color(): NodeMaterialConnectionPoint;
  65736. /**
  65737. * Gets the reflection object output component
  65738. */
  65739. get reflection(): NodeMaterialConnectionPoint;
  65740. /**
  65741. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65742. */
  65743. get hasTexture(): boolean;
  65744. /**
  65745. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65746. */
  65747. get reflectionColor(): string;
  65748. protected _getTexture(): Nullable<BaseTexture>;
  65749. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65750. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65751. /**
  65752. * Gets the code to inject in the vertex shader
  65753. * @param state current state of the node material building
  65754. * @returns the shader code
  65755. */
  65756. handleVertexSide(state: NodeMaterialBuildState): string;
  65757. /**
  65758. * Gets the main code of the block (fragment side)
  65759. * @param state current state of the node material building
  65760. * @param normalVarName name of the existing variable corresponding to the normal
  65761. * @returns the shader code
  65762. */
  65763. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65764. protected _buildBlock(state: NodeMaterialBuildState): this;
  65765. protected _dumpPropertiesCode(): string;
  65766. serialize(): any;
  65767. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65768. }
  65769. }
  65770. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  65771. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65772. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65773. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65774. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65776. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65777. import { Scene } from "babylonjs/scene";
  65778. import { Nullable } from "babylonjs/types";
  65779. /**
  65780. * Block used to implement the sheen module of the PBR material
  65781. */
  65782. export class SheenBlock extends NodeMaterialBlock {
  65783. /**
  65784. * Create a new SheenBlock
  65785. * @param name defines the block name
  65786. */
  65787. constructor(name: string);
  65788. /**
  65789. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65790. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65791. * making it easier to setup and tweak the effect
  65792. */
  65793. albedoScaling: boolean;
  65794. /**
  65795. * Defines if the sheen is linked to the sheen color.
  65796. */
  65797. linkSheenWithAlbedo: boolean;
  65798. /**
  65799. * Initialize the block and prepare the context for build
  65800. * @param state defines the state that will be used for the build
  65801. */
  65802. initialize(state: NodeMaterialBuildState): void;
  65803. /**
  65804. * Gets the current class name
  65805. * @returns the class name
  65806. */
  65807. getClassName(): string;
  65808. /**
  65809. * Gets the intensity input component
  65810. */
  65811. get intensity(): NodeMaterialConnectionPoint;
  65812. /**
  65813. * Gets the color input component
  65814. */
  65815. get color(): NodeMaterialConnectionPoint;
  65816. /**
  65817. * Gets the roughness input component
  65818. */
  65819. get roughness(): NodeMaterialConnectionPoint;
  65820. /**
  65821. * Gets the texture input component
  65822. */
  65823. get texture(): NodeMaterialConnectionPoint;
  65824. /**
  65825. * Gets the sheen object output component
  65826. */
  65827. get sheen(): NodeMaterialConnectionPoint;
  65828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65829. /**
  65830. * Gets the main code of the block (fragment side)
  65831. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65832. * @returns the shader code
  65833. */
  65834. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65835. protected _buildBlock(state: NodeMaterialBuildState): this;
  65836. protected _dumpPropertiesCode(): string;
  65837. serialize(): any;
  65838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65839. }
  65840. }
  65841. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  65842. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65843. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65847. import { Scene } from "babylonjs/scene";
  65848. /**
  65849. * Block used to implement the reflectivity module of the PBR material
  65850. */
  65851. export class ReflectivityBlock extends NodeMaterialBlock {
  65852. /**
  65853. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65854. */
  65855. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65856. /**
  65857. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65858. */
  65859. useMetallnessFromMetallicTextureBlue: boolean;
  65860. /**
  65861. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65862. */
  65863. useRoughnessFromMetallicTextureAlpha: boolean;
  65864. /**
  65865. * Specifies if the metallic texture contains the roughness information in its green channel.
  65866. */
  65867. useRoughnessFromMetallicTextureGreen: boolean;
  65868. /**
  65869. * Create a new ReflectivityBlock
  65870. * @param name defines the block name
  65871. */
  65872. constructor(name: string);
  65873. /**
  65874. * Initialize the block and prepare the context for build
  65875. * @param state defines the state that will be used for the build
  65876. */
  65877. initialize(state: NodeMaterialBuildState): void;
  65878. /**
  65879. * Gets the current class name
  65880. * @returns the class name
  65881. */
  65882. getClassName(): string;
  65883. /**
  65884. * Gets the metallic input component
  65885. */
  65886. get metallic(): NodeMaterialConnectionPoint;
  65887. /**
  65888. * Gets the roughness input component
  65889. */
  65890. get roughness(): NodeMaterialConnectionPoint;
  65891. /**
  65892. * Gets the texture input component
  65893. */
  65894. get texture(): NodeMaterialConnectionPoint;
  65895. /**
  65896. * Gets the reflectivity object output component
  65897. */
  65898. get reflectivity(): NodeMaterialConnectionPoint;
  65899. /**
  65900. * Gets the main code of the block (fragment side)
  65901. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65902. * @returns the shader code
  65903. */
  65904. getCode(aoIntensityVarName: string): string;
  65905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65906. protected _buildBlock(state: NodeMaterialBuildState): this;
  65907. protected _dumpPropertiesCode(): string;
  65908. serialize(): any;
  65909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65910. }
  65911. }
  65912. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  65913. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65918. /**
  65919. * Block used to implement the anisotropy module of the PBR material
  65920. */
  65921. export class AnisotropyBlock extends NodeMaterialBlock {
  65922. /**
  65923. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65924. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65925. * It's less burden on the user side in the editor part.
  65926. */
  65927. /** @hidden */
  65928. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65929. /** @hidden */
  65930. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65931. /**
  65932. * Create a new AnisotropyBlock
  65933. * @param name defines the block name
  65934. */
  65935. constructor(name: string);
  65936. /**
  65937. * Initialize the block and prepare the context for build
  65938. * @param state defines the state that will be used for the build
  65939. */
  65940. initialize(state: NodeMaterialBuildState): void;
  65941. /**
  65942. * Gets the current class name
  65943. * @returns the class name
  65944. */
  65945. getClassName(): string;
  65946. /**
  65947. * Gets the intensity input component
  65948. */
  65949. get intensity(): NodeMaterialConnectionPoint;
  65950. /**
  65951. * Gets the direction input component
  65952. */
  65953. get direction(): NodeMaterialConnectionPoint;
  65954. /**
  65955. * Gets the texture input component
  65956. */
  65957. get texture(): NodeMaterialConnectionPoint;
  65958. /**
  65959. * Gets the uv input component
  65960. */
  65961. get uv(): NodeMaterialConnectionPoint;
  65962. /**
  65963. * Gets the worldTangent input component
  65964. */
  65965. get worldTangent(): NodeMaterialConnectionPoint;
  65966. /**
  65967. * Gets the anisotropy object output component
  65968. */
  65969. get anisotropy(): NodeMaterialConnectionPoint;
  65970. private _generateTBNSpace;
  65971. /**
  65972. * Gets the main code of the block (fragment side)
  65973. * @param state current state of the node material building
  65974. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65975. * @returns the shader code
  65976. */
  65977. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65978. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65979. protected _buildBlock(state: NodeMaterialBuildState): this;
  65980. }
  65981. }
  65982. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  65983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65986. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65988. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65989. import { Nullable } from "babylonjs/types";
  65990. import { Mesh } from "babylonjs/Meshes/mesh";
  65991. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65992. import { Effect } from "babylonjs/Materials/effect";
  65993. /**
  65994. * Block used to implement the clear coat module of the PBR material
  65995. */
  65996. export class ClearCoatBlock extends NodeMaterialBlock {
  65997. private _scene;
  65998. /**
  65999. * Create a new ClearCoatBlock
  66000. * @param name defines the block name
  66001. */
  66002. constructor(name: string);
  66003. /**
  66004. * Initialize the block and prepare the context for build
  66005. * @param state defines the state that will be used for the build
  66006. */
  66007. initialize(state: NodeMaterialBuildState): void;
  66008. /**
  66009. * Gets the current class name
  66010. * @returns the class name
  66011. */
  66012. getClassName(): string;
  66013. /**
  66014. * Gets the intensity input component
  66015. */
  66016. get intensity(): NodeMaterialConnectionPoint;
  66017. /**
  66018. * Gets the roughness input component
  66019. */
  66020. get roughness(): NodeMaterialConnectionPoint;
  66021. /**
  66022. * Gets the ior input component
  66023. */
  66024. get ior(): NodeMaterialConnectionPoint;
  66025. /**
  66026. * Gets the texture input component
  66027. */
  66028. get texture(): NodeMaterialConnectionPoint;
  66029. /**
  66030. * Gets the bump texture input component
  66031. */
  66032. get bumpTexture(): NodeMaterialConnectionPoint;
  66033. /**
  66034. * Gets the uv input component
  66035. */
  66036. get uv(): NodeMaterialConnectionPoint;
  66037. /**
  66038. * Gets the tint color input component
  66039. */
  66040. get tintColor(): NodeMaterialConnectionPoint;
  66041. /**
  66042. * Gets the tint "at distance" input component
  66043. */
  66044. get tintAtDistance(): NodeMaterialConnectionPoint;
  66045. /**
  66046. * Gets the tint thickness input component
  66047. */
  66048. get tintThickness(): NodeMaterialConnectionPoint;
  66049. /**
  66050. * Gets the tint texture input component
  66051. */
  66052. get tintTexture(): NodeMaterialConnectionPoint;
  66053. /**
  66054. * Gets the world tangent input component
  66055. */
  66056. get worldTangent(): NodeMaterialConnectionPoint;
  66057. /**
  66058. * Gets the clear coat object output component
  66059. */
  66060. get clearcoat(): NodeMaterialConnectionPoint;
  66061. autoConfigure(material: NodeMaterial): void;
  66062. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66063. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66064. private _generateTBNSpace;
  66065. /**
  66066. * Gets the main code of the block (fragment side)
  66067. * @param state current state of the node material building
  66068. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66069. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66070. * @param worldPosVarName name of the variable holding the world position
  66071. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66072. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66073. * @param worldNormalVarName name of the variable holding the world normal
  66074. * @returns the shader code
  66075. */
  66076. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66077. protected _buildBlock(state: NodeMaterialBuildState): this;
  66078. }
  66079. }
  66080. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66084. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66086. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66087. import { Nullable } from "babylonjs/types";
  66088. /**
  66089. * Block used to implement the sub surface module of the PBR material
  66090. */
  66091. export class SubSurfaceBlock extends NodeMaterialBlock {
  66092. /**
  66093. * Create a new SubSurfaceBlock
  66094. * @param name defines the block name
  66095. */
  66096. constructor(name: string);
  66097. /**
  66098. * Stores the intensity of the different subsurface effects in the thickness texture.
  66099. * * the green channel is the translucency intensity.
  66100. * * the blue channel is the scattering intensity.
  66101. * * the alpha channel is the refraction intensity.
  66102. */
  66103. useMaskFromThicknessTexture: boolean;
  66104. /**
  66105. * Initialize the block and prepare the context for build
  66106. * @param state defines the state that will be used for the build
  66107. */
  66108. initialize(state: NodeMaterialBuildState): void;
  66109. /**
  66110. * Gets the current class name
  66111. * @returns the class name
  66112. */
  66113. getClassName(): string;
  66114. /**
  66115. * Gets the min thickness input component
  66116. */
  66117. get minThickness(): NodeMaterialConnectionPoint;
  66118. /**
  66119. * Gets the max thickness input component
  66120. */
  66121. get maxThickness(): NodeMaterialConnectionPoint;
  66122. /**
  66123. * Gets the thickness texture component
  66124. */
  66125. get thicknessTexture(): NodeMaterialConnectionPoint;
  66126. /**
  66127. * Gets the tint color input component
  66128. */
  66129. get tintColor(): NodeMaterialConnectionPoint;
  66130. /**
  66131. * Gets the translucency intensity input component
  66132. */
  66133. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66134. /**
  66135. * Gets the translucency diffusion distance input component
  66136. */
  66137. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66138. /**
  66139. * Gets the refraction object parameters
  66140. */
  66141. get refraction(): NodeMaterialConnectionPoint;
  66142. /**
  66143. * Gets the sub surface object output component
  66144. */
  66145. get subsurface(): NodeMaterialConnectionPoint;
  66146. autoConfigure(material: NodeMaterial): void;
  66147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66148. /**
  66149. * Gets the main code of the block (fragment side)
  66150. * @param state current state of the node material building
  66151. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66152. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66153. * @param worldPosVarName name of the variable holding the world position
  66154. * @returns the shader code
  66155. */
  66156. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66157. protected _buildBlock(state: NodeMaterialBuildState): this;
  66158. }
  66159. }
  66160. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66164. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66165. import { Light } from "babylonjs/Lights/light";
  66166. import { Nullable } from "babylonjs/types";
  66167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66168. import { Effect } from "babylonjs/Materials/effect";
  66169. import { Mesh } from "babylonjs/Meshes/mesh";
  66170. import { Scene } from "babylonjs/scene";
  66171. /**
  66172. * Block used to implement the PBR metallic/roughness model
  66173. */
  66174. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66175. /**
  66176. * Gets or sets the light associated with this block
  66177. */
  66178. light: Nullable<Light>;
  66179. private _lightId;
  66180. private _scene;
  66181. private _environmentBRDFTexture;
  66182. private _environmentBrdfSamplerName;
  66183. private _vNormalWName;
  66184. private _invertNormalName;
  66185. /**
  66186. * Create a new ReflectionBlock
  66187. * @param name defines the block name
  66188. */
  66189. constructor(name: string);
  66190. /**
  66191. * Intensity of the direct lights e.g. the four lights available in your scene.
  66192. * This impacts both the direct diffuse and specular highlights.
  66193. */
  66194. directIntensity: number;
  66195. /**
  66196. * Intensity of the environment e.g. how much the environment will light the object
  66197. * either through harmonics for rough material or through the refelction for shiny ones.
  66198. */
  66199. environmentIntensity: number;
  66200. /**
  66201. * This is a special control allowing the reduction of the specular highlights coming from the
  66202. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66203. */
  66204. specularIntensity: number;
  66205. /**
  66206. * Defines the falloff type used in this material.
  66207. * It by default is Physical.
  66208. */
  66209. lightFalloff: number;
  66210. /**
  66211. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66212. */
  66213. useAlphaFromAlbedoTexture: boolean;
  66214. /**
  66215. * Specifies that alpha test should be used
  66216. */
  66217. useAlphaTest: boolean;
  66218. /**
  66219. * Defines the alpha limits in alpha test mode.
  66220. */
  66221. alphaTestCutoff: number;
  66222. /**
  66223. * Specifies that alpha blending should be used
  66224. */
  66225. useAlphaBlending: boolean;
  66226. /**
  66227. * Defines if the alpha value should be determined via the rgb values.
  66228. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66229. */
  66230. opacityRGB: boolean;
  66231. /**
  66232. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66233. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66234. */
  66235. useRadianceOverAlpha: boolean;
  66236. /**
  66237. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66238. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66239. */
  66240. useSpecularOverAlpha: boolean;
  66241. /**
  66242. * Enables specular anti aliasing in the PBR shader.
  66243. * It will both interacts on the Geometry for analytical and IBL lighting.
  66244. * It also prefilter the roughness map based on the bump values.
  66245. */
  66246. enableSpecularAntiAliasing: boolean;
  66247. /**
  66248. * Defines if the material uses energy conservation.
  66249. */
  66250. useEnergyConservation: boolean;
  66251. /**
  66252. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66253. * too much the area relying on ambient texture to define their ambient occlusion.
  66254. */
  66255. useRadianceOcclusion: boolean;
  66256. /**
  66257. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66258. * makes the reflect vector face the model (under horizon).
  66259. */
  66260. useHorizonOcclusion: boolean;
  66261. /**
  66262. * If set to true, no lighting calculations will be applied.
  66263. */
  66264. unlit: boolean;
  66265. /**
  66266. * Force normal to face away from face.
  66267. */
  66268. forceNormalForward: boolean;
  66269. /**
  66270. * Defines the material debug mode.
  66271. * It helps seeing only some components of the material while troubleshooting.
  66272. */
  66273. debugMode: number;
  66274. /**
  66275. * Specify from where on screen the debug mode should start.
  66276. * The value goes from -1 (full screen) to 1 (not visible)
  66277. * It helps with side by side comparison against the final render
  66278. * This defaults to 0
  66279. */
  66280. debugLimit: number;
  66281. /**
  66282. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66283. * You can use the factor to better multiply the final value.
  66284. */
  66285. debugFactor: number;
  66286. /**
  66287. * Initialize the block and prepare the context for build
  66288. * @param state defines the state that will be used for the build
  66289. */
  66290. initialize(state: NodeMaterialBuildState): void;
  66291. /**
  66292. * Gets the current class name
  66293. * @returns the class name
  66294. */
  66295. getClassName(): string;
  66296. /**
  66297. * Gets the world position input component
  66298. */
  66299. get worldPosition(): NodeMaterialConnectionPoint;
  66300. /**
  66301. * Gets the world normal input component
  66302. */
  66303. get worldNormal(): NodeMaterialConnectionPoint;
  66304. /**
  66305. * Gets the perturbed normal input component
  66306. */
  66307. get perturbedNormal(): NodeMaterialConnectionPoint;
  66308. /**
  66309. * Gets the camera position input component
  66310. */
  66311. get cameraPosition(): NodeMaterialConnectionPoint;
  66312. /**
  66313. * Gets the base color input component
  66314. */
  66315. get baseColor(): NodeMaterialConnectionPoint;
  66316. /**
  66317. * Gets the base texture input component
  66318. */
  66319. get baseTexture(): NodeMaterialConnectionPoint;
  66320. /**
  66321. * Gets the opacity texture input component
  66322. */
  66323. get opacityTexture(): NodeMaterialConnectionPoint;
  66324. /**
  66325. * Gets the ambient color input component
  66326. */
  66327. get ambientColor(): NodeMaterialConnectionPoint;
  66328. /**
  66329. * Gets the reflectivity object parameters
  66330. */
  66331. get reflectivity(): NodeMaterialConnectionPoint;
  66332. /**
  66333. * Gets the ambient occlusion object parameters
  66334. */
  66335. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66336. /**
  66337. * Gets the reflection object parameters
  66338. */
  66339. get reflection(): NodeMaterialConnectionPoint;
  66340. /**
  66341. * Gets the sheen object parameters
  66342. */
  66343. get sheen(): NodeMaterialConnectionPoint;
  66344. /**
  66345. * Gets the clear coat object parameters
  66346. */
  66347. get clearcoat(): NodeMaterialConnectionPoint;
  66348. /**
  66349. * Gets the sub surface object parameters
  66350. */
  66351. get subsurface(): NodeMaterialConnectionPoint;
  66352. /**
  66353. * Gets the anisotropy object parameters
  66354. */
  66355. get anisotropy(): NodeMaterialConnectionPoint;
  66356. /**
  66357. * Gets the ambient output component
  66358. */
  66359. get ambient(): NodeMaterialConnectionPoint;
  66360. /**
  66361. * Gets the diffuse output component
  66362. */
  66363. get diffuse(): NodeMaterialConnectionPoint;
  66364. /**
  66365. * Gets the specular output component
  66366. */
  66367. get specular(): NodeMaterialConnectionPoint;
  66368. /**
  66369. * Gets the sheen output component
  66370. */
  66371. get sheenDir(): NodeMaterialConnectionPoint;
  66372. /**
  66373. * Gets the clear coat output component
  66374. */
  66375. get clearcoatDir(): NodeMaterialConnectionPoint;
  66376. /**
  66377. * Gets the indirect diffuse output component
  66378. */
  66379. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66380. /**
  66381. * Gets the indirect specular output component
  66382. */
  66383. get specularIndirect(): NodeMaterialConnectionPoint;
  66384. /**
  66385. * Gets the indirect sheen output component
  66386. */
  66387. get sheenIndirect(): NodeMaterialConnectionPoint;
  66388. /**
  66389. * Gets the indirect clear coat output component
  66390. */
  66391. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66392. /**
  66393. * Gets the refraction output component
  66394. */
  66395. get refraction(): NodeMaterialConnectionPoint;
  66396. /**
  66397. * Gets the global lighting output component
  66398. */
  66399. get lighting(): NodeMaterialConnectionPoint;
  66400. /**
  66401. * Gets the shadow output component
  66402. */
  66403. get shadow(): NodeMaterialConnectionPoint;
  66404. /**
  66405. * Gets the alpha output component
  66406. */
  66407. get alpha(): NodeMaterialConnectionPoint;
  66408. autoConfigure(material: NodeMaterial): void;
  66409. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66410. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66411. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66412. private _injectVertexCode;
  66413. /**
  66414. * Gets the code corresponding to the albedo/opacity module
  66415. * @returns the shader code
  66416. */
  66417. getAlbedoOpacityCode(): string;
  66418. protected _buildBlock(state: NodeMaterialBuildState): this;
  66419. protected _dumpPropertiesCode(): string;
  66420. serialize(): any;
  66421. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66422. }
  66423. }
  66424. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  66425. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  66426. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  66427. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  66428. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  66429. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  66430. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66431. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  66432. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  66433. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  66434. }
  66435. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  66436. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  66437. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  66438. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  66439. }
  66440. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  66441. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66442. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66443. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66444. /**
  66445. * Block used to compute value of one parameter modulo another
  66446. */
  66447. export class ModBlock extends NodeMaterialBlock {
  66448. /**
  66449. * Creates a new ModBlock
  66450. * @param name defines the block name
  66451. */
  66452. constructor(name: string);
  66453. /**
  66454. * Gets the current class name
  66455. * @returns the class name
  66456. */
  66457. getClassName(): string;
  66458. /**
  66459. * Gets the left operand input component
  66460. */
  66461. get left(): NodeMaterialConnectionPoint;
  66462. /**
  66463. * Gets the right operand input component
  66464. */
  66465. get right(): NodeMaterialConnectionPoint;
  66466. /**
  66467. * Gets the output component
  66468. */
  66469. get output(): NodeMaterialConnectionPoint;
  66470. protected _buildBlock(state: NodeMaterialBuildState): this;
  66471. }
  66472. }
  66473. declare module "babylonjs/Materials/Node/Blocks/index" {
  66474. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  66475. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  66476. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  66477. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  66478. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  66479. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  66480. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  66481. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  66482. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  66483. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  66484. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  66485. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  66486. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  66487. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  66488. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  66489. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  66490. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  66491. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  66492. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  66493. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  66494. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  66495. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  66496. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  66497. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  66498. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  66499. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  66500. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  66501. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  66502. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  66503. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  66504. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  66505. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  66506. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  66507. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  66508. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  66509. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  66510. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  66511. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  66512. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  66513. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  66514. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  66515. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  66516. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  66517. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  66518. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  66519. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  66520. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  66521. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  66522. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  66523. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  66524. }
  66525. declare module "babylonjs/Materials/Node/Optimizers/index" {
  66526. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  66527. }
  66528. declare module "babylonjs/Materials/Node/index" {
  66529. export * from "babylonjs/Materials/Node/Enums/index";
  66530. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66531. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  66532. export * from "babylonjs/Materials/Node/nodeMaterial";
  66533. export * from "babylonjs/Materials/Node/Blocks/index";
  66534. export * from "babylonjs/Materials/Node/Optimizers/index";
  66535. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  66536. }
  66537. declare module "babylonjs/Materials/index" {
  66538. export * from "babylonjs/Materials/Background/index";
  66539. export * from "babylonjs/Materials/colorCurves";
  66540. export * from "babylonjs/Materials/iEffectFallbacks";
  66541. export * from "babylonjs/Materials/effectFallbacks";
  66542. export * from "babylonjs/Materials/effect";
  66543. export * from "babylonjs/Materials/fresnelParameters";
  66544. export * from "babylonjs/Materials/imageProcessingConfiguration";
  66545. export * from "babylonjs/Materials/material";
  66546. export * from "babylonjs/Materials/materialDefines";
  66547. export * from "babylonjs/Materials/materialHelper";
  66548. export * from "babylonjs/Materials/multiMaterial";
  66549. export * from "babylonjs/Materials/PBR/index";
  66550. export * from "babylonjs/Materials/pushMaterial";
  66551. export * from "babylonjs/Materials/shaderMaterial";
  66552. export * from "babylonjs/Materials/standardMaterial";
  66553. export * from "babylonjs/Materials/Textures/index";
  66554. export * from "babylonjs/Materials/uniformBuffer";
  66555. export * from "babylonjs/Materials/materialFlags";
  66556. export * from "babylonjs/Materials/Node/index";
  66557. export * from "babylonjs/Materials/effectRenderer";
  66558. export * from "babylonjs/Materials/shadowDepthWrapper";
  66559. }
  66560. declare module "babylonjs/Maths/index" {
  66561. export * from "babylonjs/Maths/math.scalar";
  66562. export * from "babylonjs/Maths/math";
  66563. export * from "babylonjs/Maths/sphericalPolynomial";
  66564. }
  66565. declare module "babylonjs/Misc/workerPool" {
  66566. import { IDisposable } from "babylonjs/scene";
  66567. /**
  66568. * Helper class to push actions to a pool of workers.
  66569. */
  66570. export class WorkerPool implements IDisposable {
  66571. private _workerInfos;
  66572. private _pendingActions;
  66573. /**
  66574. * Constructor
  66575. * @param workers Array of workers to use for actions
  66576. */
  66577. constructor(workers: Array<Worker>);
  66578. /**
  66579. * Terminates all workers and clears any pending actions.
  66580. */
  66581. dispose(): void;
  66582. /**
  66583. * Pushes an action to the worker pool. If all the workers are active, the action will be
  66584. * pended until a worker has completed its action.
  66585. * @param action The action to perform. Call onComplete when the action is complete.
  66586. */
  66587. push(action: (worker: Worker, onComplete: () => void) => void): void;
  66588. private _execute;
  66589. }
  66590. }
  66591. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  66592. import { IDisposable } from "babylonjs/scene";
  66593. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66594. /**
  66595. * Configuration for Draco compression
  66596. */
  66597. export interface IDracoCompressionConfiguration {
  66598. /**
  66599. * Configuration for the decoder.
  66600. */
  66601. decoder: {
  66602. /**
  66603. * The url to the WebAssembly module.
  66604. */
  66605. wasmUrl?: string;
  66606. /**
  66607. * The url to the WebAssembly binary.
  66608. */
  66609. wasmBinaryUrl?: string;
  66610. /**
  66611. * The url to the fallback JavaScript module.
  66612. */
  66613. fallbackUrl?: string;
  66614. };
  66615. }
  66616. /**
  66617. * Draco compression (https://google.github.io/draco/)
  66618. *
  66619. * This class wraps the Draco module.
  66620. *
  66621. * **Encoder**
  66622. *
  66623. * The encoder is not currently implemented.
  66624. *
  66625. * **Decoder**
  66626. *
  66627. * 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.
  66628. *
  66629. * To update the configuration, use the following code:
  66630. * ```javascript
  66631. * DracoCompression.Configuration = {
  66632. * decoder: {
  66633. * wasmUrl: "<url to the WebAssembly library>",
  66634. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66635. * fallbackUrl: "<url to the fallback JavaScript library>",
  66636. * }
  66637. * };
  66638. * ```
  66639. *
  66640. * 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.
  66641. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66642. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66643. *
  66644. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66645. * ```javascript
  66646. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66647. * ```
  66648. *
  66649. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66650. */
  66651. export class DracoCompression implements IDisposable {
  66652. private _workerPoolPromise?;
  66653. private _decoderModulePromise?;
  66654. /**
  66655. * The configuration. Defaults to the following urls:
  66656. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66657. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66658. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66659. */
  66660. static Configuration: IDracoCompressionConfiguration;
  66661. /**
  66662. * Returns true if the decoder configuration is available.
  66663. */
  66664. static get DecoderAvailable(): boolean;
  66665. /**
  66666. * Default number of workers to create when creating the draco compression object.
  66667. */
  66668. static DefaultNumWorkers: number;
  66669. private static GetDefaultNumWorkers;
  66670. private static _Default;
  66671. /**
  66672. * Default instance for the draco compression object.
  66673. */
  66674. static get Default(): DracoCompression;
  66675. /**
  66676. * Constructor
  66677. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66678. */
  66679. constructor(numWorkers?: number);
  66680. /**
  66681. * Stop all async operations and release resources.
  66682. */
  66683. dispose(): void;
  66684. /**
  66685. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66686. * @returns a promise that resolves when ready
  66687. */
  66688. whenReadyAsync(): Promise<void>;
  66689. /**
  66690. * Decode Draco compressed mesh data to vertex data.
  66691. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66692. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66693. * @returns A promise that resolves with the decoded vertex data
  66694. */
  66695. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66696. [kind: string]: number;
  66697. }): Promise<VertexData>;
  66698. }
  66699. }
  66700. declare module "babylonjs/Meshes/Compression/index" {
  66701. export * from "babylonjs/Meshes/Compression/dracoCompression";
  66702. }
  66703. declare module "babylonjs/Meshes/csg" {
  66704. import { Nullable } from "babylonjs/types";
  66705. import { Scene } from "babylonjs/scene";
  66706. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  66707. import { Mesh } from "babylonjs/Meshes/mesh";
  66708. import { Material } from "babylonjs/Materials/material";
  66709. /**
  66710. * Class for building Constructive Solid Geometry
  66711. */
  66712. export class CSG {
  66713. private polygons;
  66714. /**
  66715. * The world matrix
  66716. */
  66717. matrix: Matrix;
  66718. /**
  66719. * Stores the position
  66720. */
  66721. position: Vector3;
  66722. /**
  66723. * Stores the rotation
  66724. */
  66725. rotation: Vector3;
  66726. /**
  66727. * Stores the rotation quaternion
  66728. */
  66729. rotationQuaternion: Nullable<Quaternion>;
  66730. /**
  66731. * Stores the scaling vector
  66732. */
  66733. scaling: Vector3;
  66734. /**
  66735. * Convert the Mesh to CSG
  66736. * @param mesh The Mesh to convert to CSG
  66737. * @returns A new CSG from the Mesh
  66738. */
  66739. static FromMesh(mesh: Mesh): CSG;
  66740. /**
  66741. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66742. * @param polygons Polygons used to construct a CSG solid
  66743. */
  66744. private static FromPolygons;
  66745. /**
  66746. * Clones, or makes a deep copy, of the CSG
  66747. * @returns A new CSG
  66748. */
  66749. clone(): CSG;
  66750. /**
  66751. * Unions this CSG with another CSG
  66752. * @param csg The CSG to union against this CSG
  66753. * @returns The unioned CSG
  66754. */
  66755. union(csg: CSG): CSG;
  66756. /**
  66757. * Unions this CSG with another CSG in place
  66758. * @param csg The CSG to union against this CSG
  66759. */
  66760. unionInPlace(csg: CSG): void;
  66761. /**
  66762. * Subtracts this CSG with another CSG
  66763. * @param csg The CSG to subtract against this CSG
  66764. * @returns A new CSG
  66765. */
  66766. subtract(csg: CSG): CSG;
  66767. /**
  66768. * Subtracts this CSG with another CSG in place
  66769. * @param csg The CSG to subtact against this CSG
  66770. */
  66771. subtractInPlace(csg: CSG): void;
  66772. /**
  66773. * Intersect this CSG with another CSG
  66774. * @param csg The CSG to intersect against this CSG
  66775. * @returns A new CSG
  66776. */
  66777. intersect(csg: CSG): CSG;
  66778. /**
  66779. * Intersects this CSG with another CSG in place
  66780. * @param csg The CSG to intersect against this CSG
  66781. */
  66782. intersectInPlace(csg: CSG): void;
  66783. /**
  66784. * Return a new CSG solid with solid and empty space switched. This solid is
  66785. * not modified.
  66786. * @returns A new CSG solid with solid and empty space switched
  66787. */
  66788. inverse(): CSG;
  66789. /**
  66790. * Inverses the CSG in place
  66791. */
  66792. inverseInPlace(): void;
  66793. /**
  66794. * This is used to keep meshes transformations so they can be restored
  66795. * when we build back a Babylon Mesh
  66796. * NB : All CSG operations are performed in world coordinates
  66797. * @param csg The CSG to copy the transform attributes from
  66798. * @returns This CSG
  66799. */
  66800. copyTransformAttributes(csg: CSG): CSG;
  66801. /**
  66802. * Build Raw mesh from CSG
  66803. * Coordinates here are in world space
  66804. * @param name The name of the mesh geometry
  66805. * @param scene The Scene
  66806. * @param keepSubMeshes Specifies if the submeshes should be kept
  66807. * @returns A new Mesh
  66808. */
  66809. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66810. /**
  66811. * Build Mesh from CSG taking material and transforms into account
  66812. * @param name The name of the Mesh
  66813. * @param material The material of the Mesh
  66814. * @param scene The Scene
  66815. * @param keepSubMeshes Specifies if submeshes should be kept
  66816. * @returns The new Mesh
  66817. */
  66818. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66819. }
  66820. }
  66821. declare module "babylonjs/Meshes/trailMesh" {
  66822. import { Mesh } from "babylonjs/Meshes/mesh";
  66823. import { Scene } from "babylonjs/scene";
  66824. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66825. /**
  66826. * Class used to create a trail following a mesh
  66827. */
  66828. export class TrailMesh extends Mesh {
  66829. private _generator;
  66830. private _autoStart;
  66831. private _running;
  66832. private _diameter;
  66833. private _length;
  66834. private _sectionPolygonPointsCount;
  66835. private _sectionVectors;
  66836. private _sectionNormalVectors;
  66837. private _beforeRenderObserver;
  66838. /**
  66839. * @constructor
  66840. * @param name The value used by scene.getMeshByName() to do a lookup.
  66841. * @param generator The mesh or transform node to generate a trail.
  66842. * @param scene The scene to add this mesh to.
  66843. * @param diameter Diameter of trailing mesh. Default is 1.
  66844. * @param length Length of trailing mesh. Default is 60.
  66845. * @param autoStart Automatically start trailing mesh. Default true.
  66846. */
  66847. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66848. /**
  66849. * "TrailMesh"
  66850. * @returns "TrailMesh"
  66851. */
  66852. getClassName(): string;
  66853. private _createMesh;
  66854. /**
  66855. * Start trailing mesh.
  66856. */
  66857. start(): void;
  66858. /**
  66859. * Stop trailing mesh.
  66860. */
  66861. stop(): void;
  66862. /**
  66863. * Update trailing mesh geometry.
  66864. */
  66865. update(): void;
  66866. /**
  66867. * Returns a new TrailMesh object.
  66868. * @param name is a string, the name given to the new mesh
  66869. * @param newGenerator use new generator object for cloned trail mesh
  66870. * @returns a new mesh
  66871. */
  66872. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66873. /**
  66874. * Serializes this trail mesh
  66875. * @param serializationObject object to write serialization to
  66876. */
  66877. serialize(serializationObject: any): void;
  66878. /**
  66879. * Parses a serialized trail mesh
  66880. * @param parsedMesh the serialized mesh
  66881. * @param scene the scene to create the trail mesh in
  66882. * @returns the created trail mesh
  66883. */
  66884. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66885. }
  66886. }
  66887. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  66888. import { Nullable } from "babylonjs/types";
  66889. import { Scene } from "babylonjs/scene";
  66890. import { Vector4 } from "babylonjs/Maths/math.vector";
  66891. import { Color4 } from "babylonjs/Maths/math.color";
  66892. import { Mesh } from "babylonjs/Meshes/mesh";
  66893. /**
  66894. * Class containing static functions to help procedurally build meshes
  66895. */
  66896. export class TiledBoxBuilder {
  66897. /**
  66898. * Creates a box mesh
  66899. * 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)
  66900. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66904. * @param name defines the name of the mesh
  66905. * @param options defines the options used to create the mesh
  66906. * @param scene defines the hosting scene
  66907. * @returns the box mesh
  66908. */
  66909. static CreateTiledBox(name: string, options: {
  66910. pattern?: number;
  66911. width?: number;
  66912. height?: number;
  66913. depth?: number;
  66914. tileSize?: number;
  66915. tileWidth?: number;
  66916. tileHeight?: number;
  66917. alignHorizontal?: number;
  66918. alignVertical?: number;
  66919. faceUV?: Vector4[];
  66920. faceColors?: Color4[];
  66921. sideOrientation?: number;
  66922. updatable?: boolean;
  66923. }, scene?: Nullable<Scene>): Mesh;
  66924. }
  66925. }
  66926. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  66927. import { Vector4 } from "babylonjs/Maths/math.vector";
  66928. import { Mesh } from "babylonjs/Meshes/mesh";
  66929. /**
  66930. * Class containing static functions to help procedurally build meshes
  66931. */
  66932. export class TorusKnotBuilder {
  66933. /**
  66934. * Creates a torus knot mesh
  66935. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66936. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66937. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66938. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66942. * @param name defines the name of the mesh
  66943. * @param options defines the options used to create the mesh
  66944. * @param scene defines the hosting scene
  66945. * @returns the torus knot mesh
  66946. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66947. */
  66948. static CreateTorusKnot(name: string, options: {
  66949. radius?: number;
  66950. tube?: number;
  66951. radialSegments?: number;
  66952. tubularSegments?: number;
  66953. p?: number;
  66954. q?: number;
  66955. updatable?: boolean;
  66956. sideOrientation?: number;
  66957. frontUVs?: Vector4;
  66958. backUVs?: Vector4;
  66959. }, scene: any): Mesh;
  66960. }
  66961. }
  66962. declare module "babylonjs/Meshes/polygonMesh" {
  66963. import { Scene } from "babylonjs/scene";
  66964. import { Vector2 } from "babylonjs/Maths/math.vector";
  66965. import { Mesh } from "babylonjs/Meshes/mesh";
  66966. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66967. import { Path2 } from "babylonjs/Maths/math.path";
  66968. /**
  66969. * Polygon
  66970. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66971. */
  66972. export class Polygon {
  66973. /**
  66974. * Creates a rectangle
  66975. * @param xmin bottom X coord
  66976. * @param ymin bottom Y coord
  66977. * @param xmax top X coord
  66978. * @param ymax top Y coord
  66979. * @returns points that make the resulting rectation
  66980. */
  66981. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66982. /**
  66983. * Creates a circle
  66984. * @param radius radius of circle
  66985. * @param cx scale in x
  66986. * @param cy scale in y
  66987. * @param numberOfSides number of sides that make up the circle
  66988. * @returns points that make the resulting circle
  66989. */
  66990. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66991. /**
  66992. * Creates a polygon from input string
  66993. * @param input Input polygon data
  66994. * @returns the parsed points
  66995. */
  66996. static Parse(input: string): Vector2[];
  66997. /**
  66998. * Starts building a polygon from x and y coordinates
  66999. * @param x x coordinate
  67000. * @param y y coordinate
  67001. * @returns the started path2
  67002. */
  67003. static StartingAt(x: number, y: number): Path2;
  67004. }
  67005. /**
  67006. * Builds a polygon
  67007. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67008. */
  67009. export class PolygonMeshBuilder {
  67010. private _points;
  67011. private _outlinepoints;
  67012. private _holes;
  67013. private _name;
  67014. private _scene;
  67015. private _epoints;
  67016. private _eholes;
  67017. private _addToepoint;
  67018. /**
  67019. * Babylon reference to the earcut plugin.
  67020. */
  67021. bjsEarcut: any;
  67022. /**
  67023. * Creates a PolygonMeshBuilder
  67024. * @param name name of the builder
  67025. * @param contours Path of the polygon
  67026. * @param scene scene to add to when creating the mesh
  67027. * @param earcutInjection can be used to inject your own earcut reference
  67028. */
  67029. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67030. /**
  67031. * Adds a whole within the polygon
  67032. * @param hole Array of points defining the hole
  67033. * @returns this
  67034. */
  67035. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67036. /**
  67037. * Creates the polygon
  67038. * @param updatable If the mesh should be updatable
  67039. * @param depth The depth of the mesh created
  67040. * @returns the created mesh
  67041. */
  67042. build(updatable?: boolean, depth?: number): Mesh;
  67043. /**
  67044. * Creates the polygon
  67045. * @param depth The depth of the mesh created
  67046. * @returns the created VertexData
  67047. */
  67048. buildVertexData(depth?: number): VertexData;
  67049. /**
  67050. * Adds a side to the polygon
  67051. * @param positions points that make the polygon
  67052. * @param normals normals of the polygon
  67053. * @param uvs uvs of the polygon
  67054. * @param indices indices of the polygon
  67055. * @param bounds bounds of the polygon
  67056. * @param points points of the polygon
  67057. * @param depth depth of the polygon
  67058. * @param flip flip of the polygon
  67059. */
  67060. private addSide;
  67061. }
  67062. }
  67063. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67064. import { Scene } from "babylonjs/scene";
  67065. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67066. import { Color4 } from "babylonjs/Maths/math.color";
  67067. import { Mesh } from "babylonjs/Meshes/mesh";
  67068. import { Nullable } from "babylonjs/types";
  67069. /**
  67070. * Class containing static functions to help procedurally build meshes
  67071. */
  67072. export class PolygonBuilder {
  67073. /**
  67074. * Creates a polygon mesh
  67075. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67076. * * 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
  67077. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67080. * * Remember you can only change the shape positions, not their number when updating a polygon
  67081. * @param name defines the name of the mesh
  67082. * @param options defines the options used to create the mesh
  67083. * @param scene defines the hosting scene
  67084. * @param earcutInjection can be used to inject your own earcut reference
  67085. * @returns the polygon mesh
  67086. */
  67087. static CreatePolygon(name: string, options: {
  67088. shape: Vector3[];
  67089. holes?: Vector3[][];
  67090. depth?: number;
  67091. faceUV?: Vector4[];
  67092. faceColors?: Color4[];
  67093. updatable?: boolean;
  67094. sideOrientation?: number;
  67095. frontUVs?: Vector4;
  67096. backUVs?: Vector4;
  67097. wrap?: boolean;
  67098. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67099. /**
  67100. * Creates an extruded polygon mesh, with depth in the Y direction.
  67101. * * 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)
  67102. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67103. * @param name defines the name of the mesh
  67104. * @param options defines the options used to create the mesh
  67105. * @param scene defines the hosting scene
  67106. * @param earcutInjection can be used to inject your own earcut reference
  67107. * @returns the polygon mesh
  67108. */
  67109. static ExtrudePolygon(name: string, options: {
  67110. shape: Vector3[];
  67111. holes?: Vector3[][];
  67112. depth?: number;
  67113. faceUV?: Vector4[];
  67114. faceColors?: Color4[];
  67115. updatable?: boolean;
  67116. sideOrientation?: number;
  67117. frontUVs?: Vector4;
  67118. backUVs?: Vector4;
  67119. wrap?: boolean;
  67120. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67121. }
  67122. }
  67123. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67124. import { Scene } from "babylonjs/scene";
  67125. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67126. import { Mesh } from "babylonjs/Meshes/mesh";
  67127. import { Nullable } from "babylonjs/types";
  67128. /**
  67129. * Class containing static functions to help procedurally build meshes
  67130. */
  67131. export class LatheBuilder {
  67132. /**
  67133. * Creates lathe mesh.
  67134. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67135. * * 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
  67136. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67137. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67138. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67139. * * 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
  67140. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67141. * * 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
  67142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67144. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67146. * @param name defines the name of the mesh
  67147. * @param options defines the options used to create the mesh
  67148. * @param scene defines the hosting scene
  67149. * @returns the lathe mesh
  67150. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67151. */
  67152. static CreateLathe(name: string, options: {
  67153. shape: Vector3[];
  67154. radius?: number;
  67155. tessellation?: number;
  67156. clip?: number;
  67157. arc?: number;
  67158. closed?: boolean;
  67159. updatable?: boolean;
  67160. sideOrientation?: number;
  67161. frontUVs?: Vector4;
  67162. backUVs?: Vector4;
  67163. cap?: number;
  67164. invertUV?: boolean;
  67165. }, scene?: Nullable<Scene>): Mesh;
  67166. }
  67167. }
  67168. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67169. import { Nullable } from "babylonjs/types";
  67170. import { Scene } from "babylonjs/scene";
  67171. import { Vector4 } from "babylonjs/Maths/math.vector";
  67172. import { Mesh } from "babylonjs/Meshes/mesh";
  67173. /**
  67174. * Class containing static functions to help procedurally build meshes
  67175. */
  67176. export class TiledPlaneBuilder {
  67177. /**
  67178. * Creates a tiled plane mesh
  67179. * * The parameter `pattern` will, depending on value, do nothing or
  67180. * * * flip (reflect about central vertical) alternate tiles across and up
  67181. * * * flip every tile on alternate rows
  67182. * * * rotate (180 degs) alternate tiles across and up
  67183. * * * rotate every tile on alternate rows
  67184. * * * flip and rotate alternate tiles across and up
  67185. * * * flip and rotate every tile on alternate rows
  67186. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67187. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67190. * * 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)
  67191. * * 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)
  67192. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67193. * @param name defines the name of the mesh
  67194. * @param options defines the options used to create the mesh
  67195. * @param scene defines the hosting scene
  67196. * @returns the box mesh
  67197. */
  67198. static CreateTiledPlane(name: string, options: {
  67199. pattern?: number;
  67200. tileSize?: number;
  67201. tileWidth?: number;
  67202. tileHeight?: number;
  67203. size?: number;
  67204. width?: number;
  67205. height?: number;
  67206. alignHorizontal?: number;
  67207. alignVertical?: number;
  67208. sideOrientation?: number;
  67209. frontUVs?: Vector4;
  67210. backUVs?: Vector4;
  67211. updatable?: boolean;
  67212. }, scene?: Nullable<Scene>): Mesh;
  67213. }
  67214. }
  67215. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67216. import { Nullable } from "babylonjs/types";
  67217. import { Scene } from "babylonjs/scene";
  67218. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67219. import { Mesh } from "babylonjs/Meshes/mesh";
  67220. /**
  67221. * Class containing static functions to help procedurally build meshes
  67222. */
  67223. export class TubeBuilder {
  67224. /**
  67225. * Creates a tube mesh.
  67226. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67227. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67228. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67229. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67230. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67231. * * 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)
  67232. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67233. * * 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
  67234. * * 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
  67235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67237. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67239. * @param name defines the name of the mesh
  67240. * @param options defines the options used to create the mesh
  67241. * @param scene defines the hosting scene
  67242. * @returns the tube mesh
  67243. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67244. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67245. */
  67246. static CreateTube(name: string, options: {
  67247. path: Vector3[];
  67248. radius?: number;
  67249. tessellation?: number;
  67250. radiusFunction?: {
  67251. (i: number, distance: number): number;
  67252. };
  67253. cap?: number;
  67254. arc?: number;
  67255. updatable?: boolean;
  67256. sideOrientation?: number;
  67257. frontUVs?: Vector4;
  67258. backUVs?: Vector4;
  67259. instance?: Mesh;
  67260. invertUV?: boolean;
  67261. }, scene?: Nullable<Scene>): Mesh;
  67262. }
  67263. }
  67264. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67265. import { Scene } from "babylonjs/scene";
  67266. import { Vector4 } from "babylonjs/Maths/math.vector";
  67267. import { Mesh } from "babylonjs/Meshes/mesh";
  67268. import { Nullable } from "babylonjs/types";
  67269. /**
  67270. * Class containing static functions to help procedurally build meshes
  67271. */
  67272. export class IcoSphereBuilder {
  67273. /**
  67274. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67275. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67276. * * 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`)
  67277. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67278. * * 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
  67279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67282. * @param name defines the name of the mesh
  67283. * @param options defines the options used to create the mesh
  67284. * @param scene defines the hosting scene
  67285. * @returns the icosahedron mesh
  67286. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67287. */
  67288. static CreateIcoSphere(name: string, options: {
  67289. radius?: number;
  67290. radiusX?: number;
  67291. radiusY?: number;
  67292. radiusZ?: number;
  67293. flat?: boolean;
  67294. subdivisions?: number;
  67295. sideOrientation?: number;
  67296. frontUVs?: Vector4;
  67297. backUVs?: Vector4;
  67298. updatable?: boolean;
  67299. }, scene?: Nullable<Scene>): Mesh;
  67300. }
  67301. }
  67302. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67303. import { Vector3 } from "babylonjs/Maths/math.vector";
  67304. import { Mesh } from "babylonjs/Meshes/mesh";
  67305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67306. /**
  67307. * Class containing static functions to help procedurally build meshes
  67308. */
  67309. export class DecalBuilder {
  67310. /**
  67311. * Creates a decal mesh.
  67312. * 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
  67313. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67314. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67315. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67316. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67317. * @param name defines the name of the mesh
  67318. * @param sourceMesh defines the mesh where the decal must be applied
  67319. * @param options defines the options used to create the mesh
  67320. * @param scene defines the hosting scene
  67321. * @returns the decal mesh
  67322. * @see https://doc.babylonjs.com/how_to/decals
  67323. */
  67324. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67325. position?: Vector3;
  67326. normal?: Vector3;
  67327. size?: Vector3;
  67328. angle?: number;
  67329. }): Mesh;
  67330. }
  67331. }
  67332. declare module "babylonjs/Meshes/meshBuilder" {
  67333. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  67334. import { Nullable } from "babylonjs/types";
  67335. import { Scene } from "babylonjs/scene";
  67336. import { Mesh } from "babylonjs/Meshes/mesh";
  67337. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  67338. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  67339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67340. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67341. import { Plane } from "babylonjs/Maths/math.plane";
  67342. /**
  67343. * Class containing static functions to help procedurally build meshes
  67344. */
  67345. export class MeshBuilder {
  67346. /**
  67347. * Creates a box mesh
  67348. * * The parameter `size` sets the size (float) of each box side (default 1)
  67349. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67350. * * 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)
  67351. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67355. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67356. * @param name defines the name of the mesh
  67357. * @param options defines the options used to create the mesh
  67358. * @param scene defines the hosting scene
  67359. * @returns the box mesh
  67360. */
  67361. static CreateBox(name: string, options: {
  67362. size?: number;
  67363. width?: number;
  67364. height?: number;
  67365. depth?: number;
  67366. faceUV?: Vector4[];
  67367. faceColors?: Color4[];
  67368. sideOrientation?: number;
  67369. frontUVs?: Vector4;
  67370. backUVs?: Vector4;
  67371. wrap?: boolean;
  67372. topBaseAt?: number;
  67373. bottomBaseAt?: number;
  67374. updatable?: boolean;
  67375. }, scene?: Nullable<Scene>): Mesh;
  67376. /**
  67377. * Creates a tiled box mesh
  67378. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67380. * @param name defines the name of the mesh
  67381. * @param options defines the options used to create the mesh
  67382. * @param scene defines the hosting scene
  67383. * @returns the tiled box mesh
  67384. */
  67385. static CreateTiledBox(name: string, options: {
  67386. pattern?: number;
  67387. size?: number;
  67388. width?: number;
  67389. height?: number;
  67390. depth: number;
  67391. tileSize?: number;
  67392. tileWidth?: number;
  67393. tileHeight?: number;
  67394. faceUV?: Vector4[];
  67395. faceColors?: Color4[];
  67396. alignHorizontal?: number;
  67397. alignVertical?: number;
  67398. sideOrientation?: number;
  67399. updatable?: boolean;
  67400. }, scene?: Nullable<Scene>): Mesh;
  67401. /**
  67402. * Creates a sphere mesh
  67403. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67404. * * 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`)
  67405. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67406. * * 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
  67407. * * 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)
  67408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67411. * @param name defines the name of the mesh
  67412. * @param options defines the options used to create the mesh
  67413. * @param scene defines the hosting scene
  67414. * @returns the sphere mesh
  67415. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67416. */
  67417. static CreateSphere(name: string, options: {
  67418. segments?: number;
  67419. diameter?: number;
  67420. diameterX?: number;
  67421. diameterY?: number;
  67422. diameterZ?: number;
  67423. arc?: number;
  67424. slice?: number;
  67425. sideOrientation?: number;
  67426. frontUVs?: Vector4;
  67427. backUVs?: Vector4;
  67428. updatable?: boolean;
  67429. }, scene?: Nullable<Scene>): Mesh;
  67430. /**
  67431. * Creates a plane polygonal mesh. By default, this is a disc
  67432. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67433. * * 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
  67434. * * 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
  67435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67438. * @param name defines the name of the mesh
  67439. * @param options defines the options used to create the mesh
  67440. * @param scene defines the hosting scene
  67441. * @returns the plane polygonal mesh
  67442. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67443. */
  67444. static CreateDisc(name: string, options: {
  67445. radius?: number;
  67446. tessellation?: number;
  67447. arc?: number;
  67448. updatable?: boolean;
  67449. sideOrientation?: number;
  67450. frontUVs?: Vector4;
  67451. backUVs?: Vector4;
  67452. }, scene?: Nullable<Scene>): Mesh;
  67453. /**
  67454. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67455. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67456. * * 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`)
  67457. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67458. * * 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
  67459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67462. * @param name defines the name of the mesh
  67463. * @param options defines the options used to create the mesh
  67464. * @param scene defines the hosting scene
  67465. * @returns the icosahedron mesh
  67466. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67467. */
  67468. static CreateIcoSphere(name: string, options: {
  67469. radius?: number;
  67470. radiusX?: number;
  67471. radiusY?: number;
  67472. radiusZ?: number;
  67473. flat?: boolean;
  67474. subdivisions?: number;
  67475. sideOrientation?: number;
  67476. frontUVs?: Vector4;
  67477. backUVs?: Vector4;
  67478. updatable?: boolean;
  67479. }, scene?: Nullable<Scene>): Mesh;
  67480. /**
  67481. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67482. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67483. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67484. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67485. * * 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
  67486. * * 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
  67487. * * 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
  67488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67490. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67491. * * 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
  67492. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67493. * * 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
  67494. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67496. * @param name defines the name of the mesh
  67497. * @param options defines the options used to create the mesh
  67498. * @param scene defines the hosting scene
  67499. * @returns the ribbon mesh
  67500. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67502. */
  67503. static CreateRibbon(name: string, options: {
  67504. pathArray: Vector3[][];
  67505. closeArray?: boolean;
  67506. closePath?: boolean;
  67507. offset?: number;
  67508. updatable?: boolean;
  67509. sideOrientation?: number;
  67510. frontUVs?: Vector4;
  67511. backUVs?: Vector4;
  67512. instance?: Mesh;
  67513. invertUV?: boolean;
  67514. uvs?: Vector2[];
  67515. colors?: Color4[];
  67516. }, scene?: Nullable<Scene>): Mesh;
  67517. /**
  67518. * Creates a cylinder or a cone mesh
  67519. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67520. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67521. * * 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.
  67522. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67523. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67524. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67525. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67526. * * 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).
  67527. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67528. * * 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).
  67529. * * 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
  67530. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67531. * * 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
  67532. * * 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.
  67533. * * If `enclose` is false, a ring surface is one element.
  67534. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67535. * * 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
  67536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67539. * @param name defines the name of the mesh
  67540. * @param options defines the options used to create the mesh
  67541. * @param scene defines the hosting scene
  67542. * @returns the cylinder mesh
  67543. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67544. */
  67545. static CreateCylinder(name: string, options: {
  67546. height?: number;
  67547. diameterTop?: number;
  67548. diameterBottom?: number;
  67549. diameter?: number;
  67550. tessellation?: number;
  67551. subdivisions?: number;
  67552. arc?: number;
  67553. faceColors?: Color4[];
  67554. faceUV?: Vector4[];
  67555. updatable?: boolean;
  67556. hasRings?: boolean;
  67557. enclose?: boolean;
  67558. cap?: number;
  67559. sideOrientation?: number;
  67560. frontUVs?: Vector4;
  67561. backUVs?: Vector4;
  67562. }, scene?: Nullable<Scene>): Mesh;
  67563. /**
  67564. * Creates a torus mesh
  67565. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67566. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67567. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67571. * @param name defines the name of the mesh
  67572. * @param options defines the options used to create the mesh
  67573. * @param scene defines the hosting scene
  67574. * @returns the torus mesh
  67575. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67576. */
  67577. static CreateTorus(name: string, options: {
  67578. diameter?: number;
  67579. thickness?: number;
  67580. tessellation?: number;
  67581. updatable?: boolean;
  67582. sideOrientation?: number;
  67583. frontUVs?: Vector4;
  67584. backUVs?: Vector4;
  67585. }, scene?: Nullable<Scene>): Mesh;
  67586. /**
  67587. * Creates a torus knot mesh
  67588. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67589. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67590. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67591. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67595. * @param name defines the name of the mesh
  67596. * @param options defines the options used to create the mesh
  67597. * @param scene defines the hosting scene
  67598. * @returns the torus knot mesh
  67599. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67600. */
  67601. static CreateTorusKnot(name: string, options: {
  67602. radius?: number;
  67603. tube?: number;
  67604. radialSegments?: number;
  67605. tubularSegments?: number;
  67606. p?: number;
  67607. q?: number;
  67608. updatable?: boolean;
  67609. sideOrientation?: number;
  67610. frontUVs?: Vector4;
  67611. backUVs?: Vector4;
  67612. }, scene?: Nullable<Scene>): Mesh;
  67613. /**
  67614. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67615. * * 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
  67616. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67617. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67618. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67619. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67620. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67621. * * 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
  67622. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67625. * @param name defines the name of the new line system
  67626. * @param options defines the options used to create the line system
  67627. * @param scene defines the hosting scene
  67628. * @returns a new line system mesh
  67629. */
  67630. static CreateLineSystem(name: string, options: {
  67631. lines: Vector3[][];
  67632. updatable?: boolean;
  67633. instance?: Nullable<LinesMesh>;
  67634. colors?: Nullable<Color4[][]>;
  67635. useVertexAlpha?: boolean;
  67636. }, scene: Nullable<Scene>): LinesMesh;
  67637. /**
  67638. * Creates a line mesh
  67639. * 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
  67640. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67641. * * The parameter `points` is an array successive Vector3
  67642. * * 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
  67643. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67644. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67645. * * When updating an instance, remember that only point positions can change, not the number of points
  67646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67648. * @param name defines the name of the new line system
  67649. * @param options defines the options used to create the line system
  67650. * @param scene defines the hosting scene
  67651. * @returns a new line mesh
  67652. */
  67653. static CreateLines(name: string, options: {
  67654. points: Vector3[];
  67655. updatable?: boolean;
  67656. instance?: Nullable<LinesMesh>;
  67657. colors?: Color4[];
  67658. useVertexAlpha?: boolean;
  67659. }, scene?: Nullable<Scene>): LinesMesh;
  67660. /**
  67661. * Creates a dashed line mesh
  67662. * * 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
  67663. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67664. * * The parameter `points` is an array successive Vector3
  67665. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67666. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67667. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67668. * * 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
  67669. * * When updating an instance, remember that only point positions can change, not the number of points
  67670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67671. * @param name defines the name of the mesh
  67672. * @param options defines the options used to create the mesh
  67673. * @param scene defines the hosting scene
  67674. * @returns the dashed line mesh
  67675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67676. */
  67677. static CreateDashedLines(name: string, options: {
  67678. points: Vector3[];
  67679. dashSize?: number;
  67680. gapSize?: number;
  67681. dashNb?: number;
  67682. updatable?: boolean;
  67683. instance?: LinesMesh;
  67684. }, scene?: Nullable<Scene>): LinesMesh;
  67685. /**
  67686. * 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.
  67687. * * 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.
  67688. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67689. * * 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.
  67690. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67691. * * 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
  67692. * * 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
  67693. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67696. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67698. * @param name defines the name of the mesh
  67699. * @param options defines the options used to create the mesh
  67700. * @param scene defines the hosting scene
  67701. * @returns the extruded shape mesh
  67702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67704. */
  67705. static ExtrudeShape(name: string, options: {
  67706. shape: Vector3[];
  67707. path: Vector3[];
  67708. scale?: number;
  67709. rotation?: number;
  67710. cap?: number;
  67711. updatable?: boolean;
  67712. sideOrientation?: number;
  67713. frontUVs?: Vector4;
  67714. backUVs?: Vector4;
  67715. instance?: Mesh;
  67716. invertUV?: boolean;
  67717. }, scene?: Nullable<Scene>): Mesh;
  67718. /**
  67719. * Creates an custom extruded shape mesh.
  67720. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67721. * * 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.
  67722. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67723. * * 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
  67724. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67725. * * 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
  67726. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67727. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67728. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67729. * * 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
  67730. * * 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
  67731. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67736. * @param name defines the name of the mesh
  67737. * @param options defines the options used to create the mesh
  67738. * @param scene defines the hosting scene
  67739. * @returns the custom extruded shape mesh
  67740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67741. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67742. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67743. */
  67744. static ExtrudeShapeCustom(name: string, options: {
  67745. shape: Vector3[];
  67746. path: Vector3[];
  67747. scaleFunction?: any;
  67748. rotationFunction?: any;
  67749. ribbonCloseArray?: boolean;
  67750. ribbonClosePath?: boolean;
  67751. cap?: number;
  67752. updatable?: boolean;
  67753. sideOrientation?: number;
  67754. frontUVs?: Vector4;
  67755. backUVs?: Vector4;
  67756. instance?: Mesh;
  67757. invertUV?: boolean;
  67758. }, scene?: Nullable<Scene>): Mesh;
  67759. /**
  67760. * Creates lathe mesh.
  67761. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67762. * * 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
  67763. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67764. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67765. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67766. * * 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
  67767. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67768. * * 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
  67769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67771. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67773. * @param name defines the name of the mesh
  67774. * @param options defines the options used to create the mesh
  67775. * @param scene defines the hosting scene
  67776. * @returns the lathe mesh
  67777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67778. */
  67779. static CreateLathe(name: string, options: {
  67780. shape: Vector3[];
  67781. radius?: number;
  67782. tessellation?: number;
  67783. clip?: number;
  67784. arc?: number;
  67785. closed?: boolean;
  67786. updatable?: boolean;
  67787. sideOrientation?: number;
  67788. frontUVs?: Vector4;
  67789. backUVs?: Vector4;
  67790. cap?: number;
  67791. invertUV?: boolean;
  67792. }, scene?: Nullable<Scene>): Mesh;
  67793. /**
  67794. * Creates a tiled plane mesh
  67795. * * You can set a limited pattern arrangement with the tiles
  67796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67799. * @param name defines the name of the mesh
  67800. * @param options defines the options used to create the mesh
  67801. * @param scene defines the hosting scene
  67802. * @returns the plane mesh
  67803. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67804. */
  67805. static CreateTiledPlane(name: string, options: {
  67806. pattern?: number;
  67807. tileSize?: number;
  67808. tileWidth?: number;
  67809. tileHeight?: number;
  67810. size?: number;
  67811. width?: number;
  67812. height?: number;
  67813. alignHorizontal?: number;
  67814. alignVertical?: number;
  67815. sideOrientation?: number;
  67816. frontUVs?: Vector4;
  67817. backUVs?: Vector4;
  67818. updatable?: boolean;
  67819. }, scene?: Nullable<Scene>): Mesh;
  67820. /**
  67821. * Creates a plane mesh
  67822. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67823. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67824. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67828. * @param name defines the name of the mesh
  67829. * @param options defines the options used to create the mesh
  67830. * @param scene defines the hosting scene
  67831. * @returns the plane mesh
  67832. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67833. */
  67834. static CreatePlane(name: string, options: {
  67835. size?: number;
  67836. width?: number;
  67837. height?: number;
  67838. sideOrientation?: number;
  67839. frontUVs?: Vector4;
  67840. backUVs?: Vector4;
  67841. updatable?: boolean;
  67842. sourcePlane?: Plane;
  67843. }, scene?: Nullable<Scene>): Mesh;
  67844. /**
  67845. * Creates a ground mesh
  67846. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67847. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67849. * @param name defines the name of the mesh
  67850. * @param options defines the options used to create the mesh
  67851. * @param scene defines the hosting scene
  67852. * @returns the ground mesh
  67853. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67854. */
  67855. static CreateGround(name: string, options: {
  67856. width?: number;
  67857. height?: number;
  67858. subdivisions?: number;
  67859. subdivisionsX?: number;
  67860. subdivisionsY?: number;
  67861. updatable?: boolean;
  67862. }, scene?: Nullable<Scene>): Mesh;
  67863. /**
  67864. * Creates a tiled ground mesh
  67865. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67866. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67867. * * 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
  67868. * * 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
  67869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67870. * @param name defines the name of the mesh
  67871. * @param options defines the options used to create the mesh
  67872. * @param scene defines the hosting scene
  67873. * @returns the tiled ground mesh
  67874. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67875. */
  67876. static CreateTiledGround(name: string, options: {
  67877. xmin: number;
  67878. zmin: number;
  67879. xmax: number;
  67880. zmax: number;
  67881. subdivisions?: {
  67882. w: number;
  67883. h: number;
  67884. };
  67885. precision?: {
  67886. w: number;
  67887. h: number;
  67888. };
  67889. updatable?: boolean;
  67890. }, scene?: Nullable<Scene>): Mesh;
  67891. /**
  67892. * Creates a ground mesh from a height map
  67893. * * The parameter `url` sets the URL of the height map image resource.
  67894. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67895. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67896. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67897. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67898. * * 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.
  67899. * * 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).
  67900. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67902. * @param name defines the name of the mesh
  67903. * @param url defines the url to the height map
  67904. * @param options defines the options used to create the mesh
  67905. * @param scene defines the hosting scene
  67906. * @returns the ground mesh
  67907. * @see https://doc.babylonjs.com/babylon101/height_map
  67908. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67909. */
  67910. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67911. width?: number;
  67912. height?: number;
  67913. subdivisions?: number;
  67914. minHeight?: number;
  67915. maxHeight?: number;
  67916. colorFilter?: Color3;
  67917. alphaFilter?: number;
  67918. updatable?: boolean;
  67919. onReady?: (mesh: GroundMesh) => void;
  67920. }, scene?: Nullable<Scene>): GroundMesh;
  67921. /**
  67922. * Creates a polygon mesh
  67923. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67924. * * 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
  67925. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67928. * * Remember you can only change the shape positions, not their number when updating a polygon
  67929. * @param name defines the name of the mesh
  67930. * @param options defines the options used to create the mesh
  67931. * @param scene defines the hosting scene
  67932. * @param earcutInjection can be used to inject your own earcut reference
  67933. * @returns the polygon mesh
  67934. */
  67935. static CreatePolygon(name: string, options: {
  67936. shape: Vector3[];
  67937. holes?: Vector3[][];
  67938. depth?: number;
  67939. faceUV?: Vector4[];
  67940. faceColors?: Color4[];
  67941. updatable?: boolean;
  67942. sideOrientation?: number;
  67943. frontUVs?: Vector4;
  67944. backUVs?: Vector4;
  67945. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67946. /**
  67947. * Creates an extruded polygon mesh, with depth in the Y direction.
  67948. * * 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)
  67949. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67950. * @param name defines the name of the mesh
  67951. * @param options defines the options used to create the mesh
  67952. * @param scene defines the hosting scene
  67953. * @param earcutInjection can be used to inject your own earcut reference
  67954. * @returns the polygon mesh
  67955. */
  67956. static ExtrudePolygon(name: string, options: {
  67957. shape: Vector3[];
  67958. holes?: Vector3[][];
  67959. depth?: number;
  67960. faceUV?: Vector4[];
  67961. faceColors?: Color4[];
  67962. updatable?: boolean;
  67963. sideOrientation?: number;
  67964. frontUVs?: Vector4;
  67965. backUVs?: Vector4;
  67966. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67967. /**
  67968. * Creates a tube mesh.
  67969. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67970. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67971. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67972. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67973. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67974. * * 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)
  67975. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67976. * * 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
  67977. * * 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
  67978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67982. * @param name defines the name of the mesh
  67983. * @param options defines the options used to create the mesh
  67984. * @param scene defines the hosting scene
  67985. * @returns the tube mesh
  67986. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67987. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67988. */
  67989. static CreateTube(name: string, options: {
  67990. path: Vector3[];
  67991. radius?: number;
  67992. tessellation?: number;
  67993. radiusFunction?: {
  67994. (i: number, distance: number): number;
  67995. };
  67996. cap?: number;
  67997. arc?: number;
  67998. updatable?: boolean;
  67999. sideOrientation?: number;
  68000. frontUVs?: Vector4;
  68001. backUVs?: Vector4;
  68002. instance?: Mesh;
  68003. invertUV?: boolean;
  68004. }, scene?: Nullable<Scene>): Mesh;
  68005. /**
  68006. * Creates a polyhedron mesh
  68007. * * 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
  68008. * * The parameter `size` (positive float, default 1) sets the polygon size
  68009. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68010. * * 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`
  68011. * * 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
  68012. * * 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)`)
  68013. * * 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
  68014. * * 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
  68015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68018. * @param name defines the name of the mesh
  68019. * @param options defines the options used to create the mesh
  68020. * @param scene defines the hosting scene
  68021. * @returns the polyhedron mesh
  68022. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68023. */
  68024. static CreatePolyhedron(name: string, options: {
  68025. type?: number;
  68026. size?: number;
  68027. sizeX?: number;
  68028. sizeY?: number;
  68029. sizeZ?: number;
  68030. custom?: any;
  68031. faceUV?: Vector4[];
  68032. faceColors?: Color4[];
  68033. flat?: boolean;
  68034. updatable?: boolean;
  68035. sideOrientation?: number;
  68036. frontUVs?: Vector4;
  68037. backUVs?: Vector4;
  68038. }, scene?: Nullable<Scene>): Mesh;
  68039. /**
  68040. * Creates a decal mesh.
  68041. * 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
  68042. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68043. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68044. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68045. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68046. * @param name defines the name of the mesh
  68047. * @param sourceMesh defines the mesh where the decal must be applied
  68048. * @param options defines the options used to create the mesh
  68049. * @param scene defines the hosting scene
  68050. * @returns the decal mesh
  68051. * @see https://doc.babylonjs.com/how_to/decals
  68052. */
  68053. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68054. position?: Vector3;
  68055. normal?: Vector3;
  68056. size?: Vector3;
  68057. angle?: number;
  68058. }): Mesh;
  68059. }
  68060. }
  68061. declare module "babylonjs/Meshes/meshSimplification" {
  68062. import { Mesh } from "babylonjs/Meshes/mesh";
  68063. /**
  68064. * A simplifier interface for future simplification implementations
  68065. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68066. */
  68067. export interface ISimplifier {
  68068. /**
  68069. * Simplification of a given mesh according to the given settings.
  68070. * Since this requires computation, it is assumed that the function runs async.
  68071. * @param settings The settings of the simplification, including quality and distance
  68072. * @param successCallback A callback that will be called after the mesh was simplified.
  68073. * @param errorCallback in case of an error, this callback will be called. optional.
  68074. */
  68075. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68076. }
  68077. /**
  68078. * Expected simplification settings.
  68079. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68080. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68081. */
  68082. export interface ISimplificationSettings {
  68083. /**
  68084. * Gets or sets the expected quality
  68085. */
  68086. quality: number;
  68087. /**
  68088. * Gets or sets the distance when this optimized version should be used
  68089. */
  68090. distance: number;
  68091. /**
  68092. * Gets an already optimized mesh
  68093. */
  68094. optimizeMesh?: boolean;
  68095. }
  68096. /**
  68097. * Class used to specify simplification options
  68098. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68099. */
  68100. export class SimplificationSettings implements ISimplificationSettings {
  68101. /** expected quality */
  68102. quality: number;
  68103. /** distance when this optimized version should be used */
  68104. distance: number;
  68105. /** already optimized mesh */
  68106. optimizeMesh?: boolean | undefined;
  68107. /**
  68108. * Creates a SimplificationSettings
  68109. * @param quality expected quality
  68110. * @param distance distance when this optimized version should be used
  68111. * @param optimizeMesh already optimized mesh
  68112. */
  68113. constructor(
  68114. /** expected quality */
  68115. quality: number,
  68116. /** distance when this optimized version should be used */
  68117. distance: number,
  68118. /** already optimized mesh */
  68119. optimizeMesh?: boolean | undefined);
  68120. }
  68121. /**
  68122. * Interface used to define a simplification task
  68123. */
  68124. export interface ISimplificationTask {
  68125. /**
  68126. * Array of settings
  68127. */
  68128. settings: Array<ISimplificationSettings>;
  68129. /**
  68130. * Simplification type
  68131. */
  68132. simplificationType: SimplificationType;
  68133. /**
  68134. * Mesh to simplify
  68135. */
  68136. mesh: Mesh;
  68137. /**
  68138. * Callback called on success
  68139. */
  68140. successCallback?: () => void;
  68141. /**
  68142. * Defines if parallel processing can be used
  68143. */
  68144. parallelProcessing: boolean;
  68145. }
  68146. /**
  68147. * Queue used to order the simplification tasks
  68148. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68149. */
  68150. export class SimplificationQueue {
  68151. private _simplificationArray;
  68152. /**
  68153. * Gets a boolean indicating that the process is still running
  68154. */
  68155. running: boolean;
  68156. /**
  68157. * Creates a new queue
  68158. */
  68159. constructor();
  68160. /**
  68161. * Adds a new simplification task
  68162. * @param task defines a task to add
  68163. */
  68164. addTask(task: ISimplificationTask): void;
  68165. /**
  68166. * Execute next task
  68167. */
  68168. executeNext(): void;
  68169. /**
  68170. * Execute a simplification task
  68171. * @param task defines the task to run
  68172. */
  68173. runSimplification(task: ISimplificationTask): void;
  68174. private getSimplifier;
  68175. }
  68176. /**
  68177. * The implemented types of simplification
  68178. * At the moment only Quadratic Error Decimation is implemented
  68179. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68180. */
  68181. export enum SimplificationType {
  68182. /** Quadratic error decimation */
  68183. QUADRATIC = 0
  68184. }
  68185. /**
  68186. * An implementation of the Quadratic Error simplification algorithm.
  68187. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68188. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68189. * @author RaananW
  68190. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68191. */
  68192. export class QuadraticErrorSimplification implements ISimplifier {
  68193. private _mesh;
  68194. private triangles;
  68195. private vertices;
  68196. private references;
  68197. private _reconstructedMesh;
  68198. /** Gets or sets the number pf sync interations */
  68199. syncIterations: number;
  68200. /** Gets or sets the aggressiveness of the simplifier */
  68201. aggressiveness: number;
  68202. /** Gets or sets the number of allowed iterations for decimation */
  68203. decimationIterations: number;
  68204. /** Gets or sets the espilon to use for bounding box computation */
  68205. boundingBoxEpsilon: number;
  68206. /**
  68207. * Creates a new QuadraticErrorSimplification
  68208. * @param _mesh defines the target mesh
  68209. */
  68210. constructor(_mesh: Mesh);
  68211. /**
  68212. * Simplification of a given mesh according to the given settings.
  68213. * Since this requires computation, it is assumed that the function runs async.
  68214. * @param settings The settings of the simplification, including quality and distance
  68215. * @param successCallback A callback that will be called after the mesh was simplified.
  68216. */
  68217. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68218. private runDecimation;
  68219. private initWithMesh;
  68220. private init;
  68221. private reconstructMesh;
  68222. private initDecimatedMesh;
  68223. private isFlipped;
  68224. private updateTriangles;
  68225. private identifyBorder;
  68226. private updateMesh;
  68227. private vertexError;
  68228. private calculateError;
  68229. }
  68230. }
  68231. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68232. import { Scene } from "babylonjs/scene";
  68233. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68234. import { ISceneComponent } from "babylonjs/sceneComponent";
  68235. module "babylonjs/scene" {
  68236. interface Scene {
  68237. /** @hidden (Backing field) */
  68238. _simplificationQueue: SimplificationQueue;
  68239. /**
  68240. * Gets or sets the simplification queue attached to the scene
  68241. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68242. */
  68243. simplificationQueue: SimplificationQueue;
  68244. }
  68245. }
  68246. module "babylonjs/Meshes/mesh" {
  68247. interface Mesh {
  68248. /**
  68249. * Simplify the mesh according to the given array of settings.
  68250. * Function will return immediately and will simplify async
  68251. * @param settings a collection of simplification settings
  68252. * @param parallelProcessing should all levels calculate parallel or one after the other
  68253. * @param simplificationType the type of simplification to run
  68254. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68255. * @returns the current mesh
  68256. */
  68257. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68258. }
  68259. }
  68260. /**
  68261. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68262. * created in a scene
  68263. */
  68264. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68265. /**
  68266. * The component name helpfull to identify the component in the list of scene components.
  68267. */
  68268. readonly name: string;
  68269. /**
  68270. * The scene the component belongs to.
  68271. */
  68272. scene: Scene;
  68273. /**
  68274. * Creates a new instance of the component for the given scene
  68275. * @param scene Defines the scene to register the component in
  68276. */
  68277. constructor(scene: Scene);
  68278. /**
  68279. * Registers the component in a given scene
  68280. */
  68281. register(): void;
  68282. /**
  68283. * Rebuilds the elements related to this component in case of
  68284. * context lost for instance.
  68285. */
  68286. rebuild(): void;
  68287. /**
  68288. * Disposes the component and the associated ressources
  68289. */
  68290. dispose(): void;
  68291. private _beforeCameraUpdate;
  68292. }
  68293. }
  68294. declare module "babylonjs/Meshes/Builders/index" {
  68295. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68296. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68297. export * from "babylonjs/Meshes/Builders/discBuilder";
  68298. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68299. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68300. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68301. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68302. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68303. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68304. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68305. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68306. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68307. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68308. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68309. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68310. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68311. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68312. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68313. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68314. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68315. }
  68316. declare module "babylonjs/Meshes/thinInstanceMesh" {
  68317. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  68318. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  68319. import { Matrix } from "babylonjs/Maths/math.vector";
  68320. module "babylonjs/Meshes/mesh" {
  68321. interface Mesh {
  68322. /**
  68323. * Creates a new thin instance
  68324. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68325. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68326. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68327. */
  68328. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68329. /**
  68330. * Adds the transformation (matrix) of the current mesh as a thin instance
  68331. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68332. * @returns the thin instance index number
  68333. */
  68334. thinInstanceAddSelf(refresh: boolean): number;
  68335. /**
  68336. * Registers a custom attribute to be used with thin instances
  68337. * @param kind name of the attribute
  68338. * @param stride size in floats of the attribute
  68339. */
  68340. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68341. /**
  68342. * Sets the matrix of a thin instance
  68343. * @param index index of the thin instance
  68344. * @param matrix matrix to set
  68345. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68346. */
  68347. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68348. /**
  68349. * Sets the value of a custom attribute for a thin instance
  68350. * @param kind name of the attribute
  68351. * @param index index of the thin instance
  68352. * @param value value to set
  68353. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68354. */
  68355. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68356. /**
  68357. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  68358. */
  68359. thinInstanceCount: number;
  68360. /**
  68361. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68362. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68363. * @param buffer buffer to set
  68364. * @param stride size in floats of each value of the buffer
  68365. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68366. */
  68367. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68368. /**
  68369. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68370. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68371. */
  68372. thinInstanceBufferUpdated(kind: string): void;
  68373. /**
  68374. * Refreshes the bounding info, taking into account all the thin instances defined
  68375. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68376. */
  68377. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68378. /** @hidden */
  68379. _thinInstanceInitializeUserStorage(): void;
  68380. /** @hidden */
  68381. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68382. /** @hidden */
  68383. _userThinInstanceBuffersStorage: {
  68384. data: {
  68385. [key: string]: Float32Array;
  68386. };
  68387. sizes: {
  68388. [key: string]: number;
  68389. };
  68390. vertexBuffers: {
  68391. [key: string]: Nullable<VertexBuffer>;
  68392. };
  68393. strides: {
  68394. [key: string]: number;
  68395. };
  68396. };
  68397. }
  68398. }
  68399. }
  68400. declare module "babylonjs/Meshes/index" {
  68401. export * from "babylonjs/Meshes/abstractMesh";
  68402. export * from "babylonjs/Meshes/buffer";
  68403. export * from "babylonjs/Meshes/Compression/index";
  68404. export * from "babylonjs/Meshes/csg";
  68405. export * from "babylonjs/Meshes/geometry";
  68406. export * from "babylonjs/Meshes/groundMesh";
  68407. export * from "babylonjs/Meshes/trailMesh";
  68408. export * from "babylonjs/Meshes/instancedMesh";
  68409. export * from "babylonjs/Meshes/linesMesh";
  68410. export * from "babylonjs/Meshes/mesh";
  68411. export * from "babylonjs/Meshes/mesh.vertexData";
  68412. export * from "babylonjs/Meshes/meshBuilder";
  68413. export * from "babylonjs/Meshes/meshSimplification";
  68414. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  68415. export * from "babylonjs/Meshes/polygonMesh";
  68416. export * from "babylonjs/Meshes/subMesh";
  68417. export * from "babylonjs/Meshes/meshLODLevel";
  68418. export * from "babylonjs/Meshes/transformNode";
  68419. export * from "babylonjs/Meshes/Builders/index";
  68420. export * from "babylonjs/Meshes/dataBuffer";
  68421. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  68422. import "babylonjs/Meshes/thinInstanceMesh";
  68423. export * from "babylonjs/Meshes/thinInstanceMesh";
  68424. }
  68425. declare module "babylonjs/Morph/index" {
  68426. export * from "babylonjs/Morph/morphTarget";
  68427. export * from "babylonjs/Morph/morphTargetManager";
  68428. }
  68429. declare module "babylonjs/Navigation/INavigationEngine" {
  68430. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68431. import { Vector3 } from "babylonjs/Maths/math";
  68432. import { Mesh } from "babylonjs/Meshes/mesh";
  68433. import { Scene } from "babylonjs/scene";
  68434. /**
  68435. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68436. */
  68437. export interface INavigationEnginePlugin {
  68438. /**
  68439. * plugin name
  68440. */
  68441. name: string;
  68442. /**
  68443. * Creates a navigation mesh
  68444. * @param meshes array of all the geometry used to compute the navigatio mesh
  68445. * @param parameters bunch of parameters used to filter geometry
  68446. */
  68447. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68448. /**
  68449. * Create a navigation mesh debug mesh
  68450. * @param scene is where the mesh will be added
  68451. * @returns debug display mesh
  68452. */
  68453. createDebugNavMesh(scene: Scene): Mesh;
  68454. /**
  68455. * Get a navigation mesh constrained position, closest to the parameter position
  68456. * @param position world position
  68457. * @returns the closest point to position constrained by the navigation mesh
  68458. */
  68459. getClosestPoint(position: Vector3): Vector3;
  68460. /**
  68461. * Get a navigation mesh constrained position, closest to the parameter position
  68462. * @param position world position
  68463. * @param result output the closest point to position constrained by the navigation mesh
  68464. */
  68465. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68466. /**
  68467. * Get a navigation mesh constrained position, within a particular radius
  68468. * @param position world position
  68469. * @param maxRadius the maximum distance to the constrained world position
  68470. * @returns the closest point to position constrained by the navigation mesh
  68471. */
  68472. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68473. /**
  68474. * Get a navigation mesh constrained position, within a particular radius
  68475. * @param position world position
  68476. * @param maxRadius the maximum distance to the constrained world position
  68477. * @param result output the closest point to position constrained by the navigation mesh
  68478. */
  68479. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68480. /**
  68481. * Compute the final position from a segment made of destination-position
  68482. * @param position world position
  68483. * @param destination world position
  68484. * @returns the resulting point along the navmesh
  68485. */
  68486. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68487. /**
  68488. * Compute the final position from a segment made of destination-position
  68489. * @param position world position
  68490. * @param destination world position
  68491. * @param result output the resulting point along the navmesh
  68492. */
  68493. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68494. /**
  68495. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68496. * @param start world position
  68497. * @param end world position
  68498. * @returns array containing world position composing the path
  68499. */
  68500. computePath(start: Vector3, end: Vector3): Vector3[];
  68501. /**
  68502. * If this plugin is supported
  68503. * @returns true if plugin is supported
  68504. */
  68505. isSupported(): boolean;
  68506. /**
  68507. * Create a new Crowd so you can add agents
  68508. * @param maxAgents the maximum agent count in the crowd
  68509. * @param maxAgentRadius the maximum radius an agent can have
  68510. * @param scene to attach the crowd to
  68511. * @returns the crowd you can add agents to
  68512. */
  68513. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68514. /**
  68515. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68516. * The queries will try to find a solution within those bounds
  68517. * default is (1,1,1)
  68518. * @param extent x,y,z value that define the extent around the queries point of reference
  68519. */
  68520. setDefaultQueryExtent(extent: Vector3): void;
  68521. /**
  68522. * Get the Bounding box extent specified by setDefaultQueryExtent
  68523. * @returns the box extent values
  68524. */
  68525. getDefaultQueryExtent(): Vector3;
  68526. /**
  68527. * build the navmesh from a previously saved state using getNavmeshData
  68528. * @param data the Uint8Array returned by getNavmeshData
  68529. */
  68530. buildFromNavmeshData(data: Uint8Array): void;
  68531. /**
  68532. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68533. * @returns data the Uint8Array that can be saved and reused
  68534. */
  68535. getNavmeshData(): Uint8Array;
  68536. /**
  68537. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68538. * @param result output the box extent values
  68539. */
  68540. getDefaultQueryExtentToRef(result: Vector3): void;
  68541. /**
  68542. * Release all resources
  68543. */
  68544. dispose(): void;
  68545. }
  68546. /**
  68547. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68548. */
  68549. export interface ICrowd {
  68550. /**
  68551. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68552. * You can attach anything to that node. The node position is updated in the scene update tick.
  68553. * @param pos world position that will be constrained by the navigation mesh
  68554. * @param parameters agent parameters
  68555. * @param transform hooked to the agent that will be update by the scene
  68556. * @returns agent index
  68557. */
  68558. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68559. /**
  68560. * Returns the agent position in world space
  68561. * @param index agent index returned by addAgent
  68562. * @returns world space position
  68563. */
  68564. getAgentPosition(index: number): Vector3;
  68565. /**
  68566. * Gets the agent position result in world space
  68567. * @param index agent index returned by addAgent
  68568. * @param result output world space position
  68569. */
  68570. getAgentPositionToRef(index: number, result: Vector3): void;
  68571. /**
  68572. * Gets the agent velocity in world space
  68573. * @param index agent index returned by addAgent
  68574. * @returns world space velocity
  68575. */
  68576. getAgentVelocity(index: number): Vector3;
  68577. /**
  68578. * Gets the agent velocity result in world space
  68579. * @param index agent index returned by addAgent
  68580. * @param result output world space velocity
  68581. */
  68582. getAgentVelocityToRef(index: number, result: Vector3): void;
  68583. /**
  68584. * remove a particular agent previously created
  68585. * @param index agent index returned by addAgent
  68586. */
  68587. removeAgent(index: number): void;
  68588. /**
  68589. * get the list of all agents attached to this crowd
  68590. * @returns list of agent indices
  68591. */
  68592. getAgents(): number[];
  68593. /**
  68594. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68595. * @param deltaTime in seconds
  68596. */
  68597. update(deltaTime: number): void;
  68598. /**
  68599. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68600. * @param index agent index returned by addAgent
  68601. * @param destination targeted world position
  68602. */
  68603. agentGoto(index: number, destination: Vector3): void;
  68604. /**
  68605. * Teleport the agent to a new position
  68606. * @param index agent index returned by addAgent
  68607. * @param destination targeted world position
  68608. */
  68609. agentTeleport(index: number, destination: Vector3): void;
  68610. /**
  68611. * Update agent parameters
  68612. * @param index agent index returned by addAgent
  68613. * @param parameters agent parameters
  68614. */
  68615. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68616. /**
  68617. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68618. * The queries will try to find a solution within those bounds
  68619. * default is (1,1,1)
  68620. * @param extent x,y,z value that define the extent around the queries point of reference
  68621. */
  68622. setDefaultQueryExtent(extent: Vector3): void;
  68623. /**
  68624. * Get the Bounding box extent specified by setDefaultQueryExtent
  68625. * @returns the box extent values
  68626. */
  68627. getDefaultQueryExtent(): Vector3;
  68628. /**
  68629. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68630. * @param result output the box extent values
  68631. */
  68632. getDefaultQueryExtentToRef(result: Vector3): void;
  68633. /**
  68634. * Release all resources
  68635. */
  68636. dispose(): void;
  68637. }
  68638. /**
  68639. * Configures an agent
  68640. */
  68641. export interface IAgentParameters {
  68642. /**
  68643. * Agent radius. [Limit: >= 0]
  68644. */
  68645. radius: number;
  68646. /**
  68647. * Agent height. [Limit: > 0]
  68648. */
  68649. height: number;
  68650. /**
  68651. * Maximum allowed acceleration. [Limit: >= 0]
  68652. */
  68653. maxAcceleration: number;
  68654. /**
  68655. * Maximum allowed speed. [Limit: >= 0]
  68656. */
  68657. maxSpeed: number;
  68658. /**
  68659. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68660. */
  68661. collisionQueryRange: number;
  68662. /**
  68663. * The path visibility optimization range. [Limit: > 0]
  68664. */
  68665. pathOptimizationRange: number;
  68666. /**
  68667. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68668. */
  68669. separationWeight: number;
  68670. }
  68671. /**
  68672. * Configures the navigation mesh creation
  68673. */
  68674. export interface INavMeshParameters {
  68675. /**
  68676. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68677. */
  68678. cs: number;
  68679. /**
  68680. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68681. */
  68682. ch: number;
  68683. /**
  68684. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68685. */
  68686. walkableSlopeAngle: number;
  68687. /**
  68688. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68689. * be considered walkable. [Limit: >= 3] [Units: vx]
  68690. */
  68691. walkableHeight: number;
  68692. /**
  68693. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68694. */
  68695. walkableClimb: number;
  68696. /**
  68697. * The distance to erode/shrink the walkable area of the heightfield away from
  68698. * obstructions. [Limit: >=0] [Units: vx]
  68699. */
  68700. walkableRadius: number;
  68701. /**
  68702. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68703. */
  68704. maxEdgeLen: number;
  68705. /**
  68706. * The maximum distance a simplfied contour's border edges should deviate
  68707. * the original raw contour. [Limit: >=0] [Units: vx]
  68708. */
  68709. maxSimplificationError: number;
  68710. /**
  68711. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68712. */
  68713. minRegionArea: number;
  68714. /**
  68715. * Any regions with a span count smaller than this value will, if possible,
  68716. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68717. */
  68718. mergeRegionArea: number;
  68719. /**
  68720. * The maximum number of vertices allowed for polygons generated during the
  68721. * contour to polygon conversion process. [Limit: >= 3]
  68722. */
  68723. maxVertsPerPoly: number;
  68724. /**
  68725. * Sets the sampling distance to use when generating the detail mesh.
  68726. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68727. */
  68728. detailSampleDist: number;
  68729. /**
  68730. * The maximum distance the detail mesh surface should deviate from heightfield
  68731. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68732. */
  68733. detailSampleMaxError: number;
  68734. }
  68735. }
  68736. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  68737. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  68738. import { Mesh } from "babylonjs/Meshes/mesh";
  68739. import { Scene } from "babylonjs/scene";
  68740. import { Vector3 } from "babylonjs/Maths/math";
  68741. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68742. /**
  68743. * RecastJS navigation plugin
  68744. */
  68745. export class RecastJSPlugin implements INavigationEnginePlugin {
  68746. /**
  68747. * Reference to the Recast library
  68748. */
  68749. bjsRECAST: any;
  68750. /**
  68751. * plugin name
  68752. */
  68753. name: string;
  68754. /**
  68755. * the first navmesh created. We might extend this to support multiple navmeshes
  68756. */
  68757. navMesh: any;
  68758. /**
  68759. * Initializes the recastJS plugin
  68760. * @param recastInjection can be used to inject your own recast reference
  68761. */
  68762. constructor(recastInjection?: any);
  68763. /**
  68764. * Creates a navigation mesh
  68765. * @param meshes array of all the geometry used to compute the navigatio mesh
  68766. * @param parameters bunch of parameters used to filter geometry
  68767. */
  68768. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68769. /**
  68770. * Create a navigation mesh debug mesh
  68771. * @param scene is where the mesh will be added
  68772. * @returns debug display mesh
  68773. */
  68774. createDebugNavMesh(scene: Scene): Mesh;
  68775. /**
  68776. * Get a navigation mesh constrained position, closest to the parameter position
  68777. * @param position world position
  68778. * @returns the closest point to position constrained by the navigation mesh
  68779. */
  68780. getClosestPoint(position: Vector3): Vector3;
  68781. /**
  68782. * Get a navigation mesh constrained position, closest to the parameter position
  68783. * @param position world position
  68784. * @param result output the closest point to position constrained by the navigation mesh
  68785. */
  68786. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68787. /**
  68788. * Get a navigation mesh constrained position, within a particular radius
  68789. * @param position world position
  68790. * @param maxRadius the maximum distance to the constrained world position
  68791. * @returns the closest point to position constrained by the navigation mesh
  68792. */
  68793. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68794. /**
  68795. * Get a navigation mesh constrained position, within a particular radius
  68796. * @param position world position
  68797. * @param maxRadius the maximum distance to the constrained world position
  68798. * @param result output the closest point to position constrained by the navigation mesh
  68799. */
  68800. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68801. /**
  68802. * Compute the final position from a segment made of destination-position
  68803. * @param position world position
  68804. * @param destination world position
  68805. * @returns the resulting point along the navmesh
  68806. */
  68807. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68808. /**
  68809. * Compute the final position from a segment made of destination-position
  68810. * @param position world position
  68811. * @param destination world position
  68812. * @param result output the resulting point along the navmesh
  68813. */
  68814. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68815. /**
  68816. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68817. * @param start world position
  68818. * @param end world position
  68819. * @returns array containing world position composing the path
  68820. */
  68821. computePath(start: Vector3, end: Vector3): Vector3[];
  68822. /**
  68823. * Create a new Crowd so you can add agents
  68824. * @param maxAgents the maximum agent count in the crowd
  68825. * @param maxAgentRadius the maximum radius an agent can have
  68826. * @param scene to attach the crowd to
  68827. * @returns the crowd you can add agents to
  68828. */
  68829. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68830. /**
  68831. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68832. * The queries will try to find a solution within those bounds
  68833. * default is (1,1,1)
  68834. * @param extent x,y,z value that define the extent around the queries point of reference
  68835. */
  68836. setDefaultQueryExtent(extent: Vector3): void;
  68837. /**
  68838. * Get the Bounding box extent specified by setDefaultQueryExtent
  68839. * @returns the box extent values
  68840. */
  68841. getDefaultQueryExtent(): Vector3;
  68842. /**
  68843. * build the navmesh from a previously saved state using getNavmeshData
  68844. * @param data the Uint8Array returned by getNavmeshData
  68845. */
  68846. buildFromNavmeshData(data: Uint8Array): void;
  68847. /**
  68848. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68849. * @returns data the Uint8Array that can be saved and reused
  68850. */
  68851. getNavmeshData(): Uint8Array;
  68852. /**
  68853. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68854. * @param result output the box extent values
  68855. */
  68856. getDefaultQueryExtentToRef(result: Vector3): void;
  68857. /**
  68858. * Disposes
  68859. */
  68860. dispose(): void;
  68861. /**
  68862. * If this plugin is supported
  68863. * @returns true if plugin is supported
  68864. */
  68865. isSupported(): boolean;
  68866. }
  68867. /**
  68868. * Recast detour crowd implementation
  68869. */
  68870. export class RecastJSCrowd implements ICrowd {
  68871. /**
  68872. * Recast/detour plugin
  68873. */
  68874. bjsRECASTPlugin: RecastJSPlugin;
  68875. /**
  68876. * Link to the detour crowd
  68877. */
  68878. recastCrowd: any;
  68879. /**
  68880. * One transform per agent
  68881. */
  68882. transforms: TransformNode[];
  68883. /**
  68884. * All agents created
  68885. */
  68886. agents: number[];
  68887. /**
  68888. * Link to the scene is kept to unregister the crowd from the scene
  68889. */
  68890. private _scene;
  68891. /**
  68892. * Observer for crowd updates
  68893. */
  68894. private _onBeforeAnimationsObserver;
  68895. /**
  68896. * Constructor
  68897. * @param plugin recastJS plugin
  68898. * @param maxAgents the maximum agent count in the crowd
  68899. * @param maxAgentRadius the maximum radius an agent can have
  68900. * @param scene to attach the crowd to
  68901. * @returns the crowd you can add agents to
  68902. */
  68903. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68904. /**
  68905. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68906. * You can attach anything to that node. The node position is updated in the scene update tick.
  68907. * @param pos world position that will be constrained by the navigation mesh
  68908. * @param parameters agent parameters
  68909. * @param transform hooked to the agent that will be update by the scene
  68910. * @returns agent index
  68911. */
  68912. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68913. /**
  68914. * Returns the agent position in world space
  68915. * @param index agent index returned by addAgent
  68916. * @returns world space position
  68917. */
  68918. getAgentPosition(index: number): Vector3;
  68919. /**
  68920. * Returns the agent position result in world space
  68921. * @param index agent index returned by addAgent
  68922. * @param result output world space position
  68923. */
  68924. getAgentPositionToRef(index: number, result: Vector3): void;
  68925. /**
  68926. * Returns the agent velocity in world space
  68927. * @param index agent index returned by addAgent
  68928. * @returns world space velocity
  68929. */
  68930. getAgentVelocity(index: number): Vector3;
  68931. /**
  68932. * Returns the agent velocity result in world space
  68933. * @param index agent index returned by addAgent
  68934. * @param result output world space velocity
  68935. */
  68936. getAgentVelocityToRef(index: number, result: Vector3): void;
  68937. /**
  68938. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68939. * @param index agent index returned by addAgent
  68940. * @param destination targeted world position
  68941. */
  68942. agentGoto(index: number, destination: Vector3): void;
  68943. /**
  68944. * Teleport the agent to a new position
  68945. * @param index agent index returned by addAgent
  68946. * @param destination targeted world position
  68947. */
  68948. agentTeleport(index: number, destination: Vector3): void;
  68949. /**
  68950. * Update agent parameters
  68951. * @param index agent index returned by addAgent
  68952. * @param parameters agent parameters
  68953. */
  68954. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68955. /**
  68956. * remove a particular agent previously created
  68957. * @param index agent index returned by addAgent
  68958. */
  68959. removeAgent(index: number): void;
  68960. /**
  68961. * get the list of all agents attached to this crowd
  68962. * @returns list of agent indices
  68963. */
  68964. getAgents(): number[];
  68965. /**
  68966. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68967. * @param deltaTime in seconds
  68968. */
  68969. update(deltaTime: number): void;
  68970. /**
  68971. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68972. * The queries will try to find a solution within those bounds
  68973. * default is (1,1,1)
  68974. * @param extent x,y,z value that define the extent around the queries point of reference
  68975. */
  68976. setDefaultQueryExtent(extent: Vector3): void;
  68977. /**
  68978. * Get the Bounding box extent specified by setDefaultQueryExtent
  68979. * @returns the box extent values
  68980. */
  68981. getDefaultQueryExtent(): Vector3;
  68982. /**
  68983. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68984. * @param result output the box extent values
  68985. */
  68986. getDefaultQueryExtentToRef(result: Vector3): void;
  68987. /**
  68988. * Release all resources
  68989. */
  68990. dispose(): void;
  68991. }
  68992. }
  68993. declare module "babylonjs/Navigation/Plugins/index" {
  68994. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  68995. }
  68996. declare module "babylonjs/Navigation/index" {
  68997. export * from "babylonjs/Navigation/INavigationEngine";
  68998. export * from "babylonjs/Navigation/Plugins/index";
  68999. }
  69000. declare module "babylonjs/Offline/database" {
  69001. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69002. /**
  69003. * Class used to enable access to IndexedDB
  69004. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69005. */
  69006. export class Database implements IOfflineProvider {
  69007. private _callbackManifestChecked;
  69008. private _currentSceneUrl;
  69009. private _db;
  69010. private _enableSceneOffline;
  69011. private _enableTexturesOffline;
  69012. private _manifestVersionFound;
  69013. private _mustUpdateRessources;
  69014. private _hasReachedQuota;
  69015. private _isSupported;
  69016. private _idbFactory;
  69017. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69018. private static IsUASupportingBlobStorage;
  69019. /**
  69020. * Gets a boolean indicating if Database storate is enabled (off by default)
  69021. */
  69022. static IDBStorageEnabled: boolean;
  69023. /**
  69024. * Gets a boolean indicating if scene must be saved in the database
  69025. */
  69026. get enableSceneOffline(): boolean;
  69027. /**
  69028. * Gets a boolean indicating if textures must be saved in the database
  69029. */
  69030. get enableTexturesOffline(): boolean;
  69031. /**
  69032. * Creates a new Database
  69033. * @param urlToScene defines the url to load the scene
  69034. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69035. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69036. */
  69037. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69038. private static _ParseURL;
  69039. private static _ReturnFullUrlLocation;
  69040. private _checkManifestFile;
  69041. /**
  69042. * Open the database and make it available
  69043. * @param successCallback defines the callback to call on success
  69044. * @param errorCallback defines the callback to call on error
  69045. */
  69046. open(successCallback: () => void, errorCallback: () => void): void;
  69047. /**
  69048. * Loads an image from the database
  69049. * @param url defines the url to load from
  69050. * @param image defines the target DOM image
  69051. */
  69052. loadImage(url: string, image: HTMLImageElement): void;
  69053. private _loadImageFromDBAsync;
  69054. private _saveImageIntoDBAsync;
  69055. private _checkVersionFromDB;
  69056. private _loadVersionFromDBAsync;
  69057. private _saveVersionIntoDBAsync;
  69058. /**
  69059. * Loads a file from database
  69060. * @param url defines the URL to load from
  69061. * @param sceneLoaded defines a callback to call on success
  69062. * @param progressCallBack defines a callback to call when progress changed
  69063. * @param errorCallback defines a callback to call on error
  69064. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69065. */
  69066. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69067. private _loadFileAsync;
  69068. private _saveFileAsync;
  69069. /**
  69070. * Validates if xhr data is correct
  69071. * @param xhr defines the request to validate
  69072. * @param dataType defines the expected data type
  69073. * @returns true if data is correct
  69074. */
  69075. private static _ValidateXHRData;
  69076. }
  69077. }
  69078. declare module "babylonjs/Offline/index" {
  69079. export * from "babylonjs/Offline/database";
  69080. export * from "babylonjs/Offline/IOfflineProvider";
  69081. }
  69082. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69083. /** @hidden */
  69084. export var gpuUpdateParticlesPixelShader: {
  69085. name: string;
  69086. shader: string;
  69087. };
  69088. }
  69089. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69090. /** @hidden */
  69091. export var gpuUpdateParticlesVertexShader: {
  69092. name: string;
  69093. shader: string;
  69094. };
  69095. }
  69096. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69097. /** @hidden */
  69098. export var clipPlaneFragmentDeclaration2: {
  69099. name: string;
  69100. shader: string;
  69101. };
  69102. }
  69103. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69104. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69105. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69106. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69107. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69108. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69109. /** @hidden */
  69110. export var gpuRenderParticlesPixelShader: {
  69111. name: string;
  69112. shader: string;
  69113. };
  69114. }
  69115. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69116. /** @hidden */
  69117. export var clipPlaneVertexDeclaration2: {
  69118. name: string;
  69119. shader: string;
  69120. };
  69121. }
  69122. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69123. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69124. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69125. /** @hidden */
  69126. export var gpuRenderParticlesVertexShader: {
  69127. name: string;
  69128. shader: string;
  69129. };
  69130. }
  69131. declare module "babylonjs/Particles/gpuParticleSystem" {
  69132. import { Nullable } from "babylonjs/types";
  69133. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69134. import { Observable } from "babylonjs/Misc/observable";
  69135. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69136. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69137. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69138. import { Scene, IDisposable } from "babylonjs/scene";
  69139. import { Effect } from "babylonjs/Materials/effect";
  69140. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69141. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69142. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69143. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69144. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69145. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69146. /**
  69147. * This represents a GPU particle system in Babylon
  69148. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69149. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69150. */
  69151. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69152. /**
  69153. * The layer mask we are rendering the particles through.
  69154. */
  69155. layerMask: number;
  69156. private _capacity;
  69157. private _activeCount;
  69158. private _currentActiveCount;
  69159. private _accumulatedCount;
  69160. private _renderEffect;
  69161. private _updateEffect;
  69162. private _buffer0;
  69163. private _buffer1;
  69164. private _spriteBuffer;
  69165. private _updateVAO;
  69166. private _renderVAO;
  69167. private _targetIndex;
  69168. private _sourceBuffer;
  69169. private _targetBuffer;
  69170. private _engine;
  69171. private _currentRenderId;
  69172. private _started;
  69173. private _stopped;
  69174. private _timeDelta;
  69175. private _randomTexture;
  69176. private _randomTexture2;
  69177. private _attributesStrideSize;
  69178. private _updateEffectOptions;
  69179. private _randomTextureSize;
  69180. private _actualFrame;
  69181. private _customEffect;
  69182. private readonly _rawTextureWidth;
  69183. /**
  69184. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69185. */
  69186. static get IsSupported(): boolean;
  69187. /**
  69188. * An event triggered when the system is disposed.
  69189. */
  69190. onDisposeObservable: Observable<IParticleSystem>;
  69191. /**
  69192. * Gets the maximum number of particles active at the same time.
  69193. * @returns The max number of active particles.
  69194. */
  69195. getCapacity(): number;
  69196. /**
  69197. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69198. * to override the particles.
  69199. */
  69200. forceDepthWrite: boolean;
  69201. /**
  69202. * Gets or set the number of active particles
  69203. */
  69204. get activeParticleCount(): number;
  69205. set activeParticleCount(value: number);
  69206. private _preWarmDone;
  69207. /**
  69208. * Specifies if the particles are updated in emitter local space or world space.
  69209. */
  69210. isLocal: boolean;
  69211. /**
  69212. * Is this system ready to be used/rendered
  69213. * @return true if the system is ready
  69214. */
  69215. isReady(): boolean;
  69216. /**
  69217. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69218. * @returns True if it has been started, otherwise false.
  69219. */
  69220. isStarted(): boolean;
  69221. /**
  69222. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69223. * @returns True if it has been stopped, otherwise false.
  69224. */
  69225. isStopped(): boolean;
  69226. /**
  69227. * Gets a boolean indicating that the system is stopping
  69228. * @returns true if the system is currently stopping
  69229. */
  69230. isStopping(): boolean;
  69231. /**
  69232. * Gets the number of particles active at the same time.
  69233. * @returns The number of active particles.
  69234. */
  69235. getActiveCount(): number;
  69236. /**
  69237. * Starts the particle system and begins to emit
  69238. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69239. */
  69240. start(delay?: number): void;
  69241. /**
  69242. * Stops the particle system.
  69243. */
  69244. stop(): void;
  69245. /**
  69246. * Remove all active particles
  69247. */
  69248. reset(): void;
  69249. /**
  69250. * Returns the string "GPUParticleSystem"
  69251. * @returns a string containing the class name
  69252. */
  69253. getClassName(): string;
  69254. /**
  69255. * Gets the custom effect used to render the particles
  69256. * @param blendMode Blend mode for which the effect should be retrieved
  69257. * @returns The effect
  69258. */
  69259. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69260. /**
  69261. * Sets the custom effect used to render the particles
  69262. * @param effect The effect to set
  69263. * @param blendMode Blend mode for which the effect should be set
  69264. */
  69265. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69266. /** @hidden */
  69267. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69268. /**
  69269. * Observable that will be called just before the particles are drawn
  69270. */
  69271. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69272. /**
  69273. * Gets the name of the particle vertex shader
  69274. */
  69275. get vertexShaderName(): string;
  69276. private _colorGradientsTexture;
  69277. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69278. /**
  69279. * Adds a new color gradient
  69280. * @param gradient defines the gradient to use (between 0 and 1)
  69281. * @param color1 defines the color to affect to the specified gradient
  69282. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69283. * @returns the current particle system
  69284. */
  69285. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69286. private _refreshColorGradient;
  69287. /** Force the system to rebuild all gradients that need to be resync */
  69288. forceRefreshGradients(): void;
  69289. /**
  69290. * Remove a specific color gradient
  69291. * @param gradient defines the gradient to remove
  69292. * @returns the current particle system
  69293. */
  69294. removeColorGradient(gradient: number): GPUParticleSystem;
  69295. private _angularSpeedGradientsTexture;
  69296. private _sizeGradientsTexture;
  69297. private _velocityGradientsTexture;
  69298. private _limitVelocityGradientsTexture;
  69299. private _dragGradientsTexture;
  69300. private _addFactorGradient;
  69301. /**
  69302. * Adds a new size gradient
  69303. * @param gradient defines the gradient to use (between 0 and 1)
  69304. * @param factor defines the size factor to affect to the specified gradient
  69305. * @returns the current particle system
  69306. */
  69307. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69308. /**
  69309. * Remove a specific size gradient
  69310. * @param gradient defines the gradient to remove
  69311. * @returns the current particle system
  69312. */
  69313. removeSizeGradient(gradient: number): GPUParticleSystem;
  69314. private _refreshFactorGradient;
  69315. /**
  69316. * Adds a new angular speed gradient
  69317. * @param gradient defines the gradient to use (between 0 and 1)
  69318. * @param factor defines the angular speed to affect to the specified gradient
  69319. * @returns the current particle system
  69320. */
  69321. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69322. /**
  69323. * Remove a specific angular speed gradient
  69324. * @param gradient defines the gradient to remove
  69325. * @returns the current particle system
  69326. */
  69327. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69328. /**
  69329. * Adds a new velocity gradient
  69330. * @param gradient defines the gradient to use (between 0 and 1)
  69331. * @param factor defines the velocity to affect to the specified gradient
  69332. * @returns the current particle system
  69333. */
  69334. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69335. /**
  69336. * Remove a specific velocity gradient
  69337. * @param gradient defines the gradient to remove
  69338. * @returns the current particle system
  69339. */
  69340. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69341. /**
  69342. * Adds a new limit velocity gradient
  69343. * @param gradient defines the gradient to use (between 0 and 1)
  69344. * @param factor defines the limit velocity value to affect to the specified gradient
  69345. * @returns the current particle system
  69346. */
  69347. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69348. /**
  69349. * Remove a specific limit velocity gradient
  69350. * @param gradient defines the gradient to remove
  69351. * @returns the current particle system
  69352. */
  69353. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69354. /**
  69355. * Adds a new drag gradient
  69356. * @param gradient defines the gradient to use (between 0 and 1)
  69357. * @param factor defines the drag value to affect to the specified gradient
  69358. * @returns the current particle system
  69359. */
  69360. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69361. /**
  69362. * Remove a specific drag gradient
  69363. * @param gradient defines the gradient to remove
  69364. * @returns the current particle system
  69365. */
  69366. removeDragGradient(gradient: number): GPUParticleSystem;
  69367. /**
  69368. * Not supported by GPUParticleSystem
  69369. * @param gradient defines the gradient to use (between 0 and 1)
  69370. * @param factor defines the emit rate value to affect to the specified gradient
  69371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69372. * @returns the current particle system
  69373. */
  69374. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69375. /**
  69376. * Not supported by GPUParticleSystem
  69377. * @param gradient defines the gradient to remove
  69378. * @returns the current particle system
  69379. */
  69380. removeEmitRateGradient(gradient: number): IParticleSystem;
  69381. /**
  69382. * Not supported by GPUParticleSystem
  69383. * @param gradient defines the gradient to use (between 0 and 1)
  69384. * @param factor defines the start size value to affect to the specified gradient
  69385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69386. * @returns the current particle system
  69387. */
  69388. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69389. /**
  69390. * Not supported by GPUParticleSystem
  69391. * @param gradient defines the gradient to remove
  69392. * @returns the current particle system
  69393. */
  69394. removeStartSizeGradient(gradient: number): IParticleSystem;
  69395. /**
  69396. * Not supported by GPUParticleSystem
  69397. * @param gradient defines the gradient to use (between 0 and 1)
  69398. * @param min defines the color remap minimal range
  69399. * @param max defines the color remap maximal range
  69400. * @returns the current particle system
  69401. */
  69402. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69403. /**
  69404. * Not supported by GPUParticleSystem
  69405. * @param gradient defines the gradient to remove
  69406. * @returns the current particle system
  69407. */
  69408. removeColorRemapGradient(): IParticleSystem;
  69409. /**
  69410. * Not supported by GPUParticleSystem
  69411. * @param gradient defines the gradient to use (between 0 and 1)
  69412. * @param min defines the alpha remap minimal range
  69413. * @param max defines the alpha remap maximal range
  69414. * @returns the current particle system
  69415. */
  69416. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69417. /**
  69418. * Not supported by GPUParticleSystem
  69419. * @param gradient defines the gradient to remove
  69420. * @returns the current particle system
  69421. */
  69422. removeAlphaRemapGradient(): IParticleSystem;
  69423. /**
  69424. * Not supported by GPUParticleSystem
  69425. * @param gradient defines the gradient to use (between 0 and 1)
  69426. * @param color defines the color to affect to the specified gradient
  69427. * @returns the current particle system
  69428. */
  69429. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69430. /**
  69431. * Not supported by GPUParticleSystem
  69432. * @param gradient defines the gradient to remove
  69433. * @returns the current particle system
  69434. */
  69435. removeRampGradient(): IParticleSystem;
  69436. /**
  69437. * Not supported by GPUParticleSystem
  69438. * @returns the list of ramp gradients
  69439. */
  69440. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69441. /**
  69442. * Not supported by GPUParticleSystem
  69443. * Gets or sets a boolean indicating that ramp gradients must be used
  69444. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69445. */
  69446. get useRampGradients(): boolean;
  69447. set useRampGradients(value: boolean);
  69448. /**
  69449. * Not supported by GPUParticleSystem
  69450. * @param gradient defines the gradient to use (between 0 and 1)
  69451. * @param factor defines the life time factor to affect to the specified gradient
  69452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69453. * @returns the current particle system
  69454. */
  69455. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69456. /**
  69457. * Not supported by GPUParticleSystem
  69458. * @param gradient defines the gradient to remove
  69459. * @returns the current particle system
  69460. */
  69461. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69462. /**
  69463. * Instantiates a GPU particle system.
  69464. * 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.
  69465. * @param name The name of the particle system
  69466. * @param options The options used to create the system
  69467. * @param scene The scene the particle system belongs to
  69468. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69469. * @param customEffect a custom effect used to change the way particles are rendered by default
  69470. */
  69471. constructor(name: string, options: Partial<{
  69472. capacity: number;
  69473. randomTextureSize: number;
  69474. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69475. protected _reset(): void;
  69476. private _createUpdateVAO;
  69477. private _createRenderVAO;
  69478. private _initialize;
  69479. /** @hidden */
  69480. _recreateUpdateEffect(): void;
  69481. private _getEffect;
  69482. /**
  69483. * Fill the defines array according to the current settings of the particle system
  69484. * @param defines Array to be updated
  69485. * @param blendMode blend mode to take into account when updating the array
  69486. */
  69487. fillDefines(defines: Array<string>, blendMode?: number): void;
  69488. /**
  69489. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69490. * @param uniforms Uniforms array to fill
  69491. * @param attributes Attributes array to fill
  69492. * @param samplers Samplers array to fill
  69493. */
  69494. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69495. /** @hidden */
  69496. _recreateRenderEffect(): Effect;
  69497. /**
  69498. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69499. * @param preWarm defines if we are in the pre-warmimg phase
  69500. */
  69501. animate(preWarm?: boolean): void;
  69502. private _createFactorGradientTexture;
  69503. private _createSizeGradientTexture;
  69504. private _createAngularSpeedGradientTexture;
  69505. private _createVelocityGradientTexture;
  69506. private _createLimitVelocityGradientTexture;
  69507. private _createDragGradientTexture;
  69508. private _createColorGradientTexture;
  69509. /**
  69510. * Renders the particle system in its current state
  69511. * @param preWarm defines if the system should only update the particles but not render them
  69512. * @returns the current number of particles
  69513. */
  69514. render(preWarm?: boolean): number;
  69515. /**
  69516. * Rebuilds the particle system
  69517. */
  69518. rebuild(): void;
  69519. private _releaseBuffers;
  69520. private _releaseVAOs;
  69521. /**
  69522. * Disposes the particle system and free the associated resources
  69523. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69524. */
  69525. dispose(disposeTexture?: boolean): void;
  69526. /**
  69527. * Clones the particle system.
  69528. * @param name The name of the cloned object
  69529. * @param newEmitter The new emitter to use
  69530. * @returns the cloned particle system
  69531. */
  69532. clone(name: string, newEmitter: any): GPUParticleSystem;
  69533. /**
  69534. * Serializes the particle system to a JSON object
  69535. * @param serializeTexture defines if the texture must be serialized as well
  69536. * @returns the JSON object
  69537. */
  69538. serialize(serializeTexture?: boolean): any;
  69539. /**
  69540. * Parses a JSON object to create a GPU particle system.
  69541. * @param parsedParticleSystem The JSON object to parse
  69542. * @param scene The scene to create the particle system in
  69543. * @param rootUrl The root url to use to load external dependencies like texture
  69544. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69545. * @returns the parsed GPU particle system
  69546. */
  69547. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69548. }
  69549. }
  69550. declare module "babylonjs/Particles/particleSystemSet" {
  69551. import { Nullable } from "babylonjs/types";
  69552. import { Color3 } from "babylonjs/Maths/math.color";
  69553. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69555. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69556. import { Scene, IDisposable } from "babylonjs/scene";
  69557. /**
  69558. * Represents a set of particle systems working together to create a specific effect
  69559. */
  69560. export class ParticleSystemSet implements IDisposable {
  69561. /**
  69562. * Gets or sets base Assets URL
  69563. */
  69564. static BaseAssetsUrl: string;
  69565. private _emitterCreationOptions;
  69566. private _emitterNode;
  69567. /**
  69568. * Gets the particle system list
  69569. */
  69570. systems: IParticleSystem[];
  69571. /**
  69572. * Gets the emitter node used with this set
  69573. */
  69574. get emitterNode(): Nullable<TransformNode>;
  69575. /**
  69576. * Creates a new emitter mesh as a sphere
  69577. * @param options defines the options used to create the sphere
  69578. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69579. * @param scene defines the hosting scene
  69580. */
  69581. setEmitterAsSphere(options: {
  69582. diameter: number;
  69583. segments: number;
  69584. color: Color3;
  69585. }, renderingGroupId: number, scene: Scene): void;
  69586. /**
  69587. * Starts all particle systems of the set
  69588. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69589. */
  69590. start(emitter?: AbstractMesh): void;
  69591. /**
  69592. * Release all associated resources
  69593. */
  69594. dispose(): void;
  69595. /**
  69596. * Serialize the set into a JSON compatible object
  69597. * @param serializeTexture defines if the texture must be serialized as well
  69598. * @returns a JSON compatible representation of the set
  69599. */
  69600. serialize(serializeTexture?: boolean): any;
  69601. /**
  69602. * Parse a new ParticleSystemSet from a serialized source
  69603. * @param data defines a JSON compatible representation of the set
  69604. * @param scene defines the hosting scene
  69605. * @param gpu defines if we want GPU particles or CPU particles
  69606. * @returns a new ParticleSystemSet
  69607. */
  69608. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69609. }
  69610. }
  69611. declare module "babylonjs/Particles/particleHelper" {
  69612. import { Nullable } from "babylonjs/types";
  69613. import { Scene } from "babylonjs/scene";
  69614. import { Vector3 } from "babylonjs/Maths/math.vector";
  69615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69616. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69617. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  69618. /**
  69619. * This class is made for on one-liner static method to help creating particle system set.
  69620. */
  69621. export class ParticleHelper {
  69622. /**
  69623. * Gets or sets base Assets URL
  69624. */
  69625. static BaseAssetsUrl: string;
  69626. /** Define the Url to load snippets */
  69627. static SnippetUrl: string;
  69628. /**
  69629. * Create a default particle system that you can tweak
  69630. * @param emitter defines the emitter to use
  69631. * @param capacity defines the system capacity (default is 500 particles)
  69632. * @param scene defines the hosting scene
  69633. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69634. * @returns the new Particle system
  69635. */
  69636. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69637. /**
  69638. * This is the main static method (one-liner) of this helper to create different particle systems
  69639. * @param type This string represents the type to the particle system to create
  69640. * @param scene The scene where the particle system should live
  69641. * @param gpu If the system will use gpu
  69642. * @returns the ParticleSystemSet created
  69643. */
  69644. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69645. /**
  69646. * Static function used to export a particle system to a ParticleSystemSet variable.
  69647. * Please note that the emitter shape is not exported
  69648. * @param systems defines the particle systems to export
  69649. * @returns the created particle system set
  69650. */
  69651. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69652. /**
  69653. * Creates a particle system from a snippet saved in a remote file
  69654. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69655. * @param url defines the url to load from
  69656. * @param scene defines the hosting scene
  69657. * @param gpu If the system will use gpu
  69658. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69659. * @returns a promise that will resolve to the new particle system
  69660. */
  69661. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69662. /**
  69663. * Creates a particle system from a snippet saved by the particle system editor
  69664. * @param snippetId defines the snippet to load
  69665. * @param scene defines the hosting scene
  69666. * @param gpu If the system will use gpu
  69667. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69668. * @returns a promise that will resolve to the new particle system
  69669. */
  69670. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69671. }
  69672. }
  69673. declare module "babylonjs/Particles/particleSystemComponent" {
  69674. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69675. import { Effect } from "babylonjs/Materials/effect";
  69676. import "babylonjs/Shaders/particles.vertex";
  69677. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  69678. module "babylonjs/Engines/engine" {
  69679. interface Engine {
  69680. /**
  69681. * Create an effect to use with particle systems.
  69682. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69683. * the particle system for which you want to create a custom effect in the last parameter
  69684. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69685. * @param uniformsNames defines a list of attribute names
  69686. * @param samplers defines an array of string used to represent textures
  69687. * @param defines defines the string containing the defines to use to compile the shaders
  69688. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69689. * @param onCompiled defines a function to call when the effect creation is successful
  69690. * @param onError defines a function to call when the effect creation has failed
  69691. * @param particleSystem the particle system you want to create the effect for
  69692. * @returns the new Effect
  69693. */
  69694. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69695. }
  69696. }
  69697. module "babylonjs/Meshes/mesh" {
  69698. interface Mesh {
  69699. /**
  69700. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69701. * @returns an array of IParticleSystem
  69702. */
  69703. getEmittedParticleSystems(): IParticleSystem[];
  69704. /**
  69705. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69706. * @returns an array of IParticleSystem
  69707. */
  69708. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69709. }
  69710. }
  69711. }
  69712. declare module "babylonjs/Particles/pointsCloudSystem" {
  69713. import { Color4 } from "babylonjs/Maths/math";
  69714. import { Mesh } from "babylonjs/Meshes/mesh";
  69715. import { Scene, IDisposable } from "babylonjs/scene";
  69716. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  69717. /** Defines the 4 color options */
  69718. export enum PointColor {
  69719. /** color value */
  69720. Color = 2,
  69721. /** uv value */
  69722. UV = 1,
  69723. /** random value */
  69724. Random = 0,
  69725. /** stated value */
  69726. Stated = 3
  69727. }
  69728. /**
  69729. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69730. * 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.
  69731. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69732. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69733. *
  69734. * Full documentation here : TO BE ENTERED
  69735. */
  69736. export class PointsCloudSystem implements IDisposable {
  69737. /**
  69738. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69739. * Example : var p = SPS.particles[i];
  69740. */
  69741. particles: CloudPoint[];
  69742. /**
  69743. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69744. */
  69745. nbParticles: number;
  69746. /**
  69747. * This a counter for your own usage. It's not set by any SPS functions.
  69748. */
  69749. counter: number;
  69750. /**
  69751. * The PCS name. This name is also given to the underlying mesh.
  69752. */
  69753. name: string;
  69754. /**
  69755. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69756. */
  69757. mesh: Mesh;
  69758. /**
  69759. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69760. * Please read :
  69761. */
  69762. vars: any;
  69763. /**
  69764. * @hidden
  69765. */
  69766. _size: number;
  69767. private _scene;
  69768. private _promises;
  69769. private _positions;
  69770. private _indices;
  69771. private _normals;
  69772. private _colors;
  69773. private _uvs;
  69774. private _indices32;
  69775. private _positions32;
  69776. private _colors32;
  69777. private _uvs32;
  69778. private _updatable;
  69779. private _isVisibilityBoxLocked;
  69780. private _alwaysVisible;
  69781. private _groups;
  69782. private _groupCounter;
  69783. private _computeParticleColor;
  69784. private _computeParticleTexture;
  69785. private _computeParticleRotation;
  69786. private _computeBoundingBox;
  69787. private _isReady;
  69788. /**
  69789. * Creates a PCS (Points Cloud System) object
  69790. * @param name (String) is the PCS name, this will be the underlying mesh name
  69791. * @param pointSize (number) is the size for each point
  69792. * @param scene (Scene) is the scene in which the PCS is added
  69793. * @param options defines the options of the PCS e.g.
  69794. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69795. */
  69796. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69797. updatable?: boolean;
  69798. });
  69799. /**
  69800. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69801. * If no points were added to the PCS, the returned mesh is just a single point.
  69802. * @returns a promise for the created mesh
  69803. */
  69804. buildMeshAsync(): Promise<Mesh>;
  69805. /**
  69806. * @hidden
  69807. */
  69808. private _buildMesh;
  69809. private _addParticle;
  69810. private _randomUnitVector;
  69811. private _getColorIndicesForCoord;
  69812. private _setPointsColorOrUV;
  69813. private _colorFromTexture;
  69814. private _calculateDensity;
  69815. /**
  69816. * Adds points to the PCS in random positions within a unit sphere
  69817. * @param nb (positive integer) the number of particles to be created from this model
  69818. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69819. * @returns the number of groups in the system
  69820. */
  69821. addPoints(nb: number, pointFunction?: any): number;
  69822. /**
  69823. * Adds points to the PCS from the surface of the model shape
  69824. * @param mesh is any Mesh object that will be used as a surface model for the points
  69825. * @param nb (positive integer) the number of particles to be created from this model
  69826. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69827. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69828. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69829. * @returns the number of groups in the system
  69830. */
  69831. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69832. /**
  69833. * Adds points to the PCS inside the model shape
  69834. * @param mesh is any Mesh object that will be used as a surface model for the points
  69835. * @param nb (positive integer) the number of particles to be created from this model
  69836. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69837. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69838. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69839. * @returns the number of groups in the system
  69840. */
  69841. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69842. /**
  69843. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69844. * This method calls `updateParticle()` for each particle of the SPS.
  69845. * For an animated SPS, it is usually called within the render loop.
  69846. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69847. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69848. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69849. * @returns the PCS.
  69850. */
  69851. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69852. /**
  69853. * Disposes the PCS.
  69854. */
  69855. dispose(): void;
  69856. /**
  69857. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69858. * doc :
  69859. * @returns the PCS.
  69860. */
  69861. refreshVisibleSize(): PointsCloudSystem;
  69862. /**
  69863. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69864. * @param size the size (float) of the visibility box
  69865. * note : this doesn't lock the PCS mesh bounding box.
  69866. * doc :
  69867. */
  69868. setVisibilityBox(size: number): void;
  69869. /**
  69870. * Gets whether the PCS is always visible or not
  69871. * doc :
  69872. */
  69873. get isAlwaysVisible(): boolean;
  69874. /**
  69875. * Sets the PCS as always visible or not
  69876. * doc :
  69877. */
  69878. set isAlwaysVisible(val: boolean);
  69879. /**
  69880. * Tells to `setParticles()` to compute the particle rotations or not
  69881. * Default value : false. The PCS is faster when it's set to false
  69882. * Note : particle rotations are only applied to parent particles
  69883. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69884. */
  69885. set computeParticleRotation(val: boolean);
  69886. /**
  69887. * Tells to `setParticles()` to compute the particle colors or not.
  69888. * Default value : true. The PCS is faster when it's set to false.
  69889. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69890. */
  69891. set computeParticleColor(val: boolean);
  69892. set computeParticleTexture(val: boolean);
  69893. /**
  69894. * Gets if `setParticles()` computes the particle colors or not.
  69895. * Default value : false. The PCS is faster when it's set to false.
  69896. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69897. */
  69898. get computeParticleColor(): boolean;
  69899. /**
  69900. * Gets if `setParticles()` computes the particle textures or not.
  69901. * Default value : false. The PCS is faster when it's set to false.
  69902. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69903. */
  69904. get computeParticleTexture(): boolean;
  69905. /**
  69906. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69907. */
  69908. set computeBoundingBox(val: boolean);
  69909. /**
  69910. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69911. */
  69912. get computeBoundingBox(): boolean;
  69913. /**
  69914. * This function does nothing. It may be overwritten to set all the particle first values.
  69915. * The PCS doesn't call this function, you may have to call it by your own.
  69916. * doc :
  69917. */
  69918. initParticles(): void;
  69919. /**
  69920. * This function does nothing. It may be overwritten to recycle a particle
  69921. * The PCS doesn't call this function, you can to call it
  69922. * doc :
  69923. * @param particle The particle to recycle
  69924. * @returns the recycled particle
  69925. */
  69926. recycleParticle(particle: CloudPoint): CloudPoint;
  69927. /**
  69928. * Updates a particle : this function should be overwritten by the user.
  69929. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69930. * doc :
  69931. * @example : just set a particle position or velocity and recycle conditions
  69932. * @param particle The particle to update
  69933. * @returns the updated particle
  69934. */
  69935. updateParticle(particle: CloudPoint): CloudPoint;
  69936. /**
  69937. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69938. * This does nothing and may be overwritten by the user.
  69939. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69940. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69941. * @param update the boolean update value actually passed to setParticles()
  69942. */
  69943. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69944. /**
  69945. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69946. * This will be passed three parameters.
  69947. * This does nothing and may be overwritten by the user.
  69948. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69949. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69950. * @param update the boolean update value actually passed to setParticles()
  69951. */
  69952. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69953. }
  69954. }
  69955. declare module "babylonjs/Particles/cloudPoint" {
  69956. import { Nullable } from "babylonjs/types";
  69957. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  69958. import { Mesh } from "babylonjs/Meshes/mesh";
  69959. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  69960. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  69961. /**
  69962. * Represents one particle of a points cloud system.
  69963. */
  69964. export class CloudPoint {
  69965. /**
  69966. * particle global index
  69967. */
  69968. idx: number;
  69969. /**
  69970. * The color of the particle
  69971. */
  69972. color: Nullable<Color4>;
  69973. /**
  69974. * The world space position of the particle.
  69975. */
  69976. position: Vector3;
  69977. /**
  69978. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69979. */
  69980. rotation: Vector3;
  69981. /**
  69982. * The world space rotation quaternion of the particle.
  69983. */
  69984. rotationQuaternion: Nullable<Quaternion>;
  69985. /**
  69986. * The uv of the particle.
  69987. */
  69988. uv: Nullable<Vector2>;
  69989. /**
  69990. * The current speed of the particle.
  69991. */
  69992. velocity: Vector3;
  69993. /**
  69994. * The pivot point in the particle local space.
  69995. */
  69996. pivot: Vector3;
  69997. /**
  69998. * Must the particle be translated from its pivot point in its local space ?
  69999. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70000. * Default : false
  70001. */
  70002. translateFromPivot: boolean;
  70003. /**
  70004. * Index of this particle in the global "positions" array (Internal use)
  70005. * @hidden
  70006. */
  70007. _pos: number;
  70008. /**
  70009. * @hidden Index of this particle in the global "indices" array (Internal use)
  70010. */
  70011. _ind: number;
  70012. /**
  70013. * Group this particle belongs to
  70014. */
  70015. _group: PointsGroup;
  70016. /**
  70017. * Group id of this particle
  70018. */
  70019. groupId: number;
  70020. /**
  70021. * Index of the particle in its group id (Internal use)
  70022. */
  70023. idxInGroup: number;
  70024. /**
  70025. * @hidden Particle BoundingInfo object (Internal use)
  70026. */
  70027. _boundingInfo: BoundingInfo;
  70028. /**
  70029. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70030. */
  70031. _pcs: PointsCloudSystem;
  70032. /**
  70033. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70034. */
  70035. _stillInvisible: boolean;
  70036. /**
  70037. * @hidden Last computed particle rotation matrix
  70038. */
  70039. _rotationMatrix: number[];
  70040. /**
  70041. * Parent particle Id, if any.
  70042. * Default null.
  70043. */
  70044. parentId: Nullable<number>;
  70045. /**
  70046. * @hidden Internal global position in the PCS.
  70047. */
  70048. _globalPosition: Vector3;
  70049. /**
  70050. * Creates a Point Cloud object.
  70051. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70052. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70053. * @param group (PointsGroup) is the group the particle belongs to
  70054. * @param groupId (integer) is the group identifier in the PCS.
  70055. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70056. * @param pcs defines the PCS it is associated to
  70057. */
  70058. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70059. /**
  70060. * get point size
  70061. */
  70062. get size(): Vector3;
  70063. /**
  70064. * Set point size
  70065. */
  70066. set size(scale: Vector3);
  70067. /**
  70068. * Legacy support, changed quaternion to rotationQuaternion
  70069. */
  70070. get quaternion(): Nullable<Quaternion>;
  70071. /**
  70072. * Legacy support, changed quaternion to rotationQuaternion
  70073. */
  70074. set quaternion(q: Nullable<Quaternion>);
  70075. /**
  70076. * Returns a boolean. True if the particle intersects a mesh, else false
  70077. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70078. * @param target is the object (point or mesh) what the intersection is computed against
  70079. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70080. * @returns true if it intersects
  70081. */
  70082. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70083. /**
  70084. * get the rotation matrix of the particle
  70085. * @hidden
  70086. */
  70087. getRotationMatrix(m: Matrix): void;
  70088. }
  70089. /**
  70090. * Represents a group of points in a points cloud system
  70091. * * PCS internal tool, don't use it manually.
  70092. */
  70093. export class PointsGroup {
  70094. /**
  70095. * The group id
  70096. * @hidden
  70097. */
  70098. groupID: number;
  70099. /**
  70100. * image data for group (internal use)
  70101. * @hidden
  70102. */
  70103. _groupImageData: Nullable<ArrayBufferView>;
  70104. /**
  70105. * Image Width (internal use)
  70106. * @hidden
  70107. */
  70108. _groupImgWidth: number;
  70109. /**
  70110. * Image Height (internal use)
  70111. * @hidden
  70112. */
  70113. _groupImgHeight: number;
  70114. /**
  70115. * Custom position function (internal use)
  70116. * @hidden
  70117. */
  70118. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70119. /**
  70120. * density per facet for surface points
  70121. * @hidden
  70122. */
  70123. _groupDensity: number[];
  70124. /**
  70125. * Only when points are colored by texture carries pointer to texture list array
  70126. * @hidden
  70127. */
  70128. _textureNb: number;
  70129. /**
  70130. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70131. * PCS internal tool, don't use it manually.
  70132. * @hidden
  70133. */
  70134. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70135. }
  70136. }
  70137. declare module "babylonjs/Particles/index" {
  70138. export * from "babylonjs/Particles/baseParticleSystem";
  70139. export * from "babylonjs/Particles/EmitterTypes/index";
  70140. export * from "babylonjs/Particles/gpuParticleSystem";
  70141. export * from "babylonjs/Particles/IParticleSystem";
  70142. export * from "babylonjs/Particles/particle";
  70143. export * from "babylonjs/Particles/particleHelper";
  70144. export * from "babylonjs/Particles/particleSystem";
  70145. import "babylonjs/Particles/particleSystemComponent";
  70146. export * from "babylonjs/Particles/particleSystemComponent";
  70147. export * from "babylonjs/Particles/particleSystemSet";
  70148. export * from "babylonjs/Particles/solidParticle";
  70149. export * from "babylonjs/Particles/solidParticleSystem";
  70150. export * from "babylonjs/Particles/cloudPoint";
  70151. export * from "babylonjs/Particles/pointsCloudSystem";
  70152. export * from "babylonjs/Particles/subEmitter";
  70153. }
  70154. declare module "babylonjs/Physics/physicsEngineComponent" {
  70155. import { Nullable } from "babylonjs/types";
  70156. import { Observable, Observer } from "babylonjs/Misc/observable";
  70157. import { Vector3 } from "babylonjs/Maths/math.vector";
  70158. import { Mesh } from "babylonjs/Meshes/mesh";
  70159. import { ISceneComponent } from "babylonjs/sceneComponent";
  70160. import { Scene } from "babylonjs/scene";
  70161. import { Node } from "babylonjs/node";
  70162. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70163. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70164. module "babylonjs/scene" {
  70165. interface Scene {
  70166. /** @hidden (Backing field) */
  70167. _physicsEngine: Nullable<IPhysicsEngine>;
  70168. /** @hidden */
  70169. _physicsTimeAccumulator: number;
  70170. /**
  70171. * Gets the current physics engine
  70172. * @returns a IPhysicsEngine or null if none attached
  70173. */
  70174. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70175. /**
  70176. * Enables physics to the current scene
  70177. * @param gravity defines the scene's gravity for the physics engine
  70178. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70179. * @return a boolean indicating if the physics engine was initialized
  70180. */
  70181. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70182. /**
  70183. * Disables and disposes the physics engine associated with the scene
  70184. */
  70185. disablePhysicsEngine(): void;
  70186. /**
  70187. * Gets a boolean indicating if there is an active physics engine
  70188. * @returns a boolean indicating if there is an active physics engine
  70189. */
  70190. isPhysicsEnabled(): boolean;
  70191. /**
  70192. * Deletes a physics compound impostor
  70193. * @param compound defines the compound to delete
  70194. */
  70195. deleteCompoundImpostor(compound: any): void;
  70196. /**
  70197. * An event triggered when physic simulation is about to be run
  70198. */
  70199. onBeforePhysicsObservable: Observable<Scene>;
  70200. /**
  70201. * An event triggered when physic simulation has been done
  70202. */
  70203. onAfterPhysicsObservable: Observable<Scene>;
  70204. }
  70205. }
  70206. module "babylonjs/Meshes/abstractMesh" {
  70207. interface AbstractMesh {
  70208. /** @hidden */
  70209. _physicsImpostor: Nullable<PhysicsImpostor>;
  70210. /**
  70211. * Gets or sets impostor used for physic simulation
  70212. * @see http://doc.babylonjs.com/features/physics_engine
  70213. */
  70214. physicsImpostor: Nullable<PhysicsImpostor>;
  70215. /**
  70216. * Gets the current physics impostor
  70217. * @see http://doc.babylonjs.com/features/physics_engine
  70218. * @returns a physics impostor or null
  70219. */
  70220. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70221. /** Apply a physic impulse to the mesh
  70222. * @param force defines the force to apply
  70223. * @param contactPoint defines where to apply the force
  70224. * @returns the current mesh
  70225. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  70226. */
  70227. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70228. /**
  70229. * Creates a physic joint between two meshes
  70230. * @param otherMesh defines the other mesh to use
  70231. * @param pivot1 defines the pivot to use on this mesh
  70232. * @param pivot2 defines the pivot to use on the other mesh
  70233. * @param options defines additional options (can be plugin dependent)
  70234. * @returns the current mesh
  70235. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70236. */
  70237. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70238. /** @hidden */
  70239. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70240. }
  70241. }
  70242. /**
  70243. * Defines the physics engine scene component responsible to manage a physics engine
  70244. */
  70245. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70246. /**
  70247. * The component name helpful to identify the component in the list of scene components.
  70248. */
  70249. readonly name: string;
  70250. /**
  70251. * The scene the component belongs to.
  70252. */
  70253. scene: Scene;
  70254. /**
  70255. * Creates a new instance of the component for the given scene
  70256. * @param scene Defines the scene to register the component in
  70257. */
  70258. constructor(scene: Scene);
  70259. /**
  70260. * Registers the component in a given scene
  70261. */
  70262. register(): void;
  70263. /**
  70264. * Rebuilds the elements related to this component in case of
  70265. * context lost for instance.
  70266. */
  70267. rebuild(): void;
  70268. /**
  70269. * Disposes the component and the associated ressources
  70270. */
  70271. dispose(): void;
  70272. }
  70273. }
  70274. declare module "babylonjs/Physics/physicsHelper" {
  70275. import { Nullable } from "babylonjs/types";
  70276. import { Vector3 } from "babylonjs/Maths/math.vector";
  70277. import { Mesh } from "babylonjs/Meshes/mesh";
  70278. import { Scene } from "babylonjs/scene";
  70279. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70280. /**
  70281. * A helper for physics simulations
  70282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70283. */
  70284. export class PhysicsHelper {
  70285. private _scene;
  70286. private _physicsEngine;
  70287. /**
  70288. * Initializes the Physics helper
  70289. * @param scene Babylon.js scene
  70290. */
  70291. constructor(scene: Scene);
  70292. /**
  70293. * Applies a radial explosion impulse
  70294. * @param origin the origin of the explosion
  70295. * @param radiusOrEventOptions the radius or the options of radial explosion
  70296. * @param strength the explosion strength
  70297. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70298. * @returns A physics radial explosion event, or null
  70299. */
  70300. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70301. /**
  70302. * Applies a radial explosion force
  70303. * @param origin the origin of the explosion
  70304. * @param radiusOrEventOptions the radius or the options of radial explosion
  70305. * @param strength the explosion strength
  70306. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70307. * @returns A physics radial explosion event, or null
  70308. */
  70309. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70310. /**
  70311. * Creates a gravitational field
  70312. * @param origin the origin of the explosion
  70313. * @param radiusOrEventOptions the radius or the options of radial explosion
  70314. * @param strength the explosion strength
  70315. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70316. * @returns A physics gravitational field event, or null
  70317. */
  70318. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70319. /**
  70320. * Creates a physics updraft event
  70321. * @param origin the origin of the updraft
  70322. * @param radiusOrEventOptions the radius or the options of the updraft
  70323. * @param strength the strength of the updraft
  70324. * @param height the height of the updraft
  70325. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70326. * @returns A physics updraft event, or null
  70327. */
  70328. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70329. /**
  70330. * Creates a physics vortex event
  70331. * @param origin the of the vortex
  70332. * @param radiusOrEventOptions the radius or the options of the vortex
  70333. * @param strength the strength of the vortex
  70334. * @param height the height of the vortex
  70335. * @returns a Physics vortex event, or null
  70336. * A physics vortex event or null
  70337. */
  70338. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70339. }
  70340. /**
  70341. * Represents a physics radial explosion event
  70342. */
  70343. class PhysicsRadialExplosionEvent {
  70344. private _scene;
  70345. private _options;
  70346. private _sphere;
  70347. private _dataFetched;
  70348. /**
  70349. * Initializes a radial explosioin event
  70350. * @param _scene BabylonJS scene
  70351. * @param _options The options for the vortex event
  70352. */
  70353. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70354. /**
  70355. * Returns the data related to the radial explosion event (sphere).
  70356. * @returns The radial explosion event data
  70357. */
  70358. getData(): PhysicsRadialExplosionEventData;
  70359. /**
  70360. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70361. * @param impostor A physics imposter
  70362. * @param origin the origin of the explosion
  70363. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70364. */
  70365. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70366. /**
  70367. * Triggers affecterd impostors callbacks
  70368. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70369. */
  70370. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70371. /**
  70372. * Disposes the sphere.
  70373. * @param force Specifies if the sphere should be disposed by force
  70374. */
  70375. dispose(force?: boolean): void;
  70376. /*** Helpers ***/
  70377. private _prepareSphere;
  70378. private _intersectsWithSphere;
  70379. }
  70380. /**
  70381. * Represents a gravitational field event
  70382. */
  70383. class PhysicsGravitationalFieldEvent {
  70384. private _physicsHelper;
  70385. private _scene;
  70386. private _origin;
  70387. private _options;
  70388. private _tickCallback;
  70389. private _sphere;
  70390. private _dataFetched;
  70391. /**
  70392. * Initializes the physics gravitational field event
  70393. * @param _physicsHelper A physics helper
  70394. * @param _scene BabylonJS scene
  70395. * @param _origin The origin position of the gravitational field event
  70396. * @param _options The options for the vortex event
  70397. */
  70398. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70399. /**
  70400. * Returns the data related to the gravitational field event (sphere).
  70401. * @returns A gravitational field event
  70402. */
  70403. getData(): PhysicsGravitationalFieldEventData;
  70404. /**
  70405. * Enables the gravitational field.
  70406. */
  70407. enable(): void;
  70408. /**
  70409. * Disables the gravitational field.
  70410. */
  70411. disable(): void;
  70412. /**
  70413. * Disposes the sphere.
  70414. * @param force The force to dispose from the gravitational field event
  70415. */
  70416. dispose(force?: boolean): void;
  70417. private _tick;
  70418. }
  70419. /**
  70420. * Represents a physics updraft event
  70421. */
  70422. class PhysicsUpdraftEvent {
  70423. private _scene;
  70424. private _origin;
  70425. private _options;
  70426. private _physicsEngine;
  70427. private _originTop;
  70428. private _originDirection;
  70429. private _tickCallback;
  70430. private _cylinder;
  70431. private _cylinderPosition;
  70432. private _dataFetched;
  70433. /**
  70434. * Initializes the physics updraft event
  70435. * @param _scene BabylonJS scene
  70436. * @param _origin The origin position of the updraft
  70437. * @param _options The options for the updraft event
  70438. */
  70439. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70440. /**
  70441. * Returns the data related to the updraft event (cylinder).
  70442. * @returns A physics updraft event
  70443. */
  70444. getData(): PhysicsUpdraftEventData;
  70445. /**
  70446. * Enables the updraft.
  70447. */
  70448. enable(): void;
  70449. /**
  70450. * Disables the updraft.
  70451. */
  70452. disable(): void;
  70453. /**
  70454. * Disposes the cylinder.
  70455. * @param force Specifies if the updraft should be disposed by force
  70456. */
  70457. dispose(force?: boolean): void;
  70458. private getImpostorHitData;
  70459. private _tick;
  70460. /*** Helpers ***/
  70461. private _prepareCylinder;
  70462. private _intersectsWithCylinder;
  70463. }
  70464. /**
  70465. * Represents a physics vortex event
  70466. */
  70467. class PhysicsVortexEvent {
  70468. private _scene;
  70469. private _origin;
  70470. private _options;
  70471. private _physicsEngine;
  70472. private _originTop;
  70473. private _tickCallback;
  70474. private _cylinder;
  70475. private _cylinderPosition;
  70476. private _dataFetched;
  70477. /**
  70478. * Initializes the physics vortex event
  70479. * @param _scene The BabylonJS scene
  70480. * @param _origin The origin position of the vortex
  70481. * @param _options The options for the vortex event
  70482. */
  70483. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70484. /**
  70485. * Returns the data related to the vortex event (cylinder).
  70486. * @returns The physics vortex event data
  70487. */
  70488. getData(): PhysicsVortexEventData;
  70489. /**
  70490. * Enables the vortex.
  70491. */
  70492. enable(): void;
  70493. /**
  70494. * Disables the cortex.
  70495. */
  70496. disable(): void;
  70497. /**
  70498. * Disposes the sphere.
  70499. * @param force
  70500. */
  70501. dispose(force?: boolean): void;
  70502. private getImpostorHitData;
  70503. private _tick;
  70504. /*** Helpers ***/
  70505. private _prepareCylinder;
  70506. private _intersectsWithCylinder;
  70507. }
  70508. /**
  70509. * Options fot the radial explosion event
  70510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70511. */
  70512. export class PhysicsRadialExplosionEventOptions {
  70513. /**
  70514. * The radius of the sphere for the radial explosion.
  70515. */
  70516. radius: number;
  70517. /**
  70518. * The strenth of the explosion.
  70519. */
  70520. strength: number;
  70521. /**
  70522. * The strenght of the force in correspondence to the distance of the affected object
  70523. */
  70524. falloff: PhysicsRadialImpulseFalloff;
  70525. /**
  70526. * Sphere options for the radial explosion.
  70527. */
  70528. sphere: {
  70529. segments: number;
  70530. diameter: number;
  70531. };
  70532. /**
  70533. * Sphere options for the radial explosion.
  70534. */
  70535. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70536. }
  70537. /**
  70538. * Options fot the updraft event
  70539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70540. */
  70541. export class PhysicsUpdraftEventOptions {
  70542. /**
  70543. * The radius of the cylinder for the vortex
  70544. */
  70545. radius: number;
  70546. /**
  70547. * The strenth of the updraft.
  70548. */
  70549. strength: number;
  70550. /**
  70551. * The height of the cylinder for the updraft.
  70552. */
  70553. height: number;
  70554. /**
  70555. * The mode for the the updraft.
  70556. */
  70557. updraftMode: PhysicsUpdraftMode;
  70558. }
  70559. /**
  70560. * Options fot the vortex event
  70561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70562. */
  70563. export class PhysicsVortexEventOptions {
  70564. /**
  70565. * The radius of the cylinder for the vortex
  70566. */
  70567. radius: number;
  70568. /**
  70569. * The strenth of the vortex.
  70570. */
  70571. strength: number;
  70572. /**
  70573. * The height of the cylinder for the vortex.
  70574. */
  70575. height: number;
  70576. /**
  70577. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70578. */
  70579. centripetalForceThreshold: number;
  70580. /**
  70581. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70582. */
  70583. centripetalForceMultiplier: number;
  70584. /**
  70585. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70586. */
  70587. centrifugalForceMultiplier: number;
  70588. /**
  70589. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70590. */
  70591. updraftForceMultiplier: number;
  70592. }
  70593. /**
  70594. * The strenght of the force in correspondence to the distance of the affected object
  70595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70596. */
  70597. export enum PhysicsRadialImpulseFalloff {
  70598. /** Defines that impulse is constant in strength across it's whole radius */
  70599. Constant = 0,
  70600. /** Defines that impulse gets weaker if it's further from the origin */
  70601. Linear = 1
  70602. }
  70603. /**
  70604. * The strength of the force in correspondence to the distance of the affected object
  70605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70606. */
  70607. export enum PhysicsUpdraftMode {
  70608. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70609. Center = 0,
  70610. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70611. Perpendicular = 1
  70612. }
  70613. /**
  70614. * Interface for a physics hit data
  70615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70616. */
  70617. export interface PhysicsHitData {
  70618. /**
  70619. * The force applied at the contact point
  70620. */
  70621. force: Vector3;
  70622. /**
  70623. * The contact point
  70624. */
  70625. contactPoint: Vector3;
  70626. /**
  70627. * The distance from the origin to the contact point
  70628. */
  70629. distanceFromOrigin: number;
  70630. }
  70631. /**
  70632. * Interface for radial explosion event data
  70633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70634. */
  70635. export interface PhysicsRadialExplosionEventData {
  70636. /**
  70637. * A sphere used for the radial explosion event
  70638. */
  70639. sphere: Mesh;
  70640. }
  70641. /**
  70642. * Interface for gravitational field event data
  70643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70644. */
  70645. export interface PhysicsGravitationalFieldEventData {
  70646. /**
  70647. * A sphere mesh used for the gravitational field event
  70648. */
  70649. sphere: Mesh;
  70650. }
  70651. /**
  70652. * Interface for updraft event data
  70653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70654. */
  70655. export interface PhysicsUpdraftEventData {
  70656. /**
  70657. * A cylinder used for the updraft event
  70658. */
  70659. cylinder: Mesh;
  70660. }
  70661. /**
  70662. * Interface for vortex event data
  70663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70664. */
  70665. export interface PhysicsVortexEventData {
  70666. /**
  70667. * A cylinder used for the vortex event
  70668. */
  70669. cylinder: Mesh;
  70670. }
  70671. /**
  70672. * Interface for an affected physics impostor
  70673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70674. */
  70675. export interface PhysicsAffectedImpostorWithData {
  70676. /**
  70677. * The impostor affected by the effect
  70678. */
  70679. impostor: PhysicsImpostor;
  70680. /**
  70681. * The data about the hit/horce from the explosion
  70682. */
  70683. hitData: PhysicsHitData;
  70684. }
  70685. }
  70686. declare module "babylonjs/Physics/Plugins/index" {
  70687. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  70688. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  70689. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  70690. }
  70691. declare module "babylonjs/Physics/index" {
  70692. export * from "babylonjs/Physics/IPhysicsEngine";
  70693. export * from "babylonjs/Physics/physicsEngine";
  70694. export * from "babylonjs/Physics/physicsEngineComponent";
  70695. export * from "babylonjs/Physics/physicsHelper";
  70696. export * from "babylonjs/Physics/physicsImpostor";
  70697. export * from "babylonjs/Physics/physicsJoint";
  70698. export * from "babylonjs/Physics/Plugins/index";
  70699. }
  70700. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  70701. /** @hidden */
  70702. export var blackAndWhitePixelShader: {
  70703. name: string;
  70704. shader: string;
  70705. };
  70706. }
  70707. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  70708. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70709. import { Camera } from "babylonjs/Cameras/camera";
  70710. import { Engine } from "babylonjs/Engines/engine";
  70711. import "babylonjs/Shaders/blackAndWhite.fragment";
  70712. /**
  70713. * Post process used to render in black and white
  70714. */
  70715. export class BlackAndWhitePostProcess extends PostProcess {
  70716. /**
  70717. * Linear about to convert he result to black and white (default: 1)
  70718. */
  70719. degree: number;
  70720. /**
  70721. * Creates a black and white post process
  70722. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70723. * @param name The name of the effect.
  70724. * @param options The required width/height ratio to downsize to before computing the render pass.
  70725. * @param camera The camera to apply the render pass to.
  70726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70727. * @param engine The engine which the post process will be applied. (default: current engine)
  70728. * @param reusable If the post process can be reused on the same frame. (default: false)
  70729. */
  70730. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70731. }
  70732. }
  70733. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  70734. import { Nullable } from "babylonjs/types";
  70735. import { Camera } from "babylonjs/Cameras/camera";
  70736. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70737. import { Engine } from "babylonjs/Engines/engine";
  70738. /**
  70739. * This represents a set of one or more post processes in Babylon.
  70740. * A post process can be used to apply a shader to a texture after it is rendered.
  70741. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70742. */
  70743. export class PostProcessRenderEffect {
  70744. private _postProcesses;
  70745. private _getPostProcesses;
  70746. private _singleInstance;
  70747. private _cameras;
  70748. private _indicesForCamera;
  70749. /**
  70750. * Name of the effect
  70751. * @hidden
  70752. */
  70753. _name: string;
  70754. /**
  70755. * Instantiates a post process render effect.
  70756. * A post process can be used to apply a shader to a texture after it is rendered.
  70757. * @param engine The engine the effect is tied to
  70758. * @param name The name of the effect
  70759. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70760. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70761. */
  70762. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70763. /**
  70764. * Checks if all the post processes in the effect are supported.
  70765. */
  70766. get isSupported(): boolean;
  70767. /**
  70768. * Updates the current state of the effect
  70769. * @hidden
  70770. */
  70771. _update(): void;
  70772. /**
  70773. * Attaches the effect on cameras
  70774. * @param cameras The camera to attach to.
  70775. * @hidden
  70776. */
  70777. _attachCameras(cameras: Camera): void;
  70778. /**
  70779. * Attaches the effect on cameras
  70780. * @param cameras The camera to attach to.
  70781. * @hidden
  70782. */
  70783. _attachCameras(cameras: Camera[]): void;
  70784. /**
  70785. * Detaches the effect on cameras
  70786. * @param cameras The camera to detatch from.
  70787. * @hidden
  70788. */
  70789. _detachCameras(cameras: Camera): void;
  70790. /**
  70791. * Detatches the effect on cameras
  70792. * @param cameras The camera to detatch from.
  70793. * @hidden
  70794. */
  70795. _detachCameras(cameras: Camera[]): void;
  70796. /**
  70797. * Enables the effect on given cameras
  70798. * @param cameras The camera to enable.
  70799. * @hidden
  70800. */
  70801. _enable(cameras: Camera): void;
  70802. /**
  70803. * Enables the effect on given cameras
  70804. * @param cameras The camera to enable.
  70805. * @hidden
  70806. */
  70807. _enable(cameras: Nullable<Camera[]>): void;
  70808. /**
  70809. * Disables the effect on the given cameras
  70810. * @param cameras The camera to disable.
  70811. * @hidden
  70812. */
  70813. _disable(cameras: Camera): void;
  70814. /**
  70815. * Disables the effect on the given cameras
  70816. * @param cameras The camera to disable.
  70817. * @hidden
  70818. */
  70819. _disable(cameras: Nullable<Camera[]>): void;
  70820. /**
  70821. * Gets a list of the post processes contained in the effect.
  70822. * @param camera The camera to get the post processes on.
  70823. * @returns The list of the post processes in the effect.
  70824. */
  70825. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70826. }
  70827. }
  70828. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  70829. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70830. /** @hidden */
  70831. export var extractHighlightsPixelShader: {
  70832. name: string;
  70833. shader: string;
  70834. };
  70835. }
  70836. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  70837. import { Nullable } from "babylonjs/types";
  70838. import { Camera } from "babylonjs/Cameras/camera";
  70839. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70840. import { Engine } from "babylonjs/Engines/engine";
  70841. import "babylonjs/Shaders/extractHighlights.fragment";
  70842. /**
  70843. * 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.
  70844. */
  70845. export class ExtractHighlightsPostProcess extends PostProcess {
  70846. /**
  70847. * The luminance threshold, pixels below this value will be set to black.
  70848. */
  70849. threshold: number;
  70850. /** @hidden */
  70851. _exposure: number;
  70852. /**
  70853. * Post process which has the input texture to be used when performing highlight extraction
  70854. * @hidden
  70855. */
  70856. _inputPostProcess: Nullable<PostProcess>;
  70857. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70858. }
  70859. }
  70860. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  70861. /** @hidden */
  70862. export var bloomMergePixelShader: {
  70863. name: string;
  70864. shader: string;
  70865. };
  70866. }
  70867. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  70868. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70869. import { Nullable } from "babylonjs/types";
  70870. import { Engine } from "babylonjs/Engines/engine";
  70871. import { Camera } from "babylonjs/Cameras/camera";
  70872. import "babylonjs/Shaders/bloomMerge.fragment";
  70873. /**
  70874. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70875. */
  70876. export class BloomMergePostProcess extends PostProcess {
  70877. /** Weight of the bloom to be added to the original input. */
  70878. weight: number;
  70879. /**
  70880. * Creates a new instance of @see BloomMergePostProcess
  70881. * @param name The name of the effect.
  70882. * @param originalFromInput Post process which's input will be used for the merge.
  70883. * @param blurred Blurred highlights post process which's output will be used.
  70884. * @param weight Weight of the bloom to be added to the original input.
  70885. * @param options The required width/height ratio to downsize to before computing the render pass.
  70886. * @param camera The camera to apply the render pass to.
  70887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70888. * @param engine The engine which the post process will be applied. (default: current engine)
  70889. * @param reusable If the post process can be reused on the same frame. (default: false)
  70890. * @param textureType Type of textures used when performing the post process. (default: 0)
  70891. * @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)
  70892. */
  70893. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70894. /** Weight of the bloom to be added to the original input. */
  70895. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70896. }
  70897. }
  70898. declare module "babylonjs/PostProcesses/bloomEffect" {
  70899. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70900. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70901. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70902. import { Camera } from "babylonjs/Cameras/camera";
  70903. import { Scene } from "babylonjs/scene";
  70904. /**
  70905. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70906. */
  70907. export class BloomEffect extends PostProcessRenderEffect {
  70908. private bloomScale;
  70909. /**
  70910. * @hidden Internal
  70911. */
  70912. _effects: Array<PostProcess>;
  70913. /**
  70914. * @hidden Internal
  70915. */
  70916. _downscale: ExtractHighlightsPostProcess;
  70917. private _blurX;
  70918. private _blurY;
  70919. private _merge;
  70920. /**
  70921. * The luminance threshold to find bright areas of the image to bloom.
  70922. */
  70923. get threshold(): number;
  70924. set threshold(value: number);
  70925. /**
  70926. * The strength of the bloom.
  70927. */
  70928. get weight(): number;
  70929. set weight(value: number);
  70930. /**
  70931. * Specifies the size of the bloom blur kernel, relative to the final output size
  70932. */
  70933. get kernel(): number;
  70934. set kernel(value: number);
  70935. /**
  70936. * Creates a new instance of @see BloomEffect
  70937. * @param scene The scene the effect belongs to.
  70938. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70939. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70940. * @param bloomWeight The the strength of bloom.
  70941. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70942. * @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)
  70943. */
  70944. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70945. /**
  70946. * Disposes each of the internal effects for a given camera.
  70947. * @param camera The camera to dispose the effect on.
  70948. */
  70949. disposeEffects(camera: Camera): void;
  70950. /**
  70951. * @hidden Internal
  70952. */
  70953. _updateEffects(): void;
  70954. /**
  70955. * Internal
  70956. * @returns if all the contained post processes are ready.
  70957. * @hidden
  70958. */
  70959. _isReady(): boolean;
  70960. }
  70961. }
  70962. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  70963. /** @hidden */
  70964. export var chromaticAberrationPixelShader: {
  70965. name: string;
  70966. shader: string;
  70967. };
  70968. }
  70969. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  70970. import { Vector2 } from "babylonjs/Maths/math.vector";
  70971. import { Nullable } from "babylonjs/types";
  70972. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70973. import { Camera } from "babylonjs/Cameras/camera";
  70974. import { Engine } from "babylonjs/Engines/engine";
  70975. import "babylonjs/Shaders/chromaticAberration.fragment";
  70976. /**
  70977. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70978. */
  70979. export class ChromaticAberrationPostProcess extends PostProcess {
  70980. /**
  70981. * The amount of seperation of rgb channels (default: 30)
  70982. */
  70983. aberrationAmount: number;
  70984. /**
  70985. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70986. */
  70987. radialIntensity: number;
  70988. /**
  70989. * 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))
  70990. */
  70991. direction: Vector2;
  70992. /**
  70993. * 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))
  70994. */
  70995. centerPosition: Vector2;
  70996. /**
  70997. * Creates a new instance ChromaticAberrationPostProcess
  70998. * @param name The name of the effect.
  70999. * @param screenWidth The width of the screen to apply the effect on.
  71000. * @param screenHeight The height of the screen to apply the effect on.
  71001. * @param options The required width/height ratio to downsize to before computing the render pass.
  71002. * @param camera The camera to apply the render pass to.
  71003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71004. * @param engine The engine which the post process will be applied. (default: current engine)
  71005. * @param reusable If the post process can be reused on the same frame. (default: false)
  71006. * @param textureType Type of textures used when performing the post process. (default: 0)
  71007. * @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)
  71008. */
  71009. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71010. }
  71011. }
  71012. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71013. /** @hidden */
  71014. export var circleOfConfusionPixelShader: {
  71015. name: string;
  71016. shader: string;
  71017. };
  71018. }
  71019. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71020. import { Nullable } from "babylonjs/types";
  71021. import { Engine } from "babylonjs/Engines/engine";
  71022. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71023. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71024. import { Camera } from "babylonjs/Cameras/camera";
  71025. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71026. /**
  71027. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71028. */
  71029. export class CircleOfConfusionPostProcess extends PostProcess {
  71030. /**
  71031. * 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.
  71032. */
  71033. lensSize: number;
  71034. /**
  71035. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71036. */
  71037. fStop: number;
  71038. /**
  71039. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71040. */
  71041. focusDistance: number;
  71042. /**
  71043. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71044. */
  71045. focalLength: number;
  71046. private _depthTexture;
  71047. /**
  71048. * Creates a new instance CircleOfConfusionPostProcess
  71049. * @param name The name of the effect.
  71050. * @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.
  71051. * @param options The required width/height ratio to downsize to before computing the render pass.
  71052. * @param camera The camera to apply the render pass to.
  71053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71054. * @param engine The engine which the post process will be applied. (default: current engine)
  71055. * @param reusable If the post process can be reused on the same frame. (default: false)
  71056. * @param textureType Type of textures used when performing the post process. (default: 0)
  71057. * @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)
  71058. */
  71059. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71060. /**
  71061. * 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.
  71062. */
  71063. set depthTexture(value: RenderTargetTexture);
  71064. }
  71065. }
  71066. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71067. /** @hidden */
  71068. export var colorCorrectionPixelShader: {
  71069. name: string;
  71070. shader: string;
  71071. };
  71072. }
  71073. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71074. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71075. import { Engine } from "babylonjs/Engines/engine";
  71076. import { Camera } from "babylonjs/Cameras/camera";
  71077. import "babylonjs/Shaders/colorCorrection.fragment";
  71078. /**
  71079. *
  71080. * This post-process allows the modification of rendered colors by using
  71081. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71082. *
  71083. * The object needs to be provided an url to a texture containing the color
  71084. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71085. * Use an image editing software to tweak the LUT to match your needs.
  71086. *
  71087. * For an example of a color LUT, see here:
  71088. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71089. * For explanations on color grading, see here:
  71090. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71091. *
  71092. */
  71093. export class ColorCorrectionPostProcess extends PostProcess {
  71094. private _colorTableTexture;
  71095. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71096. }
  71097. }
  71098. declare module "babylonjs/Shaders/convolution.fragment" {
  71099. /** @hidden */
  71100. export var convolutionPixelShader: {
  71101. name: string;
  71102. shader: string;
  71103. };
  71104. }
  71105. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71106. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71107. import { Nullable } from "babylonjs/types";
  71108. import { Camera } from "babylonjs/Cameras/camera";
  71109. import { Engine } from "babylonjs/Engines/engine";
  71110. import "babylonjs/Shaders/convolution.fragment";
  71111. /**
  71112. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71113. * input texture to perform effects such as edge detection or sharpening
  71114. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71115. */
  71116. export class ConvolutionPostProcess extends PostProcess {
  71117. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71118. kernel: number[];
  71119. /**
  71120. * Creates a new instance ConvolutionPostProcess
  71121. * @param name The name of the effect.
  71122. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71123. * @param options The required width/height ratio to downsize to before computing the render pass.
  71124. * @param camera The camera to apply the render pass to.
  71125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71126. * @param engine The engine which the post process will be applied. (default: current engine)
  71127. * @param reusable If the post process can be reused on the same frame. (default: false)
  71128. * @param textureType Type of textures used when performing the post process. (default: 0)
  71129. */
  71130. constructor(name: string,
  71131. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71132. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71133. /**
  71134. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71135. */
  71136. static EdgeDetect0Kernel: number[];
  71137. /**
  71138. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71139. */
  71140. static EdgeDetect1Kernel: number[];
  71141. /**
  71142. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71143. */
  71144. static EdgeDetect2Kernel: number[];
  71145. /**
  71146. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71147. */
  71148. static SharpenKernel: number[];
  71149. /**
  71150. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71151. */
  71152. static EmbossKernel: number[];
  71153. /**
  71154. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71155. */
  71156. static GaussianKernel: number[];
  71157. }
  71158. }
  71159. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71160. import { Nullable } from "babylonjs/types";
  71161. import { Vector2 } from "babylonjs/Maths/math.vector";
  71162. import { Camera } from "babylonjs/Cameras/camera";
  71163. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71164. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71165. import { Engine } from "babylonjs/Engines/engine";
  71166. import { Scene } from "babylonjs/scene";
  71167. /**
  71168. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71169. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71170. * based on samples that have a large difference in distance than the center pixel.
  71171. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71172. */
  71173. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71174. direction: Vector2;
  71175. /**
  71176. * Creates a new instance CircleOfConfusionPostProcess
  71177. * @param name The name of the effect.
  71178. * @param scene The scene the effect belongs to.
  71179. * @param direction The direction the blur should be applied.
  71180. * @param kernel The size of the kernel used to blur.
  71181. * @param options The required width/height ratio to downsize to before computing the render pass.
  71182. * @param camera The camera to apply the render pass to.
  71183. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71184. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71186. * @param engine The engine which the post process will be applied. (default: current engine)
  71187. * @param reusable If the post process can be reused on the same frame. (default: false)
  71188. * @param textureType Type of textures used when performing the post process. (default: 0)
  71189. * @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)
  71190. */
  71191. 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);
  71192. }
  71193. }
  71194. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71195. /** @hidden */
  71196. export var depthOfFieldMergePixelShader: {
  71197. name: string;
  71198. shader: string;
  71199. };
  71200. }
  71201. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71202. import { Nullable } from "babylonjs/types";
  71203. import { Camera } from "babylonjs/Cameras/camera";
  71204. import { Effect } from "babylonjs/Materials/effect";
  71205. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71206. import { Engine } from "babylonjs/Engines/engine";
  71207. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71208. /**
  71209. * Options to be set when merging outputs from the default pipeline.
  71210. */
  71211. export class DepthOfFieldMergePostProcessOptions {
  71212. /**
  71213. * The original image to merge on top of
  71214. */
  71215. originalFromInput: PostProcess;
  71216. /**
  71217. * Parameters to perform the merge of the depth of field effect
  71218. */
  71219. depthOfField?: {
  71220. circleOfConfusion: PostProcess;
  71221. blurSteps: Array<PostProcess>;
  71222. };
  71223. /**
  71224. * Parameters to perform the merge of bloom effect
  71225. */
  71226. bloom?: {
  71227. blurred: PostProcess;
  71228. weight: number;
  71229. };
  71230. }
  71231. /**
  71232. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71233. */
  71234. export class DepthOfFieldMergePostProcess extends PostProcess {
  71235. private blurSteps;
  71236. /**
  71237. * Creates a new instance of DepthOfFieldMergePostProcess
  71238. * @param name The name of the effect.
  71239. * @param originalFromInput Post process which's input will be used for the merge.
  71240. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71241. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71242. * @param options The required width/height ratio to downsize to before computing the render pass.
  71243. * @param camera The camera to apply the render pass to.
  71244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71245. * @param engine The engine which the post process will be applied. (default: current engine)
  71246. * @param reusable If the post process can be reused on the same frame. (default: false)
  71247. * @param textureType Type of textures used when performing the post process. (default: 0)
  71248. * @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)
  71249. */
  71250. 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);
  71251. /**
  71252. * Updates the effect with the current post process compile time values and recompiles the shader.
  71253. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71254. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71255. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71256. * @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
  71257. * @param onCompiled Called when the shader has been compiled.
  71258. * @param onError Called if there is an error when compiling a shader.
  71259. */
  71260. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71261. }
  71262. }
  71263. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71264. import { Nullable } from "babylonjs/types";
  71265. import { Camera } from "babylonjs/Cameras/camera";
  71266. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71267. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71268. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71269. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71270. import { Scene } from "babylonjs/scene";
  71271. /**
  71272. * Specifies the level of max blur that should be applied when using the depth of field effect
  71273. */
  71274. export enum DepthOfFieldEffectBlurLevel {
  71275. /**
  71276. * Subtle blur
  71277. */
  71278. Low = 0,
  71279. /**
  71280. * Medium blur
  71281. */
  71282. Medium = 1,
  71283. /**
  71284. * Large blur
  71285. */
  71286. High = 2
  71287. }
  71288. /**
  71289. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71290. */
  71291. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71292. private _circleOfConfusion;
  71293. /**
  71294. * @hidden Internal, blurs from high to low
  71295. */
  71296. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71297. private _depthOfFieldBlurY;
  71298. private _dofMerge;
  71299. /**
  71300. * @hidden Internal post processes in depth of field effect
  71301. */
  71302. _effects: Array<PostProcess>;
  71303. /**
  71304. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71305. */
  71306. set focalLength(value: number);
  71307. get focalLength(): number;
  71308. /**
  71309. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71310. */
  71311. set fStop(value: number);
  71312. get fStop(): number;
  71313. /**
  71314. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71315. */
  71316. set focusDistance(value: number);
  71317. get focusDistance(): number;
  71318. /**
  71319. * 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.
  71320. */
  71321. set lensSize(value: number);
  71322. get lensSize(): number;
  71323. /**
  71324. * Creates a new instance DepthOfFieldEffect
  71325. * @param scene The scene the effect belongs to.
  71326. * @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.
  71327. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71328. * @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)
  71329. */
  71330. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71331. /**
  71332. * Get the current class name of the current effet
  71333. * @returns "DepthOfFieldEffect"
  71334. */
  71335. getClassName(): string;
  71336. /**
  71337. * 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.
  71338. */
  71339. set depthTexture(value: RenderTargetTexture);
  71340. /**
  71341. * Disposes each of the internal effects for a given camera.
  71342. * @param camera The camera to dispose the effect on.
  71343. */
  71344. disposeEffects(camera: Camera): void;
  71345. /**
  71346. * @hidden Internal
  71347. */
  71348. _updateEffects(): void;
  71349. /**
  71350. * Internal
  71351. * @returns if all the contained post processes are ready.
  71352. * @hidden
  71353. */
  71354. _isReady(): boolean;
  71355. }
  71356. }
  71357. declare module "babylonjs/Shaders/displayPass.fragment" {
  71358. /** @hidden */
  71359. export var displayPassPixelShader: {
  71360. name: string;
  71361. shader: string;
  71362. };
  71363. }
  71364. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  71365. import { Nullable } from "babylonjs/types";
  71366. import { Camera } from "babylonjs/Cameras/camera";
  71367. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71368. import { Engine } from "babylonjs/Engines/engine";
  71369. import "babylonjs/Shaders/displayPass.fragment";
  71370. /**
  71371. * DisplayPassPostProcess which produces an output the same as it's input
  71372. */
  71373. export class DisplayPassPostProcess extends PostProcess {
  71374. /**
  71375. * Creates the DisplayPassPostProcess
  71376. * @param name The name of the effect.
  71377. * @param options The required width/height ratio to downsize to before computing the render pass.
  71378. * @param camera The camera to apply the render pass to.
  71379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71380. * @param engine The engine which the post process will be applied. (default: current engine)
  71381. * @param reusable If the post process can be reused on the same frame. (default: false)
  71382. */
  71383. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71384. }
  71385. }
  71386. declare module "babylonjs/Shaders/filter.fragment" {
  71387. /** @hidden */
  71388. export var filterPixelShader: {
  71389. name: string;
  71390. shader: string;
  71391. };
  71392. }
  71393. declare module "babylonjs/PostProcesses/filterPostProcess" {
  71394. import { Nullable } from "babylonjs/types";
  71395. import { Matrix } from "babylonjs/Maths/math.vector";
  71396. import { Camera } from "babylonjs/Cameras/camera";
  71397. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71398. import { Engine } from "babylonjs/Engines/engine";
  71399. import "babylonjs/Shaders/filter.fragment";
  71400. /**
  71401. * Applies a kernel filter to the image
  71402. */
  71403. export class FilterPostProcess extends PostProcess {
  71404. /** The matrix to be applied to the image */
  71405. kernelMatrix: Matrix;
  71406. /**
  71407. *
  71408. * @param name The name of the effect.
  71409. * @param kernelMatrix The matrix to be applied to the image
  71410. * @param options The required width/height ratio to downsize to before computing the render pass.
  71411. * @param camera The camera to apply the render pass to.
  71412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71413. * @param engine The engine which the post process will be applied. (default: current engine)
  71414. * @param reusable If the post process can be reused on the same frame. (default: false)
  71415. */
  71416. constructor(name: string,
  71417. /** The matrix to be applied to the image */
  71418. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71419. }
  71420. }
  71421. declare module "babylonjs/Shaders/fxaa.fragment" {
  71422. /** @hidden */
  71423. export var fxaaPixelShader: {
  71424. name: string;
  71425. shader: string;
  71426. };
  71427. }
  71428. declare module "babylonjs/Shaders/fxaa.vertex" {
  71429. /** @hidden */
  71430. export var fxaaVertexShader: {
  71431. name: string;
  71432. shader: string;
  71433. };
  71434. }
  71435. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  71436. import { Nullable } from "babylonjs/types";
  71437. import { Camera } from "babylonjs/Cameras/camera";
  71438. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71439. import { Engine } from "babylonjs/Engines/engine";
  71440. import "babylonjs/Shaders/fxaa.fragment";
  71441. import "babylonjs/Shaders/fxaa.vertex";
  71442. /**
  71443. * Fxaa post process
  71444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71445. */
  71446. export class FxaaPostProcess extends PostProcess {
  71447. /** @hidden */
  71448. texelWidth: number;
  71449. /** @hidden */
  71450. texelHeight: number;
  71451. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71452. private _getDefines;
  71453. }
  71454. }
  71455. declare module "babylonjs/Shaders/grain.fragment" {
  71456. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71457. /** @hidden */
  71458. export var grainPixelShader: {
  71459. name: string;
  71460. shader: string;
  71461. };
  71462. }
  71463. declare module "babylonjs/PostProcesses/grainPostProcess" {
  71464. import { Nullable } from "babylonjs/types";
  71465. import { Camera } from "babylonjs/Cameras/camera";
  71466. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71467. import { Engine } from "babylonjs/Engines/engine";
  71468. import "babylonjs/Shaders/grain.fragment";
  71469. /**
  71470. * The GrainPostProcess adds noise to the image at mid luminance levels
  71471. */
  71472. export class GrainPostProcess extends PostProcess {
  71473. /**
  71474. * The intensity of the grain added (default: 30)
  71475. */
  71476. intensity: number;
  71477. /**
  71478. * If the grain should be randomized on every frame
  71479. */
  71480. animated: boolean;
  71481. /**
  71482. * Creates a new instance of @see GrainPostProcess
  71483. * @param name The name of the effect.
  71484. * @param options The required width/height ratio to downsize to before computing the render pass.
  71485. * @param camera The camera to apply the render pass to.
  71486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71487. * @param engine The engine which the post process will be applied. (default: current engine)
  71488. * @param reusable If the post process can be reused on the same frame. (default: false)
  71489. * @param textureType Type of textures used when performing the post process. (default: 0)
  71490. * @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)
  71491. */
  71492. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71493. }
  71494. }
  71495. declare module "babylonjs/Shaders/highlights.fragment" {
  71496. /** @hidden */
  71497. export var highlightsPixelShader: {
  71498. name: string;
  71499. shader: string;
  71500. };
  71501. }
  71502. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  71503. import { Nullable } from "babylonjs/types";
  71504. import { Camera } from "babylonjs/Cameras/camera";
  71505. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71506. import { Engine } from "babylonjs/Engines/engine";
  71507. import "babylonjs/Shaders/highlights.fragment";
  71508. /**
  71509. * Extracts highlights from the image
  71510. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71511. */
  71512. export class HighlightsPostProcess extends PostProcess {
  71513. /**
  71514. * Extracts highlights from the image
  71515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71516. * @param name The name of the effect.
  71517. * @param options The required width/height ratio to downsize to before computing the render pass.
  71518. * @param camera The camera to apply the render pass to.
  71519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71520. * @param engine The engine which the post process will be applied. (default: current engine)
  71521. * @param reusable If the post process can be reused on the same frame. (default: false)
  71522. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71523. */
  71524. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71525. }
  71526. }
  71527. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  71528. /** @hidden */
  71529. export var mrtFragmentDeclaration: {
  71530. name: string;
  71531. shader: string;
  71532. };
  71533. }
  71534. declare module "babylonjs/Shaders/geometry.fragment" {
  71535. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  71536. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  71537. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  71538. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  71539. /** @hidden */
  71540. export var geometryPixelShader: {
  71541. name: string;
  71542. shader: string;
  71543. };
  71544. }
  71545. declare module "babylonjs/Shaders/geometry.vertex" {
  71546. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  71547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  71548. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  71549. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  71550. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71551. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71552. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71553. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  71554. /** @hidden */
  71555. export var geometryVertexShader: {
  71556. name: string;
  71557. shader: string;
  71558. };
  71559. }
  71560. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  71561. import { Matrix } from "babylonjs/Maths/math.vector";
  71562. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71563. import { Mesh } from "babylonjs/Meshes/mesh";
  71564. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  71565. import { Effect } from "babylonjs/Materials/effect";
  71566. import { Scene } from "babylonjs/scene";
  71567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71568. import "babylonjs/Shaders/geometry.fragment";
  71569. import "babylonjs/Shaders/geometry.vertex";
  71570. /** @hidden */
  71571. interface ISavedTransformationMatrix {
  71572. world: Matrix;
  71573. viewProjection: Matrix;
  71574. }
  71575. /**
  71576. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  71577. */
  71578. export class GeometryBufferRenderer {
  71579. /**
  71580. * Constant used to retrieve the position texture index in the G-Buffer textures array
  71581. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  71582. */
  71583. static readonly POSITION_TEXTURE_TYPE: number;
  71584. /**
  71585. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  71586. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  71587. */
  71588. static readonly VELOCITY_TEXTURE_TYPE: number;
  71589. /**
  71590. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  71591. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  71592. */
  71593. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  71594. /**
  71595. * Dictionary used to store the previous transformation matrices of each rendered mesh
  71596. * in order to compute objects velocities when enableVelocity is set to "true"
  71597. * @hidden
  71598. */
  71599. _previousTransformationMatrices: {
  71600. [index: number]: ISavedTransformationMatrix;
  71601. };
  71602. /**
  71603. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  71604. * in order to compute objects velocities when enableVelocity is set to "true"
  71605. * @hidden
  71606. */
  71607. _previousBonesTransformationMatrices: {
  71608. [index: number]: Float32Array;
  71609. };
  71610. /**
  71611. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  71612. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  71613. */
  71614. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  71615. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  71616. renderTransparentMeshes: boolean;
  71617. private _scene;
  71618. private _multiRenderTarget;
  71619. private _ratio;
  71620. private _enablePosition;
  71621. private _enableVelocity;
  71622. private _enableReflectivity;
  71623. private _positionIndex;
  71624. private _velocityIndex;
  71625. private _reflectivityIndex;
  71626. protected _effect: Effect;
  71627. protected _cachedDefines: string;
  71628. /**
  71629. * Set the render list (meshes to be rendered) used in the G buffer.
  71630. */
  71631. set renderList(meshes: Mesh[]);
  71632. /**
  71633. * Gets wether or not G buffer are supported by the running hardware.
  71634. * This requires draw buffer supports
  71635. */
  71636. get isSupported(): boolean;
  71637. /**
  71638. * Returns the index of the given texture type in the G-Buffer textures array
  71639. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  71640. * @returns the index of the given texture type in the G-Buffer textures array
  71641. */
  71642. getTextureIndex(textureType: number): number;
  71643. /**
  71644. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  71645. */
  71646. get enablePosition(): boolean;
  71647. /**
  71648. * Sets whether or not objects positions are enabled for the G buffer.
  71649. */
  71650. set enablePosition(enable: boolean);
  71651. /**
  71652. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  71653. */
  71654. get enableVelocity(): boolean;
  71655. /**
  71656. * Sets wether or not objects velocities are enabled for the G buffer.
  71657. */
  71658. set enableVelocity(enable: boolean);
  71659. /**
  71660. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  71661. */
  71662. get enableReflectivity(): boolean;
  71663. /**
  71664. * Sets wether or not objects roughness are enabled for the G buffer.
  71665. */
  71666. set enableReflectivity(enable: boolean);
  71667. /**
  71668. * Gets the scene associated with the buffer.
  71669. */
  71670. get scene(): Scene;
  71671. /**
  71672. * Gets the ratio used by the buffer during its creation.
  71673. * How big is the buffer related to the main canvas.
  71674. */
  71675. get ratio(): number;
  71676. /** @hidden */
  71677. static _SceneComponentInitialization: (scene: Scene) => void;
  71678. /**
  71679. * Creates a new G Buffer for the scene
  71680. * @param scene The scene the buffer belongs to
  71681. * @param ratio How big is the buffer related to the main canvas.
  71682. */
  71683. constructor(scene: Scene, ratio?: number);
  71684. /**
  71685. * Checks wether everything is ready to render a submesh to the G buffer.
  71686. * @param subMesh the submesh to check readiness for
  71687. * @param useInstances is the mesh drawn using instance or not
  71688. * @returns true if ready otherwise false
  71689. */
  71690. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71691. /**
  71692. * Gets the current underlying G Buffer.
  71693. * @returns the buffer
  71694. */
  71695. getGBuffer(): MultiRenderTarget;
  71696. /**
  71697. * Gets the number of samples used to render the buffer (anti aliasing).
  71698. */
  71699. get samples(): number;
  71700. /**
  71701. * Sets the number of samples used to render the buffer (anti aliasing).
  71702. */
  71703. set samples(value: number);
  71704. /**
  71705. * Disposes the renderer and frees up associated resources.
  71706. */
  71707. dispose(): void;
  71708. protected _createRenderTargets(): void;
  71709. private _copyBonesTransformationMatrices;
  71710. }
  71711. }
  71712. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  71713. import { Nullable } from "babylonjs/types";
  71714. import { Scene } from "babylonjs/scene";
  71715. import { ISceneComponent } from "babylonjs/sceneComponent";
  71716. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  71717. module "babylonjs/scene" {
  71718. interface Scene {
  71719. /** @hidden (Backing field) */
  71720. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71721. /**
  71722. * Gets or Sets the current geometry buffer associated to the scene.
  71723. */
  71724. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71725. /**
  71726. * Enables a GeometryBufferRender and associates it with the scene
  71727. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71728. * @returns the GeometryBufferRenderer
  71729. */
  71730. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71731. /**
  71732. * Disables the GeometryBufferRender associated with the scene
  71733. */
  71734. disableGeometryBufferRenderer(): void;
  71735. }
  71736. }
  71737. /**
  71738. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71739. * in several rendering techniques.
  71740. */
  71741. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71742. /**
  71743. * The component name helpful to identify the component in the list of scene components.
  71744. */
  71745. readonly name: string;
  71746. /**
  71747. * The scene the component belongs to.
  71748. */
  71749. scene: Scene;
  71750. /**
  71751. * Creates a new instance of the component for the given scene
  71752. * @param scene Defines the scene to register the component in
  71753. */
  71754. constructor(scene: Scene);
  71755. /**
  71756. * Registers the component in a given scene
  71757. */
  71758. register(): void;
  71759. /**
  71760. * Rebuilds the elements related to this component in case of
  71761. * context lost for instance.
  71762. */
  71763. rebuild(): void;
  71764. /**
  71765. * Disposes the component and the associated ressources
  71766. */
  71767. dispose(): void;
  71768. private _gatherRenderTargets;
  71769. }
  71770. }
  71771. declare module "babylonjs/Shaders/motionBlur.fragment" {
  71772. /** @hidden */
  71773. export var motionBlurPixelShader: {
  71774. name: string;
  71775. shader: string;
  71776. };
  71777. }
  71778. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  71779. import { Nullable } from "babylonjs/types";
  71780. import { Camera } from "babylonjs/Cameras/camera";
  71781. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71782. import { Scene } from "babylonjs/scene";
  71783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71784. import "babylonjs/Animations/animatable";
  71785. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71786. import "babylonjs/Shaders/motionBlur.fragment";
  71787. import { Engine } from "babylonjs/Engines/engine";
  71788. /**
  71789. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71790. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71791. * As an example, all you have to do is to create the post-process:
  71792. * var mb = new BABYLON.MotionBlurPostProcess(
  71793. * 'mb', // The name of the effect.
  71794. * scene, // The scene containing the objects to blur according to their velocity.
  71795. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71796. * camera // The camera to apply the render pass to.
  71797. * );
  71798. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71799. */
  71800. export class MotionBlurPostProcess extends PostProcess {
  71801. /**
  71802. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71803. */
  71804. motionStrength: number;
  71805. /**
  71806. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71807. */
  71808. get motionBlurSamples(): number;
  71809. /**
  71810. * Sets the number of iterations to be used for motion blur quality
  71811. */
  71812. set motionBlurSamples(samples: number);
  71813. private _motionBlurSamples;
  71814. private _geometryBufferRenderer;
  71815. /**
  71816. * Creates a new instance MotionBlurPostProcess
  71817. * @param name The name of the effect.
  71818. * @param scene The scene containing the objects to blur according to their velocity.
  71819. * @param options The required width/height ratio to downsize to before computing the render pass.
  71820. * @param camera The camera to apply the render pass to.
  71821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71822. * @param engine The engine which the post process will be applied. (default: current engine)
  71823. * @param reusable If the post process can be reused on the same frame. (default: false)
  71824. * @param textureType Type of textures used when performing the post process. (default: 0)
  71825. * @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)
  71826. */
  71827. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71828. /**
  71829. * Excludes the given skinned mesh from computing bones velocities.
  71830. * 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.
  71831. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71832. */
  71833. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71834. /**
  71835. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71836. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71837. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71838. */
  71839. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71840. /**
  71841. * Disposes the post process.
  71842. * @param camera The camera to dispose the post process on.
  71843. */
  71844. dispose(camera?: Camera): void;
  71845. }
  71846. }
  71847. declare module "babylonjs/Shaders/refraction.fragment" {
  71848. /** @hidden */
  71849. export var refractionPixelShader: {
  71850. name: string;
  71851. shader: string;
  71852. };
  71853. }
  71854. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  71855. import { Color3 } from "babylonjs/Maths/math.color";
  71856. import { Camera } from "babylonjs/Cameras/camera";
  71857. import { Texture } from "babylonjs/Materials/Textures/texture";
  71858. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71859. import { Engine } from "babylonjs/Engines/engine";
  71860. import "babylonjs/Shaders/refraction.fragment";
  71861. /**
  71862. * Post process which applies a refractin texture
  71863. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71864. */
  71865. export class RefractionPostProcess extends PostProcess {
  71866. /** the base color of the refraction (used to taint the rendering) */
  71867. color: Color3;
  71868. /** simulated refraction depth */
  71869. depth: number;
  71870. /** the coefficient of the base color (0 to remove base color tainting) */
  71871. colorLevel: number;
  71872. private _refTexture;
  71873. private _ownRefractionTexture;
  71874. /**
  71875. * Gets or sets the refraction texture
  71876. * Please note that you are responsible for disposing the texture if you set it manually
  71877. */
  71878. get refractionTexture(): Texture;
  71879. set refractionTexture(value: Texture);
  71880. /**
  71881. * Initializes the RefractionPostProcess
  71882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71883. * @param name The name of the effect.
  71884. * @param refractionTextureUrl Url of the refraction texture to use
  71885. * @param color the base color of the refraction (used to taint the rendering)
  71886. * @param depth simulated refraction depth
  71887. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71888. * @param camera The camera to apply the render pass to.
  71889. * @param options The required width/height ratio to downsize to before computing the render pass.
  71890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71891. * @param engine The engine which the post process will be applied. (default: current engine)
  71892. * @param reusable If the post process can be reused on the same frame. (default: false)
  71893. */
  71894. constructor(name: string, refractionTextureUrl: string,
  71895. /** the base color of the refraction (used to taint the rendering) */
  71896. color: Color3,
  71897. /** simulated refraction depth */
  71898. depth: number,
  71899. /** the coefficient of the base color (0 to remove base color tainting) */
  71900. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71901. /**
  71902. * Disposes of the post process
  71903. * @param camera Camera to dispose post process on
  71904. */
  71905. dispose(camera: Camera): void;
  71906. }
  71907. }
  71908. declare module "babylonjs/Shaders/sharpen.fragment" {
  71909. /** @hidden */
  71910. export var sharpenPixelShader: {
  71911. name: string;
  71912. shader: string;
  71913. };
  71914. }
  71915. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  71916. import { Nullable } from "babylonjs/types";
  71917. import { Camera } from "babylonjs/Cameras/camera";
  71918. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71919. import "babylonjs/Shaders/sharpen.fragment";
  71920. import { Engine } from "babylonjs/Engines/engine";
  71921. /**
  71922. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71923. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71924. */
  71925. export class SharpenPostProcess extends PostProcess {
  71926. /**
  71927. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71928. */
  71929. colorAmount: number;
  71930. /**
  71931. * How much sharpness should be applied (default: 0.3)
  71932. */
  71933. edgeAmount: number;
  71934. /**
  71935. * Creates a new instance ConvolutionPostProcess
  71936. * @param name The name of the effect.
  71937. * @param options The required width/height ratio to downsize to before computing the render pass.
  71938. * @param camera The camera to apply the render pass to.
  71939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71940. * @param engine The engine which the post process will be applied. (default: current engine)
  71941. * @param reusable If the post process can be reused on the same frame. (default: false)
  71942. * @param textureType Type of textures used when performing the post process. (default: 0)
  71943. * @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)
  71944. */
  71945. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71946. }
  71947. }
  71948. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  71949. import { Nullable } from "babylonjs/types";
  71950. import { Camera } from "babylonjs/Cameras/camera";
  71951. import { Engine } from "babylonjs/Engines/engine";
  71952. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71953. import { IInspectable } from "babylonjs/Misc/iInspectable";
  71954. /**
  71955. * PostProcessRenderPipeline
  71956. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71957. */
  71958. export class PostProcessRenderPipeline {
  71959. private engine;
  71960. private _renderEffects;
  71961. private _renderEffectsForIsolatedPass;
  71962. /**
  71963. * List of inspectable custom properties (used by the Inspector)
  71964. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71965. */
  71966. inspectableCustomProperties: IInspectable[];
  71967. /**
  71968. * @hidden
  71969. */
  71970. protected _cameras: Camera[];
  71971. /** @hidden */
  71972. _name: string;
  71973. /**
  71974. * Gets pipeline name
  71975. */
  71976. get name(): string;
  71977. /** Gets the list of attached cameras */
  71978. get cameras(): Camera[];
  71979. /**
  71980. * Initializes a PostProcessRenderPipeline
  71981. * @param engine engine to add the pipeline to
  71982. * @param name name of the pipeline
  71983. */
  71984. constructor(engine: Engine, name: string);
  71985. /**
  71986. * Gets the class name
  71987. * @returns "PostProcessRenderPipeline"
  71988. */
  71989. getClassName(): string;
  71990. /**
  71991. * If all the render effects in the pipeline are supported
  71992. */
  71993. get isSupported(): boolean;
  71994. /**
  71995. * Adds an effect to the pipeline
  71996. * @param renderEffect the effect to add
  71997. */
  71998. addEffect(renderEffect: PostProcessRenderEffect): void;
  71999. /** @hidden */
  72000. _rebuild(): void;
  72001. /** @hidden */
  72002. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72003. /** @hidden */
  72004. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72005. /** @hidden */
  72006. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72007. /** @hidden */
  72008. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72009. /** @hidden */
  72010. _attachCameras(cameras: Camera, unique: boolean): void;
  72011. /** @hidden */
  72012. _attachCameras(cameras: Camera[], unique: boolean): void;
  72013. /** @hidden */
  72014. _detachCameras(cameras: Camera): void;
  72015. /** @hidden */
  72016. _detachCameras(cameras: Nullable<Camera[]>): void;
  72017. /** @hidden */
  72018. _update(): void;
  72019. /** @hidden */
  72020. _reset(): void;
  72021. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72022. /**
  72023. * Disposes of the pipeline
  72024. */
  72025. dispose(): void;
  72026. }
  72027. }
  72028. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72029. import { Camera } from "babylonjs/Cameras/camera";
  72030. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72031. /**
  72032. * PostProcessRenderPipelineManager class
  72033. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72034. */
  72035. export class PostProcessRenderPipelineManager {
  72036. private _renderPipelines;
  72037. /**
  72038. * Initializes a PostProcessRenderPipelineManager
  72039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72040. */
  72041. constructor();
  72042. /**
  72043. * Gets the list of supported render pipelines
  72044. */
  72045. get supportedPipelines(): PostProcessRenderPipeline[];
  72046. /**
  72047. * Adds a pipeline to the manager
  72048. * @param renderPipeline The pipeline to add
  72049. */
  72050. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72051. /**
  72052. * Attaches a camera to the pipeline
  72053. * @param renderPipelineName The name of the pipeline to attach to
  72054. * @param cameras the camera to attach
  72055. * @param unique if the camera can be attached multiple times to the pipeline
  72056. */
  72057. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72058. /**
  72059. * Detaches a camera from the pipeline
  72060. * @param renderPipelineName The name of the pipeline to detach from
  72061. * @param cameras the camera to detach
  72062. */
  72063. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72064. /**
  72065. * Enables an effect by name on a pipeline
  72066. * @param renderPipelineName the name of the pipeline to enable the effect in
  72067. * @param renderEffectName the name of the effect to enable
  72068. * @param cameras the cameras that the effect should be enabled on
  72069. */
  72070. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72071. /**
  72072. * Disables an effect by name on a pipeline
  72073. * @param renderPipelineName the name of the pipeline to disable the effect in
  72074. * @param renderEffectName the name of the effect to disable
  72075. * @param cameras the cameras that the effect should be disabled on
  72076. */
  72077. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72078. /**
  72079. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72080. */
  72081. update(): void;
  72082. /** @hidden */
  72083. _rebuild(): void;
  72084. /**
  72085. * Disposes of the manager and pipelines
  72086. */
  72087. dispose(): void;
  72088. }
  72089. }
  72090. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72091. import { ISceneComponent } from "babylonjs/sceneComponent";
  72092. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72093. import { Scene } from "babylonjs/scene";
  72094. module "babylonjs/scene" {
  72095. interface Scene {
  72096. /** @hidden (Backing field) */
  72097. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72098. /**
  72099. * Gets the postprocess render pipeline manager
  72100. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72101. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72102. */
  72103. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72104. }
  72105. }
  72106. /**
  72107. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72108. */
  72109. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72110. /**
  72111. * The component name helpfull to identify the component in the list of scene components.
  72112. */
  72113. readonly name: string;
  72114. /**
  72115. * The scene the component belongs to.
  72116. */
  72117. scene: Scene;
  72118. /**
  72119. * Creates a new instance of the component for the given scene
  72120. * @param scene Defines the scene to register the component in
  72121. */
  72122. constructor(scene: Scene);
  72123. /**
  72124. * Registers the component in a given scene
  72125. */
  72126. register(): void;
  72127. /**
  72128. * Rebuilds the elements related to this component in case of
  72129. * context lost for instance.
  72130. */
  72131. rebuild(): void;
  72132. /**
  72133. * Disposes the component and the associated ressources
  72134. */
  72135. dispose(): void;
  72136. private _gatherRenderTargets;
  72137. }
  72138. }
  72139. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72140. import { Nullable } from "babylonjs/types";
  72141. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72142. import { Camera } from "babylonjs/Cameras/camera";
  72143. import { IDisposable } from "babylonjs/scene";
  72144. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72145. import { Scene } from "babylonjs/scene";
  72146. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72147. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72148. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72149. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72150. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72151. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72152. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72153. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72154. import { Animation } from "babylonjs/Animations/animation";
  72155. /**
  72156. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72157. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72158. */
  72159. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72160. private _scene;
  72161. private _camerasToBeAttached;
  72162. /**
  72163. * ID of the sharpen post process,
  72164. */
  72165. private readonly SharpenPostProcessId;
  72166. /**
  72167. * @ignore
  72168. * ID of the image processing post process;
  72169. */
  72170. readonly ImageProcessingPostProcessId: string;
  72171. /**
  72172. * @ignore
  72173. * ID of the Fast Approximate Anti-Aliasing post process;
  72174. */
  72175. readonly FxaaPostProcessId: string;
  72176. /**
  72177. * ID of the chromatic aberration post process,
  72178. */
  72179. private readonly ChromaticAberrationPostProcessId;
  72180. /**
  72181. * ID of the grain post process
  72182. */
  72183. private readonly GrainPostProcessId;
  72184. /**
  72185. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72186. */
  72187. sharpen: SharpenPostProcess;
  72188. private _sharpenEffect;
  72189. private bloom;
  72190. /**
  72191. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72192. */
  72193. depthOfField: DepthOfFieldEffect;
  72194. /**
  72195. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72196. */
  72197. fxaa: FxaaPostProcess;
  72198. /**
  72199. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72200. */
  72201. imageProcessing: ImageProcessingPostProcess;
  72202. /**
  72203. * Chromatic aberration post process which will shift rgb colors in the image
  72204. */
  72205. chromaticAberration: ChromaticAberrationPostProcess;
  72206. private _chromaticAberrationEffect;
  72207. /**
  72208. * Grain post process which add noise to the image
  72209. */
  72210. grain: GrainPostProcess;
  72211. private _grainEffect;
  72212. /**
  72213. * Glow post process which adds a glow to emissive areas of the image
  72214. */
  72215. private _glowLayer;
  72216. /**
  72217. * Animations which can be used to tweak settings over a period of time
  72218. */
  72219. animations: Animation[];
  72220. private _imageProcessingConfigurationObserver;
  72221. private _sharpenEnabled;
  72222. private _bloomEnabled;
  72223. private _depthOfFieldEnabled;
  72224. private _depthOfFieldBlurLevel;
  72225. private _fxaaEnabled;
  72226. private _imageProcessingEnabled;
  72227. private _defaultPipelineTextureType;
  72228. private _bloomScale;
  72229. private _chromaticAberrationEnabled;
  72230. private _grainEnabled;
  72231. private _buildAllowed;
  72232. /**
  72233. * Gets active scene
  72234. */
  72235. get scene(): Scene;
  72236. /**
  72237. * Enable or disable the sharpen process from the pipeline
  72238. */
  72239. set sharpenEnabled(enabled: boolean);
  72240. get sharpenEnabled(): boolean;
  72241. private _resizeObserver;
  72242. private _hardwareScaleLevel;
  72243. private _bloomKernel;
  72244. /**
  72245. * Specifies the size of the bloom blur kernel, relative to the final output size
  72246. */
  72247. get bloomKernel(): number;
  72248. set bloomKernel(value: number);
  72249. /**
  72250. * Specifies the weight of the bloom in the final rendering
  72251. */
  72252. private _bloomWeight;
  72253. /**
  72254. * Specifies the luma threshold for the area that will be blurred by the bloom
  72255. */
  72256. private _bloomThreshold;
  72257. private _hdr;
  72258. /**
  72259. * The strength of the bloom.
  72260. */
  72261. set bloomWeight(value: number);
  72262. get bloomWeight(): number;
  72263. /**
  72264. * The strength of the bloom.
  72265. */
  72266. set bloomThreshold(value: number);
  72267. get bloomThreshold(): number;
  72268. /**
  72269. * The scale of the bloom, lower value will provide better performance.
  72270. */
  72271. set bloomScale(value: number);
  72272. get bloomScale(): number;
  72273. /**
  72274. * Enable or disable the bloom from the pipeline
  72275. */
  72276. set bloomEnabled(enabled: boolean);
  72277. get bloomEnabled(): boolean;
  72278. private _rebuildBloom;
  72279. /**
  72280. * If the depth of field is enabled.
  72281. */
  72282. get depthOfFieldEnabled(): boolean;
  72283. set depthOfFieldEnabled(enabled: boolean);
  72284. /**
  72285. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72286. */
  72287. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72288. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72289. /**
  72290. * If the anti aliasing is enabled.
  72291. */
  72292. set fxaaEnabled(enabled: boolean);
  72293. get fxaaEnabled(): boolean;
  72294. private _samples;
  72295. /**
  72296. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72297. */
  72298. set samples(sampleCount: number);
  72299. get samples(): number;
  72300. /**
  72301. * If image processing is enabled.
  72302. */
  72303. set imageProcessingEnabled(enabled: boolean);
  72304. get imageProcessingEnabled(): boolean;
  72305. /**
  72306. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72307. */
  72308. set glowLayerEnabled(enabled: boolean);
  72309. get glowLayerEnabled(): boolean;
  72310. /**
  72311. * Gets the glow layer (or null if not defined)
  72312. */
  72313. get glowLayer(): Nullable<GlowLayer>;
  72314. /**
  72315. * Enable or disable the chromaticAberration process from the pipeline
  72316. */
  72317. set chromaticAberrationEnabled(enabled: boolean);
  72318. get chromaticAberrationEnabled(): boolean;
  72319. /**
  72320. * Enable or disable the grain process from the pipeline
  72321. */
  72322. set grainEnabled(enabled: boolean);
  72323. get grainEnabled(): boolean;
  72324. /**
  72325. * @constructor
  72326. * @param name - The rendering pipeline name (default: "")
  72327. * @param hdr - If high dynamic range textures should be used (default: true)
  72328. * @param scene - The scene linked to this pipeline (default: the last created scene)
  72329. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  72330. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  72331. */
  72332. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  72333. /**
  72334. * Get the class name
  72335. * @returns "DefaultRenderingPipeline"
  72336. */
  72337. getClassName(): string;
  72338. /**
  72339. * Force the compilation of the entire pipeline.
  72340. */
  72341. prepare(): void;
  72342. private _hasCleared;
  72343. private _prevPostProcess;
  72344. private _prevPrevPostProcess;
  72345. private _setAutoClearAndTextureSharing;
  72346. private _depthOfFieldSceneObserver;
  72347. private _buildPipeline;
  72348. private _disposePostProcesses;
  72349. /**
  72350. * Adds a camera to the pipeline
  72351. * @param camera the camera to be added
  72352. */
  72353. addCamera(camera: Camera): void;
  72354. /**
  72355. * Removes a camera from the pipeline
  72356. * @param camera the camera to remove
  72357. */
  72358. removeCamera(camera: Camera): void;
  72359. /**
  72360. * Dispose of the pipeline and stop all post processes
  72361. */
  72362. dispose(): void;
  72363. /**
  72364. * Serialize the rendering pipeline (Used when exporting)
  72365. * @returns the serialized object
  72366. */
  72367. serialize(): any;
  72368. /**
  72369. * Parse the serialized pipeline
  72370. * @param source Source pipeline.
  72371. * @param scene The scene to load the pipeline to.
  72372. * @param rootUrl The URL of the serialized pipeline.
  72373. * @returns An instantiated pipeline from the serialized object.
  72374. */
  72375. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  72376. }
  72377. }
  72378. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  72379. /** @hidden */
  72380. export var lensHighlightsPixelShader: {
  72381. name: string;
  72382. shader: string;
  72383. };
  72384. }
  72385. declare module "babylonjs/Shaders/depthOfField.fragment" {
  72386. /** @hidden */
  72387. export var depthOfFieldPixelShader: {
  72388. name: string;
  72389. shader: string;
  72390. };
  72391. }
  72392. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  72393. import { Camera } from "babylonjs/Cameras/camera";
  72394. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72395. import { Scene } from "babylonjs/scene";
  72396. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72397. import "babylonjs/Shaders/chromaticAberration.fragment";
  72398. import "babylonjs/Shaders/lensHighlights.fragment";
  72399. import "babylonjs/Shaders/depthOfField.fragment";
  72400. /**
  72401. * BABYLON.JS Chromatic Aberration GLSL Shader
  72402. * Author: Olivier Guyot
  72403. * Separates very slightly R, G and B colors on the edges of the screen
  72404. * Inspired by Francois Tarlier & Martins Upitis
  72405. */
  72406. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72407. /**
  72408. * @ignore
  72409. * The chromatic aberration PostProcess id in the pipeline
  72410. */
  72411. LensChromaticAberrationEffect: string;
  72412. /**
  72413. * @ignore
  72414. * The highlights enhancing PostProcess id in the pipeline
  72415. */
  72416. HighlightsEnhancingEffect: string;
  72417. /**
  72418. * @ignore
  72419. * The depth-of-field PostProcess id in the pipeline
  72420. */
  72421. LensDepthOfFieldEffect: string;
  72422. private _scene;
  72423. private _depthTexture;
  72424. private _grainTexture;
  72425. private _chromaticAberrationPostProcess;
  72426. private _highlightsPostProcess;
  72427. private _depthOfFieldPostProcess;
  72428. private _edgeBlur;
  72429. private _grainAmount;
  72430. private _chromaticAberration;
  72431. private _distortion;
  72432. private _highlightsGain;
  72433. private _highlightsThreshold;
  72434. private _dofDistance;
  72435. private _dofAperture;
  72436. private _dofDarken;
  72437. private _dofPentagon;
  72438. private _blurNoise;
  72439. /**
  72440. * @constructor
  72441. *
  72442. * Effect parameters are as follow:
  72443. * {
  72444. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72445. * edge_blur: number; // from 0 to x (1 for realism)
  72446. * distortion: number; // from 0 to x (1 for realism)
  72447. * grain_amount: number; // from 0 to 1
  72448. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72449. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72450. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72451. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72452. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72453. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72454. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72455. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72456. * }
  72457. * Note: if an effect parameter is unset, effect is disabled
  72458. *
  72459. * @param name The rendering pipeline name
  72460. * @param parameters - An object containing all parameters (see above)
  72461. * @param scene The scene linked to this pipeline
  72462. * @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)
  72463. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72464. */
  72465. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72466. /**
  72467. * Get the class name
  72468. * @returns "LensRenderingPipeline"
  72469. */
  72470. getClassName(): string;
  72471. /**
  72472. * Gets associated scene
  72473. */
  72474. get scene(): Scene;
  72475. /**
  72476. * Gets or sets the edge blur
  72477. */
  72478. get edgeBlur(): number;
  72479. set edgeBlur(value: number);
  72480. /**
  72481. * Gets or sets the grain amount
  72482. */
  72483. get grainAmount(): number;
  72484. set grainAmount(value: number);
  72485. /**
  72486. * Gets or sets the chromatic aberration amount
  72487. */
  72488. get chromaticAberration(): number;
  72489. set chromaticAberration(value: number);
  72490. /**
  72491. * Gets or sets the depth of field aperture
  72492. */
  72493. get dofAperture(): number;
  72494. set dofAperture(value: number);
  72495. /**
  72496. * Gets or sets the edge distortion
  72497. */
  72498. get edgeDistortion(): number;
  72499. set edgeDistortion(value: number);
  72500. /**
  72501. * Gets or sets the depth of field distortion
  72502. */
  72503. get dofDistortion(): number;
  72504. set dofDistortion(value: number);
  72505. /**
  72506. * Gets or sets the darken out of focus amount
  72507. */
  72508. get darkenOutOfFocus(): number;
  72509. set darkenOutOfFocus(value: number);
  72510. /**
  72511. * Gets or sets a boolean indicating if blur noise is enabled
  72512. */
  72513. get blurNoise(): boolean;
  72514. set blurNoise(value: boolean);
  72515. /**
  72516. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72517. */
  72518. get pentagonBokeh(): boolean;
  72519. set pentagonBokeh(value: boolean);
  72520. /**
  72521. * Gets or sets the highlight grain amount
  72522. */
  72523. get highlightsGain(): number;
  72524. set highlightsGain(value: number);
  72525. /**
  72526. * Gets or sets the highlight threshold
  72527. */
  72528. get highlightsThreshold(): number;
  72529. set highlightsThreshold(value: number);
  72530. /**
  72531. * Sets the amount of blur at the edges
  72532. * @param amount blur amount
  72533. */
  72534. setEdgeBlur(amount: number): void;
  72535. /**
  72536. * Sets edge blur to 0
  72537. */
  72538. disableEdgeBlur(): void;
  72539. /**
  72540. * Sets the amout of grain
  72541. * @param amount Amount of grain
  72542. */
  72543. setGrainAmount(amount: number): void;
  72544. /**
  72545. * Set grain amount to 0
  72546. */
  72547. disableGrain(): void;
  72548. /**
  72549. * Sets the chromatic aberration amount
  72550. * @param amount amount of chromatic aberration
  72551. */
  72552. setChromaticAberration(amount: number): void;
  72553. /**
  72554. * Sets chromatic aberration amount to 0
  72555. */
  72556. disableChromaticAberration(): void;
  72557. /**
  72558. * Sets the EdgeDistortion amount
  72559. * @param amount amount of EdgeDistortion
  72560. */
  72561. setEdgeDistortion(amount: number): void;
  72562. /**
  72563. * Sets edge distortion to 0
  72564. */
  72565. disableEdgeDistortion(): void;
  72566. /**
  72567. * Sets the FocusDistance amount
  72568. * @param amount amount of FocusDistance
  72569. */
  72570. setFocusDistance(amount: number): void;
  72571. /**
  72572. * Disables depth of field
  72573. */
  72574. disableDepthOfField(): void;
  72575. /**
  72576. * Sets the Aperture amount
  72577. * @param amount amount of Aperture
  72578. */
  72579. setAperture(amount: number): void;
  72580. /**
  72581. * Sets the DarkenOutOfFocus amount
  72582. * @param amount amount of DarkenOutOfFocus
  72583. */
  72584. setDarkenOutOfFocus(amount: number): void;
  72585. private _pentagonBokehIsEnabled;
  72586. /**
  72587. * Creates a pentagon bokeh effect
  72588. */
  72589. enablePentagonBokeh(): void;
  72590. /**
  72591. * Disables the pentagon bokeh effect
  72592. */
  72593. disablePentagonBokeh(): void;
  72594. /**
  72595. * Enables noise blur
  72596. */
  72597. enableNoiseBlur(): void;
  72598. /**
  72599. * Disables noise blur
  72600. */
  72601. disableNoiseBlur(): void;
  72602. /**
  72603. * Sets the HighlightsGain amount
  72604. * @param amount amount of HighlightsGain
  72605. */
  72606. setHighlightsGain(amount: number): void;
  72607. /**
  72608. * Sets the HighlightsThreshold amount
  72609. * @param amount amount of HighlightsThreshold
  72610. */
  72611. setHighlightsThreshold(amount: number): void;
  72612. /**
  72613. * Disables highlights
  72614. */
  72615. disableHighlights(): void;
  72616. /**
  72617. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72618. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72619. */
  72620. dispose(disableDepthRender?: boolean): void;
  72621. private _createChromaticAberrationPostProcess;
  72622. private _createHighlightsPostProcess;
  72623. private _createDepthOfFieldPostProcess;
  72624. private _createGrainTexture;
  72625. }
  72626. }
  72627. declare module "babylonjs/Shaders/ssao2.fragment" {
  72628. /** @hidden */
  72629. export var ssao2PixelShader: {
  72630. name: string;
  72631. shader: string;
  72632. };
  72633. }
  72634. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  72635. /** @hidden */
  72636. export var ssaoCombinePixelShader: {
  72637. name: string;
  72638. shader: string;
  72639. };
  72640. }
  72641. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  72642. import { Camera } from "babylonjs/Cameras/camera";
  72643. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72644. import { Scene } from "babylonjs/scene";
  72645. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72646. import "babylonjs/Shaders/ssao2.fragment";
  72647. import "babylonjs/Shaders/ssaoCombine.fragment";
  72648. /**
  72649. * Render pipeline to produce ssao effect
  72650. */
  72651. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72652. /**
  72653. * @ignore
  72654. * The PassPostProcess id in the pipeline that contains the original scene color
  72655. */
  72656. SSAOOriginalSceneColorEffect: string;
  72657. /**
  72658. * @ignore
  72659. * The SSAO PostProcess id in the pipeline
  72660. */
  72661. SSAORenderEffect: string;
  72662. /**
  72663. * @ignore
  72664. * The horizontal blur PostProcess id in the pipeline
  72665. */
  72666. SSAOBlurHRenderEffect: string;
  72667. /**
  72668. * @ignore
  72669. * The vertical blur PostProcess id in the pipeline
  72670. */
  72671. SSAOBlurVRenderEffect: string;
  72672. /**
  72673. * @ignore
  72674. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72675. */
  72676. SSAOCombineRenderEffect: string;
  72677. /**
  72678. * The output strength of the SSAO post-process. Default value is 1.0.
  72679. */
  72680. totalStrength: number;
  72681. /**
  72682. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72683. */
  72684. maxZ: number;
  72685. /**
  72686. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72687. */
  72688. minZAspect: number;
  72689. private _samples;
  72690. /**
  72691. * Number of samples used for the SSAO calculations. Default value is 8
  72692. */
  72693. set samples(n: number);
  72694. get samples(): number;
  72695. private _textureSamples;
  72696. /**
  72697. * Number of samples to use for antialiasing
  72698. */
  72699. set textureSamples(n: number);
  72700. get textureSamples(): number;
  72701. /**
  72702. * Ratio object used for SSAO ratio and blur ratio
  72703. */
  72704. private _ratio;
  72705. /**
  72706. * Dynamically generated sphere sampler.
  72707. */
  72708. private _sampleSphere;
  72709. /**
  72710. * Blur filter offsets
  72711. */
  72712. private _samplerOffsets;
  72713. private _expensiveBlur;
  72714. /**
  72715. * If bilateral blur should be used
  72716. */
  72717. set expensiveBlur(b: boolean);
  72718. get expensiveBlur(): boolean;
  72719. /**
  72720. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72721. */
  72722. radius: number;
  72723. /**
  72724. * The base color of the SSAO post-process
  72725. * The final result is "base + ssao" between [0, 1]
  72726. */
  72727. base: number;
  72728. /**
  72729. * Support test.
  72730. */
  72731. static get IsSupported(): boolean;
  72732. private _scene;
  72733. private _depthTexture;
  72734. private _normalTexture;
  72735. private _randomTexture;
  72736. private _originalColorPostProcess;
  72737. private _ssaoPostProcess;
  72738. private _blurHPostProcess;
  72739. private _blurVPostProcess;
  72740. private _ssaoCombinePostProcess;
  72741. /**
  72742. * Gets active scene
  72743. */
  72744. get scene(): Scene;
  72745. /**
  72746. * @constructor
  72747. * @param name The rendering pipeline name
  72748. * @param scene The scene linked to this pipeline
  72749. * @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 }
  72750. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72751. */
  72752. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72753. /**
  72754. * Get the class name
  72755. * @returns "SSAO2RenderingPipeline"
  72756. */
  72757. getClassName(): string;
  72758. /**
  72759. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72760. */
  72761. dispose(disableGeometryBufferRenderer?: boolean): void;
  72762. private _createBlurPostProcess;
  72763. /** @hidden */
  72764. _rebuild(): void;
  72765. private _bits;
  72766. private _radicalInverse_VdC;
  72767. private _hammersley;
  72768. private _hemisphereSample_uniform;
  72769. private _generateHemisphere;
  72770. private _createSSAOPostProcess;
  72771. private _createSSAOCombinePostProcess;
  72772. private _createRandomTexture;
  72773. /**
  72774. * Serialize the rendering pipeline (Used when exporting)
  72775. * @returns the serialized object
  72776. */
  72777. serialize(): any;
  72778. /**
  72779. * Parse the serialized pipeline
  72780. * @param source Source pipeline.
  72781. * @param scene The scene to load the pipeline to.
  72782. * @param rootUrl The URL of the serialized pipeline.
  72783. * @returns An instantiated pipeline from the serialized object.
  72784. */
  72785. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72786. }
  72787. }
  72788. declare module "babylonjs/Shaders/ssao.fragment" {
  72789. /** @hidden */
  72790. export var ssaoPixelShader: {
  72791. name: string;
  72792. shader: string;
  72793. };
  72794. }
  72795. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  72796. import { Camera } from "babylonjs/Cameras/camera";
  72797. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72798. import { Scene } from "babylonjs/scene";
  72799. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72800. import "babylonjs/Shaders/ssao.fragment";
  72801. import "babylonjs/Shaders/ssaoCombine.fragment";
  72802. /**
  72803. * Render pipeline to produce ssao effect
  72804. */
  72805. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72806. /**
  72807. * @ignore
  72808. * The PassPostProcess id in the pipeline that contains the original scene color
  72809. */
  72810. SSAOOriginalSceneColorEffect: string;
  72811. /**
  72812. * @ignore
  72813. * The SSAO PostProcess id in the pipeline
  72814. */
  72815. SSAORenderEffect: string;
  72816. /**
  72817. * @ignore
  72818. * The horizontal blur PostProcess id in the pipeline
  72819. */
  72820. SSAOBlurHRenderEffect: string;
  72821. /**
  72822. * @ignore
  72823. * The vertical blur PostProcess id in the pipeline
  72824. */
  72825. SSAOBlurVRenderEffect: string;
  72826. /**
  72827. * @ignore
  72828. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72829. */
  72830. SSAOCombineRenderEffect: string;
  72831. /**
  72832. * The output strength of the SSAO post-process. Default value is 1.0.
  72833. */
  72834. totalStrength: number;
  72835. /**
  72836. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72837. */
  72838. radius: number;
  72839. /**
  72840. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72841. * Must not be equal to fallOff and superior to fallOff.
  72842. * Default value is 0.0075
  72843. */
  72844. area: number;
  72845. /**
  72846. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72847. * Must not be equal to area and inferior to area.
  72848. * Default value is 0.000001
  72849. */
  72850. fallOff: number;
  72851. /**
  72852. * The base color of the SSAO post-process
  72853. * The final result is "base + ssao" between [0, 1]
  72854. */
  72855. base: number;
  72856. private _scene;
  72857. private _depthTexture;
  72858. private _randomTexture;
  72859. private _originalColorPostProcess;
  72860. private _ssaoPostProcess;
  72861. private _blurHPostProcess;
  72862. private _blurVPostProcess;
  72863. private _ssaoCombinePostProcess;
  72864. private _firstUpdate;
  72865. /**
  72866. * Gets active scene
  72867. */
  72868. get scene(): Scene;
  72869. /**
  72870. * @constructor
  72871. * @param name - The rendering pipeline name
  72872. * @param scene - The scene linked to this pipeline
  72873. * @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 }
  72874. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72875. */
  72876. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72877. /**
  72878. * Get the class name
  72879. * @returns "SSAORenderingPipeline"
  72880. */
  72881. getClassName(): string;
  72882. /**
  72883. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72884. */
  72885. dispose(disableDepthRender?: boolean): void;
  72886. private _createBlurPostProcess;
  72887. /** @hidden */
  72888. _rebuild(): void;
  72889. private _createSSAOPostProcess;
  72890. private _createSSAOCombinePostProcess;
  72891. private _createRandomTexture;
  72892. }
  72893. }
  72894. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  72895. /** @hidden */
  72896. export var screenSpaceReflectionPixelShader: {
  72897. name: string;
  72898. shader: string;
  72899. };
  72900. }
  72901. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  72902. import { Nullable } from "babylonjs/types";
  72903. import { Camera } from "babylonjs/Cameras/camera";
  72904. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72905. import { Scene } from "babylonjs/scene";
  72906. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  72907. import { Engine } from "babylonjs/Engines/engine";
  72908. /**
  72909. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72910. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72911. */
  72912. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72913. /**
  72914. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72915. */
  72916. threshold: number;
  72917. /**
  72918. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72919. */
  72920. strength: number;
  72921. /**
  72922. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72923. */
  72924. reflectionSpecularFalloffExponent: number;
  72925. /**
  72926. * 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]
  72927. */
  72928. step: number;
  72929. /**
  72930. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72931. */
  72932. roughnessFactor: number;
  72933. private _geometryBufferRenderer;
  72934. private _enableSmoothReflections;
  72935. private _reflectionSamples;
  72936. private _smoothSteps;
  72937. /**
  72938. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72939. * @param name The name of the effect.
  72940. * @param scene The scene containing the objects to calculate reflections.
  72941. * @param options The required width/height ratio to downsize to before computing the render pass.
  72942. * @param camera The camera to apply the render pass to.
  72943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72944. * @param engine The engine which the post process will be applied. (default: current engine)
  72945. * @param reusable If the post process can be reused on the same frame. (default: false)
  72946. * @param textureType Type of textures used when performing the post process. (default: 0)
  72947. * @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)
  72948. */
  72949. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72950. /**
  72951. * Gets wether or not smoothing reflections is enabled.
  72952. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72953. */
  72954. get enableSmoothReflections(): boolean;
  72955. /**
  72956. * Sets wether or not smoothing reflections is enabled.
  72957. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72958. */
  72959. set enableSmoothReflections(enabled: boolean);
  72960. /**
  72961. * Gets the number of samples taken while computing reflections. More samples count is high,
  72962. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72963. */
  72964. get reflectionSamples(): number;
  72965. /**
  72966. * Sets the number of samples taken while computing reflections. More samples count is high,
  72967. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72968. */
  72969. set reflectionSamples(samples: number);
  72970. /**
  72971. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72972. * more the post-process will require GPU power and can generate a drop in FPS.
  72973. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72974. */
  72975. get smoothSteps(): number;
  72976. set smoothSteps(steps: number);
  72977. private _updateEffectDefines;
  72978. }
  72979. }
  72980. declare module "babylonjs/Shaders/standard.fragment" {
  72981. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  72982. /** @hidden */
  72983. export var standardPixelShader: {
  72984. name: string;
  72985. shader: string;
  72986. };
  72987. }
  72988. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  72989. import { Nullable } from "babylonjs/types";
  72990. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72991. import { Camera } from "babylonjs/Cameras/camera";
  72992. import { Texture } from "babylonjs/Materials/Textures/texture";
  72993. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72994. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72995. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72996. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72997. import { IDisposable } from "babylonjs/scene";
  72998. import { SpotLight } from "babylonjs/Lights/spotLight";
  72999. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73000. import { Scene } from "babylonjs/scene";
  73001. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73002. import { Animation } from "babylonjs/Animations/animation";
  73003. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73004. import "babylonjs/Shaders/standard.fragment";
  73005. /**
  73006. * Standard rendering pipeline
  73007. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73008. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73009. */
  73010. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73011. /**
  73012. * Public members
  73013. */
  73014. /**
  73015. * Post-process which contains the original scene color before the pipeline applies all the effects
  73016. */
  73017. originalPostProcess: Nullable<PostProcess>;
  73018. /**
  73019. * Post-process used to down scale an image x4
  73020. */
  73021. downSampleX4PostProcess: Nullable<PostProcess>;
  73022. /**
  73023. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73024. */
  73025. brightPassPostProcess: Nullable<PostProcess>;
  73026. /**
  73027. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73028. */
  73029. blurHPostProcesses: PostProcess[];
  73030. /**
  73031. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73032. */
  73033. blurVPostProcesses: PostProcess[];
  73034. /**
  73035. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73036. */
  73037. textureAdderPostProcess: Nullable<PostProcess>;
  73038. /**
  73039. * Post-process used to create volumetric lighting effect
  73040. */
  73041. volumetricLightPostProcess: Nullable<PostProcess>;
  73042. /**
  73043. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73044. */
  73045. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73046. /**
  73047. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73048. */
  73049. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73050. /**
  73051. * Post-process used to merge the volumetric light effect and the real scene color
  73052. */
  73053. volumetricLightMergePostProces: Nullable<PostProcess>;
  73054. /**
  73055. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73056. */
  73057. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73058. /**
  73059. * Base post-process used to calculate the average luminance of the final image for HDR
  73060. */
  73061. luminancePostProcess: Nullable<PostProcess>;
  73062. /**
  73063. * Post-processes used to create down sample post-processes in order to get
  73064. * the average luminance of the final image for HDR
  73065. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73066. */
  73067. luminanceDownSamplePostProcesses: PostProcess[];
  73068. /**
  73069. * Post-process used to create a HDR effect (light adaptation)
  73070. */
  73071. hdrPostProcess: Nullable<PostProcess>;
  73072. /**
  73073. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73074. */
  73075. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73076. /**
  73077. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73078. */
  73079. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73080. /**
  73081. * Post-process used to merge the final HDR post-process and the real scene color
  73082. */
  73083. hdrFinalPostProcess: Nullable<PostProcess>;
  73084. /**
  73085. * Post-process used to create a lens flare effect
  73086. */
  73087. lensFlarePostProcess: Nullable<PostProcess>;
  73088. /**
  73089. * Post-process that merges the result of the lens flare post-process and the real scene color
  73090. */
  73091. lensFlareComposePostProcess: Nullable<PostProcess>;
  73092. /**
  73093. * Post-process used to create a motion blur effect
  73094. */
  73095. motionBlurPostProcess: Nullable<PostProcess>;
  73096. /**
  73097. * Post-process used to create a depth of field effect
  73098. */
  73099. depthOfFieldPostProcess: Nullable<PostProcess>;
  73100. /**
  73101. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73102. */
  73103. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73104. /**
  73105. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73106. */
  73107. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73108. /**
  73109. * Represents the brightness threshold in order to configure the illuminated surfaces
  73110. */
  73111. brightThreshold: number;
  73112. /**
  73113. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73114. */
  73115. blurWidth: number;
  73116. /**
  73117. * Sets if the blur for highlighted surfaces must be only horizontal
  73118. */
  73119. horizontalBlur: boolean;
  73120. /**
  73121. * Gets the overall exposure used by the pipeline
  73122. */
  73123. get exposure(): number;
  73124. /**
  73125. * Sets the overall exposure used by the pipeline
  73126. */
  73127. set exposure(value: number);
  73128. /**
  73129. * Texture used typically to simulate "dirty" on camera lens
  73130. */
  73131. lensTexture: Nullable<Texture>;
  73132. /**
  73133. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73134. */
  73135. volumetricLightCoefficient: number;
  73136. /**
  73137. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73138. */
  73139. volumetricLightPower: number;
  73140. /**
  73141. * Used the set the blur intensity to smooth the volumetric lights
  73142. */
  73143. volumetricLightBlurScale: number;
  73144. /**
  73145. * Light (spot or directional) used to generate the volumetric lights rays
  73146. * The source light must have a shadow generate so the pipeline can get its
  73147. * depth map
  73148. */
  73149. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73150. /**
  73151. * For eye adaptation, represents the minimum luminance the eye can see
  73152. */
  73153. hdrMinimumLuminance: number;
  73154. /**
  73155. * For eye adaptation, represents the decrease luminance speed
  73156. */
  73157. hdrDecreaseRate: number;
  73158. /**
  73159. * For eye adaptation, represents the increase luminance speed
  73160. */
  73161. hdrIncreaseRate: number;
  73162. /**
  73163. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73164. */
  73165. get hdrAutoExposure(): boolean;
  73166. /**
  73167. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73168. */
  73169. set hdrAutoExposure(value: boolean);
  73170. /**
  73171. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73172. */
  73173. lensColorTexture: Nullable<Texture>;
  73174. /**
  73175. * The overall strengh for the lens flare effect
  73176. */
  73177. lensFlareStrength: number;
  73178. /**
  73179. * Dispersion coefficient for lens flare ghosts
  73180. */
  73181. lensFlareGhostDispersal: number;
  73182. /**
  73183. * Main lens flare halo width
  73184. */
  73185. lensFlareHaloWidth: number;
  73186. /**
  73187. * Based on the lens distortion effect, defines how much the lens flare result
  73188. * is distorted
  73189. */
  73190. lensFlareDistortionStrength: number;
  73191. /**
  73192. * Configures the blur intensity used for for lens flare (halo)
  73193. */
  73194. lensFlareBlurWidth: number;
  73195. /**
  73196. * Lens star texture must be used to simulate rays on the flares and is available
  73197. * in the documentation
  73198. */
  73199. lensStarTexture: Nullable<Texture>;
  73200. /**
  73201. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73202. * flare effect by taking account of the dirt texture
  73203. */
  73204. lensFlareDirtTexture: Nullable<Texture>;
  73205. /**
  73206. * Represents the focal length for the depth of field effect
  73207. */
  73208. depthOfFieldDistance: number;
  73209. /**
  73210. * Represents the blur intensity for the blurred part of the depth of field effect
  73211. */
  73212. depthOfFieldBlurWidth: number;
  73213. /**
  73214. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73215. */
  73216. get motionStrength(): number;
  73217. /**
  73218. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73219. */
  73220. set motionStrength(strength: number);
  73221. /**
  73222. * Gets wether or not the motion blur post-process is object based or screen based.
  73223. */
  73224. get objectBasedMotionBlur(): boolean;
  73225. /**
  73226. * Sets wether or not the motion blur post-process should be object based or screen based
  73227. */
  73228. set objectBasedMotionBlur(value: boolean);
  73229. /**
  73230. * List of animations for the pipeline (IAnimatable implementation)
  73231. */
  73232. animations: Animation[];
  73233. /**
  73234. * Private members
  73235. */
  73236. private _scene;
  73237. private _currentDepthOfFieldSource;
  73238. private _basePostProcess;
  73239. private _fixedExposure;
  73240. private _currentExposure;
  73241. private _hdrAutoExposure;
  73242. private _hdrCurrentLuminance;
  73243. private _motionStrength;
  73244. private _isObjectBasedMotionBlur;
  73245. private _floatTextureType;
  73246. private _camerasToBeAttached;
  73247. private _ratio;
  73248. private _bloomEnabled;
  73249. private _depthOfFieldEnabled;
  73250. private _vlsEnabled;
  73251. private _lensFlareEnabled;
  73252. private _hdrEnabled;
  73253. private _motionBlurEnabled;
  73254. private _fxaaEnabled;
  73255. private _screenSpaceReflectionsEnabled;
  73256. private _motionBlurSamples;
  73257. private _volumetricLightStepsCount;
  73258. private _samples;
  73259. /**
  73260. * @ignore
  73261. * Specifies if the bloom pipeline is enabled
  73262. */
  73263. get BloomEnabled(): boolean;
  73264. set BloomEnabled(enabled: boolean);
  73265. /**
  73266. * @ignore
  73267. * Specifies if the depth of field pipeline is enabed
  73268. */
  73269. get DepthOfFieldEnabled(): boolean;
  73270. set DepthOfFieldEnabled(enabled: boolean);
  73271. /**
  73272. * @ignore
  73273. * Specifies if the lens flare pipeline is enabed
  73274. */
  73275. get LensFlareEnabled(): boolean;
  73276. set LensFlareEnabled(enabled: boolean);
  73277. /**
  73278. * @ignore
  73279. * Specifies if the HDR pipeline is enabled
  73280. */
  73281. get HDREnabled(): boolean;
  73282. set HDREnabled(enabled: boolean);
  73283. /**
  73284. * @ignore
  73285. * Specifies if the volumetric lights scattering effect is enabled
  73286. */
  73287. get VLSEnabled(): boolean;
  73288. set VLSEnabled(enabled: boolean);
  73289. /**
  73290. * @ignore
  73291. * Specifies if the motion blur effect is enabled
  73292. */
  73293. get MotionBlurEnabled(): boolean;
  73294. set MotionBlurEnabled(enabled: boolean);
  73295. /**
  73296. * Specifies if anti-aliasing is enabled
  73297. */
  73298. get fxaaEnabled(): boolean;
  73299. set fxaaEnabled(enabled: boolean);
  73300. /**
  73301. * Specifies if screen space reflections are enabled.
  73302. */
  73303. get screenSpaceReflectionsEnabled(): boolean;
  73304. set screenSpaceReflectionsEnabled(enabled: boolean);
  73305. /**
  73306. * Specifies the number of steps used to calculate the volumetric lights
  73307. * Typically in interval [50, 200]
  73308. */
  73309. get volumetricLightStepsCount(): number;
  73310. set volumetricLightStepsCount(count: number);
  73311. /**
  73312. * Specifies the number of samples used for the motion blur effect
  73313. * Typically in interval [16, 64]
  73314. */
  73315. get motionBlurSamples(): number;
  73316. set motionBlurSamples(samples: number);
  73317. /**
  73318. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73319. */
  73320. get samples(): number;
  73321. set samples(sampleCount: number);
  73322. /**
  73323. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73324. * @constructor
  73325. * @param name The rendering pipeline name
  73326. * @param scene The scene linked to this pipeline
  73327. * @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)
  73328. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  73329. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73330. */
  73331. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  73332. private _buildPipeline;
  73333. private _createDownSampleX4PostProcess;
  73334. private _createBrightPassPostProcess;
  73335. private _createBlurPostProcesses;
  73336. private _createTextureAdderPostProcess;
  73337. private _createVolumetricLightPostProcess;
  73338. private _createLuminancePostProcesses;
  73339. private _createHdrPostProcess;
  73340. private _createLensFlarePostProcess;
  73341. private _createDepthOfFieldPostProcess;
  73342. private _createMotionBlurPostProcess;
  73343. private _getDepthTexture;
  73344. private _disposePostProcesses;
  73345. /**
  73346. * Dispose of the pipeline and stop all post processes
  73347. */
  73348. dispose(): void;
  73349. /**
  73350. * Serialize the rendering pipeline (Used when exporting)
  73351. * @returns the serialized object
  73352. */
  73353. serialize(): any;
  73354. /**
  73355. * Parse the serialized pipeline
  73356. * @param source Source pipeline.
  73357. * @param scene The scene to load the pipeline to.
  73358. * @param rootUrl The URL of the serialized pipeline.
  73359. * @returns An instantiated pipeline from the serialized object.
  73360. */
  73361. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  73362. /**
  73363. * Luminance steps
  73364. */
  73365. static LuminanceSteps: number;
  73366. }
  73367. }
  73368. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  73369. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  73370. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  73371. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  73372. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  73373. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  73374. }
  73375. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  73376. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  73377. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73378. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73379. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73380. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73381. }
  73382. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  73383. /** @hidden */
  73384. export var stereoscopicInterlacePixelShader: {
  73385. name: string;
  73386. shader: string;
  73387. };
  73388. }
  73389. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  73390. import { Camera } from "babylonjs/Cameras/camera";
  73391. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73392. import { Engine } from "babylonjs/Engines/engine";
  73393. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  73394. /**
  73395. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73396. */
  73397. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73398. private _stepSize;
  73399. private _passedProcess;
  73400. /**
  73401. * Initializes a StereoscopicInterlacePostProcessI
  73402. * @param name The name of the effect.
  73403. * @param rigCameras The rig cameras to be appled to the post process
  73404. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73405. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73407. * @param engine The engine which the post process will be applied. (default: current engine)
  73408. * @param reusable If the post process can be reused on the same frame. (default: false)
  73409. */
  73410. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73411. }
  73412. /**
  73413. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73414. */
  73415. export class StereoscopicInterlacePostProcess extends PostProcess {
  73416. private _stepSize;
  73417. private _passedProcess;
  73418. /**
  73419. * Initializes a StereoscopicInterlacePostProcess
  73420. * @param name The name of the effect.
  73421. * @param rigCameras The rig cameras to be appled to the post process
  73422. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73424. * @param engine The engine which the post process will be applied. (default: current engine)
  73425. * @param reusable If the post process can be reused on the same frame. (default: false)
  73426. */
  73427. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73428. }
  73429. }
  73430. declare module "babylonjs/Shaders/tonemap.fragment" {
  73431. /** @hidden */
  73432. export var tonemapPixelShader: {
  73433. name: string;
  73434. shader: string;
  73435. };
  73436. }
  73437. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  73438. import { Camera } from "babylonjs/Cameras/camera";
  73439. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73440. import "babylonjs/Shaders/tonemap.fragment";
  73441. import { Engine } from "babylonjs/Engines/engine";
  73442. /** Defines operator used for tonemapping */
  73443. export enum TonemappingOperator {
  73444. /** Hable */
  73445. Hable = 0,
  73446. /** Reinhard */
  73447. Reinhard = 1,
  73448. /** HejiDawson */
  73449. HejiDawson = 2,
  73450. /** Photographic */
  73451. Photographic = 3
  73452. }
  73453. /**
  73454. * Defines a post process to apply tone mapping
  73455. */
  73456. export class TonemapPostProcess extends PostProcess {
  73457. private _operator;
  73458. /** Defines the required exposure adjustement */
  73459. exposureAdjustment: number;
  73460. /**
  73461. * Creates a new TonemapPostProcess
  73462. * @param name defines the name of the postprocess
  73463. * @param _operator defines the operator to use
  73464. * @param exposureAdjustment defines the required exposure adjustement
  73465. * @param camera defines the camera to use (can be null)
  73466. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73467. * @param engine defines the hosting engine (can be ignore if camera is set)
  73468. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73469. */
  73470. constructor(name: string, _operator: TonemappingOperator,
  73471. /** Defines the required exposure adjustement */
  73472. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73473. }
  73474. }
  73475. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  73476. /** @hidden */
  73477. export var volumetricLightScatteringPixelShader: {
  73478. name: string;
  73479. shader: string;
  73480. };
  73481. }
  73482. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  73483. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73484. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73485. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73486. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73487. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73488. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73489. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73490. /** @hidden */
  73491. export var volumetricLightScatteringPassVertexShader: {
  73492. name: string;
  73493. shader: string;
  73494. };
  73495. }
  73496. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  73497. /** @hidden */
  73498. export var volumetricLightScatteringPassPixelShader: {
  73499. name: string;
  73500. shader: string;
  73501. };
  73502. }
  73503. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  73504. import { Vector3 } from "babylonjs/Maths/math.vector";
  73505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73506. import { Mesh } from "babylonjs/Meshes/mesh";
  73507. import { Camera } from "babylonjs/Cameras/camera";
  73508. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73509. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73510. import { Scene } from "babylonjs/scene";
  73511. import "babylonjs/Meshes/Builders/planeBuilder";
  73512. import "babylonjs/Shaders/depth.vertex";
  73513. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  73514. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  73515. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  73516. import { Engine } from "babylonjs/Engines/engine";
  73517. /**
  73518. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73519. */
  73520. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73521. private _volumetricLightScatteringPass;
  73522. private _volumetricLightScatteringRTT;
  73523. private _viewPort;
  73524. private _screenCoordinates;
  73525. private _cachedDefines;
  73526. /**
  73527. * If not undefined, the mesh position is computed from the attached node position
  73528. */
  73529. attachedNode: {
  73530. position: Vector3;
  73531. };
  73532. /**
  73533. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73534. */
  73535. customMeshPosition: Vector3;
  73536. /**
  73537. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73538. */
  73539. useCustomMeshPosition: boolean;
  73540. /**
  73541. * If the post-process should inverse the light scattering direction
  73542. */
  73543. invert: boolean;
  73544. /**
  73545. * The internal mesh used by the post-process
  73546. */
  73547. mesh: Mesh;
  73548. /**
  73549. * @hidden
  73550. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73551. */
  73552. get useDiffuseColor(): boolean;
  73553. set useDiffuseColor(useDiffuseColor: boolean);
  73554. /**
  73555. * Array containing the excluded meshes not rendered in the internal pass
  73556. */
  73557. excludedMeshes: AbstractMesh[];
  73558. /**
  73559. * Controls the overall intensity of the post-process
  73560. */
  73561. exposure: number;
  73562. /**
  73563. * Dissipates each sample's contribution in range [0, 1]
  73564. */
  73565. decay: number;
  73566. /**
  73567. * Controls the overall intensity of each sample
  73568. */
  73569. weight: number;
  73570. /**
  73571. * Controls the density of each sample
  73572. */
  73573. density: number;
  73574. /**
  73575. * @constructor
  73576. * @param name The post-process name
  73577. * @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)
  73578. * @param camera The camera that the post-process will be attached to
  73579. * @param mesh The mesh used to create the light scattering
  73580. * @param samples The post-process quality, default 100
  73581. * @param samplingModeThe post-process filtering mode
  73582. * @param engine The babylon engine
  73583. * @param reusable If the post-process is reusable
  73584. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73585. */
  73586. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73587. /**
  73588. * Returns the string "VolumetricLightScatteringPostProcess"
  73589. * @returns "VolumetricLightScatteringPostProcess"
  73590. */
  73591. getClassName(): string;
  73592. private _isReady;
  73593. /**
  73594. * Sets the new light position for light scattering effect
  73595. * @param position The new custom light position
  73596. */
  73597. setCustomMeshPosition(position: Vector3): void;
  73598. /**
  73599. * Returns the light position for light scattering effect
  73600. * @return Vector3 The custom light position
  73601. */
  73602. getCustomMeshPosition(): Vector3;
  73603. /**
  73604. * Disposes the internal assets and detaches the post-process from the camera
  73605. */
  73606. dispose(camera: Camera): void;
  73607. /**
  73608. * Returns the render target texture used by the post-process
  73609. * @return the render target texture used by the post-process
  73610. */
  73611. getPass(): RenderTargetTexture;
  73612. private _meshExcluded;
  73613. private _createPass;
  73614. private _updateMeshScreenCoordinates;
  73615. /**
  73616. * Creates a default mesh for the Volumeric Light Scattering post-process
  73617. * @param name The mesh name
  73618. * @param scene The scene where to create the mesh
  73619. * @return the default mesh
  73620. */
  73621. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73622. }
  73623. }
  73624. declare module "babylonjs/PostProcesses/index" {
  73625. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  73626. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  73627. export * from "babylonjs/PostProcesses/bloomEffect";
  73628. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  73629. export * from "babylonjs/PostProcesses/blurPostProcess";
  73630. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73631. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  73632. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  73633. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  73634. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73635. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  73636. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  73637. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  73638. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73639. export * from "babylonjs/PostProcesses/filterPostProcess";
  73640. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  73641. export * from "babylonjs/PostProcesses/grainPostProcess";
  73642. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  73643. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73644. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  73645. export * from "babylonjs/PostProcesses/passPostProcess";
  73646. export * from "babylonjs/PostProcesses/postProcess";
  73647. export * from "babylonjs/PostProcesses/postProcessManager";
  73648. export * from "babylonjs/PostProcesses/refractionPostProcess";
  73649. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  73650. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  73651. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  73652. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  73653. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  73654. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  73655. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  73656. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73657. }
  73658. declare module "babylonjs/Probes/index" {
  73659. export * from "babylonjs/Probes/reflectionProbe";
  73660. }
  73661. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  73662. import { Scene } from "babylonjs/scene";
  73663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73664. import { SmartArray } from "babylonjs/Misc/smartArray";
  73665. import { ISceneComponent } from "babylonjs/sceneComponent";
  73666. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  73667. import "babylonjs/Meshes/Builders/boxBuilder";
  73668. import "babylonjs/Shaders/color.fragment";
  73669. import "babylonjs/Shaders/color.vertex";
  73670. import { Color3 } from "babylonjs/Maths/math.color";
  73671. import { Observable } from "babylonjs/Misc/observable";
  73672. module "babylonjs/scene" {
  73673. interface Scene {
  73674. /** @hidden (Backing field) */
  73675. _boundingBoxRenderer: BoundingBoxRenderer;
  73676. /** @hidden (Backing field) */
  73677. _forceShowBoundingBoxes: boolean;
  73678. /**
  73679. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73680. */
  73681. forceShowBoundingBoxes: boolean;
  73682. /**
  73683. * Gets the bounding box renderer associated with the scene
  73684. * @returns a BoundingBoxRenderer
  73685. */
  73686. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73687. }
  73688. }
  73689. module "babylonjs/Meshes/abstractMesh" {
  73690. interface AbstractMesh {
  73691. /** @hidden (Backing field) */
  73692. _showBoundingBox: boolean;
  73693. /**
  73694. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73695. */
  73696. showBoundingBox: boolean;
  73697. }
  73698. }
  73699. /**
  73700. * Component responsible of rendering the bounding box of the meshes in a scene.
  73701. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73702. */
  73703. export class BoundingBoxRenderer implements ISceneComponent {
  73704. /**
  73705. * The component name helpfull to identify the component in the list of scene components.
  73706. */
  73707. readonly name: string;
  73708. /**
  73709. * The scene the component belongs to.
  73710. */
  73711. scene: Scene;
  73712. /**
  73713. * Color of the bounding box lines placed in front of an object
  73714. */
  73715. frontColor: Color3;
  73716. /**
  73717. * Color of the bounding box lines placed behind an object
  73718. */
  73719. backColor: Color3;
  73720. /**
  73721. * Defines if the renderer should show the back lines or not
  73722. */
  73723. showBackLines: boolean;
  73724. /**
  73725. * Observable raised before rendering a bounding box
  73726. */
  73727. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73728. /**
  73729. * Observable raised after rendering a bounding box
  73730. */
  73731. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73732. /**
  73733. * @hidden
  73734. */
  73735. renderList: SmartArray<BoundingBox>;
  73736. private _colorShader;
  73737. private _vertexBuffers;
  73738. private _indexBuffer;
  73739. private _fillIndexBuffer;
  73740. private _fillIndexData;
  73741. /**
  73742. * Instantiates a new bounding box renderer in a scene.
  73743. * @param scene the scene the renderer renders in
  73744. */
  73745. constructor(scene: Scene);
  73746. /**
  73747. * Registers the component in a given scene
  73748. */
  73749. register(): void;
  73750. private _evaluateSubMesh;
  73751. private _activeMesh;
  73752. private _prepareRessources;
  73753. private _createIndexBuffer;
  73754. /**
  73755. * Rebuilds the elements related to this component in case of
  73756. * context lost for instance.
  73757. */
  73758. rebuild(): void;
  73759. /**
  73760. * @hidden
  73761. */
  73762. reset(): void;
  73763. /**
  73764. * Render the bounding boxes of a specific rendering group
  73765. * @param renderingGroupId defines the rendering group to render
  73766. */
  73767. render(renderingGroupId: number): void;
  73768. /**
  73769. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73770. * @param mesh Define the mesh to render the occlusion bounding box for
  73771. */
  73772. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73773. /**
  73774. * Dispose and release the resources attached to this renderer.
  73775. */
  73776. dispose(): void;
  73777. }
  73778. }
  73779. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  73780. import { Nullable } from "babylonjs/types";
  73781. import { Scene } from "babylonjs/scene";
  73782. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  73783. import { Camera } from "babylonjs/Cameras/camera";
  73784. import { ISceneComponent } from "babylonjs/sceneComponent";
  73785. module "babylonjs/scene" {
  73786. interface Scene {
  73787. /** @hidden (Backing field) */
  73788. _depthRenderer: {
  73789. [id: string]: DepthRenderer;
  73790. };
  73791. /**
  73792. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73793. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73794. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73795. * @returns the created depth renderer
  73796. */
  73797. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  73798. /**
  73799. * Disables a depth renderer for a given camera
  73800. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73801. */
  73802. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73803. }
  73804. }
  73805. /**
  73806. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73807. * in several rendering techniques.
  73808. */
  73809. export class DepthRendererSceneComponent implements ISceneComponent {
  73810. /**
  73811. * The component name helpfull to identify the component in the list of scene components.
  73812. */
  73813. readonly name: string;
  73814. /**
  73815. * The scene the component belongs to.
  73816. */
  73817. scene: Scene;
  73818. /**
  73819. * Creates a new instance of the component for the given scene
  73820. * @param scene Defines the scene to register the component in
  73821. */
  73822. constructor(scene: Scene);
  73823. /**
  73824. * Registers the component in a given scene
  73825. */
  73826. register(): void;
  73827. /**
  73828. * Rebuilds the elements related to this component in case of
  73829. * context lost for instance.
  73830. */
  73831. rebuild(): void;
  73832. /**
  73833. * Disposes the component and the associated ressources
  73834. */
  73835. dispose(): void;
  73836. private _gatherRenderTargets;
  73837. private _gatherActiveCameraRenderTargets;
  73838. }
  73839. }
  73840. declare module "babylonjs/Shaders/outline.fragment" {
  73841. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73842. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  73843. /** @hidden */
  73844. export var outlinePixelShader: {
  73845. name: string;
  73846. shader: string;
  73847. };
  73848. }
  73849. declare module "babylonjs/Shaders/outline.vertex" {
  73850. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73851. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73852. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73853. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73854. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73855. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73856. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73857. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73858. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  73859. /** @hidden */
  73860. export var outlineVertexShader: {
  73861. name: string;
  73862. shader: string;
  73863. };
  73864. }
  73865. declare module "babylonjs/Rendering/outlineRenderer" {
  73866. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73867. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  73868. import { Scene } from "babylonjs/scene";
  73869. import { ISceneComponent } from "babylonjs/sceneComponent";
  73870. import "babylonjs/Shaders/outline.fragment";
  73871. import "babylonjs/Shaders/outline.vertex";
  73872. module "babylonjs/scene" {
  73873. interface Scene {
  73874. /** @hidden */
  73875. _outlineRenderer: OutlineRenderer;
  73876. /**
  73877. * Gets the outline renderer associated with the scene
  73878. * @returns a OutlineRenderer
  73879. */
  73880. getOutlineRenderer(): OutlineRenderer;
  73881. }
  73882. }
  73883. module "babylonjs/Meshes/abstractMesh" {
  73884. interface AbstractMesh {
  73885. /** @hidden (Backing field) */
  73886. _renderOutline: boolean;
  73887. /**
  73888. * Gets or sets a boolean indicating if the outline must be rendered as well
  73889. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73890. */
  73891. renderOutline: boolean;
  73892. /** @hidden (Backing field) */
  73893. _renderOverlay: boolean;
  73894. /**
  73895. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73896. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73897. */
  73898. renderOverlay: boolean;
  73899. }
  73900. }
  73901. /**
  73902. * This class is responsible to draw bothe outline/overlay of meshes.
  73903. * It should not be used directly but through the available method on mesh.
  73904. */
  73905. export class OutlineRenderer implements ISceneComponent {
  73906. /**
  73907. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73908. */
  73909. private static _StencilReference;
  73910. /**
  73911. * The name of the component. Each component must have a unique name.
  73912. */
  73913. name: string;
  73914. /**
  73915. * The scene the component belongs to.
  73916. */
  73917. scene: Scene;
  73918. /**
  73919. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73920. */
  73921. zOffset: number;
  73922. private _engine;
  73923. private _effect;
  73924. private _cachedDefines;
  73925. private _savedDepthWrite;
  73926. /**
  73927. * Instantiates a new outline renderer. (There could be only one per scene).
  73928. * @param scene Defines the scene it belongs to
  73929. */
  73930. constructor(scene: Scene);
  73931. /**
  73932. * Register the component to one instance of a scene.
  73933. */
  73934. register(): void;
  73935. /**
  73936. * Rebuilds the elements related to this component in case of
  73937. * context lost for instance.
  73938. */
  73939. rebuild(): void;
  73940. /**
  73941. * Disposes the component and the associated ressources.
  73942. */
  73943. dispose(): void;
  73944. /**
  73945. * Renders the outline in the canvas.
  73946. * @param subMesh Defines the sumesh to render
  73947. * @param batch Defines the batch of meshes in case of instances
  73948. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73949. */
  73950. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73951. /**
  73952. * Returns whether or not the outline renderer is ready for a given submesh.
  73953. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73954. * @param subMesh Defines the submesh to check readyness for
  73955. * @param useInstances Defines wheter wee are trying to render instances or not
  73956. * @returns true if ready otherwise false
  73957. */
  73958. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73959. private _beforeRenderingMesh;
  73960. private _afterRenderingMesh;
  73961. }
  73962. }
  73963. declare module "babylonjs/Rendering/index" {
  73964. export * from "babylonjs/Rendering/boundingBoxRenderer";
  73965. export * from "babylonjs/Rendering/depthRenderer";
  73966. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  73967. export * from "babylonjs/Rendering/edgesRenderer";
  73968. export * from "babylonjs/Rendering/geometryBufferRenderer";
  73969. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73970. export * from "babylonjs/Rendering/outlineRenderer";
  73971. export * from "babylonjs/Rendering/renderingGroup";
  73972. export * from "babylonjs/Rendering/renderingManager";
  73973. export * from "babylonjs/Rendering/utilityLayerRenderer";
  73974. }
  73975. declare module "babylonjs/Sprites/ISprites" {
  73976. /**
  73977. * Defines the basic options interface of a Sprite Frame Source Size.
  73978. */
  73979. export interface ISpriteJSONSpriteSourceSize {
  73980. /**
  73981. * number of the original width of the Frame
  73982. */
  73983. w: number;
  73984. /**
  73985. * number of the original height of the Frame
  73986. */
  73987. h: number;
  73988. }
  73989. /**
  73990. * Defines the basic options interface of a Sprite Frame Data.
  73991. */
  73992. export interface ISpriteJSONSpriteFrameData {
  73993. /**
  73994. * number of the x offset of the Frame
  73995. */
  73996. x: number;
  73997. /**
  73998. * number of the y offset of the Frame
  73999. */
  74000. y: number;
  74001. /**
  74002. * number of the width of the Frame
  74003. */
  74004. w: number;
  74005. /**
  74006. * number of the height of the Frame
  74007. */
  74008. h: number;
  74009. }
  74010. /**
  74011. * Defines the basic options interface of a JSON Sprite.
  74012. */
  74013. export interface ISpriteJSONSprite {
  74014. /**
  74015. * string name of the Frame
  74016. */
  74017. filename: string;
  74018. /**
  74019. * ISpriteJSONSpriteFrame basic object of the frame data
  74020. */
  74021. frame: ISpriteJSONSpriteFrameData;
  74022. /**
  74023. * boolean to flag is the frame was rotated.
  74024. */
  74025. rotated: boolean;
  74026. /**
  74027. * boolean to flag is the frame was trimmed.
  74028. */
  74029. trimmed: boolean;
  74030. /**
  74031. * ISpriteJSONSpriteFrame basic object of the source data
  74032. */
  74033. spriteSourceSize: ISpriteJSONSpriteFrameData;
  74034. /**
  74035. * ISpriteJSONSpriteFrame basic object of the source data
  74036. */
  74037. sourceSize: ISpriteJSONSpriteSourceSize;
  74038. }
  74039. /**
  74040. * Defines the basic options interface of a JSON atlas.
  74041. */
  74042. export interface ISpriteJSONAtlas {
  74043. /**
  74044. * Array of objects that contain the frame data.
  74045. */
  74046. frames: Array<ISpriteJSONSprite>;
  74047. /**
  74048. * object basic object containing the sprite meta data.
  74049. */
  74050. meta?: object;
  74051. }
  74052. }
  74053. declare module "babylonjs/Shaders/spriteMap.fragment" {
  74054. /** @hidden */
  74055. export var spriteMapPixelShader: {
  74056. name: string;
  74057. shader: string;
  74058. };
  74059. }
  74060. declare module "babylonjs/Shaders/spriteMap.vertex" {
  74061. /** @hidden */
  74062. export var spriteMapVertexShader: {
  74063. name: string;
  74064. shader: string;
  74065. };
  74066. }
  74067. declare module "babylonjs/Sprites/spriteMap" {
  74068. import { IDisposable, Scene } from "babylonjs/scene";
  74069. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  74070. import { Texture } from "babylonjs/Materials/Textures/texture";
  74071. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  74072. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  74073. import "babylonjs/Meshes/Builders/planeBuilder";
  74074. import "babylonjs/Shaders/spriteMap.fragment";
  74075. import "babylonjs/Shaders/spriteMap.vertex";
  74076. /**
  74077. * Defines the basic options interface of a SpriteMap
  74078. */
  74079. export interface ISpriteMapOptions {
  74080. /**
  74081. * Vector2 of the number of cells in the grid.
  74082. */
  74083. stageSize?: Vector2;
  74084. /**
  74085. * Vector2 of the size of the output plane in World Units.
  74086. */
  74087. outputSize?: Vector2;
  74088. /**
  74089. * Vector3 of the position of the output plane in World Units.
  74090. */
  74091. outputPosition?: Vector3;
  74092. /**
  74093. * Vector3 of the rotation of the output plane.
  74094. */
  74095. outputRotation?: Vector3;
  74096. /**
  74097. * number of layers that the system will reserve in resources.
  74098. */
  74099. layerCount?: number;
  74100. /**
  74101. * number of max animation frames a single cell will reserve in resources.
  74102. */
  74103. maxAnimationFrames?: number;
  74104. /**
  74105. * number cell index of the base tile when the system compiles.
  74106. */
  74107. baseTile?: number;
  74108. /**
  74109. * boolean flip the sprite after its been repositioned by the framing data.
  74110. */
  74111. flipU?: boolean;
  74112. /**
  74113. * Vector3 scalar of the global RGB values of the SpriteMap.
  74114. */
  74115. colorMultiply?: Vector3;
  74116. }
  74117. /**
  74118. * Defines the IDisposable interface in order to be cleanable from resources.
  74119. */
  74120. export interface ISpriteMap extends IDisposable {
  74121. /**
  74122. * String name of the SpriteMap.
  74123. */
  74124. name: string;
  74125. /**
  74126. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  74127. */
  74128. atlasJSON: ISpriteJSONAtlas;
  74129. /**
  74130. * Texture of the SpriteMap.
  74131. */
  74132. spriteSheet: Texture;
  74133. /**
  74134. * The parameters to initialize the SpriteMap with.
  74135. */
  74136. options: ISpriteMapOptions;
  74137. }
  74138. /**
  74139. * Class used to manage a grid restricted sprite deployment on an Output plane.
  74140. */
  74141. export class SpriteMap implements ISpriteMap {
  74142. /** The Name of the spriteMap */
  74143. name: string;
  74144. /** The JSON file with the frame and meta data */
  74145. atlasJSON: ISpriteJSONAtlas;
  74146. /** The systems Sprite Sheet Texture */
  74147. spriteSheet: Texture;
  74148. /** Arguments passed with the Constructor */
  74149. options: ISpriteMapOptions;
  74150. /** Public Sprite Storage array, parsed from atlasJSON */
  74151. sprites: Array<ISpriteJSONSprite>;
  74152. /** Returns the Number of Sprites in the System */
  74153. get spriteCount(): number;
  74154. /** Returns the Position of Output Plane*/
  74155. get position(): Vector3;
  74156. /** Returns the Position of Output Plane*/
  74157. set position(v: Vector3);
  74158. /** Returns the Rotation of Output Plane*/
  74159. get rotation(): Vector3;
  74160. /** Returns the Rotation of Output Plane*/
  74161. set rotation(v: Vector3);
  74162. /** Sets the AnimationMap*/
  74163. get animationMap(): RawTexture;
  74164. /** Sets the AnimationMap*/
  74165. set animationMap(v: RawTexture);
  74166. /** Scene that the SpriteMap was created in */
  74167. private _scene;
  74168. /** Texture Buffer of Float32 that holds tile frame data*/
  74169. private _frameMap;
  74170. /** Texture Buffers of Float32 that holds tileMap data*/
  74171. private _tileMaps;
  74172. /** Texture Buffer of Float32 that holds Animation Data*/
  74173. private _animationMap;
  74174. /** Custom ShaderMaterial Central to the System*/
  74175. private _material;
  74176. /** Custom ShaderMaterial Central to the System*/
  74177. private _output;
  74178. /** Systems Time Ticker*/
  74179. private _time;
  74180. /**
  74181. * Creates a new SpriteMap
  74182. * @param name defines the SpriteMaps Name
  74183. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  74184. * @param spriteSheet is the Texture that the Sprites are on.
  74185. * @param options a basic deployment configuration
  74186. * @param scene The Scene that the map is deployed on
  74187. */
  74188. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74189. /**
  74190. * Returns tileID location
  74191. * @returns Vector2 the cell position ID
  74192. */
  74193. getTileID(): Vector2;
  74194. /**
  74195. * Gets the UV location of the mouse over the SpriteMap.
  74196. * @returns Vector2 the UV position of the mouse interaction
  74197. */
  74198. getMousePosition(): Vector2;
  74199. /**
  74200. * Creates the "frame" texture Buffer
  74201. * -------------------------------------
  74202. * Structure of frames
  74203. * "filename": "Falling-Water-2.png",
  74204. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74205. * "rotated": true,
  74206. * "trimmed": true,
  74207. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74208. * "sourceSize": {"w":32,"h":32}
  74209. * @returns RawTexture of the frameMap
  74210. */
  74211. private _createFrameBuffer;
  74212. /**
  74213. * Creates the tileMap texture Buffer
  74214. * @param buffer normally and array of numbers, or a false to generate from scratch
  74215. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74216. * @returns RawTexture of the tileMap
  74217. */
  74218. private _createTileBuffer;
  74219. /**
  74220. * Modifies the data of the tileMaps
  74221. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74222. * @param pos is the iVector2 Coordinates of the Tile
  74223. * @param tile The SpriteIndex of the new Tile
  74224. */
  74225. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74226. /**
  74227. * Creates the animationMap texture Buffer
  74228. * @param buffer normally and array of numbers, or a false to generate from scratch
  74229. * @returns RawTexture of the animationMap
  74230. */
  74231. private _createTileAnimationBuffer;
  74232. /**
  74233. * Modifies the data of the animationMap
  74234. * @param cellID is the Index of the Sprite
  74235. * @param _frame is the target Animation frame
  74236. * @param toCell is the Target Index of the next frame of the animation
  74237. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74238. * @param speed is a global scalar of the time variable on the map.
  74239. */
  74240. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74241. /**
  74242. * Exports the .tilemaps file
  74243. */
  74244. saveTileMaps(): void;
  74245. /**
  74246. * Imports the .tilemaps file
  74247. * @param url of the .tilemaps file
  74248. */
  74249. loadTileMaps(url: string): void;
  74250. /**
  74251. * Release associated resources
  74252. */
  74253. dispose(): void;
  74254. }
  74255. }
  74256. declare module "babylonjs/Sprites/spritePackedManager" {
  74257. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74258. import { Scene } from "babylonjs/scene";
  74259. /**
  74260. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74261. * @see http://doc.babylonjs.com/babylon101/sprites
  74262. */
  74263. export class SpritePackedManager extends SpriteManager {
  74264. /** defines the packed manager's name */
  74265. name: string;
  74266. /**
  74267. * Creates a new sprite manager from a packed sprite sheet
  74268. * @param name defines the manager's name
  74269. * @param imgUrl defines the sprite sheet url
  74270. * @param capacity defines the maximum allowed number of sprites
  74271. * @param scene defines the hosting scene
  74272. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74273. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74274. * @param samplingMode defines the smapling mode to use with spritesheet
  74275. * @param fromPacked set to true; do not alter
  74276. */
  74277. constructor(
  74278. /** defines the packed manager's name */
  74279. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74280. }
  74281. }
  74282. declare module "babylonjs/Sprites/index" {
  74283. export * from "babylonjs/Sprites/sprite";
  74284. export * from "babylonjs/Sprites/ISprites";
  74285. export * from "babylonjs/Sprites/spriteManager";
  74286. export * from "babylonjs/Sprites/spriteMap";
  74287. export * from "babylonjs/Sprites/spritePackedManager";
  74288. export * from "babylonjs/Sprites/spriteSceneComponent";
  74289. }
  74290. declare module "babylonjs/States/index" {
  74291. export * from "babylonjs/States/alphaCullingState";
  74292. export * from "babylonjs/States/depthCullingState";
  74293. export * from "babylonjs/States/stencilState";
  74294. }
  74295. declare module "babylonjs/Misc/assetsManager" {
  74296. import { Scene } from "babylonjs/scene";
  74297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74298. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74299. import { Skeleton } from "babylonjs/Bones/skeleton";
  74300. import { Observable } from "babylonjs/Misc/observable";
  74301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74302. import { Texture } from "babylonjs/Materials/Textures/texture";
  74303. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74304. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74305. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74306. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74307. /**
  74308. * Defines the list of states available for a task inside a AssetsManager
  74309. */
  74310. export enum AssetTaskState {
  74311. /**
  74312. * Initialization
  74313. */
  74314. INIT = 0,
  74315. /**
  74316. * Running
  74317. */
  74318. RUNNING = 1,
  74319. /**
  74320. * Done
  74321. */
  74322. DONE = 2,
  74323. /**
  74324. * Error
  74325. */
  74326. ERROR = 3
  74327. }
  74328. /**
  74329. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74330. */
  74331. export abstract class AbstractAssetTask {
  74332. /**
  74333. * Task name
  74334. */ name: string;
  74335. /**
  74336. * Callback called when the task is successful
  74337. */
  74338. onSuccess: (task: any) => void;
  74339. /**
  74340. * Callback called when the task is not successful
  74341. */
  74342. onError: (task: any, message?: string, exception?: any) => void;
  74343. /**
  74344. * Creates a new AssetsManager
  74345. * @param name defines the name of the task
  74346. */
  74347. constructor(
  74348. /**
  74349. * Task name
  74350. */ name: string);
  74351. private _isCompleted;
  74352. private _taskState;
  74353. private _errorObject;
  74354. /**
  74355. * Get if the task is completed
  74356. */
  74357. get isCompleted(): boolean;
  74358. /**
  74359. * Gets the current state of the task
  74360. */
  74361. get taskState(): AssetTaskState;
  74362. /**
  74363. * Gets the current error object (if task is in error)
  74364. */
  74365. get errorObject(): {
  74366. message?: string;
  74367. exception?: any;
  74368. };
  74369. /**
  74370. * Internal only
  74371. * @hidden
  74372. */
  74373. _setErrorObject(message?: string, exception?: any): void;
  74374. /**
  74375. * Execute the current task
  74376. * @param scene defines the scene where you want your assets to be loaded
  74377. * @param onSuccess is a callback called when the task is successfully executed
  74378. * @param onError is a callback called if an error occurs
  74379. */
  74380. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74381. /**
  74382. * Execute the current task
  74383. * @param scene defines the scene where you want your assets to be loaded
  74384. * @param onSuccess is a callback called when the task is successfully executed
  74385. * @param onError is a callback called if an error occurs
  74386. */
  74387. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74388. /**
  74389. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74390. * This can be used with failed tasks that have the reason for failure fixed.
  74391. */
  74392. reset(): void;
  74393. private onErrorCallback;
  74394. private onDoneCallback;
  74395. }
  74396. /**
  74397. * Define the interface used by progress events raised during assets loading
  74398. */
  74399. export interface IAssetsProgressEvent {
  74400. /**
  74401. * Defines the number of remaining tasks to process
  74402. */
  74403. remainingCount: number;
  74404. /**
  74405. * Defines the total number of tasks
  74406. */
  74407. totalCount: number;
  74408. /**
  74409. * Defines the task that was just processed
  74410. */
  74411. task: AbstractAssetTask;
  74412. }
  74413. /**
  74414. * Class used to share progress information about assets loading
  74415. */
  74416. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74417. /**
  74418. * Defines the number of remaining tasks to process
  74419. */
  74420. remainingCount: number;
  74421. /**
  74422. * Defines the total number of tasks
  74423. */
  74424. totalCount: number;
  74425. /**
  74426. * Defines the task that was just processed
  74427. */
  74428. task: AbstractAssetTask;
  74429. /**
  74430. * Creates a AssetsProgressEvent
  74431. * @param remainingCount defines the number of remaining tasks to process
  74432. * @param totalCount defines the total number of tasks
  74433. * @param task defines the task that was just processed
  74434. */
  74435. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74436. }
  74437. /**
  74438. * Define a task used by AssetsManager to load meshes
  74439. */
  74440. export class MeshAssetTask extends AbstractAssetTask {
  74441. /**
  74442. * Defines the name of the task
  74443. */
  74444. name: string;
  74445. /**
  74446. * Defines the list of mesh's names you want to load
  74447. */
  74448. meshesNames: any;
  74449. /**
  74450. * Defines the root url to use as a base to load your meshes and associated resources
  74451. */
  74452. rootUrl: string;
  74453. /**
  74454. * Defines the filename or File of the scene to load from
  74455. */
  74456. sceneFilename: string | File;
  74457. /**
  74458. * Gets the list of loaded meshes
  74459. */
  74460. loadedMeshes: Array<AbstractMesh>;
  74461. /**
  74462. * Gets the list of loaded particle systems
  74463. */
  74464. loadedParticleSystems: Array<IParticleSystem>;
  74465. /**
  74466. * Gets the list of loaded skeletons
  74467. */
  74468. loadedSkeletons: Array<Skeleton>;
  74469. /**
  74470. * Gets the list of loaded animation groups
  74471. */
  74472. loadedAnimationGroups: Array<AnimationGroup>;
  74473. /**
  74474. * Callback called when the task is successful
  74475. */
  74476. onSuccess: (task: MeshAssetTask) => void;
  74477. /**
  74478. * Callback called when the task is successful
  74479. */
  74480. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74481. /**
  74482. * Creates a new MeshAssetTask
  74483. * @param name defines the name of the task
  74484. * @param meshesNames defines the list of mesh's names you want to load
  74485. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74486. * @param sceneFilename defines the filename or File of the scene to load from
  74487. */
  74488. constructor(
  74489. /**
  74490. * Defines the name of the task
  74491. */
  74492. name: string,
  74493. /**
  74494. * Defines the list of mesh's names you want to load
  74495. */
  74496. meshesNames: any,
  74497. /**
  74498. * Defines the root url to use as a base to load your meshes and associated resources
  74499. */
  74500. rootUrl: string,
  74501. /**
  74502. * Defines the filename or File of the scene to load from
  74503. */
  74504. sceneFilename: string | File);
  74505. /**
  74506. * Execute the current task
  74507. * @param scene defines the scene where you want your assets to be loaded
  74508. * @param onSuccess is a callback called when the task is successfully executed
  74509. * @param onError is a callback called if an error occurs
  74510. */
  74511. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74512. }
  74513. /**
  74514. * Define a task used by AssetsManager to load text content
  74515. */
  74516. export class TextFileAssetTask extends AbstractAssetTask {
  74517. /**
  74518. * Defines the name of the task
  74519. */
  74520. name: string;
  74521. /**
  74522. * Defines the location of the file to load
  74523. */
  74524. url: string;
  74525. /**
  74526. * Gets the loaded text string
  74527. */
  74528. text: string;
  74529. /**
  74530. * Callback called when the task is successful
  74531. */
  74532. onSuccess: (task: TextFileAssetTask) => void;
  74533. /**
  74534. * Callback called when the task is successful
  74535. */
  74536. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74537. /**
  74538. * Creates a new TextFileAssetTask object
  74539. * @param name defines the name of the task
  74540. * @param url defines the location of the file to load
  74541. */
  74542. constructor(
  74543. /**
  74544. * Defines the name of the task
  74545. */
  74546. name: string,
  74547. /**
  74548. * Defines the location of the file to load
  74549. */
  74550. url: string);
  74551. /**
  74552. * Execute the current task
  74553. * @param scene defines the scene where you want your assets to be loaded
  74554. * @param onSuccess is a callback called when the task is successfully executed
  74555. * @param onError is a callback called if an error occurs
  74556. */
  74557. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74558. }
  74559. /**
  74560. * Define a task used by AssetsManager to load binary data
  74561. */
  74562. export class BinaryFileAssetTask extends AbstractAssetTask {
  74563. /**
  74564. * Defines the name of the task
  74565. */
  74566. name: string;
  74567. /**
  74568. * Defines the location of the file to load
  74569. */
  74570. url: string;
  74571. /**
  74572. * Gets the lodaded data (as an array buffer)
  74573. */
  74574. data: ArrayBuffer;
  74575. /**
  74576. * Callback called when the task is successful
  74577. */
  74578. onSuccess: (task: BinaryFileAssetTask) => void;
  74579. /**
  74580. * Callback called when the task is successful
  74581. */
  74582. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74583. /**
  74584. * Creates a new BinaryFileAssetTask object
  74585. * @param name defines the name of the new task
  74586. * @param url defines the location of the file to load
  74587. */
  74588. constructor(
  74589. /**
  74590. * Defines the name of the task
  74591. */
  74592. name: string,
  74593. /**
  74594. * Defines the location of the file to load
  74595. */
  74596. url: string);
  74597. /**
  74598. * Execute the current task
  74599. * @param scene defines the scene where you want your assets to be loaded
  74600. * @param onSuccess is a callback called when the task is successfully executed
  74601. * @param onError is a callback called if an error occurs
  74602. */
  74603. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74604. }
  74605. /**
  74606. * Define a task used by AssetsManager to load images
  74607. */
  74608. export class ImageAssetTask extends AbstractAssetTask {
  74609. /**
  74610. * Defines the name of the task
  74611. */
  74612. name: string;
  74613. /**
  74614. * Defines the location of the image to load
  74615. */
  74616. url: string;
  74617. /**
  74618. * Gets the loaded images
  74619. */
  74620. image: HTMLImageElement;
  74621. /**
  74622. * Callback called when the task is successful
  74623. */
  74624. onSuccess: (task: ImageAssetTask) => void;
  74625. /**
  74626. * Callback called when the task is successful
  74627. */
  74628. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74629. /**
  74630. * Creates a new ImageAssetTask
  74631. * @param name defines the name of the task
  74632. * @param url defines the location of the image to load
  74633. */
  74634. constructor(
  74635. /**
  74636. * Defines the name of the task
  74637. */
  74638. name: string,
  74639. /**
  74640. * Defines the location of the image to load
  74641. */
  74642. url: string);
  74643. /**
  74644. * Execute the current task
  74645. * @param scene defines the scene where you want your assets to be loaded
  74646. * @param onSuccess is a callback called when the task is successfully executed
  74647. * @param onError is a callback called if an error occurs
  74648. */
  74649. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74650. }
  74651. /**
  74652. * Defines the interface used by texture loading tasks
  74653. */
  74654. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74655. /**
  74656. * Gets the loaded texture
  74657. */
  74658. texture: TEX;
  74659. }
  74660. /**
  74661. * Define a task used by AssetsManager to load 2D textures
  74662. */
  74663. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74664. /**
  74665. * Defines the name of the task
  74666. */
  74667. name: string;
  74668. /**
  74669. * Defines the location of the file to load
  74670. */
  74671. url: string;
  74672. /**
  74673. * Defines if mipmap should not be generated (default is false)
  74674. */
  74675. noMipmap?: boolean | undefined;
  74676. /**
  74677. * Defines if texture must be inverted on Y axis (default is true)
  74678. */
  74679. invertY: boolean;
  74680. /**
  74681. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74682. */
  74683. samplingMode: number;
  74684. /**
  74685. * Gets the loaded texture
  74686. */
  74687. texture: Texture;
  74688. /**
  74689. * Callback called when the task is successful
  74690. */
  74691. onSuccess: (task: TextureAssetTask) => void;
  74692. /**
  74693. * Callback called when the task is successful
  74694. */
  74695. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74696. /**
  74697. * Creates a new TextureAssetTask object
  74698. * @param name defines the name of the task
  74699. * @param url defines the location of the file to load
  74700. * @param noMipmap defines if mipmap should not be generated (default is false)
  74701. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74702. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74703. */
  74704. constructor(
  74705. /**
  74706. * Defines the name of the task
  74707. */
  74708. name: string,
  74709. /**
  74710. * Defines the location of the file to load
  74711. */
  74712. url: string,
  74713. /**
  74714. * Defines if mipmap should not be generated (default is false)
  74715. */
  74716. noMipmap?: boolean | undefined,
  74717. /**
  74718. * Defines if texture must be inverted on Y axis (default is true)
  74719. */
  74720. invertY?: boolean,
  74721. /**
  74722. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74723. */
  74724. samplingMode?: number);
  74725. /**
  74726. * Execute the current task
  74727. * @param scene defines the scene where you want your assets to be loaded
  74728. * @param onSuccess is a callback called when the task is successfully executed
  74729. * @param onError is a callback called if an error occurs
  74730. */
  74731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74732. }
  74733. /**
  74734. * Define a task used by AssetsManager to load cube textures
  74735. */
  74736. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74737. /**
  74738. * Defines the name of the task
  74739. */
  74740. name: string;
  74741. /**
  74742. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74743. */
  74744. url: string;
  74745. /**
  74746. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74747. */
  74748. extensions?: string[] | undefined;
  74749. /**
  74750. * Defines if mipmaps should not be generated (default is false)
  74751. */
  74752. noMipmap?: boolean | undefined;
  74753. /**
  74754. * Defines the explicit list of files (undefined by default)
  74755. */
  74756. files?: string[] | undefined;
  74757. /**
  74758. * Gets the loaded texture
  74759. */
  74760. texture: CubeTexture;
  74761. /**
  74762. * Callback called when the task is successful
  74763. */
  74764. onSuccess: (task: CubeTextureAssetTask) => void;
  74765. /**
  74766. * Callback called when the task is successful
  74767. */
  74768. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74769. /**
  74770. * Creates a new CubeTextureAssetTask
  74771. * @param name defines the name of the task
  74772. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74773. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74774. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74775. * @param files defines the explicit list of files (undefined by default)
  74776. */
  74777. constructor(
  74778. /**
  74779. * Defines the name of the task
  74780. */
  74781. name: string,
  74782. /**
  74783. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74784. */
  74785. url: string,
  74786. /**
  74787. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74788. */
  74789. extensions?: string[] | undefined,
  74790. /**
  74791. * Defines if mipmaps should not be generated (default is false)
  74792. */
  74793. noMipmap?: boolean | undefined,
  74794. /**
  74795. * Defines the explicit list of files (undefined by default)
  74796. */
  74797. files?: string[] | undefined);
  74798. /**
  74799. * Execute the current task
  74800. * @param scene defines the scene where you want your assets to be loaded
  74801. * @param onSuccess is a callback called when the task is successfully executed
  74802. * @param onError is a callback called if an error occurs
  74803. */
  74804. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74805. }
  74806. /**
  74807. * Define a task used by AssetsManager to load HDR cube textures
  74808. */
  74809. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74810. /**
  74811. * Defines the name of the task
  74812. */
  74813. name: string;
  74814. /**
  74815. * Defines the location of the file to load
  74816. */
  74817. url: string;
  74818. /**
  74819. * Defines the desired size (the more it increases the longer the generation will be)
  74820. */
  74821. size: number;
  74822. /**
  74823. * Defines if mipmaps should not be generated (default is false)
  74824. */
  74825. noMipmap: boolean;
  74826. /**
  74827. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74828. */
  74829. generateHarmonics: boolean;
  74830. /**
  74831. * 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)
  74832. */
  74833. gammaSpace: boolean;
  74834. /**
  74835. * Internal Use Only
  74836. */
  74837. reserved: boolean;
  74838. /**
  74839. * Gets the loaded texture
  74840. */
  74841. texture: HDRCubeTexture;
  74842. /**
  74843. * Callback called when the task is successful
  74844. */
  74845. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74846. /**
  74847. * Callback called when the task is successful
  74848. */
  74849. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74850. /**
  74851. * Creates a new HDRCubeTextureAssetTask object
  74852. * @param name defines the name of the task
  74853. * @param url defines the location of the file to load
  74854. * @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.
  74855. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74856. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74857. * @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)
  74858. * @param reserved Internal use only
  74859. */
  74860. constructor(
  74861. /**
  74862. * Defines the name of the task
  74863. */
  74864. name: string,
  74865. /**
  74866. * Defines the location of the file to load
  74867. */
  74868. url: string,
  74869. /**
  74870. * Defines the desired size (the more it increases the longer the generation will be)
  74871. */
  74872. size: number,
  74873. /**
  74874. * Defines if mipmaps should not be generated (default is false)
  74875. */
  74876. noMipmap?: boolean,
  74877. /**
  74878. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74879. */
  74880. generateHarmonics?: boolean,
  74881. /**
  74882. * 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)
  74883. */
  74884. gammaSpace?: boolean,
  74885. /**
  74886. * Internal Use Only
  74887. */
  74888. reserved?: boolean);
  74889. /**
  74890. * Execute the current task
  74891. * @param scene defines the scene where you want your assets to be loaded
  74892. * @param onSuccess is a callback called when the task is successfully executed
  74893. * @param onError is a callback called if an error occurs
  74894. */
  74895. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74896. }
  74897. /**
  74898. * Define a task used by AssetsManager to load Equirectangular cube textures
  74899. */
  74900. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74901. /**
  74902. * Defines the name of the task
  74903. */
  74904. name: string;
  74905. /**
  74906. * Defines the location of the file to load
  74907. */
  74908. url: string;
  74909. /**
  74910. * Defines the desired size (the more it increases the longer the generation will be)
  74911. */
  74912. size: number;
  74913. /**
  74914. * Defines if mipmaps should not be generated (default is false)
  74915. */
  74916. noMipmap: boolean;
  74917. /**
  74918. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74919. * but the standard material would require them in Gamma space) (default is true)
  74920. */
  74921. gammaSpace: boolean;
  74922. /**
  74923. * Gets the loaded texture
  74924. */
  74925. texture: EquiRectangularCubeTexture;
  74926. /**
  74927. * Callback called when the task is successful
  74928. */
  74929. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74930. /**
  74931. * Callback called when the task is successful
  74932. */
  74933. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74934. /**
  74935. * Creates a new EquiRectangularCubeTextureAssetTask object
  74936. * @param name defines the name of the task
  74937. * @param url defines the location of the file to load
  74938. * @param size defines the desired size (the more it increases the longer the generation will be)
  74939. * If the size is omitted this implies you are using a preprocessed cubemap.
  74940. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74941. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74942. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74943. * (default is true)
  74944. */
  74945. constructor(
  74946. /**
  74947. * Defines the name of the task
  74948. */
  74949. name: string,
  74950. /**
  74951. * Defines the location of the file to load
  74952. */
  74953. url: string,
  74954. /**
  74955. * Defines the desired size (the more it increases the longer the generation will be)
  74956. */
  74957. size: number,
  74958. /**
  74959. * Defines if mipmaps should not be generated (default is false)
  74960. */
  74961. noMipmap?: boolean,
  74962. /**
  74963. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74964. * but the standard material would require them in Gamma space) (default is true)
  74965. */
  74966. gammaSpace?: boolean);
  74967. /**
  74968. * Execute the current task
  74969. * @param scene defines the scene where you want your assets to be loaded
  74970. * @param onSuccess is a callback called when the task is successfully executed
  74971. * @param onError is a callback called if an error occurs
  74972. */
  74973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74974. }
  74975. /**
  74976. * This class can be used to easily import assets into a scene
  74977. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74978. */
  74979. export class AssetsManager {
  74980. private _scene;
  74981. private _isLoading;
  74982. protected _tasks: AbstractAssetTask[];
  74983. protected _waitingTasksCount: number;
  74984. protected _totalTasksCount: number;
  74985. /**
  74986. * Callback called when all tasks are processed
  74987. */
  74988. onFinish: (tasks: AbstractAssetTask[]) => void;
  74989. /**
  74990. * Callback called when a task is successful
  74991. */
  74992. onTaskSuccess: (task: AbstractAssetTask) => void;
  74993. /**
  74994. * Callback called when a task had an error
  74995. */
  74996. onTaskError: (task: AbstractAssetTask) => void;
  74997. /**
  74998. * Callback called when a task is done (whatever the result is)
  74999. */
  75000. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  75001. /**
  75002. * Observable called when all tasks are processed
  75003. */
  75004. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  75005. /**
  75006. * Observable called when a task had an error
  75007. */
  75008. onTaskErrorObservable: Observable<AbstractAssetTask>;
  75009. /**
  75010. * Observable called when all tasks were executed
  75011. */
  75012. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  75013. /**
  75014. * Observable called when a task is done (whatever the result is)
  75015. */
  75016. onProgressObservable: Observable<IAssetsProgressEvent>;
  75017. /**
  75018. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  75019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  75020. */
  75021. useDefaultLoadingScreen: boolean;
  75022. /**
  75023. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  75024. * when all assets have been downloaded.
  75025. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  75026. */
  75027. autoHideLoadingUI: boolean;
  75028. /**
  75029. * Creates a new AssetsManager
  75030. * @param scene defines the scene to work on
  75031. */
  75032. constructor(scene: Scene);
  75033. /**
  75034. * Add a MeshAssetTask to the list of active tasks
  75035. * @param taskName defines the name of the new task
  75036. * @param meshesNames defines the name of meshes to load
  75037. * @param rootUrl defines the root url to use to locate files
  75038. * @param sceneFilename defines the filename of the scene file
  75039. * @returns a new MeshAssetTask object
  75040. */
  75041. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  75042. /**
  75043. * Add a TextFileAssetTask to the list of active tasks
  75044. * @param taskName defines the name of the new task
  75045. * @param url defines the url of the file to load
  75046. * @returns a new TextFileAssetTask object
  75047. */
  75048. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  75049. /**
  75050. * Add a BinaryFileAssetTask to the list of active tasks
  75051. * @param taskName defines the name of the new task
  75052. * @param url defines the url of the file to load
  75053. * @returns a new BinaryFileAssetTask object
  75054. */
  75055. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  75056. /**
  75057. * Add a ImageAssetTask to the list of active tasks
  75058. * @param taskName defines the name of the new task
  75059. * @param url defines the url of the file to load
  75060. * @returns a new ImageAssetTask object
  75061. */
  75062. addImageTask(taskName: string, url: string): ImageAssetTask;
  75063. /**
  75064. * Add a TextureAssetTask to the list of active tasks
  75065. * @param taskName defines the name of the new task
  75066. * @param url defines the url of the file to load
  75067. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75068. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  75069. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  75070. * @returns a new TextureAssetTask object
  75071. */
  75072. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  75073. /**
  75074. * Add a CubeTextureAssetTask to the list of active tasks
  75075. * @param taskName defines the name of the new task
  75076. * @param url defines the url of the file to load
  75077. * @param extensions defines the extension to use to load the cube map (can be null)
  75078. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75079. * @param files defines the list of files to load (can be null)
  75080. * @returns a new CubeTextureAssetTask object
  75081. */
  75082. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  75083. /**
  75084. *
  75085. * Add a HDRCubeTextureAssetTask to the list of active tasks
  75086. * @param taskName defines the name of the new task
  75087. * @param url defines the url of the file to load
  75088. * @param size defines the size you want for the cubemap (can be null)
  75089. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75090. * @param generateHarmonics defines if you want to automatically generate (true by default)
  75091. * @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)
  75092. * @param reserved Internal use only
  75093. * @returns a new HDRCubeTextureAssetTask object
  75094. */
  75095. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  75096. /**
  75097. *
  75098. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  75099. * @param taskName defines the name of the new task
  75100. * @param url defines the url of the file to load
  75101. * @param size defines the size you want for the cubemap (can be null)
  75102. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75103. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  75104. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  75105. * @returns a new EquiRectangularCubeTextureAssetTask object
  75106. */
  75107. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  75108. /**
  75109. * Remove a task from the assets manager.
  75110. * @param task the task to remove
  75111. */
  75112. removeTask(task: AbstractAssetTask): void;
  75113. private _decreaseWaitingTasksCount;
  75114. private _runTask;
  75115. /**
  75116. * Reset the AssetsManager and remove all tasks
  75117. * @return the current instance of the AssetsManager
  75118. */
  75119. reset(): AssetsManager;
  75120. /**
  75121. * Start the loading process
  75122. * @return the current instance of the AssetsManager
  75123. */
  75124. load(): AssetsManager;
  75125. /**
  75126. * Start the loading process as an async operation
  75127. * @return a promise returning the list of failed tasks
  75128. */
  75129. loadAsync(): Promise<void>;
  75130. }
  75131. }
  75132. declare module "babylonjs/Misc/deferred" {
  75133. /**
  75134. * Wrapper class for promise with external resolve and reject.
  75135. */
  75136. export class Deferred<T> {
  75137. /**
  75138. * The promise associated with this deferred object.
  75139. */
  75140. readonly promise: Promise<T>;
  75141. private _resolve;
  75142. private _reject;
  75143. /**
  75144. * The resolve method of the promise associated with this deferred object.
  75145. */
  75146. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75147. /**
  75148. * The reject method of the promise associated with this deferred object.
  75149. */
  75150. get reject(): (reason?: any) => void;
  75151. /**
  75152. * Constructor for this deferred object.
  75153. */
  75154. constructor();
  75155. }
  75156. }
  75157. declare module "babylonjs/Misc/meshExploder" {
  75158. import { Mesh } from "babylonjs/Meshes/mesh";
  75159. /**
  75160. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75161. */
  75162. export class MeshExploder {
  75163. private _centerMesh;
  75164. private _meshes;
  75165. private _meshesOrigins;
  75166. private _toCenterVectors;
  75167. private _scaledDirection;
  75168. private _newPosition;
  75169. private _centerPosition;
  75170. /**
  75171. * Explodes meshes from a center mesh.
  75172. * @param meshes The meshes to explode.
  75173. * @param centerMesh The mesh to be center of explosion.
  75174. */
  75175. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75176. private _setCenterMesh;
  75177. /**
  75178. * Get class name
  75179. * @returns "MeshExploder"
  75180. */
  75181. getClassName(): string;
  75182. /**
  75183. * "Exploded meshes"
  75184. * @returns Array of meshes with the centerMesh at index 0.
  75185. */
  75186. getMeshes(): Array<Mesh>;
  75187. /**
  75188. * Explodes meshes giving a specific direction
  75189. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75190. */
  75191. explode(direction?: number): void;
  75192. }
  75193. }
  75194. declare module "babylonjs/Misc/filesInput" {
  75195. import { Engine } from "babylonjs/Engines/engine";
  75196. import { Scene } from "babylonjs/scene";
  75197. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  75198. /**
  75199. * Class used to help managing file picking and drag'n'drop
  75200. */
  75201. export class FilesInput {
  75202. /**
  75203. * List of files ready to be loaded
  75204. */
  75205. static get FilesToLoad(): {
  75206. [key: string]: File;
  75207. };
  75208. /**
  75209. * Callback called when a file is processed
  75210. */
  75211. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  75212. private _engine;
  75213. private _currentScene;
  75214. private _sceneLoadedCallback;
  75215. private _progressCallback;
  75216. private _additionalRenderLoopLogicCallback;
  75217. private _textureLoadingCallback;
  75218. private _startingProcessingFilesCallback;
  75219. private _onReloadCallback;
  75220. private _errorCallback;
  75221. private _elementToMonitor;
  75222. private _sceneFileToLoad;
  75223. private _filesToLoad;
  75224. /**
  75225. * Creates a new FilesInput
  75226. * @param engine defines the rendering engine
  75227. * @param scene defines the hosting scene
  75228. * @param sceneLoadedCallback callback called when scene is loaded
  75229. * @param progressCallback callback called to track progress
  75230. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75231. * @param textureLoadingCallback callback called when a texture is loading
  75232. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75233. * @param onReloadCallback callback called when a reload is requested
  75234. * @param errorCallback callback call if an error occurs
  75235. */
  75236. 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);
  75237. private _dragEnterHandler;
  75238. private _dragOverHandler;
  75239. private _dropHandler;
  75240. /**
  75241. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75242. * @param elementToMonitor defines the DOM element to track
  75243. */
  75244. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75245. /**
  75246. * Release all associated resources
  75247. */
  75248. dispose(): void;
  75249. private renderFunction;
  75250. private drag;
  75251. private drop;
  75252. private _traverseFolder;
  75253. private _processFiles;
  75254. /**
  75255. * Load files from a drop event
  75256. * @param event defines the drop event to use as source
  75257. */
  75258. loadFiles(event: any): void;
  75259. private _processReload;
  75260. /**
  75261. * Reload the current scene from the loaded files
  75262. */
  75263. reload(): void;
  75264. }
  75265. }
  75266. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75267. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75268. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75269. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75270. }
  75271. declare module "babylonjs/Misc/sceneOptimizer" {
  75272. import { Scene, IDisposable } from "babylonjs/scene";
  75273. import { Observable } from "babylonjs/Misc/observable";
  75274. /**
  75275. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75276. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75277. */
  75278. export class SceneOptimization {
  75279. /**
  75280. * Defines the priority of this optimization (0 by default which means first in the list)
  75281. */
  75282. priority: number;
  75283. /**
  75284. * Gets a string describing the action executed by the current optimization
  75285. * @returns description string
  75286. */
  75287. getDescription(): string;
  75288. /**
  75289. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75290. * @param scene defines the current scene where to apply this optimization
  75291. * @param optimizer defines the current optimizer
  75292. * @returns true if everything that can be done was applied
  75293. */
  75294. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75295. /**
  75296. * Creates the SceneOptimization object
  75297. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75298. * @param desc defines the description associated with the optimization
  75299. */
  75300. constructor(
  75301. /**
  75302. * Defines the priority of this optimization (0 by default which means first in the list)
  75303. */
  75304. priority?: number);
  75305. }
  75306. /**
  75307. * Defines an optimization used to reduce the size of render target textures
  75308. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75309. */
  75310. export class TextureOptimization extends SceneOptimization {
  75311. /**
  75312. * Defines the priority of this optimization (0 by default which means first in the list)
  75313. */
  75314. priority: number;
  75315. /**
  75316. * 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
  75317. */
  75318. maximumSize: number;
  75319. /**
  75320. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75321. */
  75322. step: number;
  75323. /**
  75324. * Gets a string describing the action executed by the current optimization
  75325. * @returns description string
  75326. */
  75327. getDescription(): string;
  75328. /**
  75329. * Creates the TextureOptimization object
  75330. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75331. * @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
  75332. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75333. */
  75334. constructor(
  75335. /**
  75336. * Defines the priority of this optimization (0 by default which means first in the list)
  75337. */
  75338. priority?: number,
  75339. /**
  75340. * 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
  75341. */
  75342. maximumSize?: number,
  75343. /**
  75344. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75345. */
  75346. step?: number);
  75347. /**
  75348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75349. * @param scene defines the current scene where to apply this optimization
  75350. * @param optimizer defines the current optimizer
  75351. * @returns true if everything that can be done was applied
  75352. */
  75353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75354. }
  75355. /**
  75356. * Defines an optimization used to increase or decrease the rendering resolution
  75357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75358. */
  75359. export class HardwareScalingOptimization extends SceneOptimization {
  75360. /**
  75361. * Defines the priority of this optimization (0 by default which means first in the list)
  75362. */
  75363. priority: number;
  75364. /**
  75365. * Defines the maximum scale to use (2 by default)
  75366. */
  75367. maximumScale: number;
  75368. /**
  75369. * Defines the step to use between two passes (0.5 by default)
  75370. */
  75371. step: number;
  75372. private _currentScale;
  75373. private _directionOffset;
  75374. /**
  75375. * Gets a string describing the action executed by the current optimization
  75376. * @return description string
  75377. */
  75378. getDescription(): string;
  75379. /**
  75380. * Creates the HardwareScalingOptimization object
  75381. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75382. * @param maximumScale defines the maximum scale to use (2 by default)
  75383. * @param step defines the step to use between two passes (0.5 by default)
  75384. */
  75385. constructor(
  75386. /**
  75387. * Defines the priority of this optimization (0 by default which means first in the list)
  75388. */
  75389. priority?: number,
  75390. /**
  75391. * Defines the maximum scale to use (2 by default)
  75392. */
  75393. maximumScale?: number,
  75394. /**
  75395. * Defines the step to use between two passes (0.5 by default)
  75396. */
  75397. step?: number);
  75398. /**
  75399. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75400. * @param scene defines the current scene where to apply this optimization
  75401. * @param optimizer defines the current optimizer
  75402. * @returns true if everything that can be done was applied
  75403. */
  75404. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75405. }
  75406. /**
  75407. * Defines an optimization used to remove shadows
  75408. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75409. */
  75410. export class ShadowsOptimization extends SceneOptimization {
  75411. /**
  75412. * Gets a string describing the action executed by the current optimization
  75413. * @return description string
  75414. */
  75415. getDescription(): string;
  75416. /**
  75417. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75418. * @param scene defines the current scene where to apply this optimization
  75419. * @param optimizer defines the current optimizer
  75420. * @returns true if everything that can be done was applied
  75421. */
  75422. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75423. }
  75424. /**
  75425. * Defines an optimization used to turn post-processes off
  75426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75427. */
  75428. export class PostProcessesOptimization extends SceneOptimization {
  75429. /**
  75430. * Gets a string describing the action executed by the current optimization
  75431. * @return description string
  75432. */
  75433. getDescription(): string;
  75434. /**
  75435. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75436. * @param scene defines the current scene where to apply this optimization
  75437. * @param optimizer defines the current optimizer
  75438. * @returns true if everything that can be done was applied
  75439. */
  75440. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75441. }
  75442. /**
  75443. * Defines an optimization used to turn lens flares off
  75444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75445. */
  75446. export class LensFlaresOptimization extends SceneOptimization {
  75447. /**
  75448. * Gets a string describing the action executed by the current optimization
  75449. * @return description string
  75450. */
  75451. getDescription(): string;
  75452. /**
  75453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75454. * @param scene defines the current scene where to apply this optimization
  75455. * @param optimizer defines the current optimizer
  75456. * @returns true if everything that can be done was applied
  75457. */
  75458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75459. }
  75460. /**
  75461. * Defines an optimization based on user defined callback.
  75462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75463. */
  75464. export class CustomOptimization extends SceneOptimization {
  75465. /**
  75466. * Callback called to apply the custom optimization.
  75467. */
  75468. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75469. /**
  75470. * Callback called to get custom description
  75471. */
  75472. onGetDescription: () => string;
  75473. /**
  75474. * Gets a string describing the action executed by the current optimization
  75475. * @returns description string
  75476. */
  75477. getDescription(): string;
  75478. /**
  75479. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75480. * @param scene defines the current scene where to apply this optimization
  75481. * @param optimizer defines the current optimizer
  75482. * @returns true if everything that can be done was applied
  75483. */
  75484. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75485. }
  75486. /**
  75487. * Defines an optimization used to turn particles off
  75488. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75489. */
  75490. export class ParticlesOptimization extends SceneOptimization {
  75491. /**
  75492. * Gets a string describing the action executed by the current optimization
  75493. * @return description string
  75494. */
  75495. getDescription(): string;
  75496. /**
  75497. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75498. * @param scene defines the current scene where to apply this optimization
  75499. * @param optimizer defines the current optimizer
  75500. * @returns true if everything that can be done was applied
  75501. */
  75502. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75503. }
  75504. /**
  75505. * Defines an optimization used to turn render targets off
  75506. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75507. */
  75508. export class RenderTargetsOptimization extends SceneOptimization {
  75509. /**
  75510. * Gets a string describing the action executed by the current optimization
  75511. * @return description string
  75512. */
  75513. getDescription(): string;
  75514. /**
  75515. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75516. * @param scene defines the current scene where to apply this optimization
  75517. * @param optimizer defines the current optimizer
  75518. * @returns true if everything that can be done was applied
  75519. */
  75520. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75521. }
  75522. /**
  75523. * Defines an optimization used to merge meshes with compatible materials
  75524. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75525. */
  75526. export class MergeMeshesOptimization extends SceneOptimization {
  75527. private static _UpdateSelectionTree;
  75528. /**
  75529. * Gets or sets a boolean which defines if optimization octree has to be updated
  75530. */
  75531. static get UpdateSelectionTree(): boolean;
  75532. /**
  75533. * Gets or sets a boolean which defines if optimization octree has to be updated
  75534. */
  75535. static set UpdateSelectionTree(value: boolean);
  75536. /**
  75537. * Gets a string describing the action executed by the current optimization
  75538. * @return description string
  75539. */
  75540. getDescription(): string;
  75541. private _canBeMerged;
  75542. /**
  75543. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75544. * @param scene defines the current scene where to apply this optimization
  75545. * @param optimizer defines the current optimizer
  75546. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75547. * @returns true if everything that can be done was applied
  75548. */
  75549. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75550. }
  75551. /**
  75552. * Defines a list of options used by SceneOptimizer
  75553. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75554. */
  75555. export class SceneOptimizerOptions {
  75556. /**
  75557. * Defines the target frame rate to reach (60 by default)
  75558. */
  75559. targetFrameRate: number;
  75560. /**
  75561. * Defines the interval between two checkes (2000ms by default)
  75562. */
  75563. trackerDuration: number;
  75564. /**
  75565. * Gets the list of optimizations to apply
  75566. */
  75567. optimizations: SceneOptimization[];
  75568. /**
  75569. * Creates a new list of options used by SceneOptimizer
  75570. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75571. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75572. */
  75573. constructor(
  75574. /**
  75575. * Defines the target frame rate to reach (60 by default)
  75576. */
  75577. targetFrameRate?: number,
  75578. /**
  75579. * Defines the interval between two checkes (2000ms by default)
  75580. */
  75581. trackerDuration?: number);
  75582. /**
  75583. * Add a new optimization
  75584. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75585. * @returns the current SceneOptimizerOptions
  75586. */
  75587. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75588. /**
  75589. * Add a new custom optimization
  75590. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75591. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75592. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75593. * @returns the current SceneOptimizerOptions
  75594. */
  75595. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75596. /**
  75597. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75598. * @param targetFrameRate defines the target frame rate (60 by default)
  75599. * @returns a SceneOptimizerOptions object
  75600. */
  75601. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75602. /**
  75603. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75604. * @param targetFrameRate defines the target frame rate (60 by default)
  75605. * @returns a SceneOptimizerOptions object
  75606. */
  75607. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75608. /**
  75609. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75610. * @param targetFrameRate defines the target frame rate (60 by default)
  75611. * @returns a SceneOptimizerOptions object
  75612. */
  75613. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75614. }
  75615. /**
  75616. * Class used to run optimizations in order to reach a target frame rate
  75617. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75618. */
  75619. export class SceneOptimizer implements IDisposable {
  75620. private _isRunning;
  75621. private _options;
  75622. private _scene;
  75623. private _currentPriorityLevel;
  75624. private _targetFrameRate;
  75625. private _trackerDuration;
  75626. private _currentFrameRate;
  75627. private _sceneDisposeObserver;
  75628. private _improvementMode;
  75629. /**
  75630. * Defines an observable called when the optimizer reaches the target frame rate
  75631. */
  75632. onSuccessObservable: Observable<SceneOptimizer>;
  75633. /**
  75634. * Defines an observable called when the optimizer enables an optimization
  75635. */
  75636. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75637. /**
  75638. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75639. */
  75640. onFailureObservable: Observable<SceneOptimizer>;
  75641. /**
  75642. * Gets a boolean indicating if the optimizer is in improvement mode
  75643. */
  75644. get isInImprovementMode(): boolean;
  75645. /**
  75646. * Gets the current priority level (0 at start)
  75647. */
  75648. get currentPriorityLevel(): number;
  75649. /**
  75650. * Gets the current frame rate checked by the SceneOptimizer
  75651. */
  75652. get currentFrameRate(): number;
  75653. /**
  75654. * Gets or sets the current target frame rate (60 by default)
  75655. */
  75656. get targetFrameRate(): number;
  75657. /**
  75658. * Gets or sets the current target frame rate (60 by default)
  75659. */
  75660. set targetFrameRate(value: number);
  75661. /**
  75662. * Gets or sets the current interval between two checks (every 2000ms by default)
  75663. */
  75664. get trackerDuration(): number;
  75665. /**
  75666. * Gets or sets the current interval between two checks (every 2000ms by default)
  75667. */
  75668. set trackerDuration(value: number);
  75669. /**
  75670. * Gets the list of active optimizations
  75671. */
  75672. get optimizations(): SceneOptimization[];
  75673. /**
  75674. * Creates a new SceneOptimizer
  75675. * @param scene defines the scene to work on
  75676. * @param options defines the options to use with the SceneOptimizer
  75677. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75678. * @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)
  75679. */
  75680. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75681. /**
  75682. * Stops the current optimizer
  75683. */
  75684. stop(): void;
  75685. /**
  75686. * Reset the optimizer to initial step (current priority level = 0)
  75687. */
  75688. reset(): void;
  75689. /**
  75690. * Start the optimizer. By default it will try to reach a specific framerate
  75691. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75692. */
  75693. start(): void;
  75694. private _checkCurrentState;
  75695. /**
  75696. * Release all resources
  75697. */
  75698. dispose(): void;
  75699. /**
  75700. * Helper function to create a SceneOptimizer with one single line of code
  75701. * @param scene defines the scene to work on
  75702. * @param options defines the options to use with the SceneOptimizer
  75703. * @param onSuccess defines a callback to call on success
  75704. * @param onFailure defines a callback to call on failure
  75705. * @returns the new SceneOptimizer object
  75706. */
  75707. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75708. }
  75709. }
  75710. declare module "babylonjs/Misc/sceneSerializer" {
  75711. import { Scene } from "babylonjs/scene";
  75712. /**
  75713. * Class used to serialize a scene into a string
  75714. */
  75715. export class SceneSerializer {
  75716. /**
  75717. * Clear cache used by a previous serialization
  75718. */
  75719. static ClearCache(): void;
  75720. /**
  75721. * Serialize a scene into a JSON compatible object
  75722. * @param scene defines the scene to serialize
  75723. * @returns a JSON compatible object
  75724. */
  75725. static Serialize(scene: Scene): any;
  75726. /**
  75727. * Serialize a mesh into a JSON compatible object
  75728. * @param toSerialize defines the mesh to serialize
  75729. * @param withParents defines if parents must be serialized as well
  75730. * @param withChildren defines if children must be serialized as well
  75731. * @returns a JSON compatible object
  75732. */
  75733. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75734. }
  75735. }
  75736. declare module "babylonjs/Misc/textureTools" {
  75737. import { Texture } from "babylonjs/Materials/Textures/texture";
  75738. /**
  75739. * Class used to host texture specific utilities
  75740. */
  75741. export class TextureTools {
  75742. /**
  75743. * Uses the GPU to create a copy texture rescaled at a given size
  75744. * @param texture Texture to copy from
  75745. * @param width defines the desired width
  75746. * @param height defines the desired height
  75747. * @param useBilinearMode defines if bilinear mode has to be used
  75748. * @return the generated texture
  75749. */
  75750. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75751. }
  75752. }
  75753. declare module "babylonjs/Misc/videoRecorder" {
  75754. import { Nullable } from "babylonjs/types";
  75755. import { Engine } from "babylonjs/Engines/engine";
  75756. /**
  75757. * This represents the different options available for the video capture.
  75758. */
  75759. export interface VideoRecorderOptions {
  75760. /** Defines the mime type of the video. */
  75761. mimeType: string;
  75762. /** Defines the FPS the video should be recorded at. */
  75763. fps: number;
  75764. /** Defines the chunk size for the recording data. */
  75765. recordChunckSize: number;
  75766. /** The audio tracks to attach to the recording. */
  75767. audioTracks?: MediaStreamTrack[];
  75768. }
  75769. /**
  75770. * This can help with recording videos from BabylonJS.
  75771. * This is based on the available WebRTC functionalities of the browser.
  75772. *
  75773. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  75774. */
  75775. export class VideoRecorder {
  75776. private static readonly _defaultOptions;
  75777. /**
  75778. * Returns whether or not the VideoRecorder is available in your browser.
  75779. * @param engine Defines the Babylon Engine.
  75780. * @returns true if supported otherwise false.
  75781. */
  75782. static IsSupported(engine: Engine): boolean;
  75783. private readonly _options;
  75784. private _canvas;
  75785. private _mediaRecorder;
  75786. private _recordedChunks;
  75787. private _fileName;
  75788. private _resolve;
  75789. private _reject;
  75790. /**
  75791. * True when a recording is already in progress.
  75792. */
  75793. get isRecording(): boolean;
  75794. /**
  75795. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75796. * @param engine Defines the BabylonJS Engine you wish to record.
  75797. * @param options Defines options that can be used to customize the capture.
  75798. */
  75799. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75800. /**
  75801. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75802. */
  75803. stopRecording(): void;
  75804. /**
  75805. * Starts recording the canvas for a max duration specified in parameters.
  75806. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75807. * If null no automatic download will start and you can rely on the promise to get the data back.
  75808. * @param maxDuration Defines the maximum recording time in seconds.
  75809. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75810. * @return A promise callback at the end of the recording with the video data in Blob.
  75811. */
  75812. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75813. /**
  75814. * Releases internal resources used during the recording.
  75815. */
  75816. dispose(): void;
  75817. private _handleDataAvailable;
  75818. private _handleError;
  75819. private _handleStop;
  75820. }
  75821. }
  75822. declare module "babylonjs/Misc/screenshotTools" {
  75823. import { Camera } from "babylonjs/Cameras/camera";
  75824. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  75825. import { Engine } from "babylonjs/Engines/engine";
  75826. /**
  75827. * Class containing a set of static utilities functions for screenshots
  75828. */
  75829. export class ScreenshotTools {
  75830. /**
  75831. * Captures a screenshot of the current rendering
  75832. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75833. * @param engine defines the rendering engine
  75834. * @param camera defines the source camera
  75835. * @param size This parameter can be set to a single number or to an object with the
  75836. * following (optional) properties: precision, width, height. If a single number is passed,
  75837. * it will be used for both width and height. If an object is passed, the screenshot size
  75838. * will be derived from the parameters. The precision property is a multiplier allowing
  75839. * rendering at a higher or lower resolution
  75840. * @param successCallback defines the callback receives a single parameter which contains the
  75841. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75842. * src parameter of an <img> to display it
  75843. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75844. * Check your browser for supported MIME types
  75845. */
  75846. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75847. /**
  75848. * Captures a screenshot of the current rendering
  75849. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75850. * @param engine defines the rendering engine
  75851. * @param camera defines the source camera
  75852. * @param size This parameter can be set to a single number or to an object with the
  75853. * following (optional) properties: precision, width, height. If a single number is passed,
  75854. * it will be used for both width and height. If an object is passed, the screenshot size
  75855. * will be derived from the parameters. The precision property is a multiplier allowing
  75856. * rendering at a higher or lower resolution
  75857. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75858. * Check your browser for supported MIME types
  75859. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75860. * to the src parameter of an <img> to display it
  75861. */
  75862. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75863. /**
  75864. * Generates an image screenshot from the specified camera.
  75865. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75866. * @param engine The engine to use for rendering
  75867. * @param camera The camera to use for rendering
  75868. * @param size This parameter can be set to a single number or to an object with the
  75869. * following (optional) properties: precision, width, height. If a single number is passed,
  75870. * it will be used for both width and height. If an object is passed, the screenshot size
  75871. * will be derived from the parameters. The precision property is a multiplier allowing
  75872. * rendering at a higher or lower resolution
  75873. * @param successCallback The callback receives a single parameter which contains the
  75874. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75875. * src parameter of an <img> to display it
  75876. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75877. * Check your browser for supported MIME types
  75878. * @param samples Texture samples (default: 1)
  75879. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75880. * @param fileName A name for for the downloaded file.
  75881. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75882. */
  75883. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  75884. /**
  75885. * Generates an image screenshot from the specified camera.
  75886. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75887. * @param engine The engine to use for rendering
  75888. * @param camera The camera to use for rendering
  75889. * @param size This parameter can be set to a single number or to an object with the
  75890. * following (optional) properties: precision, width, height. If a single number is passed,
  75891. * it will be used for both width and height. If an object is passed, the screenshot size
  75892. * will be derived from the parameters. The precision property is a multiplier allowing
  75893. * rendering at a higher or lower resolution
  75894. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75895. * Check your browser for supported MIME types
  75896. * @param samples Texture samples (default: 1)
  75897. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75898. * @param fileName A name for for the downloaded file.
  75899. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75900. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75901. * to the src parameter of an <img> to display it
  75902. */
  75903. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75904. /**
  75905. * Gets height and width for screenshot size
  75906. * @private
  75907. */
  75908. private static _getScreenshotSize;
  75909. }
  75910. }
  75911. declare module "babylonjs/Misc/dataReader" {
  75912. /**
  75913. * Interface for a data buffer
  75914. */
  75915. export interface IDataBuffer {
  75916. /**
  75917. * Reads bytes from the data buffer.
  75918. * @param byteOffset The byte offset to read
  75919. * @param byteLength The byte length to read
  75920. * @returns A promise that resolves when the bytes are read
  75921. */
  75922. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75923. /**
  75924. * The byte length of the buffer.
  75925. */
  75926. readonly byteLength: number;
  75927. }
  75928. /**
  75929. * Utility class for reading from a data buffer
  75930. */
  75931. export class DataReader {
  75932. /**
  75933. * The data buffer associated with this data reader.
  75934. */
  75935. readonly buffer: IDataBuffer;
  75936. /**
  75937. * The current byte offset from the beginning of the data buffer.
  75938. */
  75939. byteOffset: number;
  75940. private _dataView;
  75941. private _dataByteOffset;
  75942. /**
  75943. * Constructor
  75944. * @param buffer The buffer to read
  75945. */
  75946. constructor(buffer: IDataBuffer);
  75947. /**
  75948. * Loads the given byte length.
  75949. * @param byteLength The byte length to load
  75950. * @returns A promise that resolves when the load is complete
  75951. */
  75952. loadAsync(byteLength: number): Promise<void>;
  75953. /**
  75954. * Read a unsigned 32-bit integer from the currently loaded data range.
  75955. * @returns The 32-bit integer read
  75956. */
  75957. readUint32(): number;
  75958. /**
  75959. * Read a byte array from the currently loaded data range.
  75960. * @param byteLength The byte length to read
  75961. * @returns The byte array read
  75962. */
  75963. readUint8Array(byteLength: number): Uint8Array;
  75964. /**
  75965. * Read a string from the currently loaded data range.
  75966. * @param byteLength The byte length to read
  75967. * @returns The string read
  75968. */
  75969. readString(byteLength: number): string;
  75970. /**
  75971. * Skips the given byte length the currently loaded data range.
  75972. * @param byteLength The byte length to skip
  75973. */
  75974. skipBytes(byteLength: number): void;
  75975. }
  75976. }
  75977. declare module "babylonjs/Misc/dataStorage" {
  75978. /**
  75979. * Class for storing data to local storage if available or in-memory storage otherwise
  75980. */
  75981. export class DataStorage {
  75982. private static _Storage;
  75983. private static _GetStorage;
  75984. /**
  75985. * Reads a string from the data storage
  75986. * @param key The key to read
  75987. * @param defaultValue The value if the key doesn't exist
  75988. * @returns The string value
  75989. */
  75990. static ReadString(key: string, defaultValue: string): string;
  75991. /**
  75992. * Writes a string to the data storage
  75993. * @param key The key to write
  75994. * @param value The value to write
  75995. */
  75996. static WriteString(key: string, value: string): void;
  75997. /**
  75998. * Reads a boolean from the data storage
  75999. * @param key The key to read
  76000. * @param defaultValue The value if the key doesn't exist
  76001. * @returns The boolean value
  76002. */
  76003. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  76004. /**
  76005. * Writes a boolean to the data storage
  76006. * @param key The key to write
  76007. * @param value The value to write
  76008. */
  76009. static WriteBoolean(key: string, value: boolean): void;
  76010. /**
  76011. * Reads a number from the data storage
  76012. * @param key The key to read
  76013. * @param defaultValue The value if the key doesn't exist
  76014. * @returns The number value
  76015. */
  76016. static ReadNumber(key: string, defaultValue: number): number;
  76017. /**
  76018. * Writes a number to the data storage
  76019. * @param key The key to write
  76020. * @param value The value to write
  76021. */
  76022. static WriteNumber(key: string, value: number): void;
  76023. }
  76024. }
  76025. declare module "babylonjs/Misc/index" {
  76026. export * from "babylonjs/Misc/andOrNotEvaluator";
  76027. export * from "babylonjs/Misc/assetsManager";
  76028. export * from "babylonjs/Misc/basis";
  76029. export * from "babylonjs/Misc/dds";
  76030. export * from "babylonjs/Misc/decorators";
  76031. export * from "babylonjs/Misc/deferred";
  76032. export * from "babylonjs/Misc/environmentTextureTools";
  76033. export * from "babylonjs/Misc/meshExploder";
  76034. export * from "babylonjs/Misc/filesInput";
  76035. export * from "babylonjs/Misc/HighDynamicRange/index";
  76036. export * from "babylonjs/Misc/khronosTextureContainer";
  76037. export * from "babylonjs/Misc/observable";
  76038. export * from "babylonjs/Misc/performanceMonitor";
  76039. export * from "babylonjs/Misc/promise";
  76040. export * from "babylonjs/Misc/sceneOptimizer";
  76041. export * from "babylonjs/Misc/sceneSerializer";
  76042. export * from "babylonjs/Misc/smartArray";
  76043. export * from "babylonjs/Misc/stringDictionary";
  76044. export * from "babylonjs/Misc/tags";
  76045. export * from "babylonjs/Misc/textureTools";
  76046. export * from "babylonjs/Misc/tga";
  76047. export * from "babylonjs/Misc/tools";
  76048. export * from "babylonjs/Misc/videoRecorder";
  76049. export * from "babylonjs/Misc/virtualJoystick";
  76050. export * from "babylonjs/Misc/workerPool";
  76051. export * from "babylonjs/Misc/logger";
  76052. export * from "babylonjs/Misc/typeStore";
  76053. export * from "babylonjs/Misc/filesInputStore";
  76054. export * from "babylonjs/Misc/deepCopier";
  76055. export * from "babylonjs/Misc/pivotTools";
  76056. export * from "babylonjs/Misc/precisionDate";
  76057. export * from "babylonjs/Misc/screenshotTools";
  76058. export * from "babylonjs/Misc/typeStore";
  76059. export * from "babylonjs/Misc/webRequest";
  76060. export * from "babylonjs/Misc/iInspectable";
  76061. export * from "babylonjs/Misc/brdfTextureTools";
  76062. export * from "babylonjs/Misc/rgbdTextureTools";
  76063. export * from "babylonjs/Misc/gradients";
  76064. export * from "babylonjs/Misc/perfCounter";
  76065. export * from "babylonjs/Misc/fileRequest";
  76066. export * from "babylonjs/Misc/customAnimationFrameRequester";
  76067. export * from "babylonjs/Misc/retryStrategy";
  76068. export * from "babylonjs/Misc/interfaces/screenshotSize";
  76069. export * from "babylonjs/Misc/canvasGenerator";
  76070. export * from "babylonjs/Misc/fileTools";
  76071. export * from "babylonjs/Misc/stringTools";
  76072. export * from "babylonjs/Misc/dataReader";
  76073. export * from "babylonjs/Misc/minMaxReducer";
  76074. export * from "babylonjs/Misc/depthReducer";
  76075. export * from "babylonjs/Misc/dataStorage";
  76076. }
  76077. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  76078. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  76079. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76080. import { Observable } from "babylonjs/Misc/observable";
  76081. import { Matrix } from "babylonjs/Maths/math.vector";
  76082. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76083. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76084. /**
  76085. * An interface for all Hit test features
  76086. */
  76087. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76088. /**
  76089. * Triggered when new babylon (transformed) hit test results are available
  76090. */
  76091. onHitTestResultObservable: Observable<T[]>;
  76092. }
  76093. /**
  76094. * Options used for hit testing
  76095. */
  76096. export interface IWebXRLegacyHitTestOptions {
  76097. /**
  76098. * Only test when user interacted with the scene. Default - hit test every frame
  76099. */
  76100. testOnPointerDownOnly?: boolean;
  76101. /**
  76102. * The node to use to transform the local results to world coordinates
  76103. */
  76104. worldParentNode?: TransformNode;
  76105. }
  76106. /**
  76107. * Interface defining the babylon result of raycasting/hit-test
  76108. */
  76109. export interface IWebXRLegacyHitResult {
  76110. /**
  76111. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76112. */
  76113. transformationMatrix: Matrix;
  76114. /**
  76115. * The native hit test result
  76116. */
  76117. xrHitResult: XRHitResult | XRHitTestResult;
  76118. }
  76119. /**
  76120. * The currently-working hit-test module.
  76121. * Hit test (or Ray-casting) is used to interact with the real world.
  76122. * For further information read here - https://github.com/immersive-web/hit-test
  76123. */
  76124. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76125. /**
  76126. * options to use when constructing this feature
  76127. */
  76128. readonly options: IWebXRLegacyHitTestOptions;
  76129. private _direction;
  76130. private _mat;
  76131. private _onSelectEnabled;
  76132. private _origin;
  76133. /**
  76134. * The module's name
  76135. */
  76136. static readonly Name: string;
  76137. /**
  76138. * The (Babylon) version of this module.
  76139. * This is an integer representing the implementation version.
  76140. * This number does not correspond to the WebXR specs version
  76141. */
  76142. static readonly Version: number;
  76143. /**
  76144. * Populated with the last native XR Hit Results
  76145. */
  76146. lastNativeXRHitResults: XRHitResult[];
  76147. /**
  76148. * Triggered when new babylon (transformed) hit test results are available
  76149. */
  76150. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76151. /**
  76152. * Creates a new instance of the (legacy version) hit test feature
  76153. * @param _xrSessionManager an instance of WebXRSessionManager
  76154. * @param options options to use when constructing this feature
  76155. */
  76156. constructor(_xrSessionManager: WebXRSessionManager,
  76157. /**
  76158. * options to use when constructing this feature
  76159. */
  76160. options?: IWebXRLegacyHitTestOptions);
  76161. /**
  76162. * execute a hit test with an XR Ray
  76163. *
  76164. * @param xrSession a native xrSession that will execute this hit test
  76165. * @param xrRay the ray (position and direction) to use for ray-casting
  76166. * @param referenceSpace native XR reference space to use for the hit-test
  76167. * @param filter filter function that will filter the results
  76168. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76169. */
  76170. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76171. /**
  76172. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76173. * @param event the (select) event to use to select with
  76174. * @param referenceSpace the reference space to use for this hit test
  76175. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76176. */
  76177. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76178. /**
  76179. * attach this feature
  76180. * Will usually be called by the features manager
  76181. *
  76182. * @returns true if successful.
  76183. */
  76184. attach(): boolean;
  76185. /**
  76186. * detach this feature.
  76187. * Will usually be called by the features manager
  76188. *
  76189. * @returns true if successful.
  76190. */
  76191. detach(): boolean;
  76192. /**
  76193. * Dispose this feature and all of the resources attached
  76194. */
  76195. dispose(): void;
  76196. protected _onXRFrame(frame: XRFrame): void;
  76197. private _onHitTestResults;
  76198. private _onSelect;
  76199. }
  76200. }
  76201. declare module "babylonjs/XR/features/WebXRHitTest" {
  76202. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76203. import { Observable } from "babylonjs/Misc/observable";
  76204. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76205. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76206. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76207. /**
  76208. * Options used for hit testing (version 2)
  76209. */
  76210. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76211. /**
  76212. * Do not create a permanent hit test. Will usually be used when only
  76213. * transient inputs are needed.
  76214. */
  76215. disablePermanentHitTest?: boolean;
  76216. /**
  76217. * Enable transient (for example touch-based) hit test inspections
  76218. */
  76219. enableTransientHitTest?: boolean;
  76220. /**
  76221. * Offset ray for the permanent hit test
  76222. */
  76223. offsetRay?: Vector3;
  76224. /**
  76225. * Offset ray for the transient hit test
  76226. */
  76227. transientOffsetRay?: Vector3;
  76228. /**
  76229. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76230. */
  76231. useReferenceSpace?: boolean;
  76232. }
  76233. /**
  76234. * Interface defining the babylon result of hit-test
  76235. */
  76236. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76237. /**
  76238. * The input source that generated this hit test (if transient)
  76239. */
  76240. inputSource?: XRInputSource;
  76241. /**
  76242. * Is this a transient hit test
  76243. */
  76244. isTransient?: boolean;
  76245. /**
  76246. * Position of the hit test result
  76247. */
  76248. position: Vector3;
  76249. /**
  76250. * Rotation of the hit test result
  76251. */
  76252. rotationQuaternion: Quaternion;
  76253. /**
  76254. * The native hit test result
  76255. */
  76256. xrHitResult: XRHitTestResult;
  76257. }
  76258. /**
  76259. * The currently-working hit-test module.
  76260. * Hit test (or Ray-casting) is used to interact with the real world.
  76261. * For further information read here - https://github.com/immersive-web/hit-test
  76262. *
  76263. * Tested on chrome (mobile) 80.
  76264. */
  76265. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76266. /**
  76267. * options to use when constructing this feature
  76268. */
  76269. readonly options: IWebXRHitTestOptions;
  76270. private _tmpMat;
  76271. private _tmpPos;
  76272. private _tmpQuat;
  76273. private _transientXrHitTestSource;
  76274. private _xrHitTestSource;
  76275. private initHitTestSource;
  76276. /**
  76277. * The module's name
  76278. */
  76279. static readonly Name: string;
  76280. /**
  76281. * The (Babylon) version of this module.
  76282. * This is an integer representing the implementation version.
  76283. * This number does not correspond to the WebXR specs version
  76284. */
  76285. static readonly Version: number;
  76286. /**
  76287. * When set to true, each hit test will have its own position/rotation objects
  76288. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76289. * the developers will clone them or copy them as they see fit.
  76290. */
  76291. autoCloneTransformation: boolean;
  76292. /**
  76293. * Triggered when new babylon (transformed) hit test results are available
  76294. */
  76295. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76296. /**
  76297. * Use this to temporarily pause hit test checks.
  76298. */
  76299. paused: boolean;
  76300. /**
  76301. * Creates a new instance of the hit test feature
  76302. * @param _xrSessionManager an instance of WebXRSessionManager
  76303. * @param options options to use when constructing this feature
  76304. */
  76305. constructor(_xrSessionManager: WebXRSessionManager,
  76306. /**
  76307. * options to use when constructing this feature
  76308. */
  76309. options?: IWebXRHitTestOptions);
  76310. /**
  76311. * attach this feature
  76312. * Will usually be called by the features manager
  76313. *
  76314. * @returns true if successful.
  76315. */
  76316. attach(): boolean;
  76317. /**
  76318. * detach this feature.
  76319. * Will usually be called by the features manager
  76320. *
  76321. * @returns true if successful.
  76322. */
  76323. detach(): boolean;
  76324. /**
  76325. * Dispose this feature and all of the resources attached
  76326. */
  76327. dispose(): void;
  76328. protected _onXRFrame(frame: XRFrame): void;
  76329. private _processWebXRHitTestResult;
  76330. }
  76331. }
  76332. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  76333. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76334. import { Observable } from "babylonjs/Misc/observable";
  76335. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76336. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76337. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76338. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  76339. /**
  76340. * Configuration options of the anchor system
  76341. */
  76342. export interface IWebXRAnchorSystemOptions {
  76343. /**
  76344. * a node that will be used to convert local to world coordinates
  76345. */
  76346. worldParentNode?: TransformNode;
  76347. /**
  76348. * If set to true a reference of the created anchors will be kept until the next session starts
  76349. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76350. */
  76351. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76352. }
  76353. /**
  76354. * A babylon container for an XR Anchor
  76355. */
  76356. export interface IWebXRAnchor {
  76357. /**
  76358. * A babylon-assigned ID for this anchor
  76359. */
  76360. id: number;
  76361. /**
  76362. * Transformation matrix to apply to an object attached to this anchor
  76363. */
  76364. transformationMatrix: Matrix;
  76365. /**
  76366. * The native anchor object
  76367. */
  76368. xrAnchor: XRAnchor;
  76369. /**
  76370. * if defined, this object will be constantly updated by the anchor's position and rotation
  76371. */
  76372. attachedNode?: TransformNode;
  76373. }
  76374. /**
  76375. * An implementation of the anchor system for WebXR.
  76376. * For further information see https://github.com/immersive-web/anchors/
  76377. */
  76378. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76379. private _options;
  76380. private _lastFrameDetected;
  76381. private _trackedAnchors;
  76382. private _referenceSpaceForFrameAnchors;
  76383. private _futureAnchors;
  76384. /**
  76385. * The module's name
  76386. */
  76387. static readonly Name: string;
  76388. /**
  76389. * The (Babylon) version of this module.
  76390. * This is an integer representing the implementation version.
  76391. * This number does not correspond to the WebXR specs version
  76392. */
  76393. static readonly Version: number;
  76394. /**
  76395. * Observers registered here will be executed when a new anchor was added to the session
  76396. */
  76397. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76398. /**
  76399. * Observers registered here will be executed when an anchor was removed from the session
  76400. */
  76401. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76402. /**
  76403. * Observers registered here will be executed when an existing anchor updates
  76404. * This can execute N times every frame
  76405. */
  76406. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76407. /**
  76408. * Set the reference space to use for anchor creation, when not using a hit test.
  76409. * Will default to the session's reference space if not defined
  76410. */
  76411. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76412. /**
  76413. * constructs a new anchor system
  76414. * @param _xrSessionManager an instance of WebXRSessionManager
  76415. * @param _options configuration object for this feature
  76416. */
  76417. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76418. private _tmpVector;
  76419. private _tmpQuaternion;
  76420. private _populateTmpTransformation;
  76421. /**
  76422. * Create a new anchor point using a hit test result at a specific point in the scene
  76423. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76424. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76425. *
  76426. * @param hitTestResult The hit test result to use for this anchor creation
  76427. * @param position an optional position offset for this anchor
  76428. * @param rotationQuaternion an optional rotation offset for this anchor
  76429. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76430. */
  76431. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  76432. /**
  76433. * Add a new anchor at a specific position and rotation
  76434. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76435. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76436. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76437. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76438. *
  76439. * @param position the position in which to add an anchor
  76440. * @param rotationQuaternion an optional rotation for the anchor transformation
  76441. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76442. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76443. */
  76444. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  76445. /**
  76446. * detach this feature.
  76447. * Will usually be called by the features manager
  76448. *
  76449. * @returns true if successful.
  76450. */
  76451. detach(): boolean;
  76452. /**
  76453. * Dispose this feature and all of the resources attached
  76454. */
  76455. dispose(): void;
  76456. protected _onXRFrame(frame: XRFrame): void;
  76457. /**
  76458. * avoiding using Array.find for global support.
  76459. * @param xrAnchor the plane to find in the array
  76460. */
  76461. private _findIndexInAnchorArray;
  76462. private _updateAnchorWithXRFrame;
  76463. private _createAnchorAtTransformation;
  76464. }
  76465. }
  76466. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  76467. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76468. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76469. import { Observable } from "babylonjs/Misc/observable";
  76470. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  76471. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76472. /**
  76473. * Options used in the plane detector module
  76474. */
  76475. export interface IWebXRPlaneDetectorOptions {
  76476. /**
  76477. * The node to use to transform the local results to world coordinates
  76478. */
  76479. worldParentNode?: TransformNode;
  76480. /**
  76481. * If set to true a reference of the created planes will be kept until the next session starts
  76482. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76483. */
  76484. doNotRemovePlanesOnSessionEnded?: boolean;
  76485. }
  76486. /**
  76487. * A babylon interface for a WebXR plane.
  76488. * A Plane is actually a polygon, built from N points in space
  76489. *
  76490. * Supported in chrome 79, not supported in canary 81 ATM
  76491. */
  76492. export interface IWebXRPlane {
  76493. /**
  76494. * a babylon-assigned ID for this polygon
  76495. */
  76496. id: number;
  76497. /**
  76498. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76499. */
  76500. polygonDefinition: Array<Vector3>;
  76501. /**
  76502. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76503. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76504. */
  76505. transformationMatrix: Matrix;
  76506. /**
  76507. * the native xr-plane object
  76508. */
  76509. xrPlane: XRPlane;
  76510. }
  76511. /**
  76512. * The plane detector is used to detect planes in the real world when in AR
  76513. * For more information see https://github.com/immersive-web/real-world-geometry/
  76514. */
  76515. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76516. private _options;
  76517. private _detectedPlanes;
  76518. private _enabled;
  76519. private _lastFrameDetected;
  76520. /**
  76521. * The module's name
  76522. */
  76523. static readonly Name: string;
  76524. /**
  76525. * The (Babylon) version of this module.
  76526. * This is an integer representing the implementation version.
  76527. * This number does not correspond to the WebXR specs version
  76528. */
  76529. static readonly Version: number;
  76530. /**
  76531. * Observers registered here will be executed when a new plane was added to the session
  76532. */
  76533. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76534. /**
  76535. * Observers registered here will be executed when a plane is no longer detected in the session
  76536. */
  76537. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76538. /**
  76539. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76540. * This can execute N times every frame
  76541. */
  76542. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76543. /**
  76544. * construct a new Plane Detector
  76545. * @param _xrSessionManager an instance of xr Session manager
  76546. * @param _options configuration to use when constructing this feature
  76547. */
  76548. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76549. /**
  76550. * detach this feature.
  76551. * Will usually be called by the features manager
  76552. *
  76553. * @returns true if successful.
  76554. */
  76555. detach(): boolean;
  76556. /**
  76557. * Dispose this feature and all of the resources attached
  76558. */
  76559. dispose(): void;
  76560. protected _onXRFrame(frame: XRFrame): void;
  76561. private _init;
  76562. private _updatePlaneWithXRPlane;
  76563. /**
  76564. * avoiding using Array.find for global support.
  76565. * @param xrPlane the plane to find in the array
  76566. */
  76567. private findIndexInPlaneArray;
  76568. }
  76569. }
  76570. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  76571. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76573. import { Observable } from "babylonjs/Misc/observable";
  76574. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76575. /**
  76576. * Options interface for the background remover plugin
  76577. */
  76578. export interface IWebXRBackgroundRemoverOptions {
  76579. /**
  76580. * Further background meshes to disable when entering AR
  76581. */
  76582. backgroundMeshes?: AbstractMesh[];
  76583. /**
  76584. * flags to configure the removal of the environment helper.
  76585. * If not set, the entire background will be removed. If set, flags should be set as well.
  76586. */
  76587. environmentHelperRemovalFlags?: {
  76588. /**
  76589. * Should the skybox be removed (default false)
  76590. */
  76591. skyBox?: boolean;
  76592. /**
  76593. * Should the ground be removed (default false)
  76594. */
  76595. ground?: boolean;
  76596. };
  76597. /**
  76598. * don't disable the environment helper
  76599. */
  76600. ignoreEnvironmentHelper?: boolean;
  76601. }
  76602. /**
  76603. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76604. */
  76605. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76606. /**
  76607. * read-only options to be used in this module
  76608. */
  76609. readonly options: IWebXRBackgroundRemoverOptions;
  76610. /**
  76611. * The module's name
  76612. */
  76613. static readonly Name: string;
  76614. /**
  76615. * The (Babylon) version of this module.
  76616. * This is an integer representing the implementation version.
  76617. * This number does not correspond to the WebXR specs version
  76618. */
  76619. static readonly Version: number;
  76620. /**
  76621. * registered observers will be triggered when the background state changes
  76622. */
  76623. onBackgroundStateChangedObservable: Observable<boolean>;
  76624. /**
  76625. * constructs a new background remover module
  76626. * @param _xrSessionManager the session manager for this module
  76627. * @param options read-only options to be used in this module
  76628. */
  76629. constructor(_xrSessionManager: WebXRSessionManager,
  76630. /**
  76631. * read-only options to be used in this module
  76632. */
  76633. options?: IWebXRBackgroundRemoverOptions);
  76634. /**
  76635. * attach this feature
  76636. * Will usually be called by the features manager
  76637. *
  76638. * @returns true if successful.
  76639. */
  76640. attach(): boolean;
  76641. /**
  76642. * detach this feature.
  76643. * Will usually be called by the features manager
  76644. *
  76645. * @returns true if successful.
  76646. */
  76647. detach(): boolean;
  76648. /**
  76649. * Dispose this feature and all of the resources attached
  76650. */
  76651. dispose(): void;
  76652. protected _onXRFrame(_xrFrame: XRFrame): void;
  76653. private _setBackgroundState;
  76654. }
  76655. }
  76656. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  76657. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76658. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  76659. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76660. import { WebXRInput } from "babylonjs/XR/webXRInput";
  76661. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76662. import { Nullable } from "babylonjs/types";
  76663. /**
  76664. * Options for the controller physics feature
  76665. */
  76666. export class IWebXRControllerPhysicsOptions {
  76667. /**
  76668. * Should the headset get its own impostor
  76669. */
  76670. enableHeadsetImpostor?: boolean;
  76671. /**
  76672. * Optional parameters for the headset impostor
  76673. */
  76674. headsetImpostorParams?: {
  76675. /**
  76676. * The type of impostor to create. Default is sphere
  76677. */
  76678. impostorType: number;
  76679. /**
  76680. * the size of the impostor. Defaults to 10cm
  76681. */
  76682. impostorSize?: number | {
  76683. width: number;
  76684. height: number;
  76685. depth: number;
  76686. };
  76687. /**
  76688. * Friction definitions
  76689. */
  76690. friction?: number;
  76691. /**
  76692. * Restitution
  76693. */
  76694. restitution?: number;
  76695. };
  76696. /**
  76697. * The physics properties of the future impostors
  76698. */
  76699. physicsProperties?: {
  76700. /**
  76701. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76702. * Note that this requires a physics engine that supports mesh impostors!
  76703. */
  76704. useControllerMesh?: boolean;
  76705. /**
  76706. * The type of impostor to create. Default is sphere
  76707. */
  76708. impostorType?: number;
  76709. /**
  76710. * the size of the impostor. Defaults to 10cm
  76711. */
  76712. impostorSize?: number | {
  76713. width: number;
  76714. height: number;
  76715. depth: number;
  76716. };
  76717. /**
  76718. * Friction definitions
  76719. */
  76720. friction?: number;
  76721. /**
  76722. * Restitution
  76723. */
  76724. restitution?: number;
  76725. };
  76726. /**
  76727. * the xr input to use with this pointer selection
  76728. */
  76729. xrInput: WebXRInput;
  76730. }
  76731. /**
  76732. * Add physics impostor to your webxr controllers,
  76733. * including naive calculation of their linear and angular velocity
  76734. */
  76735. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76736. private readonly _options;
  76737. private _attachController;
  76738. private _controllers;
  76739. private _debugMode;
  76740. private _delta;
  76741. private _headsetImpostor?;
  76742. private _headsetMesh?;
  76743. private _lastTimestamp;
  76744. private _tmpQuaternion;
  76745. private _tmpVector;
  76746. /**
  76747. * The module's name
  76748. */
  76749. static readonly Name: string;
  76750. /**
  76751. * The (Babylon) version of this module.
  76752. * This is an integer representing the implementation version.
  76753. * This number does not correspond to the webxr specs version
  76754. */
  76755. static readonly Version: number;
  76756. /**
  76757. * Construct a new Controller Physics Feature
  76758. * @param _xrSessionManager the corresponding xr session manager
  76759. * @param _options options to create this feature with
  76760. */
  76761. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76762. /**
  76763. * @hidden
  76764. * enable debugging - will show console outputs and the impostor mesh
  76765. */
  76766. _enablePhysicsDebug(): void;
  76767. /**
  76768. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76769. * @param xrController the controller to add
  76770. */
  76771. addController(xrController: WebXRInputSource): void;
  76772. /**
  76773. * attach this feature
  76774. * Will usually be called by the features manager
  76775. *
  76776. * @returns true if successful.
  76777. */
  76778. attach(): boolean;
  76779. /**
  76780. * detach this feature.
  76781. * Will usually be called by the features manager
  76782. *
  76783. * @returns true if successful.
  76784. */
  76785. detach(): boolean;
  76786. /**
  76787. * Get the headset impostor, if enabled
  76788. * @returns the impostor
  76789. */
  76790. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76791. /**
  76792. * Get the physics impostor of a specific controller.
  76793. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76794. * @param controller the controller or the controller id of which to get the impostor
  76795. * @returns the impostor or null
  76796. */
  76797. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76798. /**
  76799. * Update the physics properties provided in the constructor
  76800. * @param newProperties the new properties object
  76801. */
  76802. setPhysicsProperties(newProperties: {
  76803. impostorType?: number;
  76804. impostorSize?: number | {
  76805. width: number;
  76806. height: number;
  76807. depth: number;
  76808. };
  76809. friction?: number;
  76810. restitution?: number;
  76811. }): void;
  76812. protected _onXRFrame(_xrFrame: any): void;
  76813. private _detachController;
  76814. }
  76815. }
  76816. declare module "babylonjs/XR/features/index" {
  76817. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  76818. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  76819. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  76820. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  76821. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  76822. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  76823. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  76824. export * from "babylonjs/XR/features/WebXRHitTest";
  76825. }
  76826. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  76827. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76829. import { Scene } from "babylonjs/scene";
  76830. /**
  76831. * The motion controller class for all microsoft mixed reality controllers
  76832. */
  76833. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76834. protected readonly _mapping: {
  76835. defaultButton: {
  76836. valueNodeName: string;
  76837. unpressedNodeName: string;
  76838. pressedNodeName: string;
  76839. };
  76840. defaultAxis: {
  76841. valueNodeName: string;
  76842. minNodeName: string;
  76843. maxNodeName: string;
  76844. };
  76845. buttons: {
  76846. "xr-standard-trigger": {
  76847. rootNodeName: string;
  76848. componentProperty: string;
  76849. states: string[];
  76850. };
  76851. "xr-standard-squeeze": {
  76852. rootNodeName: string;
  76853. componentProperty: string;
  76854. states: string[];
  76855. };
  76856. "xr-standard-touchpad": {
  76857. rootNodeName: string;
  76858. labelAnchorNodeName: string;
  76859. touchPointNodeName: string;
  76860. };
  76861. "xr-standard-thumbstick": {
  76862. rootNodeName: string;
  76863. componentProperty: string;
  76864. states: string[];
  76865. };
  76866. };
  76867. axes: {
  76868. "xr-standard-touchpad": {
  76869. "x-axis": {
  76870. rootNodeName: string;
  76871. };
  76872. "y-axis": {
  76873. rootNodeName: string;
  76874. };
  76875. };
  76876. "xr-standard-thumbstick": {
  76877. "x-axis": {
  76878. rootNodeName: string;
  76879. };
  76880. "y-axis": {
  76881. rootNodeName: string;
  76882. };
  76883. };
  76884. };
  76885. };
  76886. /**
  76887. * The base url used to load the left and right controller models
  76888. */
  76889. static MODEL_BASE_URL: string;
  76890. /**
  76891. * The name of the left controller model file
  76892. */
  76893. static MODEL_LEFT_FILENAME: string;
  76894. /**
  76895. * The name of the right controller model file
  76896. */
  76897. static MODEL_RIGHT_FILENAME: string;
  76898. profileId: string;
  76899. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76900. protected _getFilenameAndPath(): {
  76901. filename: string;
  76902. path: string;
  76903. };
  76904. protected _getModelLoadingConstraints(): boolean;
  76905. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76906. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76907. protected _updateModel(): void;
  76908. }
  76909. }
  76910. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  76911. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76913. import { Scene } from "babylonjs/scene";
  76914. /**
  76915. * The motion controller class for oculus touch (quest, rift).
  76916. * This class supports legacy mapping as well the standard xr mapping
  76917. */
  76918. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76919. private _forceLegacyControllers;
  76920. private _modelRootNode;
  76921. /**
  76922. * The base url used to load the left and right controller models
  76923. */
  76924. static MODEL_BASE_URL: string;
  76925. /**
  76926. * The name of the left controller model file
  76927. */
  76928. static MODEL_LEFT_FILENAME: string;
  76929. /**
  76930. * The name of the right controller model file
  76931. */
  76932. static MODEL_RIGHT_FILENAME: string;
  76933. /**
  76934. * Base Url for the Quest controller model.
  76935. */
  76936. static QUEST_MODEL_BASE_URL: string;
  76937. profileId: string;
  76938. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76939. protected _getFilenameAndPath(): {
  76940. filename: string;
  76941. path: string;
  76942. };
  76943. protected _getModelLoadingConstraints(): boolean;
  76944. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76945. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76946. protected _updateModel(): void;
  76947. /**
  76948. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76949. * between the touch and touch 2.
  76950. */
  76951. private _isQuest;
  76952. }
  76953. }
  76954. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  76955. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76956. import { Scene } from "babylonjs/scene";
  76957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76958. /**
  76959. * The motion controller class for the standard HTC-Vive controllers
  76960. */
  76961. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76962. private _modelRootNode;
  76963. /**
  76964. * The base url used to load the left and right controller models
  76965. */
  76966. static MODEL_BASE_URL: string;
  76967. /**
  76968. * File name for the controller model.
  76969. */
  76970. static MODEL_FILENAME: string;
  76971. profileId: string;
  76972. /**
  76973. * Create a new Vive motion controller object
  76974. * @param scene the scene to use to create this controller
  76975. * @param gamepadObject the corresponding gamepad object
  76976. * @param handedness the handedness of the controller
  76977. */
  76978. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76979. protected _getFilenameAndPath(): {
  76980. filename: string;
  76981. path: string;
  76982. };
  76983. protected _getModelLoadingConstraints(): boolean;
  76984. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76985. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76986. protected _updateModel(): void;
  76987. }
  76988. }
  76989. declare module "babylonjs/XR/motionController/index" {
  76990. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76991. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  76992. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  76993. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  76994. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  76995. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  76996. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  76997. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  76998. }
  76999. declare module "babylonjs/XR/index" {
  77000. export * from "babylonjs/XR/webXRCamera";
  77001. export * from "babylonjs/XR/webXREnterExitUI";
  77002. export * from "babylonjs/XR/webXRExperienceHelper";
  77003. export * from "babylonjs/XR/webXRInput";
  77004. export * from "babylonjs/XR/webXRInputSource";
  77005. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  77006. export * from "babylonjs/XR/webXRTypes";
  77007. export * from "babylonjs/XR/webXRSessionManager";
  77008. export * from "babylonjs/XR/webXRDefaultExperience";
  77009. export * from "babylonjs/XR/webXRFeaturesManager";
  77010. export * from "babylonjs/XR/features/index";
  77011. export * from "babylonjs/XR/motionController/index";
  77012. }
  77013. declare module "babylonjs/index" {
  77014. export * from "babylonjs/abstractScene";
  77015. export * from "babylonjs/Actions/index";
  77016. export * from "babylonjs/Animations/index";
  77017. export * from "babylonjs/assetContainer";
  77018. export * from "babylonjs/Audio/index";
  77019. export * from "babylonjs/Behaviors/index";
  77020. export * from "babylonjs/Bones/index";
  77021. export * from "babylonjs/Cameras/index";
  77022. export * from "babylonjs/Collisions/index";
  77023. export * from "babylonjs/Culling/index";
  77024. export * from "babylonjs/Debug/index";
  77025. export * from "babylonjs/DeviceInput/index";
  77026. export * from "babylonjs/Engines/index";
  77027. export * from "babylonjs/Events/index";
  77028. export * from "babylonjs/Gamepads/index";
  77029. export * from "babylonjs/Gizmos/index";
  77030. export * from "babylonjs/Helpers/index";
  77031. export * from "babylonjs/Instrumentation/index";
  77032. export * from "babylonjs/Layers/index";
  77033. export * from "babylonjs/LensFlares/index";
  77034. export * from "babylonjs/Lights/index";
  77035. export * from "babylonjs/Loading/index";
  77036. export * from "babylonjs/Materials/index";
  77037. export * from "babylonjs/Maths/index";
  77038. export * from "babylonjs/Meshes/index";
  77039. export * from "babylonjs/Morph/index";
  77040. export * from "babylonjs/Navigation/index";
  77041. export * from "babylonjs/node";
  77042. export * from "babylonjs/Offline/index";
  77043. export * from "babylonjs/Particles/index";
  77044. export * from "babylonjs/Physics/index";
  77045. export * from "babylonjs/PostProcesses/index";
  77046. export * from "babylonjs/Probes/index";
  77047. export * from "babylonjs/Rendering/index";
  77048. export * from "babylonjs/scene";
  77049. export * from "babylonjs/sceneComponent";
  77050. export * from "babylonjs/Sprites/index";
  77051. export * from "babylonjs/States/index";
  77052. export * from "babylonjs/Misc/index";
  77053. export * from "babylonjs/XR/index";
  77054. export * from "babylonjs/types";
  77055. }
  77056. declare module "babylonjs/Animations/pathCursor" {
  77057. import { Vector3 } from "babylonjs/Maths/math.vector";
  77058. import { Path2 } from "babylonjs/Maths/math.path";
  77059. /**
  77060. * A cursor which tracks a point on a path
  77061. */
  77062. export class PathCursor {
  77063. private path;
  77064. /**
  77065. * Stores path cursor callbacks for when an onchange event is triggered
  77066. */
  77067. private _onchange;
  77068. /**
  77069. * The value of the path cursor
  77070. */
  77071. value: number;
  77072. /**
  77073. * The animation array of the path cursor
  77074. */
  77075. animations: Animation[];
  77076. /**
  77077. * Initializes the path cursor
  77078. * @param path The path to track
  77079. */
  77080. constructor(path: Path2);
  77081. /**
  77082. * Gets the cursor point on the path
  77083. * @returns A point on the path cursor at the cursor location
  77084. */
  77085. getPoint(): Vector3;
  77086. /**
  77087. * Moves the cursor ahead by the step amount
  77088. * @param step The amount to move the cursor forward
  77089. * @returns This path cursor
  77090. */
  77091. moveAhead(step?: number): PathCursor;
  77092. /**
  77093. * Moves the cursor behind by the step amount
  77094. * @param step The amount to move the cursor back
  77095. * @returns This path cursor
  77096. */
  77097. moveBack(step?: number): PathCursor;
  77098. /**
  77099. * Moves the cursor by the step amount
  77100. * If the step amount is greater than one, an exception is thrown
  77101. * @param step The amount to move the cursor
  77102. * @returns This path cursor
  77103. */
  77104. move(step: number): PathCursor;
  77105. /**
  77106. * Ensures that the value is limited between zero and one
  77107. * @returns This path cursor
  77108. */
  77109. private ensureLimits;
  77110. /**
  77111. * Runs onchange callbacks on change (used by the animation engine)
  77112. * @returns This path cursor
  77113. */
  77114. private raiseOnChange;
  77115. /**
  77116. * Executes a function on change
  77117. * @param f A path cursor onchange callback
  77118. * @returns This path cursor
  77119. */
  77120. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77121. }
  77122. }
  77123. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  77124. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  77125. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  77126. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  77127. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  77128. }
  77129. declare module "babylonjs/Engines/Processors/Expressions/index" {
  77130. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  77131. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  77132. }
  77133. declare module "babylonjs/Engines/Processors/index" {
  77134. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  77135. export * from "babylonjs/Engines/Processors/Expressions/index";
  77136. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  77137. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  77138. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  77139. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  77140. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  77141. export * from "babylonjs/Engines/Processors/shaderProcessor";
  77142. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  77143. }
  77144. declare module "babylonjs/Legacy/legacy" {
  77145. import * as Babylon from "babylonjs/index";
  77146. export * from "babylonjs/index";
  77147. }
  77148. declare module "babylonjs/Shaders/blur.fragment" {
  77149. /** @hidden */
  77150. export var blurPixelShader: {
  77151. name: string;
  77152. shader: string;
  77153. };
  77154. }
  77155. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  77156. /** @hidden */
  77157. export var pointCloudVertexDeclaration: {
  77158. name: string;
  77159. shader: string;
  77160. };
  77161. }
  77162. declare module "babylonjs" {
  77163. export * from "babylonjs/Legacy/legacy";
  77164. }
  77165. declare module BABYLON {
  77166. /** Alias type for value that can be null */
  77167. export type Nullable<T> = T | null;
  77168. /**
  77169. * Alias type for number that are floats
  77170. * @ignorenaming
  77171. */
  77172. export type float = number;
  77173. /**
  77174. * Alias type for number that are doubles.
  77175. * @ignorenaming
  77176. */
  77177. export type double = number;
  77178. /**
  77179. * Alias type for number that are integer
  77180. * @ignorenaming
  77181. */
  77182. export type int = number;
  77183. /** Alias type for number array or Float32Array */
  77184. export type FloatArray = number[] | Float32Array;
  77185. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  77186. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  77187. /**
  77188. * Alias for types that can be used by a Buffer or VertexBuffer.
  77189. */
  77190. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  77191. /**
  77192. * Alias type for primitive types
  77193. * @ignorenaming
  77194. */
  77195. type Primitive = undefined | null | boolean | string | number | Function;
  77196. /**
  77197. * Type modifier to make all the properties of an object Readonly
  77198. */
  77199. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  77200. /**
  77201. * Type modifier to make all the properties of an object Readonly recursively
  77202. */
  77203. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  77204. /**
  77205. * Type modifier to make object properties readonly.
  77206. */
  77207. export type DeepImmutableObject<T> = {
  77208. readonly [K in keyof T]: DeepImmutable<T[K]>;
  77209. };
  77210. /** @hidden */
  77211. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  77212. }
  77213. }
  77214. declare module BABYLON {
  77215. /**
  77216. * A class serves as a medium between the observable and its observers
  77217. */
  77218. export class EventState {
  77219. /**
  77220. * Create a new EventState
  77221. * @param mask defines the mask associated with this state
  77222. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77223. * @param target defines the original target of the state
  77224. * @param currentTarget defines the current target of the state
  77225. */
  77226. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  77227. /**
  77228. * Initialize the current event state
  77229. * @param mask defines the mask associated with this state
  77230. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77231. * @param target defines the original target of the state
  77232. * @param currentTarget defines the current target of the state
  77233. * @returns the current event state
  77234. */
  77235. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77236. /**
  77237. * An Observer can set this property to true to prevent subsequent observers of being notified
  77238. */
  77239. skipNextObservers: boolean;
  77240. /**
  77241. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77242. */
  77243. mask: number;
  77244. /**
  77245. * The object that originally notified the event
  77246. */
  77247. target?: any;
  77248. /**
  77249. * The current object in the bubbling phase
  77250. */
  77251. currentTarget?: any;
  77252. /**
  77253. * This will be populated with the return value of the last function that was executed.
  77254. * If it is the first function in the callback chain it will be the event data.
  77255. */
  77256. lastReturnValue?: any;
  77257. }
  77258. /**
  77259. * Represent an Observer registered to a given Observable object.
  77260. */
  77261. export class Observer<T> {
  77262. /**
  77263. * Defines the callback to call when the observer is notified
  77264. */
  77265. callback: (eventData: T, eventState: EventState) => void;
  77266. /**
  77267. * Defines the mask of the observer (used to filter notifications)
  77268. */
  77269. mask: number;
  77270. /**
  77271. * Defines the current scope used to restore the JS context
  77272. */
  77273. scope: any;
  77274. /** @hidden */
  77275. _willBeUnregistered: boolean;
  77276. /**
  77277. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77278. */
  77279. unregisterOnNextCall: boolean;
  77280. /**
  77281. * Creates a new observer
  77282. * @param callback defines the callback to call when the observer is notified
  77283. * @param mask defines the mask of the observer (used to filter notifications)
  77284. * @param scope defines the current scope used to restore the JS context
  77285. */
  77286. constructor(
  77287. /**
  77288. * Defines the callback to call when the observer is notified
  77289. */
  77290. callback: (eventData: T, eventState: EventState) => void,
  77291. /**
  77292. * Defines the mask of the observer (used to filter notifications)
  77293. */
  77294. mask: number,
  77295. /**
  77296. * Defines the current scope used to restore the JS context
  77297. */
  77298. scope?: any);
  77299. }
  77300. /**
  77301. * Represent a list of observers registered to multiple Observables object.
  77302. */
  77303. export class MultiObserver<T> {
  77304. private _observers;
  77305. private _observables;
  77306. /**
  77307. * Release associated resources
  77308. */
  77309. dispose(): void;
  77310. /**
  77311. * Raise a callback when one of the observable will notify
  77312. * @param observables defines a list of observables to watch
  77313. * @param callback defines the callback to call on notification
  77314. * @param mask defines the mask used to filter notifications
  77315. * @param scope defines the current scope used to restore the JS context
  77316. * @returns the new MultiObserver
  77317. */
  77318. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  77319. }
  77320. /**
  77321. * The Observable class is a simple implementation of the Observable pattern.
  77322. *
  77323. * 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.
  77324. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  77325. * 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).
  77326. * 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.
  77327. */
  77328. export class Observable<T> {
  77329. private _observers;
  77330. private _eventState;
  77331. private _onObserverAdded;
  77332. /**
  77333. * Gets the list of observers
  77334. */
  77335. get observers(): Array<Observer<T>>;
  77336. /**
  77337. * Creates a new observable
  77338. * @param onObserverAdded defines a callback to call when a new observer is added
  77339. */
  77340. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  77341. /**
  77342. * Create a new Observer with the specified callback
  77343. * @param callback the callback that will be executed for that Observer
  77344. * @param mask the mask used to filter observers
  77345. * @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.
  77346. * @param scope optional scope for the callback to be called from
  77347. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  77348. * @returns the new observer created for the callback
  77349. */
  77350. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  77351. /**
  77352. * Create a new Observer with the specified callback and unregisters after the next notification
  77353. * @param callback the callback that will be executed for that Observer
  77354. * @returns the new observer created for the callback
  77355. */
  77356. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  77357. /**
  77358. * Remove an Observer from the Observable object
  77359. * @param observer the instance of the Observer to remove
  77360. * @returns false if it doesn't belong to this Observable
  77361. */
  77362. remove(observer: Nullable<Observer<T>>): boolean;
  77363. /**
  77364. * Remove a callback from the Observable object
  77365. * @param callback the callback to remove
  77366. * @param scope optional scope. If used only the callbacks with this scope will be removed
  77367. * @returns false if it doesn't belong to this Observable
  77368. */
  77369. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  77370. private _deferUnregister;
  77371. private _remove;
  77372. /**
  77373. * Moves the observable to the top of the observer list making it get called first when notified
  77374. * @param observer the observer to move
  77375. */
  77376. makeObserverTopPriority(observer: Observer<T>): void;
  77377. /**
  77378. * Moves the observable to the bottom of the observer list making it get called last when notified
  77379. * @param observer the observer to move
  77380. */
  77381. makeObserverBottomPriority(observer: Observer<T>): void;
  77382. /**
  77383. * Notify all Observers by calling their respective callback with the given data
  77384. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  77385. * @param eventData defines the data to send to all observers
  77386. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  77387. * @param target defines the original target of the state
  77388. * @param currentTarget defines the current target of the state
  77389. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  77390. */
  77391. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  77392. /**
  77393. * Calling this will execute each callback, expecting it to be a promise or return a value.
  77394. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  77395. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  77396. * and it is crucial that all callbacks will be executed.
  77397. * The order of the callbacks is kept, callbacks are not executed parallel.
  77398. *
  77399. * @param eventData The data to be sent to each callback
  77400. * @param mask is used to filter observers defaults to -1
  77401. * @param target defines the callback target (see EventState)
  77402. * @param currentTarget defines he current object in the bubbling phase
  77403. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  77404. */
  77405. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  77406. /**
  77407. * Notify a specific observer
  77408. * @param observer defines the observer to notify
  77409. * @param eventData defines the data to be sent to each callback
  77410. * @param mask is used to filter observers defaults to -1
  77411. */
  77412. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  77413. /**
  77414. * Gets a boolean indicating if the observable has at least one observer
  77415. * @returns true is the Observable has at least one Observer registered
  77416. */
  77417. hasObservers(): boolean;
  77418. /**
  77419. * Clear the list of observers
  77420. */
  77421. clear(): void;
  77422. /**
  77423. * Clone the current observable
  77424. * @returns a new observable
  77425. */
  77426. clone(): Observable<T>;
  77427. /**
  77428. * Does this observable handles observer registered with a given mask
  77429. * @param mask defines the mask to be tested
  77430. * @return whether or not one observer registered with the given mask is handeled
  77431. **/
  77432. hasSpecificMask(mask?: number): boolean;
  77433. }
  77434. }
  77435. declare module BABYLON {
  77436. /**
  77437. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  77438. * Babylon.js
  77439. */
  77440. export class DomManagement {
  77441. /**
  77442. * Checks if the window object exists
  77443. * @returns true if the window object exists
  77444. */
  77445. static IsWindowObjectExist(): boolean;
  77446. /**
  77447. * Checks if the navigator object exists
  77448. * @returns true if the navigator object exists
  77449. */
  77450. static IsNavigatorAvailable(): boolean;
  77451. /**
  77452. * Check if the document object exists
  77453. * @returns true if the document object exists
  77454. */
  77455. static IsDocumentAvailable(): boolean;
  77456. /**
  77457. * Extracts text content from a DOM element hierarchy
  77458. * @param element defines the root element
  77459. * @returns a string
  77460. */
  77461. static GetDOMTextContent(element: HTMLElement): string;
  77462. }
  77463. }
  77464. declare module BABYLON {
  77465. /**
  77466. * Logger used througouht the application to allow configuration of
  77467. * the log level required for the messages.
  77468. */
  77469. export class Logger {
  77470. /**
  77471. * No log
  77472. */
  77473. static readonly NoneLogLevel: number;
  77474. /**
  77475. * Only message logs
  77476. */
  77477. static readonly MessageLogLevel: number;
  77478. /**
  77479. * Only warning logs
  77480. */
  77481. static readonly WarningLogLevel: number;
  77482. /**
  77483. * Only error logs
  77484. */
  77485. static readonly ErrorLogLevel: number;
  77486. /**
  77487. * All logs
  77488. */
  77489. static readonly AllLogLevel: number;
  77490. private static _LogCache;
  77491. /**
  77492. * Gets a value indicating the number of loading errors
  77493. * @ignorenaming
  77494. */
  77495. static errorsCount: number;
  77496. /**
  77497. * Callback called when a new log is added
  77498. */
  77499. static OnNewCacheEntry: (entry: string) => void;
  77500. private static _AddLogEntry;
  77501. private static _FormatMessage;
  77502. private static _LogDisabled;
  77503. private static _LogEnabled;
  77504. private static _WarnDisabled;
  77505. private static _WarnEnabled;
  77506. private static _ErrorDisabled;
  77507. private static _ErrorEnabled;
  77508. /**
  77509. * Log a message to the console
  77510. */
  77511. static Log: (message: string) => void;
  77512. /**
  77513. * Write a warning message to the console
  77514. */
  77515. static Warn: (message: string) => void;
  77516. /**
  77517. * Write an error message to the console
  77518. */
  77519. static Error: (message: string) => void;
  77520. /**
  77521. * Gets current log cache (list of logs)
  77522. */
  77523. static get LogCache(): string;
  77524. /**
  77525. * Clears the log cache
  77526. */
  77527. static ClearLogCache(): void;
  77528. /**
  77529. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  77530. */
  77531. static set LogLevels(level: number);
  77532. }
  77533. }
  77534. declare module BABYLON {
  77535. /** @hidden */
  77536. export class _TypeStore {
  77537. /** @hidden */
  77538. static RegisteredTypes: {
  77539. [key: string]: Object;
  77540. };
  77541. /** @hidden */
  77542. static GetClass(fqdn: string): any;
  77543. }
  77544. }
  77545. declare module BABYLON {
  77546. /**
  77547. * Helper to manipulate strings
  77548. */
  77549. export class StringTools {
  77550. /**
  77551. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  77552. * @param str Source string
  77553. * @param suffix Suffix to search for in the source string
  77554. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77555. */
  77556. static EndsWith(str: string, suffix: string): boolean;
  77557. /**
  77558. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  77559. * @param str Source string
  77560. * @param suffix Suffix to search for in the source string
  77561. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77562. */
  77563. static StartsWith(str: string, suffix: string): boolean;
  77564. /**
  77565. * Decodes a buffer into a string
  77566. * @param buffer The buffer to decode
  77567. * @returns The decoded string
  77568. */
  77569. static Decode(buffer: Uint8Array | Uint16Array): string;
  77570. /**
  77571. * Encode a buffer to a base64 string
  77572. * @param buffer defines the buffer to encode
  77573. * @returns the encoded string
  77574. */
  77575. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  77576. /**
  77577. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  77578. * @param num the number to convert and pad
  77579. * @param length the expected length of the string
  77580. * @returns the padded string
  77581. */
  77582. static PadNumber(num: number, length: number): string;
  77583. }
  77584. }
  77585. declare module BABYLON {
  77586. /**
  77587. * Class containing a set of static utilities functions for deep copy.
  77588. */
  77589. export class DeepCopier {
  77590. /**
  77591. * Tries to copy an object by duplicating every property
  77592. * @param source defines the source object
  77593. * @param destination defines the target object
  77594. * @param doNotCopyList defines a list of properties to avoid
  77595. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  77596. */
  77597. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  77598. }
  77599. }
  77600. declare module BABYLON {
  77601. /**
  77602. * Class containing a set of static utilities functions for precision date
  77603. */
  77604. export class PrecisionDate {
  77605. /**
  77606. * Gets either window.performance.now() if supported or Date.now() else
  77607. */
  77608. static get Now(): number;
  77609. }
  77610. }
  77611. declare module BABYLON {
  77612. /** @hidden */
  77613. export class _DevTools {
  77614. static WarnImport(name: string): string;
  77615. }
  77616. }
  77617. declare module BABYLON {
  77618. /**
  77619. * Interface used to define the mechanism to get data from the network
  77620. */
  77621. export interface IWebRequest {
  77622. /**
  77623. * Returns client's response url
  77624. */
  77625. responseURL: string;
  77626. /**
  77627. * Returns client's status
  77628. */
  77629. status: number;
  77630. /**
  77631. * Returns client's status as a text
  77632. */
  77633. statusText: string;
  77634. }
  77635. }
  77636. declare module BABYLON {
  77637. /**
  77638. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  77639. */
  77640. export class WebRequest implements IWebRequest {
  77641. private _xhr;
  77642. /**
  77643. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  77644. * i.e. when loading files, where the server/service expects an Authorization header
  77645. */
  77646. static CustomRequestHeaders: {
  77647. [key: string]: string;
  77648. };
  77649. /**
  77650. * Add callback functions in this array to update all the requests before they get sent to the network
  77651. */
  77652. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  77653. private _injectCustomRequestHeaders;
  77654. /**
  77655. * Gets or sets a function to be called when loading progress changes
  77656. */
  77657. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  77658. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  77659. /**
  77660. * Returns client's state
  77661. */
  77662. get readyState(): number;
  77663. /**
  77664. * Returns client's status
  77665. */
  77666. get status(): number;
  77667. /**
  77668. * Returns client's status as a text
  77669. */
  77670. get statusText(): string;
  77671. /**
  77672. * Returns client's response
  77673. */
  77674. get response(): any;
  77675. /**
  77676. * Returns client's response url
  77677. */
  77678. get responseURL(): string;
  77679. /**
  77680. * Returns client's response as text
  77681. */
  77682. get responseText(): string;
  77683. /**
  77684. * Gets or sets the expected response type
  77685. */
  77686. get responseType(): XMLHttpRequestResponseType;
  77687. set responseType(value: XMLHttpRequestResponseType);
  77688. /** @hidden */
  77689. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  77690. /** @hidden */
  77691. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  77692. /**
  77693. * Cancels any network activity
  77694. */
  77695. abort(): void;
  77696. /**
  77697. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  77698. * @param body defines an optional request body
  77699. */
  77700. send(body?: Document | BodyInit | null): void;
  77701. /**
  77702. * Sets the request method, request URL
  77703. * @param method defines the method to use (GET, POST, etc..)
  77704. * @param url defines the url to connect with
  77705. */
  77706. open(method: string, url: string): void;
  77707. /**
  77708. * Sets the value of a request header.
  77709. * @param name The name of the header whose value is to be set
  77710. * @param value The value to set as the body of the header
  77711. */
  77712. setRequestHeader(name: string, value: string): void;
  77713. /**
  77714. * Get the string containing the text of a particular header's value.
  77715. * @param name The name of the header
  77716. * @returns The string containing the text of the given header name
  77717. */
  77718. getResponseHeader(name: string): Nullable<string>;
  77719. }
  77720. }
  77721. declare module BABYLON {
  77722. /**
  77723. * File request interface
  77724. */
  77725. export interface IFileRequest {
  77726. /**
  77727. * Raised when the request is complete (success or error).
  77728. */
  77729. onCompleteObservable: Observable<IFileRequest>;
  77730. /**
  77731. * Aborts the request for a file.
  77732. */
  77733. abort: () => void;
  77734. }
  77735. }
  77736. declare module BABYLON {
  77737. /**
  77738. * Define options used to create a render target texture
  77739. */
  77740. export class RenderTargetCreationOptions {
  77741. /**
  77742. * Specifies is mipmaps must be generated
  77743. */
  77744. generateMipMaps?: boolean;
  77745. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  77746. generateDepthBuffer?: boolean;
  77747. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  77748. generateStencilBuffer?: boolean;
  77749. /** Defines texture type (int by default) */
  77750. type?: number;
  77751. /** Defines sampling mode (trilinear by default) */
  77752. samplingMode?: number;
  77753. /** Defines format (RGBA by default) */
  77754. format?: number;
  77755. }
  77756. }
  77757. declare module BABYLON {
  77758. /** Defines the cross module used constants to avoid circular dependncies */
  77759. export class Constants {
  77760. /** Defines that alpha blending is disabled */
  77761. static readonly ALPHA_DISABLE: number;
  77762. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  77763. static readonly ALPHA_ADD: number;
  77764. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  77765. static readonly ALPHA_COMBINE: number;
  77766. /** Defines that alpha blending is DEST - SRC * DEST */
  77767. static readonly ALPHA_SUBTRACT: number;
  77768. /** Defines that alpha blending is SRC * DEST */
  77769. static readonly ALPHA_MULTIPLY: number;
  77770. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  77771. static readonly ALPHA_MAXIMIZED: number;
  77772. /** Defines that alpha blending is SRC + DEST */
  77773. static readonly ALPHA_ONEONE: number;
  77774. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  77775. static readonly ALPHA_PREMULTIPLIED: number;
  77776. /**
  77777. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  77778. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  77779. */
  77780. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  77781. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  77782. static readonly ALPHA_INTERPOLATE: number;
  77783. /**
  77784. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  77785. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  77786. */
  77787. static readonly ALPHA_SCREENMODE: number;
  77788. /**
  77789. * Defines that alpha blending is SRC + DST
  77790. * Alpha will be set to SRC ALPHA + DST ALPHA
  77791. */
  77792. static readonly ALPHA_ONEONE_ONEONE: number;
  77793. /**
  77794. * Defines that alpha blending is SRC * DST ALPHA + DST
  77795. * Alpha will be set to 0
  77796. */
  77797. static readonly ALPHA_ALPHATOCOLOR: number;
  77798. /**
  77799. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77800. */
  77801. static readonly ALPHA_REVERSEONEMINUS: number;
  77802. /**
  77803. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  77804. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  77805. */
  77806. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  77807. /**
  77808. * Defines that alpha blending is SRC + DST
  77809. * Alpha will be set to SRC ALPHA
  77810. */
  77811. static readonly ALPHA_ONEONE_ONEZERO: number;
  77812. /**
  77813. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77814. * Alpha will be set to DST ALPHA
  77815. */
  77816. static readonly ALPHA_EXCLUSION: number;
  77817. /** Defines that alpha blending equation a SUM */
  77818. static readonly ALPHA_EQUATION_ADD: number;
  77819. /** Defines that alpha blending equation a SUBSTRACTION */
  77820. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  77821. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  77822. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  77823. /** Defines that alpha blending equation a MAX operation */
  77824. static readonly ALPHA_EQUATION_MAX: number;
  77825. /** Defines that alpha blending equation a MIN operation */
  77826. static readonly ALPHA_EQUATION_MIN: number;
  77827. /**
  77828. * Defines that alpha blending equation a DARKEN operation:
  77829. * It takes the min of the src and sums the alpha channels.
  77830. */
  77831. static readonly ALPHA_EQUATION_DARKEN: number;
  77832. /** Defines that the ressource is not delayed*/
  77833. static readonly DELAYLOADSTATE_NONE: number;
  77834. /** Defines that the ressource was successfully delay loaded */
  77835. static readonly DELAYLOADSTATE_LOADED: number;
  77836. /** Defines that the ressource is currently delay loading */
  77837. static readonly DELAYLOADSTATE_LOADING: number;
  77838. /** Defines that the ressource is delayed and has not started loading */
  77839. static readonly DELAYLOADSTATE_NOTLOADED: number;
  77840. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  77841. static readonly NEVER: number;
  77842. /** 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 */
  77843. static readonly ALWAYS: number;
  77844. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  77845. static readonly LESS: number;
  77846. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  77847. static readonly EQUAL: number;
  77848. /** 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 */
  77849. static readonly LEQUAL: number;
  77850. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  77851. static readonly GREATER: number;
  77852. /** 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 */
  77853. static readonly GEQUAL: number;
  77854. /** 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 */
  77855. static readonly NOTEQUAL: number;
  77856. /** Passed to stencilOperation to specify that stencil value must be kept */
  77857. static readonly KEEP: number;
  77858. /** Passed to stencilOperation to specify that stencil value must be replaced */
  77859. static readonly REPLACE: number;
  77860. /** Passed to stencilOperation to specify that stencil value must be incremented */
  77861. static readonly INCR: number;
  77862. /** Passed to stencilOperation to specify that stencil value must be decremented */
  77863. static readonly DECR: number;
  77864. /** Passed to stencilOperation to specify that stencil value must be inverted */
  77865. static readonly INVERT: number;
  77866. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  77867. static readonly INCR_WRAP: number;
  77868. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  77869. static readonly DECR_WRAP: number;
  77870. /** Texture is not repeating outside of 0..1 UVs */
  77871. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  77872. /** Texture is repeating outside of 0..1 UVs */
  77873. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  77874. /** Texture is repeating and mirrored */
  77875. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  77876. /** ALPHA */
  77877. static readonly TEXTUREFORMAT_ALPHA: number;
  77878. /** LUMINANCE */
  77879. static readonly TEXTUREFORMAT_LUMINANCE: number;
  77880. /** LUMINANCE_ALPHA */
  77881. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  77882. /** RGB */
  77883. static readonly TEXTUREFORMAT_RGB: number;
  77884. /** RGBA */
  77885. static readonly TEXTUREFORMAT_RGBA: number;
  77886. /** RED */
  77887. static readonly TEXTUREFORMAT_RED: number;
  77888. /** RED (2nd reference) */
  77889. static readonly TEXTUREFORMAT_R: number;
  77890. /** RG */
  77891. static readonly TEXTUREFORMAT_RG: number;
  77892. /** RED_INTEGER */
  77893. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  77894. /** RED_INTEGER (2nd reference) */
  77895. static readonly TEXTUREFORMAT_R_INTEGER: number;
  77896. /** RG_INTEGER */
  77897. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  77898. /** RGB_INTEGER */
  77899. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  77900. /** RGBA_INTEGER */
  77901. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  77902. /** UNSIGNED_BYTE */
  77903. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  77904. /** UNSIGNED_BYTE (2nd reference) */
  77905. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  77906. /** FLOAT */
  77907. static readonly TEXTURETYPE_FLOAT: number;
  77908. /** HALF_FLOAT */
  77909. static readonly TEXTURETYPE_HALF_FLOAT: number;
  77910. /** BYTE */
  77911. static readonly TEXTURETYPE_BYTE: number;
  77912. /** SHORT */
  77913. static readonly TEXTURETYPE_SHORT: number;
  77914. /** UNSIGNED_SHORT */
  77915. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  77916. /** INT */
  77917. static readonly TEXTURETYPE_INT: number;
  77918. /** UNSIGNED_INT */
  77919. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  77920. /** UNSIGNED_SHORT_4_4_4_4 */
  77921. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  77922. /** UNSIGNED_SHORT_5_5_5_1 */
  77923. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  77924. /** UNSIGNED_SHORT_5_6_5 */
  77925. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  77926. /** UNSIGNED_INT_2_10_10_10_REV */
  77927. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  77928. /** UNSIGNED_INT_24_8 */
  77929. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  77930. /** UNSIGNED_INT_10F_11F_11F_REV */
  77931. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  77932. /** UNSIGNED_INT_5_9_9_9_REV */
  77933. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  77934. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  77935. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77936. /** nearest is mag = nearest and min = nearest and no mip */
  77937. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  77938. /** mag = nearest and min = nearest and mip = none */
  77939. static readonly TEXTURE_NEAREST_NEAREST: number;
  77940. /** Bilinear is mag = linear and min = linear and no mip */
  77941. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  77942. /** mag = linear and min = linear and mip = none */
  77943. static readonly TEXTURE_LINEAR_LINEAR: number;
  77944. /** Trilinear is mag = linear and min = linear and mip = linear */
  77945. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  77946. /** Trilinear is mag = linear and min = linear and mip = linear */
  77947. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  77948. /** mag = nearest and min = nearest and mip = nearest */
  77949. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  77950. /** mag = nearest and min = linear and mip = nearest */
  77951. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  77952. /** mag = nearest and min = linear and mip = linear */
  77953. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  77954. /** mag = nearest and min = linear and mip = none */
  77955. static readonly TEXTURE_NEAREST_LINEAR: number;
  77956. /** nearest is mag = nearest and min = nearest and mip = linear */
  77957. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  77958. /** mag = linear and min = nearest and mip = nearest */
  77959. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  77960. /** mag = linear and min = nearest and mip = linear */
  77961. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  77962. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77963. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  77964. /** mag = linear and min = nearest and mip = none */
  77965. static readonly TEXTURE_LINEAR_NEAREST: number;
  77966. /** Explicit coordinates mode */
  77967. static readonly TEXTURE_EXPLICIT_MODE: number;
  77968. /** Spherical coordinates mode */
  77969. static readonly TEXTURE_SPHERICAL_MODE: number;
  77970. /** Planar coordinates mode */
  77971. static readonly TEXTURE_PLANAR_MODE: number;
  77972. /** Cubic coordinates mode */
  77973. static readonly TEXTURE_CUBIC_MODE: number;
  77974. /** Projection coordinates mode */
  77975. static readonly TEXTURE_PROJECTION_MODE: number;
  77976. /** Skybox coordinates mode */
  77977. static readonly TEXTURE_SKYBOX_MODE: number;
  77978. /** Inverse Cubic coordinates mode */
  77979. static readonly TEXTURE_INVCUBIC_MODE: number;
  77980. /** Equirectangular coordinates mode */
  77981. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  77982. /** Equirectangular Fixed coordinates mode */
  77983. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  77984. /** Equirectangular Fixed Mirrored coordinates mode */
  77985. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77986. /** Offline (baking) quality for texture filtering */
  77987. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  77988. /** High quality for texture filtering */
  77989. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  77990. /** Medium quality for texture filtering */
  77991. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  77992. /** Low quality for texture filtering */
  77993. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  77994. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  77995. static readonly SCALEMODE_FLOOR: number;
  77996. /** Defines that texture rescaling will look for the nearest power of 2 size */
  77997. static readonly SCALEMODE_NEAREST: number;
  77998. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  77999. static readonly SCALEMODE_CEILING: number;
  78000. /**
  78001. * The dirty texture flag value
  78002. */
  78003. static readonly MATERIAL_TextureDirtyFlag: number;
  78004. /**
  78005. * The dirty light flag value
  78006. */
  78007. static readonly MATERIAL_LightDirtyFlag: number;
  78008. /**
  78009. * The dirty fresnel flag value
  78010. */
  78011. static readonly MATERIAL_FresnelDirtyFlag: number;
  78012. /**
  78013. * The dirty attribute flag value
  78014. */
  78015. static readonly MATERIAL_AttributesDirtyFlag: number;
  78016. /**
  78017. * The dirty misc flag value
  78018. */
  78019. static readonly MATERIAL_MiscDirtyFlag: number;
  78020. /**
  78021. * The all dirty flag value
  78022. */
  78023. static readonly MATERIAL_AllDirtyFlag: number;
  78024. /**
  78025. * Returns the triangle fill mode
  78026. */
  78027. static readonly MATERIAL_TriangleFillMode: number;
  78028. /**
  78029. * Returns the wireframe mode
  78030. */
  78031. static readonly MATERIAL_WireFrameFillMode: number;
  78032. /**
  78033. * Returns the point fill mode
  78034. */
  78035. static readonly MATERIAL_PointFillMode: number;
  78036. /**
  78037. * Returns the point list draw mode
  78038. */
  78039. static readonly MATERIAL_PointListDrawMode: number;
  78040. /**
  78041. * Returns the line list draw mode
  78042. */
  78043. static readonly MATERIAL_LineListDrawMode: number;
  78044. /**
  78045. * Returns the line loop draw mode
  78046. */
  78047. static readonly MATERIAL_LineLoopDrawMode: number;
  78048. /**
  78049. * Returns the line strip draw mode
  78050. */
  78051. static readonly MATERIAL_LineStripDrawMode: number;
  78052. /**
  78053. * Returns the triangle strip draw mode
  78054. */
  78055. static readonly MATERIAL_TriangleStripDrawMode: number;
  78056. /**
  78057. * Returns the triangle fan draw mode
  78058. */
  78059. static readonly MATERIAL_TriangleFanDrawMode: number;
  78060. /**
  78061. * Stores the clock-wise side orientation
  78062. */
  78063. static readonly MATERIAL_ClockWiseSideOrientation: number;
  78064. /**
  78065. * Stores the counter clock-wise side orientation
  78066. */
  78067. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  78068. /**
  78069. * Nothing
  78070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78071. */
  78072. static readonly ACTION_NothingTrigger: number;
  78073. /**
  78074. * On pick
  78075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78076. */
  78077. static readonly ACTION_OnPickTrigger: number;
  78078. /**
  78079. * On left pick
  78080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78081. */
  78082. static readonly ACTION_OnLeftPickTrigger: number;
  78083. /**
  78084. * On right pick
  78085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78086. */
  78087. static readonly ACTION_OnRightPickTrigger: number;
  78088. /**
  78089. * On center pick
  78090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78091. */
  78092. static readonly ACTION_OnCenterPickTrigger: number;
  78093. /**
  78094. * On pick down
  78095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78096. */
  78097. static readonly ACTION_OnPickDownTrigger: number;
  78098. /**
  78099. * On double pick
  78100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78101. */
  78102. static readonly ACTION_OnDoublePickTrigger: number;
  78103. /**
  78104. * On pick up
  78105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78106. */
  78107. static readonly ACTION_OnPickUpTrigger: number;
  78108. /**
  78109. * On pick out.
  78110. * This trigger will only be raised if you also declared a OnPickDown
  78111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78112. */
  78113. static readonly ACTION_OnPickOutTrigger: number;
  78114. /**
  78115. * On long press
  78116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78117. */
  78118. static readonly ACTION_OnLongPressTrigger: number;
  78119. /**
  78120. * On pointer over
  78121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78122. */
  78123. static readonly ACTION_OnPointerOverTrigger: number;
  78124. /**
  78125. * On pointer out
  78126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78127. */
  78128. static readonly ACTION_OnPointerOutTrigger: number;
  78129. /**
  78130. * On every frame
  78131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78132. */
  78133. static readonly ACTION_OnEveryFrameTrigger: number;
  78134. /**
  78135. * On intersection enter
  78136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78137. */
  78138. static readonly ACTION_OnIntersectionEnterTrigger: number;
  78139. /**
  78140. * On intersection exit
  78141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78142. */
  78143. static readonly ACTION_OnIntersectionExitTrigger: number;
  78144. /**
  78145. * On key down
  78146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78147. */
  78148. static readonly ACTION_OnKeyDownTrigger: number;
  78149. /**
  78150. * On key up
  78151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78152. */
  78153. static readonly ACTION_OnKeyUpTrigger: number;
  78154. /**
  78155. * Billboard mode will only apply to Y axis
  78156. */
  78157. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  78158. /**
  78159. * Billboard mode will apply to all axes
  78160. */
  78161. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  78162. /**
  78163. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  78164. */
  78165. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  78166. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78167. * Test order :
  78168. * Is the bounding sphere outside the frustum ?
  78169. * If not, are the bounding box vertices outside the frustum ?
  78170. * It not, then the cullable object is in the frustum.
  78171. */
  78172. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  78173. /** Culling strategy : Bounding Sphere Only.
  78174. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78175. * It's also less accurate than the standard because some not visible objects can still be selected.
  78176. * Test : is the bounding sphere outside the frustum ?
  78177. * If not, then the cullable object is in the frustum.
  78178. */
  78179. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78180. /** Culling strategy : Optimistic Inclusion.
  78181. * This in an inclusion test first, then the standard exclusion test.
  78182. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78183. * 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.
  78184. * Anyway, it's as accurate as the standard strategy.
  78185. * Test :
  78186. * Is the cullable object bounding sphere center in the frustum ?
  78187. * If not, apply the default culling strategy.
  78188. */
  78189. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78190. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78191. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78192. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78193. * 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.
  78194. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78195. * Test :
  78196. * Is the cullable object bounding sphere center in the frustum ?
  78197. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78198. */
  78199. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78200. /**
  78201. * No logging while loading
  78202. */
  78203. static readonly SCENELOADER_NO_LOGGING: number;
  78204. /**
  78205. * Minimal logging while loading
  78206. */
  78207. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  78208. /**
  78209. * Summary logging while loading
  78210. */
  78211. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  78212. /**
  78213. * Detailled logging while loading
  78214. */
  78215. static readonly SCENELOADER_DETAILED_LOGGING: number;
  78216. }
  78217. }
  78218. declare module BABYLON {
  78219. /**
  78220. * This represents the required contract to create a new type of texture loader.
  78221. */
  78222. export interface IInternalTextureLoader {
  78223. /**
  78224. * Defines wether the loader supports cascade loading the different faces.
  78225. */
  78226. supportCascades: boolean;
  78227. /**
  78228. * This returns if the loader support the current file information.
  78229. * @param extension defines the file extension of the file being loaded
  78230. * @returns true if the loader can load the specified file
  78231. */
  78232. canLoad(extension: string): boolean;
  78233. /**
  78234. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78235. * @param data contains the texture data
  78236. * @param texture defines the BabylonJS internal texture
  78237. * @param createPolynomials will be true if polynomials have been requested
  78238. * @param onLoad defines the callback to trigger once the texture is ready
  78239. * @param onError defines the callback to trigger in case of error
  78240. */
  78241. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78242. /**
  78243. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78244. * @param data contains the texture data
  78245. * @param texture defines the BabylonJS internal texture
  78246. * @param callback defines the method to call once ready to upload
  78247. */
  78248. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78249. }
  78250. }
  78251. declare module BABYLON {
  78252. /**
  78253. * Class used to store and describe the pipeline context associated with an effect
  78254. */
  78255. export interface IPipelineContext {
  78256. /**
  78257. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78258. */
  78259. isAsync: boolean;
  78260. /**
  78261. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78262. */
  78263. isReady: boolean;
  78264. /** @hidden */
  78265. _getVertexShaderCode(): string | null;
  78266. /** @hidden */
  78267. _getFragmentShaderCode(): string | null;
  78268. /** @hidden */
  78269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78270. }
  78271. }
  78272. declare module BABYLON {
  78273. /**
  78274. * Class used to store gfx data (like WebGLBuffer)
  78275. */
  78276. export class DataBuffer {
  78277. /**
  78278. * Gets or sets the number of objects referencing this buffer
  78279. */
  78280. references: number;
  78281. /** Gets or sets the size of the underlying buffer */
  78282. capacity: number;
  78283. /**
  78284. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78285. */
  78286. is32Bits: boolean;
  78287. /**
  78288. * Gets the underlying buffer
  78289. */
  78290. get underlyingResource(): any;
  78291. }
  78292. }
  78293. declare module BABYLON {
  78294. /** @hidden */
  78295. export interface IShaderProcessor {
  78296. attributeProcessor?: (attribute: string) => string;
  78297. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78298. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78299. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78300. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78301. lineProcessor?: (line: string, isFragment: boolean) => string;
  78302. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78303. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78304. }
  78305. }
  78306. declare module BABYLON {
  78307. /** @hidden */
  78308. export interface ProcessingOptions {
  78309. defines: string[];
  78310. indexParameters: any;
  78311. isFragment: boolean;
  78312. shouldUseHighPrecisionShader: boolean;
  78313. supportsUniformBuffers: boolean;
  78314. shadersRepository: string;
  78315. includesShadersStore: {
  78316. [key: string]: string;
  78317. };
  78318. processor?: IShaderProcessor;
  78319. version: string;
  78320. platformName: string;
  78321. lookForClosingBracketForUniformBuffer?: boolean;
  78322. }
  78323. }
  78324. declare module BABYLON {
  78325. /** @hidden */
  78326. export class ShaderCodeNode {
  78327. line: string;
  78328. children: ShaderCodeNode[];
  78329. additionalDefineKey?: string;
  78330. additionalDefineValue?: string;
  78331. isValid(preprocessors: {
  78332. [key: string]: string;
  78333. }): boolean;
  78334. process(preprocessors: {
  78335. [key: string]: string;
  78336. }, options: ProcessingOptions): string;
  78337. }
  78338. }
  78339. declare module BABYLON {
  78340. /** @hidden */
  78341. export class ShaderCodeCursor {
  78342. private _lines;
  78343. lineIndex: number;
  78344. get currentLine(): string;
  78345. get canRead(): boolean;
  78346. set lines(value: string[]);
  78347. }
  78348. }
  78349. declare module BABYLON {
  78350. /** @hidden */
  78351. export class ShaderCodeConditionNode extends ShaderCodeNode {
  78352. process(preprocessors: {
  78353. [key: string]: string;
  78354. }, options: ProcessingOptions): string;
  78355. }
  78356. }
  78357. declare module BABYLON {
  78358. /** @hidden */
  78359. export class ShaderDefineExpression {
  78360. isTrue(preprocessors: {
  78361. [key: string]: string;
  78362. }): boolean;
  78363. private static _OperatorPriority;
  78364. private static _Stack;
  78365. static postfixToInfix(postfix: string[]): string;
  78366. static infixToPostfix(infix: string): string[];
  78367. }
  78368. }
  78369. declare module BABYLON {
  78370. /** @hidden */
  78371. export class ShaderCodeTestNode extends ShaderCodeNode {
  78372. testExpression: ShaderDefineExpression;
  78373. isValid(preprocessors: {
  78374. [key: string]: string;
  78375. }): boolean;
  78376. }
  78377. }
  78378. declare module BABYLON {
  78379. /** @hidden */
  78380. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  78381. define: string;
  78382. not: boolean;
  78383. constructor(define: string, not?: boolean);
  78384. isTrue(preprocessors: {
  78385. [key: string]: string;
  78386. }): boolean;
  78387. }
  78388. }
  78389. declare module BABYLON {
  78390. /** @hidden */
  78391. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  78392. leftOperand: ShaderDefineExpression;
  78393. rightOperand: ShaderDefineExpression;
  78394. isTrue(preprocessors: {
  78395. [key: string]: string;
  78396. }): boolean;
  78397. }
  78398. }
  78399. declare module BABYLON {
  78400. /** @hidden */
  78401. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  78402. leftOperand: ShaderDefineExpression;
  78403. rightOperand: ShaderDefineExpression;
  78404. isTrue(preprocessors: {
  78405. [key: string]: string;
  78406. }): boolean;
  78407. }
  78408. }
  78409. declare module BABYLON {
  78410. /** @hidden */
  78411. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  78412. define: string;
  78413. operand: string;
  78414. testValue: string;
  78415. constructor(define: string, operand: string, testValue: string);
  78416. isTrue(preprocessors: {
  78417. [key: string]: string;
  78418. }): boolean;
  78419. }
  78420. }
  78421. declare module BABYLON {
  78422. /**
  78423. * Class used to enable access to offline support
  78424. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  78425. */
  78426. export interface IOfflineProvider {
  78427. /**
  78428. * Gets a boolean indicating if scene must be saved in the database
  78429. */
  78430. enableSceneOffline: boolean;
  78431. /**
  78432. * Gets a boolean indicating if textures must be saved in the database
  78433. */
  78434. enableTexturesOffline: boolean;
  78435. /**
  78436. * Open the offline support and make it available
  78437. * @param successCallback defines the callback to call on success
  78438. * @param errorCallback defines the callback to call on error
  78439. */
  78440. open(successCallback: () => void, errorCallback: () => void): void;
  78441. /**
  78442. * Loads an image from the offline support
  78443. * @param url defines the url to load from
  78444. * @param image defines the target DOM image
  78445. */
  78446. loadImage(url: string, image: HTMLImageElement): void;
  78447. /**
  78448. * Loads a file from offline support
  78449. * @param url defines the URL to load from
  78450. * @param sceneLoaded defines a callback to call on success
  78451. * @param progressCallBack defines a callback to call when progress changed
  78452. * @param errorCallback defines a callback to call on error
  78453. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  78454. */
  78455. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  78456. }
  78457. }
  78458. declare module BABYLON {
  78459. /**
  78460. * Class used to help managing file picking and drag'n'drop
  78461. * File Storage
  78462. */
  78463. export class FilesInputStore {
  78464. /**
  78465. * List of files ready to be loaded
  78466. */
  78467. static FilesToLoad: {
  78468. [key: string]: File;
  78469. };
  78470. }
  78471. }
  78472. declare module BABYLON {
  78473. /**
  78474. * Class used to define a retry strategy when error happens while loading assets
  78475. */
  78476. export class RetryStrategy {
  78477. /**
  78478. * Function used to defines an exponential back off strategy
  78479. * @param maxRetries defines the maximum number of retries (3 by default)
  78480. * @param baseInterval defines the interval between retries
  78481. * @returns the strategy function to use
  78482. */
  78483. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  78484. }
  78485. }
  78486. declare module BABYLON {
  78487. /**
  78488. * @ignore
  78489. * Application error to support additional information when loading a file
  78490. */
  78491. export abstract class BaseError extends Error {
  78492. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  78493. }
  78494. }
  78495. declare module BABYLON {
  78496. /** @ignore */
  78497. export class LoadFileError extends BaseError {
  78498. request?: WebRequest;
  78499. file?: File;
  78500. /**
  78501. * Creates a new LoadFileError
  78502. * @param message defines the message of the error
  78503. * @param request defines the optional web request
  78504. * @param file defines the optional file
  78505. */
  78506. constructor(message: string, object?: WebRequest | File);
  78507. }
  78508. /** @ignore */
  78509. export class RequestFileError extends BaseError {
  78510. request: WebRequest;
  78511. /**
  78512. * Creates a new LoadFileError
  78513. * @param message defines the message of the error
  78514. * @param request defines the optional web request
  78515. */
  78516. constructor(message: string, request: WebRequest);
  78517. }
  78518. /** @ignore */
  78519. export class ReadFileError extends BaseError {
  78520. file: File;
  78521. /**
  78522. * Creates a new ReadFileError
  78523. * @param message defines the message of the error
  78524. * @param file defines the optional file
  78525. */
  78526. constructor(message: string, file: File);
  78527. }
  78528. /**
  78529. * @hidden
  78530. */
  78531. export class FileTools {
  78532. /**
  78533. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  78534. */
  78535. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  78536. /**
  78537. * Gets or sets the base URL to use to load assets
  78538. */
  78539. static BaseUrl: string;
  78540. /**
  78541. * Default behaviour for cors in the application.
  78542. * It can be a string if the expected behavior is identical in the entire app.
  78543. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  78544. */
  78545. static CorsBehavior: string | ((url: string | string[]) => string);
  78546. /**
  78547. * Gets or sets a function used to pre-process url before using them to load assets
  78548. */
  78549. static PreprocessUrl: (url: string) => string;
  78550. /**
  78551. * Removes unwanted characters from an url
  78552. * @param url defines the url to clean
  78553. * @returns the cleaned url
  78554. */
  78555. private static _CleanUrl;
  78556. /**
  78557. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  78558. * @param url define the url we are trying
  78559. * @param element define the dom element where to configure the cors policy
  78560. */
  78561. static SetCorsBehavior(url: string | string[], element: {
  78562. crossOrigin: string | null;
  78563. }): void;
  78564. /**
  78565. * Loads an image as an HTMLImageElement.
  78566. * @param input url string, ArrayBuffer, or Blob to load
  78567. * @param onLoad callback called when the image successfully loads
  78568. * @param onError callback called when the image fails to load
  78569. * @param offlineProvider offline provider for caching
  78570. * @param mimeType optional mime type
  78571. * @returns the HTMLImageElement of the loaded image
  78572. */
  78573. 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>;
  78574. /**
  78575. * Reads a file from a File object
  78576. * @param file defines the file to load
  78577. * @param onSuccess defines the callback to call when data is loaded
  78578. * @param onProgress defines the callback to call during loading process
  78579. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  78580. * @param onError defines the callback to call when an error occurs
  78581. * @returns a file request object
  78582. */
  78583. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  78584. /**
  78585. * Loads a file from a url
  78586. * @param url url to load
  78587. * @param onSuccess callback called when the file successfully loads
  78588. * @param onProgress callback called while file is loading (if the server supports this mode)
  78589. * @param offlineProvider defines the offline provider for caching
  78590. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78591. * @param onError callback called when the file fails to load
  78592. * @returns a file request object
  78593. */
  78594. 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;
  78595. /**
  78596. * Loads a file
  78597. * @param url url to load
  78598. * @param onSuccess callback called when the file successfully loads
  78599. * @param onProgress callback called while file is loading (if the server supports this mode)
  78600. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78601. * @param onError callback called when the file fails to load
  78602. * @param onOpened callback called when the web request is opened
  78603. * @returns a file request object
  78604. */
  78605. 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;
  78606. /**
  78607. * Checks if the loaded document was accessed via `file:`-Protocol.
  78608. * @returns boolean
  78609. */
  78610. static IsFileURL(): boolean;
  78611. }
  78612. }
  78613. declare module BABYLON {
  78614. /** @hidden */
  78615. export class ShaderProcessor {
  78616. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  78617. private static _ProcessPrecision;
  78618. private static _ExtractOperation;
  78619. private static _BuildSubExpression;
  78620. private static _BuildExpression;
  78621. private static _MoveCursorWithinIf;
  78622. private static _MoveCursor;
  78623. private static _EvaluatePreProcessors;
  78624. private static _PreparePreProcessors;
  78625. private static _ProcessShaderConversion;
  78626. private static _ProcessIncludes;
  78627. /**
  78628. * Loads a file from a url
  78629. * @param url url to load
  78630. * @param onSuccess callback called when the file successfully loads
  78631. * @param onProgress callback called while file is loading (if the server supports this mode)
  78632. * @param offlineProvider defines the offline provider for caching
  78633. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78634. * @param onError callback called when the file fails to load
  78635. * @returns a file request object
  78636. * @hidden
  78637. */
  78638. 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;
  78639. }
  78640. }
  78641. declare module BABYLON {
  78642. /**
  78643. * @hidden
  78644. */
  78645. export interface IColor4Like {
  78646. r: float;
  78647. g: float;
  78648. b: float;
  78649. a: float;
  78650. }
  78651. /**
  78652. * @hidden
  78653. */
  78654. export interface IColor3Like {
  78655. r: float;
  78656. g: float;
  78657. b: float;
  78658. }
  78659. /**
  78660. * @hidden
  78661. */
  78662. export interface IVector4Like {
  78663. x: float;
  78664. y: float;
  78665. z: float;
  78666. w: float;
  78667. }
  78668. /**
  78669. * @hidden
  78670. */
  78671. export interface IVector3Like {
  78672. x: float;
  78673. y: float;
  78674. z: float;
  78675. }
  78676. /**
  78677. * @hidden
  78678. */
  78679. export interface IVector2Like {
  78680. x: float;
  78681. y: float;
  78682. }
  78683. /**
  78684. * @hidden
  78685. */
  78686. export interface IMatrixLike {
  78687. toArray(): DeepImmutable<Float32Array>;
  78688. updateFlag: int;
  78689. }
  78690. /**
  78691. * @hidden
  78692. */
  78693. export interface IViewportLike {
  78694. x: float;
  78695. y: float;
  78696. width: float;
  78697. height: float;
  78698. }
  78699. /**
  78700. * @hidden
  78701. */
  78702. export interface IPlaneLike {
  78703. normal: IVector3Like;
  78704. d: float;
  78705. normalize(): void;
  78706. }
  78707. }
  78708. declare module BABYLON {
  78709. /**
  78710. * Interface used to define common properties for effect fallbacks
  78711. */
  78712. export interface IEffectFallbacks {
  78713. /**
  78714. * Removes the defines that should be removed when falling back.
  78715. * @param currentDefines defines the current define statements for the shader.
  78716. * @param effect defines the current effect we try to compile
  78717. * @returns The resulting defines with defines of the current rank removed.
  78718. */
  78719. reduce(currentDefines: string, effect: Effect): string;
  78720. /**
  78721. * Removes the fallback from the bound mesh.
  78722. */
  78723. unBindMesh(): void;
  78724. /**
  78725. * Checks to see if more fallbacks are still availible.
  78726. */
  78727. hasMoreFallbacks: boolean;
  78728. }
  78729. }
  78730. declare module BABYLON {
  78731. /**
  78732. * Class used to evalaute queries containing `and` and `or` operators
  78733. */
  78734. export class AndOrNotEvaluator {
  78735. /**
  78736. * Evaluate a query
  78737. * @param query defines the query to evaluate
  78738. * @param evaluateCallback defines the callback used to filter result
  78739. * @returns true if the query matches
  78740. */
  78741. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  78742. private static _HandleParenthesisContent;
  78743. private static _SimplifyNegation;
  78744. }
  78745. }
  78746. declare module BABYLON {
  78747. /**
  78748. * Class used to store custom tags
  78749. */
  78750. export class Tags {
  78751. /**
  78752. * Adds support for tags on the given object
  78753. * @param obj defines the object to use
  78754. */
  78755. static EnableFor(obj: any): void;
  78756. /**
  78757. * Removes tags support
  78758. * @param obj defines the object to use
  78759. */
  78760. static DisableFor(obj: any): void;
  78761. /**
  78762. * Gets a boolean indicating if the given object has tags
  78763. * @param obj defines the object to use
  78764. * @returns a boolean
  78765. */
  78766. static HasTags(obj: any): boolean;
  78767. /**
  78768. * Gets the tags available on a given object
  78769. * @param obj defines the object to use
  78770. * @param asString defines if the tags must be returned as a string instead of an array of strings
  78771. * @returns the tags
  78772. */
  78773. static GetTags(obj: any, asString?: boolean): any;
  78774. /**
  78775. * Adds tags to an object
  78776. * @param obj defines the object to use
  78777. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  78778. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  78779. */
  78780. static AddTagsTo(obj: any, tagsString: string): void;
  78781. /**
  78782. * @hidden
  78783. */
  78784. static _AddTagTo(obj: any, tag: string): void;
  78785. /**
  78786. * Removes specific tags from a specific object
  78787. * @param obj defines the object to use
  78788. * @param tagsString defines the tags to remove
  78789. */
  78790. static RemoveTagsFrom(obj: any, tagsString: string): void;
  78791. /**
  78792. * @hidden
  78793. */
  78794. static _RemoveTagFrom(obj: any, tag: string): void;
  78795. /**
  78796. * Defines if tags hosted on an object match a given query
  78797. * @param obj defines the object to use
  78798. * @param tagsQuery defines the tag query
  78799. * @returns a boolean
  78800. */
  78801. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  78802. }
  78803. }
  78804. declare module BABYLON {
  78805. /**
  78806. * Scalar computation library
  78807. */
  78808. export class Scalar {
  78809. /**
  78810. * Two pi constants convenient for computation.
  78811. */
  78812. static TwoPi: number;
  78813. /**
  78814. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78815. * @param a number
  78816. * @param b number
  78817. * @param epsilon (default = 1.401298E-45)
  78818. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78819. */
  78820. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  78821. /**
  78822. * Returns a string : the upper case translation of the number i to hexadecimal.
  78823. * @param i number
  78824. * @returns the upper case translation of the number i to hexadecimal.
  78825. */
  78826. static ToHex(i: number): string;
  78827. /**
  78828. * Returns -1 if value is negative and +1 is value is positive.
  78829. * @param value the value
  78830. * @returns the value itself if it's equal to zero.
  78831. */
  78832. static Sign(value: number): number;
  78833. /**
  78834. * Returns the value itself if it's between min and max.
  78835. * Returns min if the value is lower than min.
  78836. * Returns max if the value is greater than max.
  78837. * @param value the value to clmap
  78838. * @param min the min value to clamp to (default: 0)
  78839. * @param max the max value to clamp to (default: 1)
  78840. * @returns the clamped value
  78841. */
  78842. static Clamp(value: number, min?: number, max?: number): number;
  78843. /**
  78844. * the log2 of value.
  78845. * @param value the value to compute log2 of
  78846. * @returns the log2 of value.
  78847. */
  78848. static Log2(value: number): number;
  78849. /**
  78850. * Loops the value, so that it is never larger than length and never smaller than 0.
  78851. *
  78852. * This is similar to the modulo operator but it works with floating point numbers.
  78853. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  78854. * With t = 5 and length = 2.5, the result would be 0.0.
  78855. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  78856. * @param value the value
  78857. * @param length the length
  78858. * @returns the looped value
  78859. */
  78860. static Repeat(value: number, length: number): number;
  78861. /**
  78862. * Normalize the value between 0.0 and 1.0 using min and max values
  78863. * @param value value to normalize
  78864. * @param min max to normalize between
  78865. * @param max min to normalize between
  78866. * @returns the normalized value
  78867. */
  78868. static Normalize(value: number, min: number, max: number): number;
  78869. /**
  78870. * Denormalize the value from 0.0 and 1.0 using min and max values
  78871. * @param normalized value to denormalize
  78872. * @param min max to denormalize between
  78873. * @param max min to denormalize between
  78874. * @returns the denormalized value
  78875. */
  78876. static Denormalize(normalized: number, min: number, max: number): number;
  78877. /**
  78878. * Calculates the shortest difference between two given angles given in degrees.
  78879. * @param current current angle in degrees
  78880. * @param target target angle in degrees
  78881. * @returns the delta
  78882. */
  78883. static DeltaAngle(current: number, target: number): number;
  78884. /**
  78885. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  78886. * @param tx value
  78887. * @param length length
  78888. * @returns The returned value will move back and forth between 0 and length
  78889. */
  78890. static PingPong(tx: number, length: number): number;
  78891. /**
  78892. * Interpolates between min and max with smoothing at the limits.
  78893. *
  78894. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  78895. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  78896. * @param from from
  78897. * @param to to
  78898. * @param tx value
  78899. * @returns the smooth stepped value
  78900. */
  78901. static SmoothStep(from: number, to: number, tx: number): number;
  78902. /**
  78903. * Moves a value current towards target.
  78904. *
  78905. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  78906. * Negative values of maxDelta pushes the value away from target.
  78907. * @param current current value
  78908. * @param target target value
  78909. * @param maxDelta max distance to move
  78910. * @returns resulting value
  78911. */
  78912. static MoveTowards(current: number, target: number, maxDelta: number): number;
  78913. /**
  78914. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  78915. *
  78916. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  78917. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  78918. * @param current current value
  78919. * @param target target value
  78920. * @param maxDelta max distance to move
  78921. * @returns resulting angle
  78922. */
  78923. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  78924. /**
  78925. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  78926. * @param start start value
  78927. * @param end target value
  78928. * @param amount amount to lerp between
  78929. * @returns the lerped value
  78930. */
  78931. static Lerp(start: number, end: number, amount: number): number;
  78932. /**
  78933. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  78934. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  78935. * @param start start value
  78936. * @param end target value
  78937. * @param amount amount to lerp between
  78938. * @returns the lerped value
  78939. */
  78940. static LerpAngle(start: number, end: number, amount: number): number;
  78941. /**
  78942. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  78943. * @param a start value
  78944. * @param b target value
  78945. * @param value value between a and b
  78946. * @returns the inverseLerp value
  78947. */
  78948. static InverseLerp(a: number, b: number, value: number): number;
  78949. /**
  78950. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  78951. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  78952. * @param value1 spline value
  78953. * @param tangent1 spline value
  78954. * @param value2 spline value
  78955. * @param tangent2 spline value
  78956. * @param amount input value
  78957. * @returns hermite result
  78958. */
  78959. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  78960. /**
  78961. * Returns a random float number between and min and max values
  78962. * @param min min value of random
  78963. * @param max max value of random
  78964. * @returns random value
  78965. */
  78966. static RandomRange(min: number, max: number): number;
  78967. /**
  78968. * This function returns percentage of a number in a given range.
  78969. *
  78970. * RangeToPercent(40,20,60) will return 0.5 (50%)
  78971. * RangeToPercent(34,0,100) will return 0.34 (34%)
  78972. * @param number to convert to percentage
  78973. * @param min min range
  78974. * @param max max range
  78975. * @returns the percentage
  78976. */
  78977. static RangeToPercent(number: number, min: number, max: number): number;
  78978. /**
  78979. * This function returns number that corresponds to the percentage in a given range.
  78980. *
  78981. * PercentToRange(0.34,0,100) will return 34.
  78982. * @param percent to convert to number
  78983. * @param min min range
  78984. * @param max max range
  78985. * @returns the number
  78986. */
  78987. static PercentToRange(percent: number, min: number, max: number): number;
  78988. /**
  78989. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  78990. * @param angle The angle to normalize in radian.
  78991. * @return The converted angle.
  78992. */
  78993. static NormalizeRadians(angle: number): number;
  78994. }
  78995. }
  78996. declare module BABYLON {
  78997. /**
  78998. * Constant used to convert a value to gamma space
  78999. * @ignorenaming
  79000. */
  79001. export const ToGammaSpace: number;
  79002. /**
  79003. * Constant used to convert a value to linear space
  79004. * @ignorenaming
  79005. */
  79006. export const ToLinearSpace = 2.2;
  79007. /**
  79008. * Constant used to define the minimal number value in Babylon.js
  79009. * @ignorenaming
  79010. */
  79011. let Epsilon: number;
  79012. }
  79013. declare module BABYLON {
  79014. /**
  79015. * Class used to represent a viewport on screen
  79016. */
  79017. export class Viewport {
  79018. /** viewport left coordinate */
  79019. x: number;
  79020. /** viewport top coordinate */
  79021. y: number;
  79022. /**viewport width */
  79023. width: number;
  79024. /** viewport height */
  79025. height: number;
  79026. /**
  79027. * Creates a Viewport object located at (x, y) and sized (width, height)
  79028. * @param x defines viewport left coordinate
  79029. * @param y defines viewport top coordinate
  79030. * @param width defines the viewport width
  79031. * @param height defines the viewport height
  79032. */
  79033. constructor(
  79034. /** viewport left coordinate */
  79035. x: number,
  79036. /** viewport top coordinate */
  79037. y: number,
  79038. /**viewport width */
  79039. width: number,
  79040. /** viewport height */
  79041. height: number);
  79042. /**
  79043. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  79044. * @param renderWidth defines the rendering width
  79045. * @param renderHeight defines the rendering height
  79046. * @returns a new Viewport
  79047. */
  79048. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  79049. /**
  79050. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  79051. * @param renderWidth defines the rendering width
  79052. * @param renderHeight defines the rendering height
  79053. * @param ref defines the target viewport
  79054. * @returns the current viewport
  79055. */
  79056. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  79057. /**
  79058. * Returns a new Viewport copied from the current one
  79059. * @returns a new Viewport
  79060. */
  79061. clone(): Viewport;
  79062. }
  79063. }
  79064. declare module BABYLON {
  79065. /**
  79066. * Class containing a set of static utilities functions for arrays.
  79067. */
  79068. export class ArrayTools {
  79069. /**
  79070. * Returns an array of the given size filled with element built from the given constructor and the paramters
  79071. * @param size the number of element to construct and put in the array
  79072. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  79073. * @returns a new array filled with new objects
  79074. */
  79075. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  79076. }
  79077. }
  79078. declare module BABYLON {
  79079. /**
  79080. * Represens a plane by the equation ax + by + cz + d = 0
  79081. */
  79082. export class Plane {
  79083. private static _TmpMatrix;
  79084. /**
  79085. * Normal of the plane (a,b,c)
  79086. */
  79087. normal: Vector3;
  79088. /**
  79089. * d component of the plane
  79090. */
  79091. d: number;
  79092. /**
  79093. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79094. * @param a a component of the plane
  79095. * @param b b component of the plane
  79096. * @param c c component of the plane
  79097. * @param d d component of the plane
  79098. */
  79099. constructor(a: number, b: number, c: number, d: number);
  79100. /**
  79101. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79102. */
  79103. asArray(): number[];
  79104. /**
  79105. * @returns a new plane copied from the current Plane.
  79106. */
  79107. clone(): Plane;
  79108. /**
  79109. * @returns the string "Plane".
  79110. */
  79111. getClassName(): string;
  79112. /**
  79113. * @returns the Plane hash code.
  79114. */
  79115. getHashCode(): number;
  79116. /**
  79117. * Normalize the current Plane in place.
  79118. * @returns the updated Plane.
  79119. */
  79120. normalize(): Plane;
  79121. /**
  79122. * Applies a transformation the plane and returns the result
  79123. * @param transformation the transformation matrix to be applied to the plane
  79124. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79125. */
  79126. transform(transformation: DeepImmutable<Matrix>): Plane;
  79127. /**
  79128. * Compute the dot product between the point and the plane normal
  79129. * @param point point to calculate the dot product with
  79130. * @returns the dot product (float) of the point coordinates and the plane normal.
  79131. */
  79132. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79133. /**
  79134. * Updates the current Plane from the plane defined by the three given points.
  79135. * @param point1 one of the points used to contruct the plane
  79136. * @param point2 one of the points used to contruct the plane
  79137. * @param point3 one of the points used to contruct the plane
  79138. * @returns the updated Plane.
  79139. */
  79140. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79141. /**
  79142. * Checks if the plane is facing a given direction
  79143. * @param direction the direction to check if the plane is facing
  79144. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79145. * @returns True is the vector "direction" is the same side than the plane normal.
  79146. */
  79147. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79148. /**
  79149. * Calculates the distance to a point
  79150. * @param point point to calculate distance to
  79151. * @returns the signed distance (float) from the given point to the Plane.
  79152. */
  79153. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79154. /**
  79155. * Creates a plane from an array
  79156. * @param array the array to create a plane from
  79157. * @returns a new Plane from the given array.
  79158. */
  79159. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79160. /**
  79161. * Creates a plane from three points
  79162. * @param point1 point used to create the plane
  79163. * @param point2 point used to create the plane
  79164. * @param point3 point used to create the plane
  79165. * @returns a new Plane defined by the three given points.
  79166. */
  79167. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79168. /**
  79169. * Creates a plane from an origin point and a normal
  79170. * @param origin origin of the plane to be constructed
  79171. * @param normal normal of the plane to be constructed
  79172. * @returns a new Plane the normal vector to this plane at the given origin point.
  79173. * Note : the vector "normal" is updated because normalized.
  79174. */
  79175. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79176. /**
  79177. * Calculates the distance from a plane and a point
  79178. * @param origin origin of the plane to be constructed
  79179. * @param normal normal of the plane to be constructed
  79180. * @param point point to calculate distance to
  79181. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79182. */
  79183. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79184. }
  79185. }
  79186. declare module BABYLON {
  79187. /**
  79188. * Class representing a vector containing 2 coordinates
  79189. */
  79190. export class Vector2 {
  79191. /** defines the first coordinate */
  79192. x: number;
  79193. /** defines the second coordinate */
  79194. y: number;
  79195. /**
  79196. * Creates a new Vector2 from the given x and y coordinates
  79197. * @param x defines the first coordinate
  79198. * @param y defines the second coordinate
  79199. */
  79200. constructor(
  79201. /** defines the first coordinate */
  79202. x?: number,
  79203. /** defines the second coordinate */
  79204. y?: number);
  79205. /**
  79206. * Gets a string with the Vector2 coordinates
  79207. * @returns a string with the Vector2 coordinates
  79208. */
  79209. toString(): string;
  79210. /**
  79211. * Gets class name
  79212. * @returns the string "Vector2"
  79213. */
  79214. getClassName(): string;
  79215. /**
  79216. * Gets current vector hash code
  79217. * @returns the Vector2 hash code as a number
  79218. */
  79219. getHashCode(): number;
  79220. /**
  79221. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  79222. * @param array defines the source array
  79223. * @param index defines the offset in source array
  79224. * @returns the current Vector2
  79225. */
  79226. toArray(array: FloatArray, index?: number): Vector2;
  79227. /**
  79228. * Copy the current vector to an array
  79229. * @returns a new array with 2 elements: the Vector2 coordinates.
  79230. */
  79231. asArray(): number[];
  79232. /**
  79233. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79234. * @param source defines the source Vector2
  79235. * @returns the current updated Vector2
  79236. */
  79237. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79238. /**
  79239. * Sets the Vector2 coordinates with the given floats
  79240. * @param x defines the first coordinate
  79241. * @param y defines the second coordinate
  79242. * @returns the current updated Vector2
  79243. */
  79244. copyFromFloats(x: number, y: number): Vector2;
  79245. /**
  79246. * Sets the Vector2 coordinates with the given floats
  79247. * @param x defines the first coordinate
  79248. * @param y defines the second coordinate
  79249. * @returns the current updated Vector2
  79250. */
  79251. set(x: number, y: number): Vector2;
  79252. /**
  79253. * Add another vector with the current one
  79254. * @param otherVector defines the other vector
  79255. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79256. */
  79257. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79258. /**
  79259. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79260. * @param otherVector defines the other vector
  79261. * @param result defines the target vector
  79262. * @returns the unmodified current Vector2
  79263. */
  79264. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79265. /**
  79266. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79267. * @param otherVector defines the other vector
  79268. * @returns the current updated Vector2
  79269. */
  79270. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79271. /**
  79272. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79273. * @param otherVector defines the other vector
  79274. * @returns a new Vector2
  79275. */
  79276. addVector3(otherVector: Vector3): Vector2;
  79277. /**
  79278. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79279. * @param otherVector defines the other vector
  79280. * @returns a new Vector2
  79281. */
  79282. subtract(otherVector: Vector2): Vector2;
  79283. /**
  79284. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79285. * @param otherVector defines the other vector
  79286. * @param result defines the target vector
  79287. * @returns the unmodified current Vector2
  79288. */
  79289. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79290. /**
  79291. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79292. * @param otherVector defines the other vector
  79293. * @returns the current updated Vector2
  79294. */
  79295. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79296. /**
  79297. * Multiplies in place the current Vector2 coordinates by the given ones
  79298. * @param otherVector defines the other vector
  79299. * @returns the current updated Vector2
  79300. */
  79301. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79302. /**
  79303. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79304. * @param otherVector defines the other vector
  79305. * @returns a new Vector2
  79306. */
  79307. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79308. /**
  79309. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79310. * @param otherVector defines the other vector
  79311. * @param result defines the target vector
  79312. * @returns the unmodified current Vector2
  79313. */
  79314. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79315. /**
  79316. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  79317. * @param x defines the first coordinate
  79318. * @param y defines the second coordinate
  79319. * @returns a new Vector2
  79320. */
  79321. multiplyByFloats(x: number, y: number): Vector2;
  79322. /**
  79323. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  79324. * @param otherVector defines the other vector
  79325. * @returns a new Vector2
  79326. */
  79327. divide(otherVector: Vector2): Vector2;
  79328. /**
  79329. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  79330. * @param otherVector defines the other vector
  79331. * @param result defines the target vector
  79332. * @returns the unmodified current Vector2
  79333. */
  79334. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79335. /**
  79336. * Divides the current Vector2 coordinates by the given ones
  79337. * @param otherVector defines the other vector
  79338. * @returns the current updated Vector2
  79339. */
  79340. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79341. /**
  79342. * Gets a new Vector2 with current Vector2 negated coordinates
  79343. * @returns a new Vector2
  79344. */
  79345. negate(): Vector2;
  79346. /**
  79347. * Negate this vector in place
  79348. * @returns this
  79349. */
  79350. negateInPlace(): Vector2;
  79351. /**
  79352. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  79353. * @param result defines the Vector3 object where to store the result
  79354. * @returns the current Vector2
  79355. */
  79356. negateToRef(result: Vector2): Vector2;
  79357. /**
  79358. * Multiply the Vector2 coordinates by scale
  79359. * @param scale defines the scaling factor
  79360. * @returns the current updated Vector2
  79361. */
  79362. scaleInPlace(scale: number): Vector2;
  79363. /**
  79364. * Returns a new Vector2 scaled by "scale" from the current Vector2
  79365. * @param scale defines the scaling factor
  79366. * @returns a new Vector2
  79367. */
  79368. scale(scale: number): Vector2;
  79369. /**
  79370. * Scale the current Vector2 values by a factor to a given Vector2
  79371. * @param scale defines the scale factor
  79372. * @param result defines the Vector2 object where to store the result
  79373. * @returns the unmodified current Vector2
  79374. */
  79375. scaleToRef(scale: number, result: Vector2): Vector2;
  79376. /**
  79377. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  79378. * @param scale defines the scale factor
  79379. * @param result defines the Vector2 object where to store the result
  79380. * @returns the unmodified current Vector2
  79381. */
  79382. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  79383. /**
  79384. * Gets a boolean if two vectors are equals
  79385. * @param otherVector defines the other vector
  79386. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  79387. */
  79388. equals(otherVector: DeepImmutable<Vector2>): boolean;
  79389. /**
  79390. * Gets a boolean if two vectors are equals (using an epsilon value)
  79391. * @param otherVector defines the other vector
  79392. * @param epsilon defines the minimal distance to consider equality
  79393. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  79394. */
  79395. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  79396. /**
  79397. * Gets a new Vector2 from current Vector2 floored values
  79398. * @returns a new Vector2
  79399. */
  79400. floor(): Vector2;
  79401. /**
  79402. * Gets a new Vector2 from current Vector2 floored values
  79403. * @returns a new Vector2
  79404. */
  79405. fract(): Vector2;
  79406. /**
  79407. * Gets the length of the vector
  79408. * @returns the vector length (float)
  79409. */
  79410. length(): number;
  79411. /**
  79412. * Gets the vector squared length
  79413. * @returns the vector squared length (float)
  79414. */
  79415. lengthSquared(): number;
  79416. /**
  79417. * Normalize the vector
  79418. * @returns the current updated Vector2
  79419. */
  79420. normalize(): Vector2;
  79421. /**
  79422. * Gets a new Vector2 copied from the Vector2
  79423. * @returns a new Vector2
  79424. */
  79425. clone(): Vector2;
  79426. /**
  79427. * Gets a new Vector2(0, 0)
  79428. * @returns a new Vector2
  79429. */
  79430. static Zero(): Vector2;
  79431. /**
  79432. * Gets a new Vector2(1, 1)
  79433. * @returns a new Vector2
  79434. */
  79435. static One(): Vector2;
  79436. /**
  79437. * Gets a new Vector2 set from the given index element of the given array
  79438. * @param array defines the data source
  79439. * @param offset defines the offset in the data source
  79440. * @returns a new Vector2
  79441. */
  79442. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  79443. /**
  79444. * Sets "result" from the given index element of the given array
  79445. * @param array defines the data source
  79446. * @param offset defines the offset in the data source
  79447. * @param result defines the target vector
  79448. */
  79449. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  79450. /**
  79451. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  79452. * @param value1 defines 1st point of control
  79453. * @param value2 defines 2nd point of control
  79454. * @param value3 defines 3rd point of control
  79455. * @param value4 defines 4th point of control
  79456. * @param amount defines the interpolation factor
  79457. * @returns a new Vector2
  79458. */
  79459. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  79460. /**
  79461. * 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".
  79462. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  79463. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  79464. * @param value defines the value to clamp
  79465. * @param min defines the lower limit
  79466. * @param max defines the upper limit
  79467. * @returns a new Vector2
  79468. */
  79469. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  79470. /**
  79471. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  79472. * @param value1 defines the 1st control point
  79473. * @param tangent1 defines the outgoing tangent
  79474. * @param value2 defines the 2nd control point
  79475. * @param tangent2 defines the incoming tangent
  79476. * @param amount defines the interpolation factor
  79477. * @returns a new Vector2
  79478. */
  79479. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  79480. /**
  79481. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  79482. * @param start defines the start vector
  79483. * @param end defines the end vector
  79484. * @param amount defines the interpolation factor
  79485. * @returns a new Vector2
  79486. */
  79487. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  79488. /**
  79489. * Gets the dot product of the vector "left" and the vector "right"
  79490. * @param left defines first vector
  79491. * @param right defines second vector
  79492. * @returns the dot product (float)
  79493. */
  79494. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  79495. /**
  79496. * Returns a new Vector2 equal to the normalized given vector
  79497. * @param vector defines the vector to normalize
  79498. * @returns a new Vector2
  79499. */
  79500. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  79501. /**
  79502. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  79503. * @param left defines 1st vector
  79504. * @param right defines 2nd vector
  79505. * @returns a new Vector2
  79506. */
  79507. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79508. /**
  79509. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  79510. * @param left defines 1st vector
  79511. * @param right defines 2nd vector
  79512. * @returns a new Vector2
  79513. */
  79514. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79515. /**
  79516. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  79517. * @param vector defines the vector to transform
  79518. * @param transformation defines the matrix to apply
  79519. * @returns a new Vector2
  79520. */
  79521. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  79522. /**
  79523. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  79524. * @param vector defines the vector to transform
  79525. * @param transformation defines the matrix to apply
  79526. * @param result defines the target vector
  79527. */
  79528. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  79529. /**
  79530. * Determines if a given vector is included in a triangle
  79531. * @param p defines the vector to test
  79532. * @param p0 defines 1st triangle point
  79533. * @param p1 defines 2nd triangle point
  79534. * @param p2 defines 3rd triangle point
  79535. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  79536. */
  79537. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  79538. /**
  79539. * Gets the distance between the vectors "value1" and "value2"
  79540. * @param value1 defines first vector
  79541. * @param value2 defines second vector
  79542. * @returns the distance between vectors
  79543. */
  79544. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79545. /**
  79546. * Returns the squared distance between the vectors "value1" and "value2"
  79547. * @param value1 defines first vector
  79548. * @param value2 defines second vector
  79549. * @returns the squared distance between vectors
  79550. */
  79551. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79552. /**
  79553. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  79554. * @param value1 defines first vector
  79555. * @param value2 defines second vector
  79556. * @returns a new Vector2
  79557. */
  79558. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  79559. /**
  79560. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  79561. * @param p defines the middle point
  79562. * @param segA defines one point of the segment
  79563. * @param segB defines the other point of the segment
  79564. * @returns the shortest distance
  79565. */
  79566. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  79567. }
  79568. /**
  79569. * Class used to store (x,y,z) vector representation
  79570. * A Vector3 is the main object used in 3D geometry
  79571. * It can represent etiher the coordinates of a point the space, either a direction
  79572. * Reminder: js uses a left handed forward facing system
  79573. */
  79574. export class Vector3 {
  79575. /**
  79576. * Defines the first coordinates (on X axis)
  79577. */
  79578. x: number;
  79579. /**
  79580. * Defines the second coordinates (on Y axis)
  79581. */
  79582. y: number;
  79583. /**
  79584. * Defines the third coordinates (on Z axis)
  79585. */
  79586. z: number;
  79587. private static _UpReadOnly;
  79588. private static _ZeroReadOnly;
  79589. /**
  79590. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  79591. * @param x defines the first coordinates (on X axis)
  79592. * @param y defines the second coordinates (on Y axis)
  79593. * @param z defines the third coordinates (on Z axis)
  79594. */
  79595. constructor(
  79596. /**
  79597. * Defines the first coordinates (on X axis)
  79598. */
  79599. x?: number,
  79600. /**
  79601. * Defines the second coordinates (on Y axis)
  79602. */
  79603. y?: number,
  79604. /**
  79605. * Defines the third coordinates (on Z axis)
  79606. */
  79607. z?: number);
  79608. /**
  79609. * Creates a string representation of the Vector3
  79610. * @returns a string with the Vector3 coordinates.
  79611. */
  79612. toString(): string;
  79613. /**
  79614. * Gets the class name
  79615. * @returns the string "Vector3"
  79616. */
  79617. getClassName(): string;
  79618. /**
  79619. * Creates the Vector3 hash code
  79620. * @returns a number which tends to be unique between Vector3 instances
  79621. */
  79622. getHashCode(): number;
  79623. /**
  79624. * Creates an array containing three elements : the coordinates of the Vector3
  79625. * @returns a new array of numbers
  79626. */
  79627. asArray(): number[];
  79628. /**
  79629. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  79630. * @param array defines the destination array
  79631. * @param index defines the offset in the destination array
  79632. * @returns the current Vector3
  79633. */
  79634. toArray(array: FloatArray, index?: number): Vector3;
  79635. /**
  79636. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  79637. * @returns a new Quaternion object, computed from the Vector3 coordinates
  79638. */
  79639. toQuaternion(): Quaternion;
  79640. /**
  79641. * Adds the given vector to the current Vector3
  79642. * @param otherVector defines the second operand
  79643. * @returns the current updated Vector3
  79644. */
  79645. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79646. /**
  79647. * Adds the given coordinates to the current Vector3
  79648. * @param x defines the x coordinate of the operand
  79649. * @param y defines the y coordinate of the operand
  79650. * @param z defines the z coordinate of the operand
  79651. * @returns the current updated Vector3
  79652. */
  79653. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79654. /**
  79655. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  79656. * @param otherVector defines the second operand
  79657. * @returns the resulting Vector3
  79658. */
  79659. add(otherVector: DeepImmutable<Vector3>): Vector3;
  79660. /**
  79661. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  79662. * @param otherVector defines the second operand
  79663. * @param result defines the Vector3 object where to store the result
  79664. * @returns the current Vector3
  79665. */
  79666. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79667. /**
  79668. * Subtract the given vector from the current Vector3
  79669. * @param otherVector defines the second operand
  79670. * @returns the current updated Vector3
  79671. */
  79672. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79673. /**
  79674. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  79675. * @param otherVector defines the second operand
  79676. * @returns the resulting Vector3
  79677. */
  79678. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  79679. /**
  79680. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  79681. * @param otherVector defines the second operand
  79682. * @param result defines the Vector3 object where to store the result
  79683. * @returns the current Vector3
  79684. */
  79685. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79686. /**
  79687. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  79688. * @param x defines the x coordinate of the operand
  79689. * @param y defines the y coordinate of the operand
  79690. * @param z defines the z coordinate of the operand
  79691. * @returns the resulting Vector3
  79692. */
  79693. subtractFromFloats(x: number, y: number, z: number): Vector3;
  79694. /**
  79695. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  79696. * @param x defines the x coordinate of the operand
  79697. * @param y defines the y coordinate of the operand
  79698. * @param z defines the z coordinate of the operand
  79699. * @param result defines the Vector3 object where to store the result
  79700. * @returns the current Vector3
  79701. */
  79702. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  79703. /**
  79704. * Gets a new Vector3 set with the current Vector3 negated coordinates
  79705. * @returns a new Vector3
  79706. */
  79707. negate(): Vector3;
  79708. /**
  79709. * Negate this vector in place
  79710. * @returns this
  79711. */
  79712. negateInPlace(): Vector3;
  79713. /**
  79714. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  79715. * @param result defines the Vector3 object where to store the result
  79716. * @returns the current Vector3
  79717. */
  79718. negateToRef(result: Vector3): Vector3;
  79719. /**
  79720. * Multiplies the Vector3 coordinates by the float "scale"
  79721. * @param scale defines the multiplier factor
  79722. * @returns the current updated Vector3
  79723. */
  79724. scaleInPlace(scale: number): Vector3;
  79725. /**
  79726. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  79727. * @param scale defines the multiplier factor
  79728. * @returns a new Vector3
  79729. */
  79730. scale(scale: number): Vector3;
  79731. /**
  79732. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  79733. * @param scale defines the multiplier factor
  79734. * @param result defines the Vector3 object where to store the result
  79735. * @returns the current Vector3
  79736. */
  79737. scaleToRef(scale: number, result: Vector3): Vector3;
  79738. /**
  79739. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  79740. * @param scale defines the scale factor
  79741. * @param result defines the Vector3 object where to store the result
  79742. * @returns the unmodified current Vector3
  79743. */
  79744. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  79745. /**
  79746. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79747. * @param origin defines the origin of the projection ray
  79748. * @param plane defines the plane to project to
  79749. * @returns the projected vector3
  79750. */
  79751. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  79752. /**
  79753. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79754. * @param origin defines the origin of the projection ray
  79755. * @param plane defines the plane to project to
  79756. * @param result defines the Vector3 where to store the result
  79757. */
  79758. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  79759. /**
  79760. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  79761. * @param otherVector defines the second operand
  79762. * @returns true if both vectors are equals
  79763. */
  79764. equals(otherVector: DeepImmutable<Vector3>): boolean;
  79765. /**
  79766. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  79767. * @param otherVector defines the second operand
  79768. * @param epsilon defines the minimal distance to define values as equals
  79769. * @returns true if both vectors are distant less than epsilon
  79770. */
  79771. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  79772. /**
  79773. * Returns true if the current Vector3 coordinates equals the given floats
  79774. * @param x defines the x coordinate of the operand
  79775. * @param y defines the y coordinate of the operand
  79776. * @param z defines the z coordinate of the operand
  79777. * @returns true if both vectors are equals
  79778. */
  79779. equalsToFloats(x: number, y: number, z: number): boolean;
  79780. /**
  79781. * Multiplies the current Vector3 coordinates by the given ones
  79782. * @param otherVector defines the second operand
  79783. * @returns the current updated Vector3
  79784. */
  79785. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79786. /**
  79787. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  79788. * @param otherVector defines the second operand
  79789. * @returns the new Vector3
  79790. */
  79791. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  79792. /**
  79793. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  79794. * @param otherVector defines the second operand
  79795. * @param result defines the Vector3 object where to store the result
  79796. * @returns the current Vector3
  79797. */
  79798. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79799. /**
  79800. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  79801. * @param x defines the x coordinate of the operand
  79802. * @param y defines the y coordinate of the operand
  79803. * @param z defines the z coordinate of the operand
  79804. * @returns the new Vector3
  79805. */
  79806. multiplyByFloats(x: number, y: number, z: number): Vector3;
  79807. /**
  79808. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  79809. * @param otherVector defines the second operand
  79810. * @returns the new Vector3
  79811. */
  79812. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  79813. /**
  79814. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  79815. * @param otherVector defines the second operand
  79816. * @param result defines the Vector3 object where to store the result
  79817. * @returns the current Vector3
  79818. */
  79819. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79820. /**
  79821. * Divides the current Vector3 coordinates by the given ones.
  79822. * @param otherVector defines the second operand
  79823. * @returns the current updated Vector3
  79824. */
  79825. divideInPlace(otherVector: Vector3): Vector3;
  79826. /**
  79827. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  79828. * @param other defines the second operand
  79829. * @returns the current updated Vector3
  79830. */
  79831. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79832. /**
  79833. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  79834. * @param other defines the second operand
  79835. * @returns the current updated Vector3
  79836. */
  79837. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79838. /**
  79839. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  79840. * @param x defines the x coordinate of the operand
  79841. * @param y defines the y coordinate of the operand
  79842. * @param z defines the z coordinate of the operand
  79843. * @returns the current updated Vector3
  79844. */
  79845. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79846. /**
  79847. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  79848. * @param x defines the x coordinate of the operand
  79849. * @param y defines the y coordinate of the operand
  79850. * @param z defines the z coordinate of the operand
  79851. * @returns the current updated Vector3
  79852. */
  79853. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79854. /**
  79855. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  79856. * Check if is non uniform within a certain amount of decimal places to account for this
  79857. * @param epsilon the amount the values can differ
  79858. * @returns if the the vector is non uniform to a certain number of decimal places
  79859. */
  79860. isNonUniformWithinEpsilon(epsilon: number): boolean;
  79861. /**
  79862. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  79863. */
  79864. get isNonUniform(): boolean;
  79865. /**
  79866. * Gets a new Vector3 from current Vector3 floored values
  79867. * @returns a new Vector3
  79868. */
  79869. floor(): Vector3;
  79870. /**
  79871. * Gets a new Vector3 from current Vector3 floored values
  79872. * @returns a new Vector3
  79873. */
  79874. fract(): Vector3;
  79875. /**
  79876. * Gets the length of the Vector3
  79877. * @returns the length of the Vector3
  79878. */
  79879. length(): number;
  79880. /**
  79881. * Gets the squared length of the Vector3
  79882. * @returns squared length of the Vector3
  79883. */
  79884. lengthSquared(): number;
  79885. /**
  79886. * Normalize the current Vector3.
  79887. * Please note that this is an in place operation.
  79888. * @returns the current updated Vector3
  79889. */
  79890. normalize(): Vector3;
  79891. /**
  79892. * Reorders the x y z properties of the vector in place
  79893. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  79894. * @returns the current updated vector
  79895. */
  79896. reorderInPlace(order: string): this;
  79897. /**
  79898. * Rotates the vector around 0,0,0 by a quaternion
  79899. * @param quaternion the rotation quaternion
  79900. * @param result vector to store the result
  79901. * @returns the resulting vector
  79902. */
  79903. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  79904. /**
  79905. * Rotates a vector around a given point
  79906. * @param quaternion the rotation quaternion
  79907. * @param point the point to rotate around
  79908. * @param result vector to store the result
  79909. * @returns the resulting vector
  79910. */
  79911. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  79912. /**
  79913. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  79914. * The cross product is then orthogonal to both current and "other"
  79915. * @param other defines the right operand
  79916. * @returns the cross product
  79917. */
  79918. cross(other: Vector3): Vector3;
  79919. /**
  79920. * Normalize the current Vector3 with the given input length.
  79921. * Please note that this is an in place operation.
  79922. * @param len the length of the vector
  79923. * @returns the current updated Vector3
  79924. */
  79925. normalizeFromLength(len: number): Vector3;
  79926. /**
  79927. * Normalize the current Vector3 to a new vector
  79928. * @returns the new Vector3
  79929. */
  79930. normalizeToNew(): Vector3;
  79931. /**
  79932. * Normalize the current Vector3 to the reference
  79933. * @param reference define the Vector3 to update
  79934. * @returns the updated Vector3
  79935. */
  79936. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  79937. /**
  79938. * Creates a new Vector3 copied from the current Vector3
  79939. * @returns the new Vector3
  79940. */
  79941. clone(): Vector3;
  79942. /**
  79943. * Copies the given vector coordinates to the current Vector3 ones
  79944. * @param source defines the source Vector3
  79945. * @returns the current updated Vector3
  79946. */
  79947. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  79948. /**
  79949. * Copies the given floats to the current Vector3 coordinates
  79950. * @param x defines the x coordinate of the operand
  79951. * @param y defines the y coordinate of the operand
  79952. * @param z defines the z coordinate of the operand
  79953. * @returns the current updated Vector3
  79954. */
  79955. copyFromFloats(x: number, y: number, z: number): Vector3;
  79956. /**
  79957. * Copies the given floats to the current Vector3 coordinates
  79958. * @param x defines the x coordinate of the operand
  79959. * @param y defines the y coordinate of the operand
  79960. * @param z defines the z coordinate of the operand
  79961. * @returns the current updated Vector3
  79962. */
  79963. set(x: number, y: number, z: number): Vector3;
  79964. /**
  79965. * Copies the given float to the current Vector3 coordinates
  79966. * @param v defines the x, y and z coordinates of the operand
  79967. * @returns the current updated Vector3
  79968. */
  79969. setAll(v: number): Vector3;
  79970. /**
  79971. * Get the clip factor between two vectors
  79972. * @param vector0 defines the first operand
  79973. * @param vector1 defines the second operand
  79974. * @param axis defines the axis to use
  79975. * @param size defines the size along the axis
  79976. * @returns the clip factor
  79977. */
  79978. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  79979. /**
  79980. * Get angle between two vectors
  79981. * @param vector0 angle between vector0 and vector1
  79982. * @param vector1 angle between vector0 and vector1
  79983. * @param normal direction of the normal
  79984. * @return the angle between vector0 and vector1
  79985. */
  79986. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  79987. /**
  79988. * Returns a new Vector3 set from the index "offset" of the given array
  79989. * @param array defines the source array
  79990. * @param offset defines the offset in the source array
  79991. * @returns the new Vector3
  79992. */
  79993. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  79994. /**
  79995. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  79996. * @param array defines the source array
  79997. * @param offset defines the offset in the source array
  79998. * @returns the new Vector3
  79999. * @deprecated Please use FromArray instead.
  80000. */
  80001. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  80002. /**
  80003. * Sets the given vector "result" with the element values from the index "offset" of the given array
  80004. * @param array defines the source array
  80005. * @param offset defines the offset in the source array
  80006. * @param result defines the Vector3 where to store the result
  80007. */
  80008. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  80009. /**
  80010. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  80011. * @param array defines the source array
  80012. * @param offset defines the offset in the source array
  80013. * @param result defines the Vector3 where to store the result
  80014. * @deprecated Please use FromArrayToRef instead.
  80015. */
  80016. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  80017. /**
  80018. * Sets the given vector "result" with the given floats.
  80019. * @param x defines the x coordinate of the source
  80020. * @param y defines the y coordinate of the source
  80021. * @param z defines the z coordinate of the source
  80022. * @param result defines the Vector3 where to store the result
  80023. */
  80024. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  80025. /**
  80026. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  80027. * @returns a new empty Vector3
  80028. */
  80029. static Zero(): Vector3;
  80030. /**
  80031. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  80032. * @returns a new unit Vector3
  80033. */
  80034. static One(): Vector3;
  80035. /**
  80036. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  80037. * @returns a new up Vector3
  80038. */
  80039. static Up(): Vector3;
  80040. /**
  80041. * Gets a up Vector3 that must not be updated
  80042. */
  80043. static get UpReadOnly(): DeepImmutable<Vector3>;
  80044. /**
  80045. * Gets a zero Vector3 that must not be updated
  80046. */
  80047. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  80048. /**
  80049. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  80050. * @returns a new down Vector3
  80051. */
  80052. static Down(): Vector3;
  80053. /**
  80054. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  80055. * @param rightHandedSystem is the scene right-handed (negative z)
  80056. * @returns a new forward Vector3
  80057. */
  80058. static Forward(rightHandedSystem?: boolean): Vector3;
  80059. /**
  80060. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  80061. * @param rightHandedSystem is the scene right-handed (negative-z)
  80062. * @returns a new forward Vector3
  80063. */
  80064. static Backward(rightHandedSystem?: boolean): Vector3;
  80065. /**
  80066. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  80067. * @returns a new right Vector3
  80068. */
  80069. static Right(): Vector3;
  80070. /**
  80071. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  80072. * @returns a new left Vector3
  80073. */
  80074. static Left(): Vector3;
  80075. /**
  80076. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  80077. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80078. * @param vector defines the Vector3 to transform
  80079. * @param transformation defines the transformation matrix
  80080. * @returns the transformed Vector3
  80081. */
  80082. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80083. /**
  80084. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  80085. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80086. * @param vector defines the Vector3 to transform
  80087. * @param transformation defines the transformation matrix
  80088. * @param result defines the Vector3 where to store the result
  80089. */
  80090. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80091. /**
  80092. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  80093. * This method computes tranformed coordinates only, not transformed direction vectors
  80094. * @param x define the x coordinate of the source vector
  80095. * @param y define the y coordinate of the source vector
  80096. * @param z define the z coordinate of the source vector
  80097. * @param transformation defines the transformation matrix
  80098. * @param result defines the Vector3 where to store the result
  80099. */
  80100. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80101. /**
  80102. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  80103. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80104. * @param vector defines the Vector3 to transform
  80105. * @param transformation defines the transformation matrix
  80106. * @returns the new Vector3
  80107. */
  80108. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80109. /**
  80110. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  80111. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80112. * @param vector defines the Vector3 to transform
  80113. * @param transformation defines the transformation matrix
  80114. * @param result defines the Vector3 where to store the result
  80115. */
  80116. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80117. /**
  80118. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  80119. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80120. * @param x define the x coordinate of the source vector
  80121. * @param y define the y coordinate of the source vector
  80122. * @param z define the z coordinate of the source vector
  80123. * @param transformation defines the transformation matrix
  80124. * @param result defines the Vector3 where to store the result
  80125. */
  80126. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80127. /**
  80128. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  80129. * @param value1 defines the first control point
  80130. * @param value2 defines the second control point
  80131. * @param value3 defines the third control point
  80132. * @param value4 defines the fourth control point
  80133. * @param amount defines the amount on the spline to use
  80134. * @returns the new Vector3
  80135. */
  80136. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  80137. /**
  80138. * 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"
  80139. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80140. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80141. * @param value defines the current value
  80142. * @param min defines the lower range value
  80143. * @param max defines the upper range value
  80144. * @returns the new Vector3
  80145. */
  80146. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  80147. /**
  80148. * 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"
  80149. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80150. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80151. * @param value defines the current value
  80152. * @param min defines the lower range value
  80153. * @param max defines the upper range value
  80154. * @param result defines the Vector3 where to store the result
  80155. */
  80156. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  80157. /**
  80158. * Checks if a given vector is inside a specific range
  80159. * @param v defines the vector to test
  80160. * @param min defines the minimum range
  80161. * @param max defines the maximum range
  80162. */
  80163. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  80164. /**
  80165. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  80166. * @param value1 defines the first control point
  80167. * @param tangent1 defines the first tangent vector
  80168. * @param value2 defines the second control point
  80169. * @param tangent2 defines the second tangent vector
  80170. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  80171. * @returns the new Vector3
  80172. */
  80173. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  80174. /**
  80175. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  80176. * @param start defines the start value
  80177. * @param end defines the end value
  80178. * @param amount max defines amount between both (between 0 and 1)
  80179. * @returns the new Vector3
  80180. */
  80181. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  80182. /**
  80183. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  80184. * @param start defines the start value
  80185. * @param end defines the end value
  80186. * @param amount max defines amount between both (between 0 and 1)
  80187. * @param result defines the Vector3 where to store the result
  80188. */
  80189. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  80190. /**
  80191. * Returns the dot product (float) between the vectors "left" and "right"
  80192. * @param left defines the left operand
  80193. * @param right defines the right operand
  80194. * @returns the dot product
  80195. */
  80196. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  80197. /**
  80198. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  80199. * The cross product is then orthogonal to both "left" and "right"
  80200. * @param left defines the left operand
  80201. * @param right defines the right operand
  80202. * @returns the cross product
  80203. */
  80204. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80205. /**
  80206. * Sets the given vector "result" with the cross product of "left" and "right"
  80207. * The cross product is then orthogonal to both "left" and "right"
  80208. * @param left defines the left operand
  80209. * @param right defines the right operand
  80210. * @param result defines the Vector3 where to store the result
  80211. */
  80212. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  80213. /**
  80214. * Returns a new Vector3 as the normalization of the given vector
  80215. * @param vector defines the Vector3 to normalize
  80216. * @returns the new Vector3
  80217. */
  80218. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  80219. /**
  80220. * Sets the given vector "result" with the normalization of the given first vector
  80221. * @param vector defines the Vector3 to normalize
  80222. * @param result defines the Vector3 where to store the result
  80223. */
  80224. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  80225. /**
  80226. * Project a Vector3 onto screen space
  80227. * @param vector defines the Vector3 to project
  80228. * @param world defines the world matrix to use
  80229. * @param transform defines the transform (view x projection) matrix to use
  80230. * @param viewport defines the screen viewport to use
  80231. * @returns the new Vector3
  80232. */
  80233. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80234. /** @hidden */
  80235. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80236. /**
  80237. * Unproject from screen space to object space
  80238. * @param source defines the screen space Vector3 to use
  80239. * @param viewportWidth defines the current width of the viewport
  80240. * @param viewportHeight defines the current height of the viewport
  80241. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80242. * @param transform defines the transform (view x projection) matrix to use
  80243. * @returns the new Vector3
  80244. */
  80245. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80246. /**
  80247. * Unproject from screen space to object space
  80248. * @param source defines the screen space Vector3 to use
  80249. * @param viewportWidth defines the current width of the viewport
  80250. * @param viewportHeight defines the current height of the viewport
  80251. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80252. * @param view defines the view matrix to use
  80253. * @param projection defines the projection matrix to use
  80254. * @returns the new Vector3
  80255. */
  80256. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80257. /**
  80258. * Unproject from screen space to object space
  80259. * @param source defines the screen space Vector3 to use
  80260. * @param viewportWidth defines the current width of the viewport
  80261. * @param viewportHeight defines the current height of the viewport
  80262. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80263. * @param view defines the view matrix to use
  80264. * @param projection defines the projection matrix to use
  80265. * @param result defines the Vector3 where to store the result
  80266. */
  80267. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80268. /**
  80269. * Unproject from screen space to object space
  80270. * @param sourceX defines the screen space x coordinate to use
  80271. * @param sourceY defines the screen space y coordinate to use
  80272. * @param sourceZ defines the screen space z coordinate to use
  80273. * @param viewportWidth defines the current width of the viewport
  80274. * @param viewportHeight defines the current height of the viewport
  80275. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80276. * @param view defines the view matrix to use
  80277. * @param projection defines the projection matrix to use
  80278. * @param result defines the Vector3 where to store the result
  80279. */
  80280. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80281. /**
  80282. * Gets the minimal coordinate values between two Vector3
  80283. * @param left defines the first operand
  80284. * @param right defines the second operand
  80285. * @returns the new Vector3
  80286. */
  80287. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80288. /**
  80289. * Gets the maximal coordinate values between two Vector3
  80290. * @param left defines the first operand
  80291. * @param right defines the second operand
  80292. * @returns the new Vector3
  80293. */
  80294. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80295. /**
  80296. * Returns the distance between the vectors "value1" and "value2"
  80297. * @param value1 defines the first operand
  80298. * @param value2 defines the second operand
  80299. * @returns the distance
  80300. */
  80301. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80302. /**
  80303. * Returns the squared distance between the vectors "value1" and "value2"
  80304. * @param value1 defines the first operand
  80305. * @param value2 defines the second operand
  80306. * @returns the squared distance
  80307. */
  80308. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80309. /**
  80310. * Returns a new Vector3 located at the center between "value1" and "value2"
  80311. * @param value1 defines the first operand
  80312. * @param value2 defines the second operand
  80313. * @returns the new Vector3
  80314. */
  80315. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80316. /**
  80317. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80318. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80319. * to something in order to rotate it from its local system to the given target system
  80320. * Note: axis1, axis2 and axis3 are normalized during this operation
  80321. * @param axis1 defines the first axis
  80322. * @param axis2 defines the second axis
  80323. * @param axis3 defines the third axis
  80324. * @returns a new Vector3
  80325. */
  80326. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  80327. /**
  80328. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  80329. * @param axis1 defines the first axis
  80330. * @param axis2 defines the second axis
  80331. * @param axis3 defines the third axis
  80332. * @param ref defines the Vector3 where to store the result
  80333. */
  80334. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  80335. }
  80336. /**
  80337. * Vector4 class created for EulerAngle class conversion to Quaternion
  80338. */
  80339. export class Vector4 {
  80340. /** x value of the vector */
  80341. x: number;
  80342. /** y value of the vector */
  80343. y: number;
  80344. /** z value of the vector */
  80345. z: number;
  80346. /** w value of the vector */
  80347. w: number;
  80348. /**
  80349. * Creates a Vector4 object from the given floats.
  80350. * @param x x value of the vector
  80351. * @param y y value of the vector
  80352. * @param z z value of the vector
  80353. * @param w w value of the vector
  80354. */
  80355. constructor(
  80356. /** x value of the vector */
  80357. x: number,
  80358. /** y value of the vector */
  80359. y: number,
  80360. /** z value of the vector */
  80361. z: number,
  80362. /** w value of the vector */
  80363. w: number);
  80364. /**
  80365. * Returns the string with the Vector4 coordinates.
  80366. * @returns a string containing all the vector values
  80367. */
  80368. toString(): string;
  80369. /**
  80370. * Returns the string "Vector4".
  80371. * @returns "Vector4"
  80372. */
  80373. getClassName(): string;
  80374. /**
  80375. * Returns the Vector4 hash code.
  80376. * @returns a unique hash code
  80377. */
  80378. getHashCode(): number;
  80379. /**
  80380. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  80381. * @returns the resulting array
  80382. */
  80383. asArray(): number[];
  80384. /**
  80385. * Populates the given array from the given index with the Vector4 coordinates.
  80386. * @param array array to populate
  80387. * @param index index of the array to start at (default: 0)
  80388. * @returns the Vector4.
  80389. */
  80390. toArray(array: FloatArray, index?: number): Vector4;
  80391. /**
  80392. * Adds the given vector to the current Vector4.
  80393. * @param otherVector the vector to add
  80394. * @returns the updated Vector4.
  80395. */
  80396. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80397. /**
  80398. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  80399. * @param otherVector the vector to add
  80400. * @returns the resulting vector
  80401. */
  80402. add(otherVector: DeepImmutable<Vector4>): Vector4;
  80403. /**
  80404. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  80405. * @param otherVector the vector to add
  80406. * @param result the vector to store the result
  80407. * @returns the current Vector4.
  80408. */
  80409. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80410. /**
  80411. * Subtract in place the given vector from the current Vector4.
  80412. * @param otherVector the vector to subtract
  80413. * @returns the updated Vector4.
  80414. */
  80415. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80416. /**
  80417. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  80418. * @param otherVector the vector to add
  80419. * @returns the new vector with the result
  80420. */
  80421. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  80422. /**
  80423. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  80424. * @param otherVector the vector to subtract
  80425. * @param result the vector to store the result
  80426. * @returns the current Vector4.
  80427. */
  80428. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80429. /**
  80430. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80431. */
  80432. /**
  80433. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80434. * @param x value to subtract
  80435. * @param y value to subtract
  80436. * @param z value to subtract
  80437. * @param w value to subtract
  80438. * @returns new vector containing the result
  80439. */
  80440. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80441. /**
  80442. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80443. * @param x value to subtract
  80444. * @param y value to subtract
  80445. * @param z value to subtract
  80446. * @param w value to subtract
  80447. * @param result the vector to store the result in
  80448. * @returns the current Vector4.
  80449. */
  80450. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  80451. /**
  80452. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  80453. * @returns a new vector with the negated values
  80454. */
  80455. negate(): Vector4;
  80456. /**
  80457. * Negate this vector in place
  80458. * @returns this
  80459. */
  80460. negateInPlace(): Vector4;
  80461. /**
  80462. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  80463. * @param result defines the Vector3 object where to store the result
  80464. * @returns the current Vector4
  80465. */
  80466. negateToRef(result: Vector4): Vector4;
  80467. /**
  80468. * Multiplies the current Vector4 coordinates by scale (float).
  80469. * @param scale the number to scale with
  80470. * @returns the updated Vector4.
  80471. */
  80472. scaleInPlace(scale: number): Vector4;
  80473. /**
  80474. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  80475. * @param scale the number to scale with
  80476. * @returns a new vector with the result
  80477. */
  80478. scale(scale: number): Vector4;
  80479. /**
  80480. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  80481. * @param scale the number to scale with
  80482. * @param result a vector to store the result in
  80483. * @returns the current Vector4.
  80484. */
  80485. scaleToRef(scale: number, result: Vector4): Vector4;
  80486. /**
  80487. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  80488. * @param scale defines the scale factor
  80489. * @param result defines the Vector4 object where to store the result
  80490. * @returns the unmodified current Vector4
  80491. */
  80492. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  80493. /**
  80494. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  80495. * @param otherVector the vector to compare against
  80496. * @returns true if they are equal
  80497. */
  80498. equals(otherVector: DeepImmutable<Vector4>): boolean;
  80499. /**
  80500. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  80501. * @param otherVector vector to compare against
  80502. * @param epsilon (Default: very small number)
  80503. * @returns true if they are equal
  80504. */
  80505. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  80506. /**
  80507. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  80508. * @param x x value to compare against
  80509. * @param y y value to compare against
  80510. * @param z z value to compare against
  80511. * @param w w value to compare against
  80512. * @returns true if equal
  80513. */
  80514. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  80515. /**
  80516. * Multiplies in place the current Vector4 by the given one.
  80517. * @param otherVector vector to multiple with
  80518. * @returns the updated Vector4.
  80519. */
  80520. multiplyInPlace(otherVector: Vector4): Vector4;
  80521. /**
  80522. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  80523. * @param otherVector vector to multiple with
  80524. * @returns resulting new vector
  80525. */
  80526. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  80527. /**
  80528. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  80529. * @param otherVector vector to multiple with
  80530. * @param result vector to store the result
  80531. * @returns the current Vector4.
  80532. */
  80533. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80534. /**
  80535. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  80536. * @param x x value multiply with
  80537. * @param y y value multiply with
  80538. * @param z z value multiply with
  80539. * @param w w value multiply with
  80540. * @returns resulting new vector
  80541. */
  80542. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  80543. /**
  80544. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  80545. * @param otherVector vector to devide with
  80546. * @returns resulting new vector
  80547. */
  80548. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  80549. /**
  80550. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  80551. * @param otherVector vector to devide with
  80552. * @param result vector to store the result
  80553. * @returns the current Vector4.
  80554. */
  80555. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80556. /**
  80557. * Divides the current Vector3 coordinates by the given ones.
  80558. * @param otherVector vector to devide with
  80559. * @returns the updated Vector3.
  80560. */
  80561. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80562. /**
  80563. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  80564. * @param other defines the second operand
  80565. * @returns the current updated Vector4
  80566. */
  80567. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80568. /**
  80569. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  80570. * @param other defines the second operand
  80571. * @returns the current updated Vector4
  80572. */
  80573. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80574. /**
  80575. * Gets a new Vector4 from current Vector4 floored values
  80576. * @returns a new Vector4
  80577. */
  80578. floor(): Vector4;
  80579. /**
  80580. * Gets a new Vector4 from current Vector3 floored values
  80581. * @returns a new Vector4
  80582. */
  80583. fract(): Vector4;
  80584. /**
  80585. * Returns the Vector4 length (float).
  80586. * @returns the length
  80587. */
  80588. length(): number;
  80589. /**
  80590. * Returns the Vector4 squared length (float).
  80591. * @returns the length squared
  80592. */
  80593. lengthSquared(): number;
  80594. /**
  80595. * Normalizes in place the Vector4.
  80596. * @returns the updated Vector4.
  80597. */
  80598. normalize(): Vector4;
  80599. /**
  80600. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  80601. * @returns this converted to a new vector3
  80602. */
  80603. toVector3(): Vector3;
  80604. /**
  80605. * Returns a new Vector4 copied from the current one.
  80606. * @returns the new cloned vector
  80607. */
  80608. clone(): Vector4;
  80609. /**
  80610. * Updates the current Vector4 with the given one coordinates.
  80611. * @param source the source vector to copy from
  80612. * @returns the updated Vector4.
  80613. */
  80614. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  80615. /**
  80616. * Updates the current Vector4 coordinates with the given floats.
  80617. * @param x float to copy from
  80618. * @param y float to copy from
  80619. * @param z float to copy from
  80620. * @param w float to copy from
  80621. * @returns the updated Vector4.
  80622. */
  80623. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80624. /**
  80625. * Updates the current Vector4 coordinates with the given floats.
  80626. * @param x float to set from
  80627. * @param y float to set from
  80628. * @param z float to set from
  80629. * @param w float to set from
  80630. * @returns the updated Vector4.
  80631. */
  80632. set(x: number, y: number, z: number, w: number): Vector4;
  80633. /**
  80634. * Copies the given float to the current Vector3 coordinates
  80635. * @param v defines the x, y, z and w coordinates of the operand
  80636. * @returns the current updated Vector3
  80637. */
  80638. setAll(v: number): Vector4;
  80639. /**
  80640. * Returns a new Vector4 set from the starting index of the given array.
  80641. * @param array the array to pull values from
  80642. * @param offset the offset into the array to start at
  80643. * @returns the new vector
  80644. */
  80645. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  80646. /**
  80647. * Updates the given vector "result" from the starting index of the given array.
  80648. * @param array the array to pull values from
  80649. * @param offset the offset into the array to start at
  80650. * @param result the vector to store the result in
  80651. */
  80652. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  80653. /**
  80654. * Updates the given vector "result" from the starting index of the given Float32Array.
  80655. * @param array the array to pull values from
  80656. * @param offset the offset into the array to start at
  80657. * @param result the vector to store the result in
  80658. */
  80659. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  80660. /**
  80661. * Updates the given vector "result" coordinates from the given floats.
  80662. * @param x float to set from
  80663. * @param y float to set from
  80664. * @param z float to set from
  80665. * @param w float to set from
  80666. * @param result the vector to the floats in
  80667. */
  80668. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  80669. /**
  80670. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  80671. * @returns the new vector
  80672. */
  80673. static Zero(): Vector4;
  80674. /**
  80675. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  80676. * @returns the new vector
  80677. */
  80678. static One(): Vector4;
  80679. /**
  80680. * Returns a new normalized Vector4 from the given one.
  80681. * @param vector the vector to normalize
  80682. * @returns the vector
  80683. */
  80684. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  80685. /**
  80686. * Updates the given vector "result" from the normalization of the given one.
  80687. * @param vector the vector to normalize
  80688. * @param result the vector to store the result in
  80689. */
  80690. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  80691. /**
  80692. * Returns a vector with the minimum values from the left and right vectors
  80693. * @param left left vector to minimize
  80694. * @param right right vector to minimize
  80695. * @returns a new vector with the minimum of the left and right vector values
  80696. */
  80697. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80698. /**
  80699. * Returns a vector with the maximum values from the left and right vectors
  80700. * @param left left vector to maximize
  80701. * @param right right vector to maximize
  80702. * @returns a new vector with the maximum of the left and right vector values
  80703. */
  80704. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80705. /**
  80706. * Returns the distance (float) between the vectors "value1" and "value2".
  80707. * @param value1 value to calulate the distance between
  80708. * @param value2 value to calulate the distance between
  80709. * @return the distance between the two vectors
  80710. */
  80711. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80712. /**
  80713. * Returns the squared distance (float) between the vectors "value1" and "value2".
  80714. * @param value1 value to calulate the distance between
  80715. * @param value2 value to calulate the distance between
  80716. * @return the distance between the two vectors squared
  80717. */
  80718. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80719. /**
  80720. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  80721. * @param value1 value to calulate the center between
  80722. * @param value2 value to calulate the center between
  80723. * @return the center between the two vectors
  80724. */
  80725. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  80726. /**
  80727. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  80728. * This methods computes transformed normalized direction vectors only.
  80729. * @param vector the vector to transform
  80730. * @param transformation the transformation matrix to apply
  80731. * @returns the new vector
  80732. */
  80733. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  80734. /**
  80735. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  80736. * This methods computes transformed normalized direction vectors only.
  80737. * @param vector the vector to transform
  80738. * @param transformation the transformation matrix to apply
  80739. * @param result the vector to store the result in
  80740. */
  80741. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80742. /**
  80743. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  80744. * This methods computes transformed normalized direction vectors only.
  80745. * @param x value to transform
  80746. * @param y value to transform
  80747. * @param z value to transform
  80748. * @param w value to transform
  80749. * @param transformation the transformation matrix to apply
  80750. * @param result the vector to store the results in
  80751. */
  80752. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80753. /**
  80754. * Creates a new Vector4 from a Vector3
  80755. * @param source defines the source data
  80756. * @param w defines the 4th component (default is 0)
  80757. * @returns a new Vector4
  80758. */
  80759. static FromVector3(source: Vector3, w?: number): Vector4;
  80760. }
  80761. /**
  80762. * Class used to store quaternion data
  80763. * @see https://en.wikipedia.org/wiki/Quaternion
  80764. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  80765. */
  80766. export class Quaternion {
  80767. /** defines the first component (0 by default) */
  80768. x: number;
  80769. /** defines the second component (0 by default) */
  80770. y: number;
  80771. /** defines the third component (0 by default) */
  80772. z: number;
  80773. /** defines the fourth component (1.0 by default) */
  80774. w: number;
  80775. /**
  80776. * Creates a new Quaternion from the given floats
  80777. * @param x defines the first component (0 by default)
  80778. * @param y defines the second component (0 by default)
  80779. * @param z defines the third component (0 by default)
  80780. * @param w defines the fourth component (1.0 by default)
  80781. */
  80782. constructor(
  80783. /** defines the first component (0 by default) */
  80784. x?: number,
  80785. /** defines the second component (0 by default) */
  80786. y?: number,
  80787. /** defines the third component (0 by default) */
  80788. z?: number,
  80789. /** defines the fourth component (1.0 by default) */
  80790. w?: number);
  80791. /**
  80792. * Gets a string representation for the current quaternion
  80793. * @returns a string with the Quaternion coordinates
  80794. */
  80795. toString(): string;
  80796. /**
  80797. * Gets the class name of the quaternion
  80798. * @returns the string "Quaternion"
  80799. */
  80800. getClassName(): string;
  80801. /**
  80802. * Gets a hash code for this quaternion
  80803. * @returns the quaternion hash code
  80804. */
  80805. getHashCode(): number;
  80806. /**
  80807. * Copy the quaternion to an array
  80808. * @returns a new array populated with 4 elements from the quaternion coordinates
  80809. */
  80810. asArray(): number[];
  80811. /**
  80812. * Check if two quaternions are equals
  80813. * @param otherQuaternion defines the second operand
  80814. * @return true if the current quaternion and the given one coordinates are strictly equals
  80815. */
  80816. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  80817. /**
  80818. * Gets a boolean if two quaternions are equals (using an epsilon value)
  80819. * @param otherQuaternion defines the other quaternion
  80820. * @param epsilon defines the minimal distance to consider equality
  80821. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  80822. */
  80823. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  80824. /**
  80825. * Clone the current quaternion
  80826. * @returns a new quaternion copied from the current one
  80827. */
  80828. clone(): Quaternion;
  80829. /**
  80830. * Copy a quaternion to the current one
  80831. * @param other defines the other quaternion
  80832. * @returns the updated current quaternion
  80833. */
  80834. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  80835. /**
  80836. * Updates the current quaternion with the given float coordinates
  80837. * @param x defines the x coordinate
  80838. * @param y defines the y coordinate
  80839. * @param z defines the z coordinate
  80840. * @param w defines the w coordinate
  80841. * @returns the updated current quaternion
  80842. */
  80843. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  80844. /**
  80845. * Updates the current quaternion from the given float coordinates
  80846. * @param x defines the x coordinate
  80847. * @param y defines the y coordinate
  80848. * @param z defines the z coordinate
  80849. * @param w defines the w coordinate
  80850. * @returns the updated current quaternion
  80851. */
  80852. set(x: number, y: number, z: number, w: number): Quaternion;
  80853. /**
  80854. * Adds two quaternions
  80855. * @param other defines the second operand
  80856. * @returns a new quaternion as the addition result of the given one and the current quaternion
  80857. */
  80858. add(other: DeepImmutable<Quaternion>): Quaternion;
  80859. /**
  80860. * Add a quaternion to the current one
  80861. * @param other defines the quaternion to add
  80862. * @returns the current quaternion
  80863. */
  80864. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  80865. /**
  80866. * Subtract two quaternions
  80867. * @param other defines the second operand
  80868. * @returns a new quaternion as the subtraction result of the given one from the current one
  80869. */
  80870. subtract(other: Quaternion): Quaternion;
  80871. /**
  80872. * Multiplies the current quaternion by a scale factor
  80873. * @param value defines the scale factor
  80874. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  80875. */
  80876. scale(value: number): Quaternion;
  80877. /**
  80878. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  80879. * @param scale defines the scale factor
  80880. * @param result defines the Quaternion object where to store the result
  80881. * @returns the unmodified current quaternion
  80882. */
  80883. scaleToRef(scale: number, result: Quaternion): Quaternion;
  80884. /**
  80885. * Multiplies in place the current quaternion by a scale factor
  80886. * @param value defines the scale factor
  80887. * @returns the current modified quaternion
  80888. */
  80889. scaleInPlace(value: number): Quaternion;
  80890. /**
  80891. * Scale the current quaternion values by a factor and add the result to a given quaternion
  80892. * @param scale defines the scale factor
  80893. * @param result defines the Quaternion object where to store the result
  80894. * @returns the unmodified current quaternion
  80895. */
  80896. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  80897. /**
  80898. * Multiplies two quaternions
  80899. * @param q1 defines the second operand
  80900. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  80901. */
  80902. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  80903. /**
  80904. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  80905. * @param q1 defines the second operand
  80906. * @param result defines the target quaternion
  80907. * @returns the current quaternion
  80908. */
  80909. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  80910. /**
  80911. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  80912. * @param q1 defines the second operand
  80913. * @returns the currentupdated quaternion
  80914. */
  80915. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  80916. /**
  80917. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  80918. * @param ref defines the target quaternion
  80919. * @returns the current quaternion
  80920. */
  80921. conjugateToRef(ref: Quaternion): Quaternion;
  80922. /**
  80923. * Conjugates in place (1-q) the current quaternion
  80924. * @returns the current updated quaternion
  80925. */
  80926. conjugateInPlace(): Quaternion;
  80927. /**
  80928. * Conjugates in place (1-q) the current quaternion
  80929. * @returns a new quaternion
  80930. */
  80931. conjugate(): Quaternion;
  80932. /**
  80933. * Gets length of current quaternion
  80934. * @returns the quaternion length (float)
  80935. */
  80936. length(): number;
  80937. /**
  80938. * Normalize in place the current quaternion
  80939. * @returns the current updated quaternion
  80940. */
  80941. normalize(): Quaternion;
  80942. /**
  80943. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  80944. * @param order is a reserved parameter and is ignore for now
  80945. * @returns a new Vector3 containing the Euler angles
  80946. */
  80947. toEulerAngles(order?: string): Vector3;
  80948. /**
  80949. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  80950. * @param result defines the vector which will be filled with the Euler angles
  80951. * @param order is a reserved parameter and is ignore for now
  80952. * @returns the current unchanged quaternion
  80953. */
  80954. toEulerAnglesToRef(result: Vector3): Quaternion;
  80955. /**
  80956. * Updates the given rotation matrix with the current quaternion values
  80957. * @param result defines the target matrix
  80958. * @returns the current unchanged quaternion
  80959. */
  80960. toRotationMatrix(result: Matrix): Quaternion;
  80961. /**
  80962. * Updates the current quaternion from the given rotation matrix values
  80963. * @param matrix defines the source matrix
  80964. * @returns the current updated quaternion
  80965. */
  80966. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  80967. /**
  80968. * Creates a new quaternion from a rotation matrix
  80969. * @param matrix defines the source matrix
  80970. * @returns a new quaternion created from the given rotation matrix values
  80971. */
  80972. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  80973. /**
  80974. * Updates the given quaternion with the given rotation matrix values
  80975. * @param matrix defines the source matrix
  80976. * @param result defines the target quaternion
  80977. */
  80978. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  80979. /**
  80980. * Returns the dot product (float) between the quaternions "left" and "right"
  80981. * @param left defines the left operand
  80982. * @param right defines the right operand
  80983. * @returns the dot product
  80984. */
  80985. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  80986. /**
  80987. * Checks if the two quaternions are close to each other
  80988. * @param quat0 defines the first quaternion to check
  80989. * @param quat1 defines the second quaternion to check
  80990. * @returns true if the two quaternions are close to each other
  80991. */
  80992. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  80993. /**
  80994. * Creates an empty quaternion
  80995. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  80996. */
  80997. static Zero(): Quaternion;
  80998. /**
  80999. * Inverse a given quaternion
  81000. * @param q defines the source quaternion
  81001. * @returns a new quaternion as the inverted current quaternion
  81002. */
  81003. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  81004. /**
  81005. * Inverse a given quaternion
  81006. * @param q defines the source quaternion
  81007. * @param result the quaternion the result will be stored in
  81008. * @returns the result quaternion
  81009. */
  81010. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  81011. /**
  81012. * Creates an identity quaternion
  81013. * @returns the identity quaternion
  81014. */
  81015. static Identity(): Quaternion;
  81016. /**
  81017. * Gets a boolean indicating if the given quaternion is identity
  81018. * @param quaternion defines the quaternion to check
  81019. * @returns true if the quaternion is identity
  81020. */
  81021. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  81022. /**
  81023. * Creates a quaternion from a rotation around an axis
  81024. * @param axis defines the axis to use
  81025. * @param angle defines the angle to use
  81026. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  81027. */
  81028. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  81029. /**
  81030. * Creates a rotation around an axis and stores it into the given quaternion
  81031. * @param axis defines the axis to use
  81032. * @param angle defines the angle to use
  81033. * @param result defines the target quaternion
  81034. * @returns the target quaternion
  81035. */
  81036. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  81037. /**
  81038. * Creates a new quaternion from data stored into an array
  81039. * @param array defines the data source
  81040. * @param offset defines the offset in the source array where the data starts
  81041. * @returns a new quaternion
  81042. */
  81043. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  81044. /**
  81045. * Updates the given quaternion "result" from the starting index of the given array.
  81046. * @param array the array to pull values from
  81047. * @param offset the offset into the array to start at
  81048. * @param result the quaternion to store the result in
  81049. */
  81050. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  81051. /**
  81052. * Create a quaternion from Euler rotation angles
  81053. * @param x Pitch
  81054. * @param y Yaw
  81055. * @param z Roll
  81056. * @returns the new Quaternion
  81057. */
  81058. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  81059. /**
  81060. * Updates a quaternion from Euler rotation angles
  81061. * @param x Pitch
  81062. * @param y Yaw
  81063. * @param z Roll
  81064. * @param result the quaternion to store the result
  81065. * @returns the updated quaternion
  81066. */
  81067. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  81068. /**
  81069. * Create a quaternion from Euler rotation vector
  81070. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81071. * @returns the new Quaternion
  81072. */
  81073. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  81074. /**
  81075. * Updates a quaternion from Euler rotation vector
  81076. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81077. * @param result the quaternion to store the result
  81078. * @returns the updated quaternion
  81079. */
  81080. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  81081. /**
  81082. * Creates a new quaternion from the given Euler float angles (y, x, z)
  81083. * @param yaw defines the rotation around Y axis
  81084. * @param pitch defines the rotation around X axis
  81085. * @param roll defines the rotation around Z axis
  81086. * @returns the new quaternion
  81087. */
  81088. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  81089. /**
  81090. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  81091. * @param yaw defines the rotation around Y axis
  81092. * @param pitch defines the rotation around X axis
  81093. * @param roll defines the rotation around Z axis
  81094. * @param result defines the target quaternion
  81095. */
  81096. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  81097. /**
  81098. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  81099. * @param alpha defines the rotation around first axis
  81100. * @param beta defines the rotation around second axis
  81101. * @param gamma defines the rotation around third axis
  81102. * @returns the new quaternion
  81103. */
  81104. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  81105. /**
  81106. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  81107. * @param alpha defines the rotation around first axis
  81108. * @param beta defines the rotation around second axis
  81109. * @param gamma defines the rotation around third axis
  81110. * @param result defines the target quaternion
  81111. */
  81112. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  81113. /**
  81114. * 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)
  81115. * @param axis1 defines the first axis
  81116. * @param axis2 defines the second axis
  81117. * @param axis3 defines the third axis
  81118. * @returns the new quaternion
  81119. */
  81120. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  81121. /**
  81122. * 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
  81123. * @param axis1 defines the first axis
  81124. * @param axis2 defines the second axis
  81125. * @param axis3 defines the third axis
  81126. * @param ref defines the target quaternion
  81127. */
  81128. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  81129. /**
  81130. * Interpolates between two quaternions
  81131. * @param left defines first quaternion
  81132. * @param right defines second quaternion
  81133. * @param amount defines the gradient to use
  81134. * @returns the new interpolated quaternion
  81135. */
  81136. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81137. /**
  81138. * Interpolates between two quaternions and stores it into a target quaternion
  81139. * @param left defines first quaternion
  81140. * @param right defines second quaternion
  81141. * @param amount defines the gradient to use
  81142. * @param result defines the target quaternion
  81143. */
  81144. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  81145. /**
  81146. * Interpolate between two quaternions using Hermite interpolation
  81147. * @param value1 defines first quaternion
  81148. * @param tangent1 defines the incoming tangent
  81149. * @param value2 defines second quaternion
  81150. * @param tangent2 defines the outgoing tangent
  81151. * @param amount defines the target quaternion
  81152. * @returns the new interpolated quaternion
  81153. */
  81154. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81155. }
  81156. /**
  81157. * Class used to store matrix data (4x4)
  81158. */
  81159. export class Matrix {
  81160. private static _updateFlagSeed;
  81161. private static _identityReadOnly;
  81162. private _isIdentity;
  81163. private _isIdentityDirty;
  81164. private _isIdentity3x2;
  81165. private _isIdentity3x2Dirty;
  81166. /**
  81167. * Gets the update flag of the matrix which is an unique number for the matrix.
  81168. * It will be incremented every time the matrix data change.
  81169. * You can use it to speed the comparison between two versions of the same matrix.
  81170. */
  81171. updateFlag: number;
  81172. private readonly _m;
  81173. /**
  81174. * Gets the internal data of the matrix
  81175. */
  81176. get m(): DeepImmutable<Float32Array>;
  81177. /** @hidden */
  81178. _markAsUpdated(): void;
  81179. /** @hidden */
  81180. private _updateIdentityStatus;
  81181. /**
  81182. * Creates an empty matrix (filled with zeros)
  81183. */
  81184. constructor();
  81185. /**
  81186. * Check if the current matrix is identity
  81187. * @returns true is the matrix is the identity matrix
  81188. */
  81189. isIdentity(): boolean;
  81190. /**
  81191. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  81192. * @returns true is the matrix is the identity matrix
  81193. */
  81194. isIdentityAs3x2(): boolean;
  81195. /**
  81196. * Gets the determinant of the matrix
  81197. * @returns the matrix determinant
  81198. */
  81199. determinant(): number;
  81200. /**
  81201. * Returns the matrix as a Float32Array
  81202. * @returns the matrix underlying array
  81203. */
  81204. toArray(): DeepImmutable<Float32Array>;
  81205. /**
  81206. * Returns the matrix as a Float32Array
  81207. * @returns the matrix underlying array.
  81208. */
  81209. asArray(): DeepImmutable<Float32Array>;
  81210. /**
  81211. * Inverts the current matrix in place
  81212. * @returns the current inverted matrix
  81213. */
  81214. invert(): Matrix;
  81215. /**
  81216. * Sets all the matrix elements to zero
  81217. * @returns the current matrix
  81218. */
  81219. reset(): Matrix;
  81220. /**
  81221. * Adds the current matrix with a second one
  81222. * @param other defines the matrix to add
  81223. * @returns a new matrix as the addition of the current matrix and the given one
  81224. */
  81225. add(other: DeepImmutable<Matrix>): Matrix;
  81226. /**
  81227. * Sets the given matrix "result" to the addition of the current matrix and the given one
  81228. * @param other defines the matrix to add
  81229. * @param result defines the target matrix
  81230. * @returns the current matrix
  81231. */
  81232. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81233. /**
  81234. * Adds in place the given matrix to the current matrix
  81235. * @param other defines the second operand
  81236. * @returns the current updated matrix
  81237. */
  81238. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81239. /**
  81240. * Sets the given matrix to the current inverted Matrix
  81241. * @param other defines the target matrix
  81242. * @returns the unmodified current matrix
  81243. */
  81244. invertToRef(other: Matrix): Matrix;
  81245. /**
  81246. * add a value at the specified position in the current Matrix
  81247. * @param index the index of the value within the matrix. between 0 and 15.
  81248. * @param value the value to be added
  81249. * @returns the current updated matrix
  81250. */
  81251. addAtIndex(index: number, value: number): Matrix;
  81252. /**
  81253. * mutiply the specified position in the current Matrix by a value
  81254. * @param index the index of the value within the matrix. between 0 and 15.
  81255. * @param value the value to be added
  81256. * @returns the current updated matrix
  81257. */
  81258. multiplyAtIndex(index: number, value: number): Matrix;
  81259. /**
  81260. * Inserts the translation vector (using 3 floats) in the current matrix
  81261. * @param x defines the 1st component of the translation
  81262. * @param y defines the 2nd component of the translation
  81263. * @param z defines the 3rd component of the translation
  81264. * @returns the current updated matrix
  81265. */
  81266. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81267. /**
  81268. * Adds the translation vector (using 3 floats) in the current matrix
  81269. * @param x defines the 1st component of the translation
  81270. * @param y defines the 2nd component of the translation
  81271. * @param z defines the 3rd component of the translation
  81272. * @returns the current updated matrix
  81273. */
  81274. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81275. /**
  81276. * Inserts the translation vector in the current matrix
  81277. * @param vector3 defines the translation to insert
  81278. * @returns the current updated matrix
  81279. */
  81280. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81281. /**
  81282. * Gets the translation value of the current matrix
  81283. * @returns a new Vector3 as the extracted translation from the matrix
  81284. */
  81285. getTranslation(): Vector3;
  81286. /**
  81287. * Fill a Vector3 with the extracted translation from the matrix
  81288. * @param result defines the Vector3 where to store the translation
  81289. * @returns the current matrix
  81290. */
  81291. getTranslationToRef(result: Vector3): Matrix;
  81292. /**
  81293. * Remove rotation and scaling part from the matrix
  81294. * @returns the updated matrix
  81295. */
  81296. removeRotationAndScaling(): Matrix;
  81297. /**
  81298. * Multiply two matrices
  81299. * @param other defines the second operand
  81300. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81301. */
  81302. multiply(other: DeepImmutable<Matrix>): Matrix;
  81303. /**
  81304. * Copy the current matrix from the given one
  81305. * @param other defines the source matrix
  81306. * @returns the current updated matrix
  81307. */
  81308. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81309. /**
  81310. * Populates the given array from the starting index with the current matrix values
  81311. * @param array defines the target array
  81312. * @param offset defines the offset in the target array where to start storing values
  81313. * @returns the current matrix
  81314. */
  81315. copyToArray(array: Float32Array, offset?: number): Matrix;
  81316. /**
  81317. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  81318. * @param other defines the second operand
  81319. * @param result defines the matrix where to store the multiplication
  81320. * @returns the current matrix
  81321. */
  81322. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81323. /**
  81324. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  81325. * @param other defines the second operand
  81326. * @param result defines the array where to store the multiplication
  81327. * @param offset defines the offset in the target array where to start storing values
  81328. * @returns the current matrix
  81329. */
  81330. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  81331. /**
  81332. * Check equality between this matrix and a second one
  81333. * @param value defines the second matrix to compare
  81334. * @returns true is the current matrix and the given one values are strictly equal
  81335. */
  81336. equals(value: DeepImmutable<Matrix>): boolean;
  81337. /**
  81338. * Clone the current matrix
  81339. * @returns a new matrix from the current matrix
  81340. */
  81341. clone(): Matrix;
  81342. /**
  81343. * Returns the name of the current matrix class
  81344. * @returns the string "Matrix"
  81345. */
  81346. getClassName(): string;
  81347. /**
  81348. * Gets the hash code of the current matrix
  81349. * @returns the hash code
  81350. */
  81351. getHashCode(): number;
  81352. /**
  81353. * Decomposes the current Matrix into a translation, rotation and scaling components
  81354. * @param scale defines the scale vector3 given as a reference to update
  81355. * @param rotation defines the rotation quaternion given as a reference to update
  81356. * @param translation defines the translation vector3 given as a reference to update
  81357. * @returns true if operation was successful
  81358. */
  81359. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  81360. /**
  81361. * Gets specific row of the matrix
  81362. * @param index defines the number of the row to get
  81363. * @returns the index-th row of the current matrix as a new Vector4
  81364. */
  81365. getRow(index: number): Nullable<Vector4>;
  81366. /**
  81367. * Sets the index-th row of the current matrix to the vector4 values
  81368. * @param index defines the number of the row to set
  81369. * @param row defines the target vector4
  81370. * @returns the updated current matrix
  81371. */
  81372. setRow(index: number, row: Vector4): Matrix;
  81373. /**
  81374. * Compute the transpose of the matrix
  81375. * @returns the new transposed matrix
  81376. */
  81377. transpose(): Matrix;
  81378. /**
  81379. * Compute the transpose of the matrix and store it in a given matrix
  81380. * @param result defines the target matrix
  81381. * @returns the current matrix
  81382. */
  81383. transposeToRef(result: Matrix): Matrix;
  81384. /**
  81385. * Sets the index-th row of the current matrix with the given 4 x float values
  81386. * @param index defines the row index
  81387. * @param x defines the x component to set
  81388. * @param y defines the y component to set
  81389. * @param z defines the z component to set
  81390. * @param w defines the w component to set
  81391. * @returns the updated current matrix
  81392. */
  81393. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  81394. /**
  81395. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  81396. * @param scale defines the scale factor
  81397. * @returns a new matrix
  81398. */
  81399. scale(scale: number): Matrix;
  81400. /**
  81401. * Scale the current matrix values by a factor to a given result matrix
  81402. * @param scale defines the scale factor
  81403. * @param result defines the matrix to store the result
  81404. * @returns the current matrix
  81405. */
  81406. scaleToRef(scale: number, result: Matrix): Matrix;
  81407. /**
  81408. * Scale the current matrix values by a factor and add the result to a given matrix
  81409. * @param scale defines the scale factor
  81410. * @param result defines the Matrix to store the result
  81411. * @returns the current matrix
  81412. */
  81413. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  81414. /**
  81415. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  81416. * @param ref matrix to store the result
  81417. */
  81418. toNormalMatrix(ref: Matrix): void;
  81419. /**
  81420. * Gets only rotation part of the current matrix
  81421. * @returns a new matrix sets to the extracted rotation matrix from the current one
  81422. */
  81423. getRotationMatrix(): Matrix;
  81424. /**
  81425. * Extracts the rotation matrix from the current one and sets it as the given "result"
  81426. * @param result defines the target matrix to store data to
  81427. * @returns the current matrix
  81428. */
  81429. getRotationMatrixToRef(result: Matrix): Matrix;
  81430. /**
  81431. * Toggles model matrix from being right handed to left handed in place and vice versa
  81432. */
  81433. toggleModelMatrixHandInPlace(): void;
  81434. /**
  81435. * Toggles projection matrix from being right handed to left handed in place and vice versa
  81436. */
  81437. toggleProjectionMatrixHandInPlace(): void;
  81438. /**
  81439. * Creates a matrix from an array
  81440. * @param array defines the source array
  81441. * @param offset defines an offset in the source array
  81442. * @returns a new Matrix set from the starting index of the given array
  81443. */
  81444. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  81445. /**
  81446. * Copy the content of an array into a given matrix
  81447. * @param array defines the source array
  81448. * @param offset defines an offset in the source array
  81449. * @param result defines the target matrix
  81450. */
  81451. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  81452. /**
  81453. * Stores an array into a matrix after having multiplied each component by a given factor
  81454. * @param array defines the source array
  81455. * @param offset defines the offset in the source array
  81456. * @param scale defines the scaling factor
  81457. * @param result defines the target matrix
  81458. */
  81459. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  81460. /**
  81461. * Gets an identity matrix that must not be updated
  81462. */
  81463. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  81464. /**
  81465. * Stores a list of values (16) inside a given matrix
  81466. * @param initialM11 defines 1st value of 1st row
  81467. * @param initialM12 defines 2nd value of 1st row
  81468. * @param initialM13 defines 3rd value of 1st row
  81469. * @param initialM14 defines 4th value of 1st row
  81470. * @param initialM21 defines 1st value of 2nd row
  81471. * @param initialM22 defines 2nd value of 2nd row
  81472. * @param initialM23 defines 3rd value of 2nd row
  81473. * @param initialM24 defines 4th value of 2nd row
  81474. * @param initialM31 defines 1st value of 3rd row
  81475. * @param initialM32 defines 2nd value of 3rd row
  81476. * @param initialM33 defines 3rd value of 3rd row
  81477. * @param initialM34 defines 4th value of 3rd row
  81478. * @param initialM41 defines 1st value of 4th row
  81479. * @param initialM42 defines 2nd value of 4th row
  81480. * @param initialM43 defines 3rd value of 4th row
  81481. * @param initialM44 defines 4th value of 4th row
  81482. * @param result defines the target matrix
  81483. */
  81484. 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;
  81485. /**
  81486. * Creates new matrix from a list of values (16)
  81487. * @param initialM11 defines 1st value of 1st row
  81488. * @param initialM12 defines 2nd value of 1st row
  81489. * @param initialM13 defines 3rd value of 1st row
  81490. * @param initialM14 defines 4th value of 1st row
  81491. * @param initialM21 defines 1st value of 2nd row
  81492. * @param initialM22 defines 2nd value of 2nd row
  81493. * @param initialM23 defines 3rd value of 2nd row
  81494. * @param initialM24 defines 4th value of 2nd row
  81495. * @param initialM31 defines 1st value of 3rd row
  81496. * @param initialM32 defines 2nd value of 3rd row
  81497. * @param initialM33 defines 3rd value of 3rd row
  81498. * @param initialM34 defines 4th value of 3rd row
  81499. * @param initialM41 defines 1st value of 4th row
  81500. * @param initialM42 defines 2nd value of 4th row
  81501. * @param initialM43 defines 3rd value of 4th row
  81502. * @param initialM44 defines 4th value of 4th row
  81503. * @returns the new matrix
  81504. */
  81505. 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;
  81506. /**
  81507. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81508. * @param scale defines the scale vector3
  81509. * @param rotation defines the rotation quaternion
  81510. * @param translation defines the translation vector3
  81511. * @returns a new matrix
  81512. */
  81513. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  81514. /**
  81515. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81516. * @param scale defines the scale vector3
  81517. * @param rotation defines the rotation quaternion
  81518. * @param translation defines the translation vector3
  81519. * @param result defines the target matrix
  81520. */
  81521. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  81522. /**
  81523. * Creates a new identity matrix
  81524. * @returns a new identity matrix
  81525. */
  81526. static Identity(): Matrix;
  81527. /**
  81528. * Creates a new identity matrix and stores the result in a given matrix
  81529. * @param result defines the target matrix
  81530. */
  81531. static IdentityToRef(result: Matrix): void;
  81532. /**
  81533. * Creates a new zero matrix
  81534. * @returns a new zero matrix
  81535. */
  81536. static Zero(): Matrix;
  81537. /**
  81538. * Creates a new rotation matrix for "angle" radians around the X axis
  81539. * @param angle defines the angle (in radians) to use
  81540. * @return the new matrix
  81541. */
  81542. static RotationX(angle: number): Matrix;
  81543. /**
  81544. * Creates a new matrix as the invert of a given matrix
  81545. * @param source defines the source matrix
  81546. * @returns the new matrix
  81547. */
  81548. static Invert(source: DeepImmutable<Matrix>): Matrix;
  81549. /**
  81550. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  81551. * @param angle defines the angle (in radians) to use
  81552. * @param result defines the target matrix
  81553. */
  81554. static RotationXToRef(angle: number, result: Matrix): void;
  81555. /**
  81556. * Creates a new rotation matrix for "angle" radians around the Y axis
  81557. * @param angle defines the angle (in radians) to use
  81558. * @return the new matrix
  81559. */
  81560. static RotationY(angle: number): Matrix;
  81561. /**
  81562. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  81563. * @param angle defines the angle (in radians) to use
  81564. * @param result defines the target matrix
  81565. */
  81566. static RotationYToRef(angle: number, result: Matrix): void;
  81567. /**
  81568. * Creates a new rotation matrix for "angle" radians around the Z axis
  81569. * @param angle defines the angle (in radians) to use
  81570. * @return the new matrix
  81571. */
  81572. static RotationZ(angle: number): Matrix;
  81573. /**
  81574. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  81575. * @param angle defines the angle (in radians) to use
  81576. * @param result defines the target matrix
  81577. */
  81578. static RotationZToRef(angle: number, result: Matrix): void;
  81579. /**
  81580. * Creates a new rotation matrix for "angle" radians around the given axis
  81581. * @param axis defines the axis to use
  81582. * @param angle defines the angle (in radians) to use
  81583. * @return the new matrix
  81584. */
  81585. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  81586. /**
  81587. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  81588. * @param axis defines the axis to use
  81589. * @param angle defines the angle (in radians) to use
  81590. * @param result defines the target matrix
  81591. */
  81592. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  81593. /**
  81594. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  81595. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  81596. * @param from defines the vector to align
  81597. * @param to defines the vector to align to
  81598. * @param result defines the target matrix
  81599. */
  81600. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  81601. /**
  81602. * Creates a rotation matrix
  81603. * @param yaw defines the yaw angle in radians (Y axis)
  81604. * @param pitch defines the pitch angle in radians (X axis)
  81605. * @param roll defines the roll angle in radians (X axis)
  81606. * @returns the new rotation matrix
  81607. */
  81608. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  81609. /**
  81610. * Creates a rotation matrix and stores it in a given matrix
  81611. * @param yaw defines the yaw angle in radians (Y axis)
  81612. * @param pitch defines the pitch angle in radians (X axis)
  81613. * @param roll defines the roll angle in radians (X axis)
  81614. * @param result defines the target matrix
  81615. */
  81616. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  81617. /**
  81618. * Creates a scaling matrix
  81619. * @param x defines the scale factor on X axis
  81620. * @param y defines the scale factor on Y axis
  81621. * @param z defines the scale factor on Z axis
  81622. * @returns the new matrix
  81623. */
  81624. static Scaling(x: number, y: number, z: number): Matrix;
  81625. /**
  81626. * Creates a scaling matrix and stores it in a given matrix
  81627. * @param x defines the scale factor on X axis
  81628. * @param y defines the scale factor on Y axis
  81629. * @param z defines the scale factor on Z axis
  81630. * @param result defines the target matrix
  81631. */
  81632. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  81633. /**
  81634. * Creates a translation matrix
  81635. * @param x defines the translation on X axis
  81636. * @param y defines the translation on Y axis
  81637. * @param z defines the translationon Z axis
  81638. * @returns the new matrix
  81639. */
  81640. static Translation(x: number, y: number, z: number): Matrix;
  81641. /**
  81642. * Creates a translation matrix and stores it in a given matrix
  81643. * @param x defines the translation on X axis
  81644. * @param y defines the translation on Y axis
  81645. * @param z defines the translationon Z axis
  81646. * @param result defines the target matrix
  81647. */
  81648. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  81649. /**
  81650. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81651. * @param startValue defines the start value
  81652. * @param endValue defines the end value
  81653. * @param gradient defines the gradient factor
  81654. * @returns the new matrix
  81655. */
  81656. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81657. /**
  81658. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81659. * @param startValue defines the start value
  81660. * @param endValue defines the end value
  81661. * @param gradient defines the gradient factor
  81662. * @param result defines the Matrix object where to store data
  81663. */
  81664. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81665. /**
  81666. * Builds a new matrix whose values are computed by:
  81667. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81668. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81669. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81670. * @param startValue defines the first matrix
  81671. * @param endValue defines the second matrix
  81672. * @param gradient defines the gradient between the two matrices
  81673. * @returns the new matrix
  81674. */
  81675. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81676. /**
  81677. * Update a matrix to values which are computed by:
  81678. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81679. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81680. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81681. * @param startValue defines the first matrix
  81682. * @param endValue defines the second matrix
  81683. * @param gradient defines the gradient between the two matrices
  81684. * @param result defines the target matrix
  81685. */
  81686. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81687. /**
  81688. * 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"
  81689. * This function works in left handed mode
  81690. * @param eye defines the final position of the entity
  81691. * @param target defines where the entity should look at
  81692. * @param up defines the up vector for the entity
  81693. * @returns the new matrix
  81694. */
  81695. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81696. /**
  81697. * 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".
  81698. * This function works in left handed mode
  81699. * @param eye defines the final position of the entity
  81700. * @param target defines where the entity should look at
  81701. * @param up defines the up vector for the entity
  81702. * @param result defines the target matrix
  81703. */
  81704. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81705. /**
  81706. * 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"
  81707. * This function works in right handed mode
  81708. * @param eye defines the final position of the entity
  81709. * @param target defines where the entity should look at
  81710. * @param up defines the up vector for the entity
  81711. * @returns the new matrix
  81712. */
  81713. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81714. /**
  81715. * 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".
  81716. * This function works in right handed mode
  81717. * @param eye defines the final position of the entity
  81718. * @param target defines where the entity should look at
  81719. * @param up defines the up vector for the entity
  81720. * @param result defines the target matrix
  81721. */
  81722. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81723. /**
  81724. * Create a left-handed orthographic projection matrix
  81725. * @param width defines the viewport width
  81726. * @param height defines the viewport height
  81727. * @param znear defines the near clip plane
  81728. * @param zfar defines the far clip plane
  81729. * @returns a new matrix as a left-handed orthographic projection matrix
  81730. */
  81731. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81732. /**
  81733. * Store a left-handed orthographic projection to a given matrix
  81734. * @param width defines the viewport width
  81735. * @param height defines the viewport height
  81736. * @param znear defines the near clip plane
  81737. * @param zfar defines the far clip plane
  81738. * @param result defines the target matrix
  81739. */
  81740. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  81741. /**
  81742. * Create a left-handed orthographic projection matrix
  81743. * @param left defines the viewport left coordinate
  81744. * @param right defines the viewport right coordinate
  81745. * @param bottom defines the viewport bottom coordinate
  81746. * @param top defines the viewport top coordinate
  81747. * @param znear defines the near clip plane
  81748. * @param zfar defines the far clip plane
  81749. * @returns a new matrix as a left-handed orthographic projection matrix
  81750. */
  81751. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81752. /**
  81753. * Stores a left-handed orthographic projection into a given matrix
  81754. * @param left defines the viewport left coordinate
  81755. * @param right defines the viewport right coordinate
  81756. * @param bottom defines the viewport bottom coordinate
  81757. * @param top defines the viewport top coordinate
  81758. * @param znear defines the near clip plane
  81759. * @param zfar defines the far clip plane
  81760. * @param result defines the target matrix
  81761. */
  81762. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81763. /**
  81764. * Creates a right-handed orthographic projection matrix
  81765. * @param left defines the viewport left coordinate
  81766. * @param right defines the viewport right coordinate
  81767. * @param bottom defines the viewport bottom coordinate
  81768. * @param top defines the viewport top coordinate
  81769. * @param znear defines the near clip plane
  81770. * @param zfar defines the far clip plane
  81771. * @returns a new matrix as a right-handed orthographic projection matrix
  81772. */
  81773. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81774. /**
  81775. * Stores a right-handed orthographic projection into a given matrix
  81776. * @param left defines the viewport left coordinate
  81777. * @param right defines the viewport right coordinate
  81778. * @param bottom defines the viewport bottom coordinate
  81779. * @param top defines the viewport top coordinate
  81780. * @param znear defines the near clip plane
  81781. * @param zfar defines the far clip plane
  81782. * @param result defines the target matrix
  81783. */
  81784. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81785. /**
  81786. * Creates a left-handed perspective projection matrix
  81787. * @param width defines the viewport width
  81788. * @param height defines the viewport height
  81789. * @param znear defines the near clip plane
  81790. * @param zfar defines the far clip plane
  81791. * @returns a new matrix as a left-handed perspective projection matrix
  81792. */
  81793. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81794. /**
  81795. * Creates a left-handed perspective projection matrix
  81796. * @param fov defines the horizontal field of view
  81797. * @param aspect defines the aspect ratio
  81798. * @param znear defines the near clip plane
  81799. * @param zfar defines the far clip plane
  81800. * @returns a new matrix as a left-handed perspective projection matrix
  81801. */
  81802. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81803. /**
  81804. * Stores a left-handed perspective projection into a given matrix
  81805. * @param fov defines the horizontal field of view
  81806. * @param aspect defines the aspect ratio
  81807. * @param znear defines the near clip plane
  81808. * @param zfar defines the far clip plane
  81809. * @param result defines the target matrix
  81810. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81811. */
  81812. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81813. /**
  81814. * Stores a left-handed perspective projection into a given matrix with depth reversed
  81815. * @param fov defines the horizontal field of view
  81816. * @param aspect defines the aspect ratio
  81817. * @param znear defines the near clip plane
  81818. * @param zfar not used as infinity is used as far clip
  81819. * @param result defines the target matrix
  81820. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81821. */
  81822. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81823. /**
  81824. * Creates a right-handed perspective projection matrix
  81825. * @param fov defines the horizontal field of view
  81826. * @param aspect defines the aspect ratio
  81827. * @param znear defines the near clip plane
  81828. * @param zfar defines the far clip plane
  81829. * @returns a new matrix as a right-handed perspective projection matrix
  81830. */
  81831. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81832. /**
  81833. * Stores a right-handed perspective projection into a given matrix
  81834. * @param fov defines the horizontal field of view
  81835. * @param aspect defines the aspect ratio
  81836. * @param znear defines the near clip plane
  81837. * @param zfar defines the far clip plane
  81838. * @param result defines the target matrix
  81839. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81840. */
  81841. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81842. /**
  81843. * Stores a right-handed perspective projection into a given matrix
  81844. * @param fov defines the horizontal field of view
  81845. * @param aspect defines the aspect ratio
  81846. * @param znear defines the near clip plane
  81847. * @param zfar not used as infinity is used as far clip
  81848. * @param result defines the target matrix
  81849. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81850. */
  81851. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81852. /**
  81853. * Stores a perspective projection for WebVR info a given matrix
  81854. * @param fov defines the field of view
  81855. * @param znear defines the near clip plane
  81856. * @param zfar defines the far clip plane
  81857. * @param result defines the target matrix
  81858. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  81859. */
  81860. static PerspectiveFovWebVRToRef(fov: {
  81861. upDegrees: number;
  81862. downDegrees: number;
  81863. leftDegrees: number;
  81864. rightDegrees: number;
  81865. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  81866. /**
  81867. * Computes a complete transformation matrix
  81868. * @param viewport defines the viewport to use
  81869. * @param world defines the world matrix
  81870. * @param view defines the view matrix
  81871. * @param projection defines the projection matrix
  81872. * @param zmin defines the near clip plane
  81873. * @param zmax defines the far clip plane
  81874. * @returns the transformation matrix
  81875. */
  81876. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  81877. /**
  81878. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  81879. * @param matrix defines the matrix to use
  81880. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  81881. */
  81882. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  81883. /**
  81884. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  81885. * @param matrix defines the matrix to use
  81886. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  81887. */
  81888. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  81889. /**
  81890. * Compute the transpose of a given matrix
  81891. * @param matrix defines the matrix to transpose
  81892. * @returns the new matrix
  81893. */
  81894. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  81895. /**
  81896. * Compute the transpose of a matrix and store it in a target matrix
  81897. * @param matrix defines the matrix to transpose
  81898. * @param result defines the target matrix
  81899. */
  81900. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  81901. /**
  81902. * Computes a reflection matrix from a plane
  81903. * @param plane defines the reflection plane
  81904. * @returns a new matrix
  81905. */
  81906. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  81907. /**
  81908. * Computes a reflection matrix from a plane
  81909. * @param plane defines the reflection plane
  81910. * @param result defines the target matrix
  81911. */
  81912. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  81913. /**
  81914. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  81915. * @param xaxis defines the value of the 1st axis
  81916. * @param yaxis defines the value of the 2nd axis
  81917. * @param zaxis defines the value of the 3rd axis
  81918. * @param result defines the target matrix
  81919. */
  81920. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  81921. /**
  81922. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  81923. * @param quat defines the quaternion to use
  81924. * @param result defines the target matrix
  81925. */
  81926. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  81927. }
  81928. /**
  81929. * @hidden
  81930. */
  81931. export class TmpVectors {
  81932. static Vector2: Vector2[];
  81933. static Vector3: Vector3[];
  81934. static Vector4: Vector4[];
  81935. static Quaternion: Quaternion[];
  81936. static Matrix: Matrix[];
  81937. }
  81938. }
  81939. declare module BABYLON {
  81940. /**
  81941. * Defines potential orientation for back face culling
  81942. */
  81943. export enum Orientation {
  81944. /**
  81945. * Clockwise
  81946. */
  81947. CW = 0,
  81948. /** Counter clockwise */
  81949. CCW = 1
  81950. }
  81951. /** Class used to represent a Bezier curve */
  81952. export class BezierCurve {
  81953. /**
  81954. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  81955. * @param t defines the time
  81956. * @param x1 defines the left coordinate on X axis
  81957. * @param y1 defines the left coordinate on Y axis
  81958. * @param x2 defines the right coordinate on X axis
  81959. * @param y2 defines the right coordinate on Y axis
  81960. * @returns the interpolated value
  81961. */
  81962. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  81963. }
  81964. /**
  81965. * Defines angle representation
  81966. */
  81967. export class Angle {
  81968. private _radians;
  81969. /**
  81970. * Creates an Angle object of "radians" radians (float).
  81971. * @param radians the angle in radians
  81972. */
  81973. constructor(radians: number);
  81974. /**
  81975. * Get value in degrees
  81976. * @returns the Angle value in degrees (float)
  81977. */
  81978. degrees(): number;
  81979. /**
  81980. * Get value in radians
  81981. * @returns the Angle value in radians (float)
  81982. */
  81983. radians(): number;
  81984. /**
  81985. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  81986. * @param a defines first vector
  81987. * @param b defines second vector
  81988. * @returns a new Angle
  81989. */
  81990. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  81991. /**
  81992. * Gets a new Angle object from the given float in radians
  81993. * @param radians defines the angle value in radians
  81994. * @returns a new Angle
  81995. */
  81996. static FromRadians(radians: number): Angle;
  81997. /**
  81998. * Gets a new Angle object from the given float in degrees
  81999. * @param degrees defines the angle value in degrees
  82000. * @returns a new Angle
  82001. */
  82002. static FromDegrees(degrees: number): Angle;
  82003. }
  82004. /**
  82005. * This represents an arc in a 2d space.
  82006. */
  82007. export class Arc2 {
  82008. /** Defines the start point of the arc */
  82009. startPoint: Vector2;
  82010. /** Defines the mid point of the arc */
  82011. midPoint: Vector2;
  82012. /** Defines the end point of the arc */
  82013. endPoint: Vector2;
  82014. /**
  82015. * Defines the center point of the arc.
  82016. */
  82017. centerPoint: Vector2;
  82018. /**
  82019. * Defines the radius of the arc.
  82020. */
  82021. radius: number;
  82022. /**
  82023. * Defines the angle of the arc (from mid point to end point).
  82024. */
  82025. angle: Angle;
  82026. /**
  82027. * Defines the start angle of the arc (from start point to middle point).
  82028. */
  82029. startAngle: Angle;
  82030. /**
  82031. * Defines the orientation of the arc (clock wise/counter clock wise).
  82032. */
  82033. orientation: Orientation;
  82034. /**
  82035. * Creates an Arc object from the three given points : start, middle and end.
  82036. * @param startPoint Defines the start point of the arc
  82037. * @param midPoint Defines the midlle point of the arc
  82038. * @param endPoint Defines the end point of the arc
  82039. */
  82040. constructor(
  82041. /** Defines the start point of the arc */
  82042. startPoint: Vector2,
  82043. /** Defines the mid point of the arc */
  82044. midPoint: Vector2,
  82045. /** Defines the end point of the arc */
  82046. endPoint: Vector2);
  82047. }
  82048. /**
  82049. * Represents a 2D path made up of multiple 2D points
  82050. */
  82051. export class Path2 {
  82052. private _points;
  82053. private _length;
  82054. /**
  82055. * If the path start and end point are the same
  82056. */
  82057. closed: boolean;
  82058. /**
  82059. * Creates a Path2 object from the starting 2D coordinates x and y.
  82060. * @param x the starting points x value
  82061. * @param y the starting points y value
  82062. */
  82063. constructor(x: number, y: number);
  82064. /**
  82065. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  82066. * @param x the added points x value
  82067. * @param y the added points y value
  82068. * @returns the updated Path2.
  82069. */
  82070. addLineTo(x: number, y: number): Path2;
  82071. /**
  82072. * 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.
  82073. * @param midX middle point x value
  82074. * @param midY middle point y value
  82075. * @param endX end point x value
  82076. * @param endY end point y value
  82077. * @param numberOfSegments (default: 36)
  82078. * @returns the updated Path2.
  82079. */
  82080. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  82081. /**
  82082. * Closes the Path2.
  82083. * @returns the Path2.
  82084. */
  82085. close(): Path2;
  82086. /**
  82087. * Gets the sum of the distance between each sequential point in the path
  82088. * @returns the Path2 total length (float).
  82089. */
  82090. length(): number;
  82091. /**
  82092. * Gets the points which construct the path
  82093. * @returns the Path2 internal array of points.
  82094. */
  82095. getPoints(): Vector2[];
  82096. /**
  82097. * Retreives the point at the distance aways from the starting point
  82098. * @param normalizedLengthPosition the length along the path to retreive the point from
  82099. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  82100. */
  82101. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  82102. /**
  82103. * Creates a new path starting from an x and y position
  82104. * @param x starting x value
  82105. * @param y starting y value
  82106. * @returns a new Path2 starting at the coordinates (x, y).
  82107. */
  82108. static StartingAt(x: number, y: number): Path2;
  82109. }
  82110. /**
  82111. * Represents a 3D path made up of multiple 3D points
  82112. */
  82113. export class Path3D {
  82114. /**
  82115. * an array of Vector3, the curve axis of the Path3D
  82116. */
  82117. path: Vector3[];
  82118. private _curve;
  82119. private _distances;
  82120. private _tangents;
  82121. private _normals;
  82122. private _binormals;
  82123. private _raw;
  82124. private _alignTangentsWithPath;
  82125. private readonly _pointAtData;
  82126. /**
  82127. * new Path3D(path, normal, raw)
  82128. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  82129. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  82130. * @param path an array of Vector3, the curve axis of the Path3D
  82131. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  82132. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  82133. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  82134. */
  82135. constructor(
  82136. /**
  82137. * an array of Vector3, the curve axis of the Path3D
  82138. */
  82139. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  82140. /**
  82141. * Returns the Path3D array of successive Vector3 designing its curve.
  82142. * @returns the Path3D array of successive Vector3 designing its curve.
  82143. */
  82144. getCurve(): Vector3[];
  82145. /**
  82146. * Returns the Path3D array of successive Vector3 designing its curve.
  82147. * @returns the Path3D array of successive Vector3 designing its curve.
  82148. */
  82149. getPoints(): Vector3[];
  82150. /**
  82151. * @returns the computed length (float) of the path.
  82152. */
  82153. length(): number;
  82154. /**
  82155. * Returns an array populated with tangent vectors on each Path3D curve point.
  82156. * @returns an array populated with tangent vectors on each Path3D curve point.
  82157. */
  82158. getTangents(): Vector3[];
  82159. /**
  82160. * Returns an array populated with normal vectors on each Path3D curve point.
  82161. * @returns an array populated with normal vectors on each Path3D curve point.
  82162. */
  82163. getNormals(): Vector3[];
  82164. /**
  82165. * Returns an array populated with binormal vectors on each Path3D curve point.
  82166. * @returns an array populated with binormal vectors on each Path3D curve point.
  82167. */
  82168. getBinormals(): Vector3[];
  82169. /**
  82170. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  82171. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  82172. */
  82173. getDistances(): number[];
  82174. /**
  82175. * Returns an interpolated point along this path
  82176. * @param position the position of the point along this path, from 0.0 to 1.0
  82177. * @returns a new Vector3 as the point
  82178. */
  82179. getPointAt(position: number): Vector3;
  82180. /**
  82181. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82182. * @param position the position of the point along this path, from 0.0 to 1.0
  82183. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  82184. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  82185. */
  82186. getTangentAt(position: number, interpolated?: boolean): Vector3;
  82187. /**
  82188. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82189. * @param position the position of the point along this path, from 0.0 to 1.0
  82190. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  82191. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  82192. */
  82193. getNormalAt(position: number, interpolated?: boolean): Vector3;
  82194. /**
  82195. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  82196. * @param position the position of the point along this path, from 0.0 to 1.0
  82197. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  82198. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  82199. */
  82200. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  82201. /**
  82202. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  82203. * @param position the position of the point along this path, from 0.0 to 1.0
  82204. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  82205. */
  82206. getDistanceAt(position: number): number;
  82207. /**
  82208. * Returns the array index of the previous point of an interpolated point along this path
  82209. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82210. * @returns the array index
  82211. */
  82212. getPreviousPointIndexAt(position: number): number;
  82213. /**
  82214. * 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)
  82215. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82216. * @returns the sub position
  82217. */
  82218. getSubPositionAt(position: number): number;
  82219. /**
  82220. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  82221. * @param target the vector of which to get the closest position to
  82222. * @returns the position of the closest virtual point on this path to the target vector
  82223. */
  82224. getClosestPositionTo(target: Vector3): number;
  82225. /**
  82226. * Returns a sub path (slice) of this path
  82227. * @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
  82228. * @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
  82229. * @returns a sub path (slice) of this path
  82230. */
  82231. slice(start?: number, end?: number): Path3D;
  82232. /**
  82233. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82234. * @param path path which all values are copied into the curves points
  82235. * @param firstNormal which should be projected onto the curve
  82236. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82237. * @returns the same object updated.
  82238. */
  82239. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82240. private _compute;
  82241. private _getFirstNonNullVector;
  82242. private _getLastNonNullVector;
  82243. private _normalVector;
  82244. /**
  82245. * Updates the point at data for an interpolated point along this curve
  82246. * @param position the position of the point along this curve, from 0.0 to 1.0
  82247. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82248. * @returns the (updated) point at data
  82249. */
  82250. private _updatePointAtData;
  82251. /**
  82252. * Updates the point at data from the specified parameters
  82253. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82254. * @param point the interpolated point
  82255. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82256. */
  82257. private _setPointAtData;
  82258. /**
  82259. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82260. */
  82261. private _updateInterpolationMatrix;
  82262. }
  82263. /**
  82264. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82265. * A Curve3 is designed from a series of successive Vector3.
  82266. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82267. */
  82268. export class Curve3 {
  82269. private _points;
  82270. private _length;
  82271. /**
  82272. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82273. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82274. * @param v1 (Vector3) the control point
  82275. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82276. * @param nbPoints (integer) the wanted number of points in the curve
  82277. * @returns the created Curve3
  82278. */
  82279. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82280. /**
  82281. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82282. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82283. * @param v1 (Vector3) the first control point
  82284. * @param v2 (Vector3) the second control point
  82285. * @param v3 (Vector3) the end point of the Cubic Bezier
  82286. * @param nbPoints (integer) the wanted number of points in the curve
  82287. * @returns the created Curve3
  82288. */
  82289. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82290. /**
  82291. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82292. * @param p1 (Vector3) the origin point of the Hermite Spline
  82293. * @param t1 (Vector3) the tangent vector at the origin point
  82294. * @param p2 (Vector3) the end point of the Hermite Spline
  82295. * @param t2 (Vector3) the tangent vector at the end point
  82296. * @param nbPoints (integer) the wanted number of points in the curve
  82297. * @returns the created Curve3
  82298. */
  82299. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82300. /**
  82301. * Returns a Curve3 object along a CatmullRom Spline curve :
  82302. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82303. * @param nbPoints (integer) the wanted number of points between each curve control points
  82304. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82305. * @returns the created Curve3
  82306. */
  82307. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82308. /**
  82309. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82310. * A Curve3 is designed from a series of successive Vector3.
  82311. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82312. * @param points points which make up the curve
  82313. */
  82314. constructor(points: Vector3[]);
  82315. /**
  82316. * @returns the Curve3 stored array of successive Vector3
  82317. */
  82318. getPoints(): Vector3[];
  82319. /**
  82320. * @returns the computed length (float) of the curve.
  82321. */
  82322. length(): number;
  82323. /**
  82324. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82325. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82326. * curveA and curveB keep unchanged.
  82327. * @param curve the curve to continue from this curve
  82328. * @returns the newly constructed curve
  82329. */
  82330. continue(curve: DeepImmutable<Curve3>): Curve3;
  82331. private _computeLength;
  82332. }
  82333. }
  82334. declare module BABYLON {
  82335. /**
  82336. * This represents the main contract an easing function should follow.
  82337. * Easing functions are used throughout the animation system.
  82338. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82339. */
  82340. export interface IEasingFunction {
  82341. /**
  82342. * Given an input gradient between 0 and 1, this returns the corrseponding value
  82343. * of the easing function.
  82344. * The link below provides some of the most common examples of easing functions.
  82345. * @see https://easings.net/
  82346. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82347. * @returns the corresponding value on the curve defined by the easing function
  82348. */
  82349. ease(gradient: number): number;
  82350. }
  82351. /**
  82352. * Base class used for every default easing function.
  82353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82354. */
  82355. export class EasingFunction implements IEasingFunction {
  82356. /**
  82357. * Interpolation follows the mathematical formula associated with the easing function.
  82358. */
  82359. static readonly EASINGMODE_EASEIN: number;
  82360. /**
  82361. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  82362. */
  82363. static readonly EASINGMODE_EASEOUT: number;
  82364. /**
  82365. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  82366. */
  82367. static readonly EASINGMODE_EASEINOUT: number;
  82368. private _easingMode;
  82369. /**
  82370. * Sets the easing mode of the current function.
  82371. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  82372. */
  82373. setEasingMode(easingMode: number): void;
  82374. /**
  82375. * Gets the current easing mode.
  82376. * @returns the easing mode
  82377. */
  82378. getEasingMode(): number;
  82379. /**
  82380. * @hidden
  82381. */
  82382. easeInCore(gradient: number): number;
  82383. /**
  82384. * Given an input gradient between 0 and 1, this returns the corresponding value
  82385. * of the easing function.
  82386. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82387. * @returns the corresponding value on the curve defined by the easing function
  82388. */
  82389. ease(gradient: number): number;
  82390. }
  82391. /**
  82392. * Easing function with a circle shape (see link below).
  82393. * @see https://easings.net/#easeInCirc
  82394. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82395. */
  82396. export class CircleEase extends EasingFunction implements IEasingFunction {
  82397. /** @hidden */
  82398. easeInCore(gradient: number): number;
  82399. }
  82400. /**
  82401. * Easing function with a ease back shape (see link below).
  82402. * @see https://easings.net/#easeInBack
  82403. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82404. */
  82405. export class BackEase extends EasingFunction implements IEasingFunction {
  82406. /** Defines the amplitude of the function */
  82407. amplitude: number;
  82408. /**
  82409. * Instantiates a back ease easing
  82410. * @see https://easings.net/#easeInBack
  82411. * @param amplitude Defines the amplitude of the function
  82412. */
  82413. constructor(
  82414. /** Defines the amplitude of the function */
  82415. amplitude?: number);
  82416. /** @hidden */
  82417. easeInCore(gradient: number): number;
  82418. }
  82419. /**
  82420. * Easing function with a bouncing shape (see link below).
  82421. * @see https://easings.net/#easeInBounce
  82422. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82423. */
  82424. export class BounceEase extends EasingFunction implements IEasingFunction {
  82425. /** Defines the number of bounces */
  82426. bounces: number;
  82427. /** Defines the amplitude of the bounce */
  82428. bounciness: number;
  82429. /**
  82430. * Instantiates a bounce easing
  82431. * @see https://easings.net/#easeInBounce
  82432. * @param bounces Defines the number of bounces
  82433. * @param bounciness Defines the amplitude of the bounce
  82434. */
  82435. constructor(
  82436. /** Defines the number of bounces */
  82437. bounces?: number,
  82438. /** Defines the amplitude of the bounce */
  82439. bounciness?: number);
  82440. /** @hidden */
  82441. easeInCore(gradient: number): number;
  82442. }
  82443. /**
  82444. * Easing function with a power of 3 shape (see link below).
  82445. * @see https://easings.net/#easeInCubic
  82446. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82447. */
  82448. export class CubicEase extends EasingFunction implements IEasingFunction {
  82449. /** @hidden */
  82450. easeInCore(gradient: number): number;
  82451. }
  82452. /**
  82453. * Easing function with an elastic shape (see link below).
  82454. * @see https://easings.net/#easeInElastic
  82455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82456. */
  82457. export class ElasticEase extends EasingFunction implements IEasingFunction {
  82458. /** Defines the number of oscillations*/
  82459. oscillations: number;
  82460. /** Defines the amplitude of the oscillations*/
  82461. springiness: number;
  82462. /**
  82463. * Instantiates an elastic easing function
  82464. * @see https://easings.net/#easeInElastic
  82465. * @param oscillations Defines the number of oscillations
  82466. * @param springiness Defines the amplitude of the oscillations
  82467. */
  82468. constructor(
  82469. /** Defines the number of oscillations*/
  82470. oscillations?: number,
  82471. /** Defines the amplitude of the oscillations*/
  82472. springiness?: number);
  82473. /** @hidden */
  82474. easeInCore(gradient: number): number;
  82475. }
  82476. /**
  82477. * Easing function with an exponential shape (see link below).
  82478. * @see https://easings.net/#easeInExpo
  82479. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82480. */
  82481. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  82482. /** Defines the exponent of the function */
  82483. exponent: number;
  82484. /**
  82485. * Instantiates an exponential easing function
  82486. * @see https://easings.net/#easeInExpo
  82487. * @param exponent Defines the exponent of the function
  82488. */
  82489. constructor(
  82490. /** Defines the exponent of the function */
  82491. exponent?: number);
  82492. /** @hidden */
  82493. easeInCore(gradient: number): number;
  82494. }
  82495. /**
  82496. * Easing function with a power shape (see link below).
  82497. * @see https://easings.net/#easeInQuad
  82498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82499. */
  82500. export class PowerEase extends EasingFunction implements IEasingFunction {
  82501. /** Defines the power of the function */
  82502. power: number;
  82503. /**
  82504. * Instantiates an power base easing function
  82505. * @see https://easings.net/#easeInQuad
  82506. * @param power Defines the power of the function
  82507. */
  82508. constructor(
  82509. /** Defines the power of the function */
  82510. power?: number);
  82511. /** @hidden */
  82512. easeInCore(gradient: number): number;
  82513. }
  82514. /**
  82515. * Easing function with a power of 2 shape (see link below).
  82516. * @see https://easings.net/#easeInQuad
  82517. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82518. */
  82519. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  82520. /** @hidden */
  82521. easeInCore(gradient: number): number;
  82522. }
  82523. /**
  82524. * Easing function with a power of 4 shape (see link below).
  82525. * @see https://easings.net/#easeInQuart
  82526. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82527. */
  82528. export class QuarticEase extends EasingFunction implements IEasingFunction {
  82529. /** @hidden */
  82530. easeInCore(gradient: number): number;
  82531. }
  82532. /**
  82533. * Easing function with a power of 5 shape (see link below).
  82534. * @see https://easings.net/#easeInQuint
  82535. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82536. */
  82537. export class QuinticEase extends EasingFunction implements IEasingFunction {
  82538. /** @hidden */
  82539. easeInCore(gradient: number): number;
  82540. }
  82541. /**
  82542. * Easing function with a sin shape (see link below).
  82543. * @see https://easings.net/#easeInSine
  82544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82545. */
  82546. export class SineEase extends EasingFunction implements IEasingFunction {
  82547. /** @hidden */
  82548. easeInCore(gradient: number): number;
  82549. }
  82550. /**
  82551. * Easing function with a bezier shape (see link below).
  82552. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82553. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82554. */
  82555. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  82556. /** Defines the x component of the start tangent in the bezier curve */
  82557. x1: number;
  82558. /** Defines the y component of the start tangent in the bezier curve */
  82559. y1: number;
  82560. /** Defines the x component of the end tangent in the bezier curve */
  82561. x2: number;
  82562. /** Defines the y component of the end tangent in the bezier curve */
  82563. y2: number;
  82564. /**
  82565. * Instantiates a bezier function
  82566. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82567. * @param x1 Defines the x component of the start tangent in the bezier curve
  82568. * @param y1 Defines the y component of the start tangent in the bezier curve
  82569. * @param x2 Defines the x component of the end tangent in the bezier curve
  82570. * @param y2 Defines the y component of the end tangent in the bezier curve
  82571. */
  82572. constructor(
  82573. /** Defines the x component of the start tangent in the bezier curve */
  82574. x1?: number,
  82575. /** Defines the y component of the start tangent in the bezier curve */
  82576. y1?: number,
  82577. /** Defines the x component of the end tangent in the bezier curve */
  82578. x2?: number,
  82579. /** Defines the y component of the end tangent in the bezier curve */
  82580. y2?: number);
  82581. /** @hidden */
  82582. easeInCore(gradient: number): number;
  82583. }
  82584. }
  82585. declare module BABYLON {
  82586. /**
  82587. * Class used to hold a RBG color
  82588. */
  82589. export class Color3 {
  82590. /**
  82591. * Defines the red component (between 0 and 1, default is 0)
  82592. */
  82593. r: number;
  82594. /**
  82595. * Defines the green component (between 0 and 1, default is 0)
  82596. */
  82597. g: number;
  82598. /**
  82599. * Defines the blue component (between 0 and 1, default is 0)
  82600. */
  82601. b: number;
  82602. /**
  82603. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  82604. * @param r defines the red component (between 0 and 1, default is 0)
  82605. * @param g defines the green component (between 0 and 1, default is 0)
  82606. * @param b defines the blue component (between 0 and 1, default is 0)
  82607. */
  82608. constructor(
  82609. /**
  82610. * Defines the red component (between 0 and 1, default is 0)
  82611. */
  82612. r?: number,
  82613. /**
  82614. * Defines the green component (between 0 and 1, default is 0)
  82615. */
  82616. g?: number,
  82617. /**
  82618. * Defines the blue component (between 0 and 1, default is 0)
  82619. */
  82620. b?: number);
  82621. /**
  82622. * Creates a string with the Color3 current values
  82623. * @returns the string representation of the Color3 object
  82624. */
  82625. toString(): string;
  82626. /**
  82627. * Returns the string "Color3"
  82628. * @returns "Color3"
  82629. */
  82630. getClassName(): string;
  82631. /**
  82632. * Compute the Color3 hash code
  82633. * @returns an unique number that can be used to hash Color3 objects
  82634. */
  82635. getHashCode(): number;
  82636. /**
  82637. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  82638. * @param array defines the array where to store the r,g,b components
  82639. * @param index defines an optional index in the target array to define where to start storing values
  82640. * @returns the current Color3 object
  82641. */
  82642. toArray(array: FloatArray, index?: number): Color3;
  82643. /**
  82644. * Returns a new Color4 object from the current Color3 and the given alpha
  82645. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  82646. * @returns a new Color4 object
  82647. */
  82648. toColor4(alpha?: number): Color4;
  82649. /**
  82650. * Returns a new array populated with 3 numeric elements : red, green and blue values
  82651. * @returns the new array
  82652. */
  82653. asArray(): number[];
  82654. /**
  82655. * Returns the luminance value
  82656. * @returns a float value
  82657. */
  82658. toLuminance(): number;
  82659. /**
  82660. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  82661. * @param otherColor defines the second operand
  82662. * @returns the new Color3 object
  82663. */
  82664. multiply(otherColor: DeepImmutable<Color3>): Color3;
  82665. /**
  82666. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  82667. * @param otherColor defines the second operand
  82668. * @param result defines the Color3 object where to store the result
  82669. * @returns the current Color3
  82670. */
  82671. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82672. /**
  82673. * Determines equality between Color3 objects
  82674. * @param otherColor defines the second operand
  82675. * @returns true if the rgb values are equal to the given ones
  82676. */
  82677. equals(otherColor: DeepImmutable<Color3>): boolean;
  82678. /**
  82679. * Determines equality between the current Color3 object and a set of r,b,g values
  82680. * @param r defines the red component to check
  82681. * @param g defines the green component to check
  82682. * @param b defines the blue component to check
  82683. * @returns true if the rgb values are equal to the given ones
  82684. */
  82685. equalsFloats(r: number, g: number, b: number): boolean;
  82686. /**
  82687. * Multiplies in place each rgb value by scale
  82688. * @param scale defines the scaling factor
  82689. * @returns the updated Color3
  82690. */
  82691. scale(scale: number): Color3;
  82692. /**
  82693. * Multiplies the rgb values by scale and stores the result into "result"
  82694. * @param scale defines the scaling factor
  82695. * @param result defines the Color3 object where to store the result
  82696. * @returns the unmodified current Color3
  82697. */
  82698. scaleToRef(scale: number, result: Color3): Color3;
  82699. /**
  82700. * Scale the current Color3 values by a factor and add the result to a given Color3
  82701. * @param scale defines the scale factor
  82702. * @param result defines color to store the result into
  82703. * @returns the unmodified current Color3
  82704. */
  82705. scaleAndAddToRef(scale: number, result: Color3): Color3;
  82706. /**
  82707. * Clamps the rgb values by the min and max values and stores the result into "result"
  82708. * @param min defines minimum clamping value (default is 0)
  82709. * @param max defines maximum clamping value (default is 1)
  82710. * @param result defines color to store the result into
  82711. * @returns the original Color3
  82712. */
  82713. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  82714. /**
  82715. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  82716. * @param otherColor defines the second operand
  82717. * @returns the new Color3
  82718. */
  82719. add(otherColor: DeepImmutable<Color3>): Color3;
  82720. /**
  82721. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  82722. * @param otherColor defines the second operand
  82723. * @param result defines Color3 object to store the result into
  82724. * @returns the unmodified current Color3
  82725. */
  82726. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82727. /**
  82728. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  82729. * @param otherColor defines the second operand
  82730. * @returns the new Color3
  82731. */
  82732. subtract(otherColor: DeepImmutable<Color3>): Color3;
  82733. /**
  82734. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  82735. * @param otherColor defines the second operand
  82736. * @param result defines Color3 object to store the result into
  82737. * @returns the unmodified current Color3
  82738. */
  82739. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82740. /**
  82741. * Copy the current object
  82742. * @returns a new Color3 copied the current one
  82743. */
  82744. clone(): Color3;
  82745. /**
  82746. * Copies the rgb values from the source in the current Color3
  82747. * @param source defines the source Color3 object
  82748. * @returns the updated Color3 object
  82749. */
  82750. copyFrom(source: DeepImmutable<Color3>): Color3;
  82751. /**
  82752. * Updates the Color3 rgb values from the given floats
  82753. * @param r defines the red component to read from
  82754. * @param g defines the green component to read from
  82755. * @param b defines the blue component to read from
  82756. * @returns the current Color3 object
  82757. */
  82758. copyFromFloats(r: number, g: number, b: number): Color3;
  82759. /**
  82760. * Updates the Color3 rgb values from the given floats
  82761. * @param r defines the red component to read from
  82762. * @param g defines the green component to read from
  82763. * @param b defines the blue component to read from
  82764. * @returns the current Color3 object
  82765. */
  82766. set(r: number, g: number, b: number): Color3;
  82767. /**
  82768. * Compute the Color3 hexadecimal code as a string
  82769. * @returns a string containing the hexadecimal representation of the Color3 object
  82770. */
  82771. toHexString(): string;
  82772. /**
  82773. * Computes a new Color3 converted from the current one to linear space
  82774. * @returns a new Color3 object
  82775. */
  82776. toLinearSpace(): Color3;
  82777. /**
  82778. * Converts current color in rgb space to HSV values
  82779. * @returns a new color3 representing the HSV values
  82780. */
  82781. toHSV(): Color3;
  82782. /**
  82783. * Converts current color in rgb space to HSV values
  82784. * @param result defines the Color3 where to store the HSV values
  82785. */
  82786. toHSVToRef(result: Color3): void;
  82787. /**
  82788. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  82789. * @param convertedColor defines the Color3 object where to store the linear space version
  82790. * @returns the unmodified Color3
  82791. */
  82792. toLinearSpaceToRef(convertedColor: Color3): Color3;
  82793. /**
  82794. * Computes a new Color3 converted from the current one to gamma space
  82795. * @returns a new Color3 object
  82796. */
  82797. toGammaSpace(): Color3;
  82798. /**
  82799. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  82800. * @param convertedColor defines the Color3 object where to store the gamma space version
  82801. * @returns the unmodified Color3
  82802. */
  82803. toGammaSpaceToRef(convertedColor: Color3): Color3;
  82804. private static _BlackReadOnly;
  82805. /**
  82806. * Convert Hue, saturation and value to a Color3 (RGB)
  82807. * @param hue defines the hue
  82808. * @param saturation defines the saturation
  82809. * @param value defines the value
  82810. * @param result defines the Color3 where to store the RGB values
  82811. */
  82812. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  82813. /**
  82814. * Creates a new Color3 from the string containing valid hexadecimal values
  82815. * @param hex defines a string containing valid hexadecimal values
  82816. * @returns a new Color3 object
  82817. */
  82818. static FromHexString(hex: string): Color3;
  82819. /**
  82820. * Creates a new Color3 from the starting index of the given array
  82821. * @param array defines the source array
  82822. * @param offset defines an offset in the source array
  82823. * @returns a new Color3 object
  82824. */
  82825. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  82826. /**
  82827. * Creates a new Color3 from integer values (< 256)
  82828. * @param r defines the red component to read from (value between 0 and 255)
  82829. * @param g defines the green component to read from (value between 0 and 255)
  82830. * @param b defines the blue component to read from (value between 0 and 255)
  82831. * @returns a new Color3 object
  82832. */
  82833. static FromInts(r: number, g: number, b: number): Color3;
  82834. /**
  82835. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82836. * @param start defines the start Color3 value
  82837. * @param end defines the end Color3 value
  82838. * @param amount defines the gradient value between start and end
  82839. * @returns a new Color3 object
  82840. */
  82841. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  82842. /**
  82843. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82844. * @param left defines the start value
  82845. * @param right defines the end value
  82846. * @param amount defines the gradient factor
  82847. * @param result defines the Color3 object where to store the result
  82848. */
  82849. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  82850. /**
  82851. * Returns a Color3 value containing a red color
  82852. * @returns a new Color3 object
  82853. */
  82854. static Red(): Color3;
  82855. /**
  82856. * Returns a Color3 value containing a green color
  82857. * @returns a new Color3 object
  82858. */
  82859. static Green(): Color3;
  82860. /**
  82861. * Returns a Color3 value containing a blue color
  82862. * @returns a new Color3 object
  82863. */
  82864. static Blue(): Color3;
  82865. /**
  82866. * Returns a Color3 value containing a black color
  82867. * @returns a new Color3 object
  82868. */
  82869. static Black(): Color3;
  82870. /**
  82871. * Gets a Color3 value containing a black color that must not be updated
  82872. */
  82873. static get BlackReadOnly(): DeepImmutable<Color3>;
  82874. /**
  82875. * Returns a Color3 value containing a white color
  82876. * @returns a new Color3 object
  82877. */
  82878. static White(): Color3;
  82879. /**
  82880. * Returns a Color3 value containing a purple color
  82881. * @returns a new Color3 object
  82882. */
  82883. static Purple(): Color3;
  82884. /**
  82885. * Returns a Color3 value containing a magenta color
  82886. * @returns a new Color3 object
  82887. */
  82888. static Magenta(): Color3;
  82889. /**
  82890. * Returns a Color3 value containing a yellow color
  82891. * @returns a new Color3 object
  82892. */
  82893. static Yellow(): Color3;
  82894. /**
  82895. * Returns a Color3 value containing a gray color
  82896. * @returns a new Color3 object
  82897. */
  82898. static Gray(): Color3;
  82899. /**
  82900. * Returns a Color3 value containing a teal color
  82901. * @returns a new Color3 object
  82902. */
  82903. static Teal(): Color3;
  82904. /**
  82905. * Returns a Color3 value containing a random color
  82906. * @returns a new Color3 object
  82907. */
  82908. static Random(): Color3;
  82909. }
  82910. /**
  82911. * Class used to hold a RBGA color
  82912. */
  82913. export class Color4 {
  82914. /**
  82915. * Defines the red component (between 0 and 1, default is 0)
  82916. */
  82917. r: number;
  82918. /**
  82919. * Defines the green component (between 0 and 1, default is 0)
  82920. */
  82921. g: number;
  82922. /**
  82923. * Defines the blue component (between 0 and 1, default is 0)
  82924. */
  82925. b: number;
  82926. /**
  82927. * Defines the alpha component (between 0 and 1, default is 1)
  82928. */
  82929. a: number;
  82930. /**
  82931. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  82932. * @param r defines the red component (between 0 and 1, default is 0)
  82933. * @param g defines the green component (between 0 and 1, default is 0)
  82934. * @param b defines the blue component (between 0 and 1, default is 0)
  82935. * @param a defines the alpha component (between 0 and 1, default is 1)
  82936. */
  82937. constructor(
  82938. /**
  82939. * Defines the red component (between 0 and 1, default is 0)
  82940. */
  82941. r?: number,
  82942. /**
  82943. * Defines the green component (between 0 and 1, default is 0)
  82944. */
  82945. g?: number,
  82946. /**
  82947. * Defines the blue component (between 0 and 1, default is 0)
  82948. */
  82949. b?: number,
  82950. /**
  82951. * Defines the alpha component (between 0 and 1, default is 1)
  82952. */
  82953. a?: number);
  82954. /**
  82955. * Adds in place the given Color4 values to the current Color4 object
  82956. * @param right defines the second operand
  82957. * @returns the current updated Color4 object
  82958. */
  82959. addInPlace(right: DeepImmutable<Color4>): Color4;
  82960. /**
  82961. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  82962. * @returns the new array
  82963. */
  82964. asArray(): number[];
  82965. /**
  82966. * Stores from the starting index in the given array the Color4 successive values
  82967. * @param array defines the array where to store the r,g,b components
  82968. * @param index defines an optional index in the target array to define where to start storing values
  82969. * @returns the current Color4 object
  82970. */
  82971. toArray(array: number[], index?: number): Color4;
  82972. /**
  82973. * Determines equality between Color4 objects
  82974. * @param otherColor defines the second operand
  82975. * @returns true if the rgba values are equal to the given ones
  82976. */
  82977. equals(otherColor: DeepImmutable<Color4>): boolean;
  82978. /**
  82979. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  82980. * @param right defines the second operand
  82981. * @returns a new Color4 object
  82982. */
  82983. add(right: DeepImmutable<Color4>): Color4;
  82984. /**
  82985. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  82986. * @param right defines the second operand
  82987. * @returns a new Color4 object
  82988. */
  82989. subtract(right: DeepImmutable<Color4>): Color4;
  82990. /**
  82991. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  82992. * @param right defines the second operand
  82993. * @param result defines the Color4 object where to store the result
  82994. * @returns the current Color4 object
  82995. */
  82996. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  82997. /**
  82998. * Creates a new Color4 with the current Color4 values multiplied by scale
  82999. * @param scale defines the scaling factor to apply
  83000. * @returns a new Color4 object
  83001. */
  83002. scale(scale: number): Color4;
  83003. /**
  83004. * Multiplies the current Color4 values by scale and stores the result in "result"
  83005. * @param scale defines the scaling factor to apply
  83006. * @param result defines the Color4 object where to store the result
  83007. * @returns the current unmodified Color4
  83008. */
  83009. scaleToRef(scale: number, result: Color4): Color4;
  83010. /**
  83011. * Scale the current Color4 values by a factor and add the result to a given Color4
  83012. * @param scale defines the scale factor
  83013. * @param result defines the Color4 object where to store the result
  83014. * @returns the unmodified current Color4
  83015. */
  83016. scaleAndAddToRef(scale: number, result: Color4): Color4;
  83017. /**
  83018. * Clamps the rgb values by the min and max values and stores the result into "result"
  83019. * @param min defines minimum clamping value (default is 0)
  83020. * @param max defines maximum clamping value (default is 1)
  83021. * @param result defines color to store the result into.
  83022. * @returns the cuurent Color4
  83023. */
  83024. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  83025. /**
  83026. * Multipy an Color4 value by another and return a new Color4 object
  83027. * @param color defines the Color4 value to multiply by
  83028. * @returns a new Color4 object
  83029. */
  83030. multiply(color: Color4): Color4;
  83031. /**
  83032. * Multipy a Color4 value by another and push the result in a reference value
  83033. * @param color defines the Color4 value to multiply by
  83034. * @param result defines the Color4 to fill the result in
  83035. * @returns the result Color4
  83036. */
  83037. multiplyToRef(color: Color4, result: Color4): Color4;
  83038. /**
  83039. * Creates a string with the Color4 current values
  83040. * @returns the string representation of the Color4 object
  83041. */
  83042. toString(): string;
  83043. /**
  83044. * Returns the string "Color4"
  83045. * @returns "Color4"
  83046. */
  83047. getClassName(): string;
  83048. /**
  83049. * Compute the Color4 hash code
  83050. * @returns an unique number that can be used to hash Color4 objects
  83051. */
  83052. getHashCode(): number;
  83053. /**
  83054. * Creates a new Color4 copied from the current one
  83055. * @returns a new Color4 object
  83056. */
  83057. clone(): Color4;
  83058. /**
  83059. * Copies the given Color4 values into the current one
  83060. * @param source defines the source Color4 object
  83061. * @returns the current updated Color4 object
  83062. */
  83063. copyFrom(source: Color4): Color4;
  83064. /**
  83065. * Copies the given float values into the current one
  83066. * @param r defines the red component to read from
  83067. * @param g defines the green component to read from
  83068. * @param b defines the blue component to read from
  83069. * @param a defines the alpha component to read from
  83070. * @returns the current updated Color4 object
  83071. */
  83072. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  83073. /**
  83074. * Copies the given float values into the current one
  83075. * @param r defines the red component to read from
  83076. * @param g defines the green component to read from
  83077. * @param b defines the blue component to read from
  83078. * @param a defines the alpha component to read from
  83079. * @returns the current updated Color4 object
  83080. */
  83081. set(r: number, g: number, b: number, a: number): Color4;
  83082. /**
  83083. * Compute the Color4 hexadecimal code as a string
  83084. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  83085. * @returns a string containing the hexadecimal representation of the Color4 object
  83086. */
  83087. toHexString(returnAsColor3?: boolean): string;
  83088. /**
  83089. * Computes a new Color4 converted from the current one to linear space
  83090. * @returns a new Color4 object
  83091. */
  83092. toLinearSpace(): Color4;
  83093. /**
  83094. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  83095. * @param convertedColor defines the Color4 object where to store the linear space version
  83096. * @returns the unmodified Color4
  83097. */
  83098. toLinearSpaceToRef(convertedColor: Color4): Color4;
  83099. /**
  83100. * Computes a new Color4 converted from the current one to gamma space
  83101. * @returns a new Color4 object
  83102. */
  83103. toGammaSpace(): Color4;
  83104. /**
  83105. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  83106. * @param convertedColor defines the Color4 object where to store the gamma space version
  83107. * @returns the unmodified Color4
  83108. */
  83109. toGammaSpaceToRef(convertedColor: Color4): Color4;
  83110. /**
  83111. * Creates a new Color4 from the string containing valid hexadecimal values
  83112. * @param hex defines a string containing valid hexadecimal values
  83113. * @returns a new Color4 object
  83114. */
  83115. static FromHexString(hex: string): Color4;
  83116. /**
  83117. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83118. * @param left defines the start value
  83119. * @param right defines the end value
  83120. * @param amount defines the gradient factor
  83121. * @returns a new Color4 object
  83122. */
  83123. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  83124. /**
  83125. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83126. * @param left defines the start value
  83127. * @param right defines the end value
  83128. * @param amount defines the gradient factor
  83129. * @param result defines the Color4 object where to store data
  83130. */
  83131. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  83132. /**
  83133. * Creates a new Color4 from a Color3 and an alpha value
  83134. * @param color3 defines the source Color3 to read from
  83135. * @param alpha defines the alpha component (1.0 by default)
  83136. * @returns a new Color4 object
  83137. */
  83138. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  83139. /**
  83140. * Creates a new Color4 from the starting index element of the given array
  83141. * @param array defines the source array to read from
  83142. * @param offset defines the offset in the source array
  83143. * @returns a new Color4 object
  83144. */
  83145. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  83146. /**
  83147. * Creates a new Color3 from integer values (< 256)
  83148. * @param r defines the red component to read from (value between 0 and 255)
  83149. * @param g defines the green component to read from (value between 0 and 255)
  83150. * @param b defines the blue component to read from (value between 0 and 255)
  83151. * @param a defines the alpha component to read from (value between 0 and 255)
  83152. * @returns a new Color3 object
  83153. */
  83154. static FromInts(r: number, g: number, b: number, a: number): Color4;
  83155. /**
  83156. * Check the content of a given array and convert it to an array containing RGBA data
  83157. * If the original array was already containing count * 4 values then it is returned directly
  83158. * @param colors defines the array to check
  83159. * @param count defines the number of RGBA data to expect
  83160. * @returns an array containing count * 4 values (RGBA)
  83161. */
  83162. static CheckColors4(colors: number[], count: number): number[];
  83163. }
  83164. /**
  83165. * @hidden
  83166. */
  83167. export class TmpColors {
  83168. static Color3: Color3[];
  83169. static Color4: Color4[];
  83170. }
  83171. }
  83172. declare module BABYLON {
  83173. /**
  83174. * Defines an interface which represents an animation key frame
  83175. */
  83176. export interface IAnimationKey {
  83177. /**
  83178. * Frame of the key frame
  83179. */
  83180. frame: number;
  83181. /**
  83182. * Value at the specifies key frame
  83183. */
  83184. value: any;
  83185. /**
  83186. * The input tangent for the cubic hermite spline
  83187. */
  83188. inTangent?: any;
  83189. /**
  83190. * The output tangent for the cubic hermite spline
  83191. */
  83192. outTangent?: any;
  83193. /**
  83194. * The animation interpolation type
  83195. */
  83196. interpolation?: AnimationKeyInterpolation;
  83197. }
  83198. /**
  83199. * Enum for the animation key frame interpolation type
  83200. */
  83201. export enum AnimationKeyInterpolation {
  83202. /**
  83203. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  83204. */
  83205. STEP = 1
  83206. }
  83207. }
  83208. declare module BABYLON {
  83209. /**
  83210. * Represents the range of an animation
  83211. */
  83212. export class AnimationRange {
  83213. /**The name of the animation range**/
  83214. name: string;
  83215. /**The starting frame of the animation */
  83216. from: number;
  83217. /**The ending frame of the animation*/
  83218. to: number;
  83219. /**
  83220. * Initializes the range of an animation
  83221. * @param name The name of the animation range
  83222. * @param from The starting frame of the animation
  83223. * @param to The ending frame of the animation
  83224. */
  83225. constructor(
  83226. /**The name of the animation range**/
  83227. name: string,
  83228. /**The starting frame of the animation */
  83229. from: number,
  83230. /**The ending frame of the animation*/
  83231. to: number);
  83232. /**
  83233. * Makes a copy of the animation range
  83234. * @returns A copy of the animation range
  83235. */
  83236. clone(): AnimationRange;
  83237. }
  83238. }
  83239. declare module BABYLON {
  83240. /**
  83241. * Composed of a frame, and an action function
  83242. */
  83243. export class AnimationEvent {
  83244. /** The frame for which the event is triggered **/
  83245. frame: number;
  83246. /** The event to perform when triggered **/
  83247. action: (currentFrame: number) => void;
  83248. /** Specifies if the event should be triggered only once**/
  83249. onlyOnce?: boolean | undefined;
  83250. /**
  83251. * Specifies if the animation event is done
  83252. */
  83253. isDone: boolean;
  83254. /**
  83255. * Initializes the animation event
  83256. * @param frame The frame for which the event is triggered
  83257. * @param action The event to perform when triggered
  83258. * @param onlyOnce Specifies if the event should be triggered only once
  83259. */
  83260. constructor(
  83261. /** The frame for which the event is triggered **/
  83262. frame: number,
  83263. /** The event to perform when triggered **/
  83264. action: (currentFrame: number) => void,
  83265. /** Specifies if the event should be triggered only once**/
  83266. onlyOnce?: boolean | undefined);
  83267. /** @hidden */
  83268. _clone(): AnimationEvent;
  83269. }
  83270. }
  83271. declare module BABYLON {
  83272. /**
  83273. * Interface used to define a behavior
  83274. */
  83275. export interface Behavior<T> {
  83276. /** gets or sets behavior's name */
  83277. name: string;
  83278. /**
  83279. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83280. */
  83281. init(): void;
  83282. /**
  83283. * Called when the behavior is attached to a target
  83284. * @param target defines the target where the behavior is attached to
  83285. */
  83286. attach(target: T): void;
  83287. /**
  83288. * Called when the behavior is detached from its target
  83289. */
  83290. detach(): void;
  83291. }
  83292. /**
  83293. * Interface implemented by classes supporting behaviors
  83294. */
  83295. export interface IBehaviorAware<T> {
  83296. /**
  83297. * Attach a behavior
  83298. * @param behavior defines the behavior to attach
  83299. * @returns the current host
  83300. */
  83301. addBehavior(behavior: Behavior<T>): T;
  83302. /**
  83303. * Remove a behavior from the current object
  83304. * @param behavior defines the behavior to detach
  83305. * @returns the current host
  83306. */
  83307. removeBehavior(behavior: Behavior<T>): T;
  83308. /**
  83309. * Gets a behavior using its name to search
  83310. * @param name defines the name to search
  83311. * @returns the behavior or null if not found
  83312. */
  83313. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83314. }
  83315. }
  83316. declare module BABYLON {
  83317. /**
  83318. * Defines an array and its length.
  83319. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83320. */
  83321. export interface ISmartArrayLike<T> {
  83322. /**
  83323. * The data of the array.
  83324. */
  83325. data: Array<T>;
  83326. /**
  83327. * The active length of the array.
  83328. */
  83329. length: number;
  83330. }
  83331. /**
  83332. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83333. */
  83334. export class SmartArray<T> implements ISmartArrayLike<T> {
  83335. /**
  83336. * The full set of data from the array.
  83337. */
  83338. data: Array<T>;
  83339. /**
  83340. * The active length of the array.
  83341. */
  83342. length: number;
  83343. protected _id: number;
  83344. /**
  83345. * Instantiates a Smart Array.
  83346. * @param capacity defines the default capacity of the array.
  83347. */
  83348. constructor(capacity: number);
  83349. /**
  83350. * Pushes a value at the end of the active data.
  83351. * @param value defines the object to push in the array.
  83352. */
  83353. push(value: T): void;
  83354. /**
  83355. * Iterates over the active data and apply the lambda to them.
  83356. * @param func defines the action to apply on each value.
  83357. */
  83358. forEach(func: (content: T) => void): void;
  83359. /**
  83360. * Sorts the full sets of data.
  83361. * @param compareFn defines the comparison function to apply.
  83362. */
  83363. sort(compareFn: (a: T, b: T) => number): void;
  83364. /**
  83365. * Resets the active data to an empty array.
  83366. */
  83367. reset(): void;
  83368. /**
  83369. * Releases all the data from the array as well as the array.
  83370. */
  83371. dispose(): void;
  83372. /**
  83373. * Concats the active data with a given array.
  83374. * @param array defines the data to concatenate with.
  83375. */
  83376. concat(array: any): void;
  83377. /**
  83378. * Returns the position of a value in the active data.
  83379. * @param value defines the value to find the index for
  83380. * @returns the index if found in the active data otherwise -1
  83381. */
  83382. indexOf(value: T): number;
  83383. /**
  83384. * Returns whether an element is part of the active data.
  83385. * @param value defines the value to look for
  83386. * @returns true if found in the active data otherwise false
  83387. */
  83388. contains(value: T): boolean;
  83389. private static _GlobalId;
  83390. }
  83391. /**
  83392. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83393. * The data in this array can only be present once
  83394. */
  83395. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83396. private _duplicateId;
  83397. /**
  83398. * Pushes a value at the end of the active data.
  83399. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83400. * @param value defines the object to push in the array.
  83401. */
  83402. push(value: T): void;
  83403. /**
  83404. * Pushes a value at the end of the active data.
  83405. * If the data is already present, it won t be added again
  83406. * @param value defines the object to push in the array.
  83407. * @returns true if added false if it was already present
  83408. */
  83409. pushNoDuplicate(value: T): boolean;
  83410. /**
  83411. * Resets the active data to an empty array.
  83412. */
  83413. reset(): void;
  83414. /**
  83415. * Concats the active data with a given array.
  83416. * This ensures no dupplicate will be present in the result.
  83417. * @param array defines the data to concatenate with.
  83418. */
  83419. concatWithNoDuplicate(array: any): void;
  83420. }
  83421. }
  83422. declare module BABYLON {
  83423. /**
  83424. * @ignore
  83425. * This is a list of all the different input types that are available in the application.
  83426. * Fo instance: ArcRotateCameraGamepadInput...
  83427. */
  83428. export var CameraInputTypes: {};
  83429. /**
  83430. * This is the contract to implement in order to create a new input class.
  83431. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  83432. */
  83433. export interface ICameraInput<TCamera extends Camera> {
  83434. /**
  83435. * Defines the camera the input is attached to.
  83436. */
  83437. camera: Nullable<TCamera>;
  83438. /**
  83439. * Gets the class name of the current intput.
  83440. * @returns the class name
  83441. */
  83442. getClassName(): string;
  83443. /**
  83444. * Get the friendly name associated with the input class.
  83445. * @returns the input friendly name
  83446. */
  83447. getSimpleName(): string;
  83448. /**
  83449. * Attach the input controls to a specific dom element to get the input from.
  83450. * @param element Defines the element the controls should be listened from
  83451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83452. */
  83453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83454. /**
  83455. * Detach the current controls from the specified dom element.
  83456. * @param element Defines the element to stop listening the inputs from
  83457. */
  83458. detachControl(element: Nullable<HTMLElement>): void;
  83459. /**
  83460. * Update the current camera state depending on the inputs that have been used this frame.
  83461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83462. */
  83463. checkInputs?: () => void;
  83464. }
  83465. /**
  83466. * Represents a map of input types to input instance or input index to input instance.
  83467. */
  83468. export interface CameraInputsMap<TCamera extends Camera> {
  83469. /**
  83470. * Accessor to the input by input type.
  83471. */
  83472. [name: string]: ICameraInput<TCamera>;
  83473. /**
  83474. * Accessor to the input by input index.
  83475. */
  83476. [idx: number]: ICameraInput<TCamera>;
  83477. }
  83478. /**
  83479. * This represents the input manager used within a camera.
  83480. * It helps dealing with all the different kind of input attached to a camera.
  83481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83482. */
  83483. export class CameraInputsManager<TCamera extends Camera> {
  83484. /**
  83485. * Defines the list of inputs attahed to the camera.
  83486. */
  83487. attached: CameraInputsMap<TCamera>;
  83488. /**
  83489. * Defines the dom element the camera is collecting inputs from.
  83490. * This is null if the controls have not been attached.
  83491. */
  83492. attachedElement: Nullable<HTMLElement>;
  83493. /**
  83494. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83495. */
  83496. noPreventDefault: boolean;
  83497. /**
  83498. * Defined the camera the input manager belongs to.
  83499. */
  83500. camera: TCamera;
  83501. /**
  83502. * Update the current camera state depending on the inputs that have been used this frame.
  83503. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83504. */
  83505. checkInputs: () => void;
  83506. /**
  83507. * Instantiate a new Camera Input Manager.
  83508. * @param camera Defines the camera the input manager blongs to
  83509. */
  83510. constructor(camera: TCamera);
  83511. /**
  83512. * Add an input method to a camera
  83513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83514. * @param input camera input method
  83515. */
  83516. add(input: ICameraInput<TCamera>): void;
  83517. /**
  83518. * Remove a specific input method from a camera
  83519. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  83520. * @param inputToRemove camera input method
  83521. */
  83522. remove(inputToRemove: ICameraInput<TCamera>): void;
  83523. /**
  83524. * Remove a specific input type from a camera
  83525. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  83526. * @param inputType the type of the input to remove
  83527. */
  83528. removeByType(inputType: string): void;
  83529. private _addCheckInputs;
  83530. /**
  83531. * Attach the input controls to the currently attached dom element to listen the events from.
  83532. * @param input Defines the input to attach
  83533. */
  83534. attachInput(input: ICameraInput<TCamera>): void;
  83535. /**
  83536. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  83537. * @param element Defines the dom element to collect the events from
  83538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83539. */
  83540. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  83541. /**
  83542. * Detach the current manager inputs controls from a specific dom element.
  83543. * @param element Defines the dom element to collect the events from
  83544. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  83545. */
  83546. detachElement(element: HTMLElement, disconnect?: boolean): void;
  83547. /**
  83548. * Rebuild the dynamic inputCheck function from the current list of
  83549. * defined inputs in the manager.
  83550. */
  83551. rebuildInputCheck(): void;
  83552. /**
  83553. * Remove all attached input methods from a camera
  83554. */
  83555. clear(): void;
  83556. /**
  83557. * Serialize the current input manager attached to a camera.
  83558. * This ensures than once parsed,
  83559. * the input associated to the camera will be identical to the current ones
  83560. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  83561. */
  83562. serialize(serializedCamera: any): void;
  83563. /**
  83564. * Parses an input manager serialized JSON to restore the previous list of inputs
  83565. * and states associated to a camera.
  83566. * @param parsedCamera Defines the JSON to parse
  83567. */
  83568. parse(parsedCamera: any): void;
  83569. }
  83570. }
  83571. declare module BABYLON {
  83572. /**
  83573. * Class used to store data that will be store in GPU memory
  83574. */
  83575. export class Buffer {
  83576. private _engine;
  83577. private _buffer;
  83578. /** @hidden */
  83579. _data: Nullable<DataArray>;
  83580. private _updatable;
  83581. private _instanced;
  83582. private _divisor;
  83583. /**
  83584. * Gets the byte stride.
  83585. */
  83586. readonly byteStride: number;
  83587. /**
  83588. * Constructor
  83589. * @param engine the engine
  83590. * @param data the data to use for this buffer
  83591. * @param updatable whether the data is updatable
  83592. * @param stride the stride (optional)
  83593. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83594. * @param instanced whether the buffer is instanced (optional)
  83595. * @param useBytes set to true if the stride in in bytes (optional)
  83596. * @param divisor sets an optional divisor for instances (1 by default)
  83597. */
  83598. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  83599. /**
  83600. * Create a new VertexBuffer based on the current buffer
  83601. * @param kind defines the vertex buffer kind (position, normal, etc.)
  83602. * @param offset defines offset in the buffer (0 by default)
  83603. * @param size defines the size in floats of attributes (position is 3 for instance)
  83604. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  83605. * @param instanced defines if the vertex buffer contains indexed data
  83606. * @param useBytes defines if the offset and stride are in bytes *
  83607. * @param divisor sets an optional divisor for instances (1 by default)
  83608. * @returns the new vertex buffer
  83609. */
  83610. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  83611. /**
  83612. * Gets a boolean indicating if the Buffer is updatable?
  83613. * @returns true if the buffer is updatable
  83614. */
  83615. isUpdatable(): boolean;
  83616. /**
  83617. * Gets current buffer's data
  83618. * @returns a DataArray or null
  83619. */
  83620. getData(): Nullable<DataArray>;
  83621. /**
  83622. * Gets underlying native buffer
  83623. * @returns underlying native buffer
  83624. */
  83625. getBuffer(): Nullable<DataBuffer>;
  83626. /**
  83627. * Gets the stride in float32 units (i.e. byte stride / 4).
  83628. * May not be an integer if the byte stride is not divisible by 4.
  83629. * @returns the stride in float32 units
  83630. * @deprecated Please use byteStride instead.
  83631. */
  83632. getStrideSize(): number;
  83633. /**
  83634. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83635. * @param data defines the data to store
  83636. */
  83637. create(data?: Nullable<DataArray>): void;
  83638. /** @hidden */
  83639. _rebuild(): void;
  83640. /**
  83641. * Update current buffer data
  83642. * @param data defines the data to store
  83643. */
  83644. update(data: DataArray): void;
  83645. /**
  83646. * Updates the data directly.
  83647. * @param data the new data
  83648. * @param offset the new offset
  83649. * @param vertexCount the vertex count (optional)
  83650. * @param useBytes set to true if the offset is in bytes
  83651. */
  83652. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  83653. /**
  83654. * Release all resources
  83655. */
  83656. dispose(): void;
  83657. }
  83658. /**
  83659. * Specialized buffer used to store vertex data
  83660. */
  83661. export class VertexBuffer {
  83662. /** @hidden */
  83663. _buffer: Buffer;
  83664. private _kind;
  83665. private _size;
  83666. private _ownsBuffer;
  83667. private _instanced;
  83668. private _instanceDivisor;
  83669. /**
  83670. * The byte type.
  83671. */
  83672. static readonly BYTE: number;
  83673. /**
  83674. * The unsigned byte type.
  83675. */
  83676. static readonly UNSIGNED_BYTE: number;
  83677. /**
  83678. * The short type.
  83679. */
  83680. static readonly SHORT: number;
  83681. /**
  83682. * The unsigned short type.
  83683. */
  83684. static readonly UNSIGNED_SHORT: number;
  83685. /**
  83686. * The integer type.
  83687. */
  83688. static readonly INT: number;
  83689. /**
  83690. * The unsigned integer type.
  83691. */
  83692. static readonly UNSIGNED_INT: number;
  83693. /**
  83694. * The float type.
  83695. */
  83696. static readonly FLOAT: number;
  83697. /**
  83698. * Gets or sets the instance divisor when in instanced mode
  83699. */
  83700. get instanceDivisor(): number;
  83701. set instanceDivisor(value: number);
  83702. /**
  83703. * Gets the byte stride.
  83704. */
  83705. readonly byteStride: number;
  83706. /**
  83707. * Gets the byte offset.
  83708. */
  83709. readonly byteOffset: number;
  83710. /**
  83711. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  83712. */
  83713. readonly normalized: boolean;
  83714. /**
  83715. * Gets the data type of each component in the array.
  83716. */
  83717. readonly type: number;
  83718. /**
  83719. * Constructor
  83720. * @param engine the engine
  83721. * @param data the data to use for this vertex buffer
  83722. * @param kind the vertex buffer kind
  83723. * @param updatable whether the data is updatable
  83724. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83725. * @param stride the stride (optional)
  83726. * @param instanced whether the buffer is instanced (optional)
  83727. * @param offset the offset of the data (optional)
  83728. * @param size the number of components (optional)
  83729. * @param type the type of the component (optional)
  83730. * @param normalized whether the data contains normalized data (optional)
  83731. * @param useBytes set to true if stride and offset are in bytes (optional)
  83732. * @param divisor defines the instance divisor to use (1 by default)
  83733. */
  83734. 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);
  83735. /** @hidden */
  83736. _rebuild(): void;
  83737. /**
  83738. * Returns the kind of the VertexBuffer (string)
  83739. * @returns a string
  83740. */
  83741. getKind(): string;
  83742. /**
  83743. * Gets a boolean indicating if the VertexBuffer is updatable?
  83744. * @returns true if the buffer is updatable
  83745. */
  83746. isUpdatable(): boolean;
  83747. /**
  83748. * Gets current buffer's data
  83749. * @returns a DataArray or null
  83750. */
  83751. getData(): Nullable<DataArray>;
  83752. /**
  83753. * Gets underlying native buffer
  83754. * @returns underlying native buffer
  83755. */
  83756. getBuffer(): Nullable<DataBuffer>;
  83757. /**
  83758. * Gets the stride in float32 units (i.e. byte stride / 4).
  83759. * May not be an integer if the byte stride is not divisible by 4.
  83760. * @returns the stride in float32 units
  83761. * @deprecated Please use byteStride instead.
  83762. */
  83763. getStrideSize(): number;
  83764. /**
  83765. * Returns the offset as a multiple of the type byte length.
  83766. * @returns the offset in bytes
  83767. * @deprecated Please use byteOffset instead.
  83768. */
  83769. getOffset(): number;
  83770. /**
  83771. * Returns the number of components per vertex attribute (integer)
  83772. * @returns the size in float
  83773. */
  83774. getSize(): number;
  83775. /**
  83776. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  83777. * @returns true if this buffer is instanced
  83778. */
  83779. getIsInstanced(): boolean;
  83780. /**
  83781. * Returns the instancing divisor, zero for non-instanced (integer).
  83782. * @returns a number
  83783. */
  83784. getInstanceDivisor(): number;
  83785. /**
  83786. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83787. * @param data defines the data to store
  83788. */
  83789. create(data?: DataArray): void;
  83790. /**
  83791. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  83792. * This function will create a new buffer if the current one is not updatable
  83793. * @param data defines the data to store
  83794. */
  83795. update(data: DataArray): void;
  83796. /**
  83797. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  83798. * Returns the directly updated WebGLBuffer.
  83799. * @param data the new data
  83800. * @param offset the new offset
  83801. * @param useBytes set to true if the offset is in bytes
  83802. */
  83803. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  83804. /**
  83805. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  83806. */
  83807. dispose(): void;
  83808. /**
  83809. * Enumerates each value of this vertex buffer as numbers.
  83810. * @param count the number of values to enumerate
  83811. * @param callback the callback function called for each value
  83812. */
  83813. forEach(count: number, callback: (value: number, index: number) => void): void;
  83814. /**
  83815. * Positions
  83816. */
  83817. static readonly PositionKind: string;
  83818. /**
  83819. * Normals
  83820. */
  83821. static readonly NormalKind: string;
  83822. /**
  83823. * Tangents
  83824. */
  83825. static readonly TangentKind: string;
  83826. /**
  83827. * Texture coordinates
  83828. */
  83829. static readonly UVKind: string;
  83830. /**
  83831. * Texture coordinates 2
  83832. */
  83833. static readonly UV2Kind: string;
  83834. /**
  83835. * Texture coordinates 3
  83836. */
  83837. static readonly UV3Kind: string;
  83838. /**
  83839. * Texture coordinates 4
  83840. */
  83841. static readonly UV4Kind: string;
  83842. /**
  83843. * Texture coordinates 5
  83844. */
  83845. static readonly UV5Kind: string;
  83846. /**
  83847. * Texture coordinates 6
  83848. */
  83849. static readonly UV6Kind: string;
  83850. /**
  83851. * Colors
  83852. */
  83853. static readonly ColorKind: string;
  83854. /**
  83855. * Matrix indices (for bones)
  83856. */
  83857. static readonly MatricesIndicesKind: string;
  83858. /**
  83859. * Matrix weights (for bones)
  83860. */
  83861. static readonly MatricesWeightsKind: string;
  83862. /**
  83863. * Additional matrix indices (for bones)
  83864. */
  83865. static readonly MatricesIndicesExtraKind: string;
  83866. /**
  83867. * Additional matrix weights (for bones)
  83868. */
  83869. static readonly MatricesWeightsExtraKind: string;
  83870. /**
  83871. * Deduces the stride given a kind.
  83872. * @param kind The kind string to deduce
  83873. * @returns The deduced stride
  83874. */
  83875. static DeduceStride(kind: string): number;
  83876. /**
  83877. * Gets the byte length of the given type.
  83878. * @param type the type
  83879. * @returns the number of bytes
  83880. */
  83881. static GetTypeByteLength(type: number): number;
  83882. /**
  83883. * Enumerates each value of the given parameters as numbers.
  83884. * @param data the data to enumerate
  83885. * @param byteOffset the byte offset of the data
  83886. * @param byteStride the byte stride of the data
  83887. * @param componentCount the number of components per element
  83888. * @param componentType the type of the component
  83889. * @param count the number of values to enumerate
  83890. * @param normalized whether the data is normalized
  83891. * @param callback the callback function called for each value
  83892. */
  83893. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  83894. private static _GetFloatValue;
  83895. }
  83896. }
  83897. declare module BABYLON {
  83898. /**
  83899. * @hidden
  83900. */
  83901. export class IntersectionInfo {
  83902. bu: Nullable<number>;
  83903. bv: Nullable<number>;
  83904. distance: number;
  83905. faceId: number;
  83906. subMeshId: number;
  83907. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  83908. }
  83909. }
  83910. declare module BABYLON {
  83911. /**
  83912. * Class used to store bounding sphere information
  83913. */
  83914. export class BoundingSphere {
  83915. /**
  83916. * Gets the center of the bounding sphere in local space
  83917. */
  83918. readonly center: Vector3;
  83919. /**
  83920. * Radius of the bounding sphere in local space
  83921. */
  83922. radius: number;
  83923. /**
  83924. * Gets the center of the bounding sphere in world space
  83925. */
  83926. readonly centerWorld: Vector3;
  83927. /**
  83928. * Radius of the bounding sphere in world space
  83929. */
  83930. radiusWorld: number;
  83931. /**
  83932. * Gets the minimum vector in local space
  83933. */
  83934. readonly minimum: Vector3;
  83935. /**
  83936. * Gets the maximum vector in local space
  83937. */
  83938. readonly maximum: Vector3;
  83939. private _worldMatrix;
  83940. private static readonly TmpVector3;
  83941. /**
  83942. * Creates a new bounding sphere
  83943. * @param min defines the minimum vector (in local space)
  83944. * @param max defines the maximum vector (in local space)
  83945. * @param worldMatrix defines the new world matrix
  83946. */
  83947. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  83948. /**
  83949. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  83950. * @param min defines the new minimum vector (in local space)
  83951. * @param max defines the new maximum vector (in local space)
  83952. * @param worldMatrix defines the new world matrix
  83953. */
  83954. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  83955. /**
  83956. * Scale the current bounding sphere by applying a scale factor
  83957. * @param factor defines the scale factor to apply
  83958. * @returns the current bounding box
  83959. */
  83960. scale(factor: number): BoundingSphere;
  83961. /**
  83962. * Gets the world matrix of the bounding box
  83963. * @returns a matrix
  83964. */
  83965. getWorldMatrix(): DeepImmutable<Matrix>;
  83966. /** @hidden */
  83967. _update(worldMatrix: DeepImmutable<Matrix>): void;
  83968. /**
  83969. * Tests if the bounding sphere is intersecting the frustum planes
  83970. * @param frustumPlanes defines the frustum planes to test
  83971. * @returns true if there is an intersection
  83972. */
  83973. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83974. /**
  83975. * Tests if the bounding sphere center is in between the frustum planes.
  83976. * Used for optimistic fast inclusion.
  83977. * @param frustumPlanes defines the frustum planes to test
  83978. * @returns true if the sphere center is in between the frustum planes
  83979. */
  83980. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83981. /**
  83982. * Tests if a point is inside the bounding sphere
  83983. * @param point defines the point to test
  83984. * @returns true if the point is inside the bounding sphere
  83985. */
  83986. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  83987. /**
  83988. * Checks if two sphere intersct
  83989. * @param sphere0 sphere 0
  83990. * @param sphere1 sphere 1
  83991. * @returns true if the speres intersect
  83992. */
  83993. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  83994. }
  83995. }
  83996. declare module BABYLON {
  83997. /**
  83998. * Class used to store bounding box information
  83999. */
  84000. export class BoundingBox implements ICullable {
  84001. /**
  84002. * Gets the 8 vectors representing the bounding box in local space
  84003. */
  84004. readonly vectors: Vector3[];
  84005. /**
  84006. * Gets the center of the bounding box in local space
  84007. */
  84008. readonly center: Vector3;
  84009. /**
  84010. * Gets the center of the bounding box in world space
  84011. */
  84012. readonly centerWorld: Vector3;
  84013. /**
  84014. * Gets the extend size in local space
  84015. */
  84016. readonly extendSize: Vector3;
  84017. /**
  84018. * Gets the extend size in world space
  84019. */
  84020. readonly extendSizeWorld: Vector3;
  84021. /**
  84022. * Gets the OBB (object bounding box) directions
  84023. */
  84024. readonly directions: Vector3[];
  84025. /**
  84026. * Gets the 8 vectors representing the bounding box in world space
  84027. */
  84028. readonly vectorsWorld: Vector3[];
  84029. /**
  84030. * Gets the minimum vector in world space
  84031. */
  84032. readonly minimumWorld: Vector3;
  84033. /**
  84034. * Gets the maximum vector in world space
  84035. */
  84036. readonly maximumWorld: Vector3;
  84037. /**
  84038. * Gets the minimum vector in local space
  84039. */
  84040. readonly minimum: Vector3;
  84041. /**
  84042. * Gets the maximum vector in local space
  84043. */
  84044. readonly maximum: Vector3;
  84045. private _worldMatrix;
  84046. private static readonly TmpVector3;
  84047. /**
  84048. * @hidden
  84049. */
  84050. _tag: number;
  84051. /**
  84052. * Creates a new bounding box
  84053. * @param min defines the minimum vector (in local space)
  84054. * @param max defines the maximum vector (in local space)
  84055. * @param worldMatrix defines the new world matrix
  84056. */
  84057. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84058. /**
  84059. * Recreates the entire bounding box from scratch as if we call the constructor in place
  84060. * @param min defines the new minimum vector (in local space)
  84061. * @param max defines the new maximum vector (in local space)
  84062. * @param worldMatrix defines the new world matrix
  84063. */
  84064. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84065. /**
  84066. * Scale the current bounding box by applying a scale factor
  84067. * @param factor defines the scale factor to apply
  84068. * @returns the current bounding box
  84069. */
  84070. scale(factor: number): BoundingBox;
  84071. /**
  84072. * Gets the world matrix of the bounding box
  84073. * @returns a matrix
  84074. */
  84075. getWorldMatrix(): DeepImmutable<Matrix>;
  84076. /** @hidden */
  84077. _update(world: DeepImmutable<Matrix>): void;
  84078. /**
  84079. * Tests if the bounding box is intersecting the frustum planes
  84080. * @param frustumPlanes defines the frustum planes to test
  84081. * @returns true if there is an intersection
  84082. */
  84083. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84084. /**
  84085. * Tests if the bounding box is entirely inside the frustum planes
  84086. * @param frustumPlanes defines the frustum planes to test
  84087. * @returns true if there is an inclusion
  84088. */
  84089. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84090. /**
  84091. * Tests if a point is inside the bounding box
  84092. * @param point defines the point to test
  84093. * @returns true if the point is inside the bounding box
  84094. */
  84095. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84096. /**
  84097. * Tests if the bounding box intersects with a bounding sphere
  84098. * @param sphere defines the sphere to test
  84099. * @returns true if there is an intersection
  84100. */
  84101. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  84102. /**
  84103. * Tests if the bounding box intersects with a box defined by a min and max vectors
  84104. * @param min defines the min vector to use
  84105. * @param max defines the max vector to use
  84106. * @returns true if there is an intersection
  84107. */
  84108. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  84109. /**
  84110. * Tests if two bounding boxes are intersections
  84111. * @param box0 defines the first box to test
  84112. * @param box1 defines the second box to test
  84113. * @returns true if there is an intersection
  84114. */
  84115. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  84116. /**
  84117. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  84118. * @param minPoint defines the minimum vector of the bounding box
  84119. * @param maxPoint defines the maximum vector of the bounding box
  84120. * @param sphereCenter defines the sphere center
  84121. * @param sphereRadius defines the sphere radius
  84122. * @returns true if there is an intersection
  84123. */
  84124. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  84125. /**
  84126. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  84127. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84128. * @param frustumPlanes defines the frustum planes to test
  84129. * @return true if there is an inclusion
  84130. */
  84131. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84132. /**
  84133. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  84134. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84135. * @param frustumPlanes defines the frustum planes to test
  84136. * @return true if there is an intersection
  84137. */
  84138. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84139. }
  84140. }
  84141. declare module BABYLON {
  84142. /** @hidden */
  84143. export class Collider {
  84144. /** Define if a collision was found */
  84145. collisionFound: boolean;
  84146. /**
  84147. * Define last intersection point in local space
  84148. */
  84149. intersectionPoint: Vector3;
  84150. /**
  84151. * Define last collided mesh
  84152. */
  84153. collidedMesh: Nullable<AbstractMesh>;
  84154. private _collisionPoint;
  84155. private _planeIntersectionPoint;
  84156. private _tempVector;
  84157. private _tempVector2;
  84158. private _tempVector3;
  84159. private _tempVector4;
  84160. private _edge;
  84161. private _baseToVertex;
  84162. private _destinationPoint;
  84163. private _slidePlaneNormal;
  84164. private _displacementVector;
  84165. /** @hidden */
  84166. _radius: Vector3;
  84167. /** @hidden */
  84168. _retry: number;
  84169. private _velocity;
  84170. private _basePoint;
  84171. private _epsilon;
  84172. /** @hidden */
  84173. _velocityWorldLength: number;
  84174. /** @hidden */
  84175. _basePointWorld: Vector3;
  84176. private _velocityWorld;
  84177. private _normalizedVelocity;
  84178. /** @hidden */
  84179. _initialVelocity: Vector3;
  84180. /** @hidden */
  84181. _initialPosition: Vector3;
  84182. private _nearestDistance;
  84183. private _collisionMask;
  84184. get collisionMask(): number;
  84185. set collisionMask(mask: number);
  84186. /**
  84187. * Gets the plane normal used to compute the sliding response (in local space)
  84188. */
  84189. get slidePlaneNormal(): Vector3;
  84190. /** @hidden */
  84191. _initialize(source: Vector3, dir: Vector3, e: number): void;
  84192. /** @hidden */
  84193. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  84194. /** @hidden */
  84195. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  84196. /** @hidden */
  84197. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84198. /** @hidden */
  84199. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84200. /** @hidden */
  84201. _getResponse(pos: Vector3, vel: Vector3): void;
  84202. }
  84203. }
  84204. declare module BABYLON {
  84205. /**
  84206. * Interface for cullable objects
  84207. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  84208. */
  84209. export interface ICullable {
  84210. /**
  84211. * Checks if the object or part of the object is in the frustum
  84212. * @param frustumPlanes Camera near/planes
  84213. * @returns true if the object is in frustum otherwise false
  84214. */
  84215. isInFrustum(frustumPlanes: Plane[]): boolean;
  84216. /**
  84217. * Checks if a cullable object (mesh...) is in the camera frustum
  84218. * Unlike isInFrustum this cheks the full bounding box
  84219. * @param frustumPlanes Camera near/planes
  84220. * @returns true if the object is in frustum otherwise false
  84221. */
  84222. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84223. }
  84224. /**
  84225. * Info for a bounding data of a mesh
  84226. */
  84227. export class BoundingInfo implements ICullable {
  84228. /**
  84229. * Bounding box for the mesh
  84230. */
  84231. readonly boundingBox: BoundingBox;
  84232. /**
  84233. * Bounding sphere for the mesh
  84234. */
  84235. readonly boundingSphere: BoundingSphere;
  84236. private _isLocked;
  84237. private static readonly TmpVector3;
  84238. /**
  84239. * Constructs bounding info
  84240. * @param minimum min vector of the bounding box/sphere
  84241. * @param maximum max vector of the bounding box/sphere
  84242. * @param worldMatrix defines the new world matrix
  84243. */
  84244. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84245. /**
  84246. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84247. * @param min defines the new minimum vector (in local space)
  84248. * @param max defines the new maximum vector (in local space)
  84249. * @param worldMatrix defines the new world matrix
  84250. */
  84251. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84252. /**
  84253. * min vector of the bounding box/sphere
  84254. */
  84255. get minimum(): Vector3;
  84256. /**
  84257. * max vector of the bounding box/sphere
  84258. */
  84259. get maximum(): Vector3;
  84260. /**
  84261. * If the info is locked and won't be updated to avoid perf overhead
  84262. */
  84263. get isLocked(): boolean;
  84264. set isLocked(value: boolean);
  84265. /**
  84266. * Updates the bounding sphere and box
  84267. * @param world world matrix to be used to update
  84268. */
  84269. update(world: DeepImmutable<Matrix>): void;
  84270. /**
  84271. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84272. * @param center New center of the bounding info
  84273. * @param extend New extend of the bounding info
  84274. * @returns the current bounding info
  84275. */
  84276. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84277. /**
  84278. * Scale the current bounding info by applying a scale factor
  84279. * @param factor defines the scale factor to apply
  84280. * @returns the current bounding info
  84281. */
  84282. scale(factor: number): BoundingInfo;
  84283. /**
  84284. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84285. * @param frustumPlanes defines the frustum to test
  84286. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84287. * @returns true if the bounding info is in the frustum planes
  84288. */
  84289. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84290. /**
  84291. * Gets the world distance between the min and max points of the bounding box
  84292. */
  84293. get diagonalLength(): number;
  84294. /**
  84295. * Checks if a cullable object (mesh...) is in the camera frustum
  84296. * Unlike isInFrustum this cheks the full bounding box
  84297. * @param frustumPlanes Camera near/planes
  84298. * @returns true if the object is in frustum otherwise false
  84299. */
  84300. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84301. /** @hidden */
  84302. _checkCollision(collider: Collider): boolean;
  84303. /**
  84304. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84305. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84306. * @param point the point to check intersection with
  84307. * @returns if the point intersects
  84308. */
  84309. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84310. /**
  84311. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84312. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84313. * @param boundingInfo the bounding info to check intersection with
  84314. * @param precise if the intersection should be done using OBB
  84315. * @returns if the bounding info intersects
  84316. */
  84317. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  84318. }
  84319. }
  84320. declare module BABYLON {
  84321. /**
  84322. * Extracts minimum and maximum values from a list of indexed positions
  84323. * @param positions defines the positions to use
  84324. * @param indices defines the indices to the positions
  84325. * @param indexStart defines the start index
  84326. * @param indexCount defines the end index
  84327. * @param bias defines bias value to add to the result
  84328. * @return minimum and maximum values
  84329. */
  84330. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  84331. minimum: Vector3;
  84332. maximum: Vector3;
  84333. };
  84334. /**
  84335. * Extracts minimum and maximum values from a list of positions
  84336. * @param positions defines the positions to use
  84337. * @param start defines the start index in the positions array
  84338. * @param count defines the number of positions to handle
  84339. * @param bias defines bias value to add to the result
  84340. * @param stride defines the stride size to use (distance between two positions in the positions array)
  84341. * @return minimum and maximum values
  84342. */
  84343. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  84344. minimum: Vector3;
  84345. maximum: Vector3;
  84346. };
  84347. }
  84348. declare module BABYLON {
  84349. /** @hidden */
  84350. export class WebGLDataBuffer extends DataBuffer {
  84351. private _buffer;
  84352. constructor(resource: WebGLBuffer);
  84353. get underlyingResource(): any;
  84354. }
  84355. }
  84356. declare module BABYLON {
  84357. /** @hidden */
  84358. export class WebGLPipelineContext implements IPipelineContext {
  84359. engine: ThinEngine;
  84360. program: Nullable<WebGLProgram>;
  84361. context?: WebGLRenderingContext;
  84362. vertexShader?: WebGLShader;
  84363. fragmentShader?: WebGLShader;
  84364. isParallelCompiled: boolean;
  84365. onCompiled?: () => void;
  84366. transformFeedback?: WebGLTransformFeedback | null;
  84367. vertexCompilationError: Nullable<string>;
  84368. fragmentCompilationError: Nullable<string>;
  84369. programLinkError: Nullable<string>;
  84370. programValidationError: Nullable<string>;
  84371. get isAsync(): boolean;
  84372. get isReady(): boolean;
  84373. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  84374. _getVertexShaderCode(): string | null;
  84375. _getFragmentShaderCode(): string | null;
  84376. }
  84377. }
  84378. declare module BABYLON {
  84379. interface ThinEngine {
  84380. /**
  84381. * Create an uniform buffer
  84382. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84383. * @param elements defines the content of the uniform buffer
  84384. * @returns the webGL uniform buffer
  84385. */
  84386. createUniformBuffer(elements: FloatArray): DataBuffer;
  84387. /**
  84388. * Create a dynamic uniform buffer
  84389. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84390. * @param elements defines the content of the uniform buffer
  84391. * @returns the webGL uniform buffer
  84392. */
  84393. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  84394. /**
  84395. * Update an existing uniform buffer
  84396. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84397. * @param uniformBuffer defines the target uniform buffer
  84398. * @param elements defines the content to update
  84399. * @param offset defines the offset in the uniform buffer where update should start
  84400. * @param count defines the size of the data to update
  84401. */
  84402. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84403. /**
  84404. * Bind an uniform buffer to the current webGL context
  84405. * @param buffer defines the buffer to bind
  84406. */
  84407. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  84408. /**
  84409. * Bind a buffer to the current webGL context at a given location
  84410. * @param buffer defines the buffer to bind
  84411. * @param location defines the index where to bind the buffer
  84412. */
  84413. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  84414. /**
  84415. * Bind a specific block at a given index in a specific shader program
  84416. * @param pipelineContext defines the pipeline context to use
  84417. * @param blockName defines the block name
  84418. * @param index defines the index where to bind the block
  84419. */
  84420. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  84421. }
  84422. }
  84423. declare module BABYLON {
  84424. /**
  84425. * Uniform buffer objects.
  84426. *
  84427. * Handles blocks of uniform on the GPU.
  84428. *
  84429. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84430. *
  84431. * For more information, please refer to :
  84432. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84433. */
  84434. export class UniformBuffer {
  84435. private _engine;
  84436. private _buffer;
  84437. private _data;
  84438. private _bufferData;
  84439. private _dynamic?;
  84440. private _uniformLocations;
  84441. private _uniformSizes;
  84442. private _uniformLocationPointer;
  84443. private _needSync;
  84444. private _noUBO;
  84445. private _currentEffect;
  84446. /** @hidden */
  84447. _alreadyBound: boolean;
  84448. private static _MAX_UNIFORM_SIZE;
  84449. private static _tempBuffer;
  84450. /**
  84451. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84452. * This is dynamic to allow compat with webgl 1 and 2.
  84453. * You will need to pass the name of the uniform as well as the value.
  84454. */
  84455. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84456. /**
  84457. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84458. * This is dynamic to allow compat with webgl 1 and 2.
  84459. * You will need to pass the name of the uniform as well as the value.
  84460. */
  84461. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84462. /**
  84463. * Lambda to Update a single float in a uniform buffer.
  84464. * This is dynamic to allow compat with webgl 1 and 2.
  84465. * You will need to pass the name of the uniform as well as the value.
  84466. */
  84467. updateFloat: (name: string, x: number) => void;
  84468. /**
  84469. * Lambda to Update a vec2 of float in a uniform buffer.
  84470. * This is dynamic to allow compat with webgl 1 and 2.
  84471. * You will need to pass the name of the uniform as well as the value.
  84472. */
  84473. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84474. /**
  84475. * Lambda to Update a vec3 of float in a uniform buffer.
  84476. * This is dynamic to allow compat with webgl 1 and 2.
  84477. * You will need to pass the name of the uniform as well as the value.
  84478. */
  84479. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84480. /**
  84481. * Lambda to Update a vec4 of float in a uniform buffer.
  84482. * This is dynamic to allow compat with webgl 1 and 2.
  84483. * You will need to pass the name of the uniform as well as the value.
  84484. */
  84485. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84486. /**
  84487. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84488. * This is dynamic to allow compat with webgl 1 and 2.
  84489. * You will need to pass the name of the uniform as well as the value.
  84490. */
  84491. updateMatrix: (name: string, mat: Matrix) => void;
  84492. /**
  84493. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84494. * This is dynamic to allow compat with webgl 1 and 2.
  84495. * You will need to pass the name of the uniform as well as the value.
  84496. */
  84497. updateVector3: (name: string, vector: Vector3) => void;
  84498. /**
  84499. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84500. * This is dynamic to allow compat with webgl 1 and 2.
  84501. * You will need to pass the name of the uniform as well as the value.
  84502. */
  84503. updateVector4: (name: string, vector: Vector4) => void;
  84504. /**
  84505. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84506. * This is dynamic to allow compat with webgl 1 and 2.
  84507. * You will need to pass the name of the uniform as well as the value.
  84508. */
  84509. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84510. /**
  84511. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84512. * This is dynamic to allow compat with webgl 1 and 2.
  84513. * You will need to pass the name of the uniform as well as the value.
  84514. */
  84515. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84516. /**
  84517. * Instantiates a new Uniform buffer objects.
  84518. *
  84519. * Handles blocks of uniform on the GPU.
  84520. *
  84521. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84522. *
  84523. * For more information, please refer to :
  84524. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84525. * @param engine Define the engine the buffer is associated with
  84526. * @param data Define the data contained in the buffer
  84527. * @param dynamic Define if the buffer is updatable
  84528. */
  84529. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84530. /**
  84531. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84532. * or just falling back on setUniformXXX calls.
  84533. */
  84534. get useUbo(): boolean;
  84535. /**
  84536. * Indicates if the WebGL underlying uniform buffer is in sync
  84537. * with the javascript cache data.
  84538. */
  84539. get isSync(): boolean;
  84540. /**
  84541. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84542. * Also, a dynamic UniformBuffer will disable cache verification and always
  84543. * update the underlying WebGL uniform buffer to the GPU.
  84544. * @returns if Dynamic, otherwise false
  84545. */
  84546. isDynamic(): boolean;
  84547. /**
  84548. * The data cache on JS side.
  84549. * @returns the underlying data as a float array
  84550. */
  84551. getData(): Float32Array;
  84552. /**
  84553. * The underlying WebGL Uniform buffer.
  84554. * @returns the webgl buffer
  84555. */
  84556. getBuffer(): Nullable<DataBuffer>;
  84557. /**
  84558. * std140 layout specifies how to align data within an UBO structure.
  84559. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84560. * for specs.
  84561. */
  84562. private _fillAlignment;
  84563. /**
  84564. * Adds an uniform in the buffer.
  84565. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84566. * for the layout to be correct !
  84567. * @param name Name of the uniform, as used in the uniform block in the shader.
  84568. * @param size Data size, or data directly.
  84569. */
  84570. addUniform(name: string, size: number | number[]): void;
  84571. /**
  84572. * Adds a Matrix 4x4 to the uniform buffer.
  84573. * @param name Name of the uniform, as used in the uniform block in the shader.
  84574. * @param mat A 4x4 matrix.
  84575. */
  84576. addMatrix(name: string, mat: Matrix): void;
  84577. /**
  84578. * Adds a vec2 to the uniform buffer.
  84579. * @param name Name of the uniform, as used in the uniform block in the shader.
  84580. * @param x Define the x component value of the vec2
  84581. * @param y Define the y component value of the vec2
  84582. */
  84583. addFloat2(name: string, x: number, y: number): void;
  84584. /**
  84585. * Adds a vec3 to the uniform buffer.
  84586. * @param name Name of the uniform, as used in the uniform block in the shader.
  84587. * @param x Define the x component value of the vec3
  84588. * @param y Define the y component value of the vec3
  84589. * @param z Define the z component value of the vec3
  84590. */
  84591. addFloat3(name: string, x: number, y: number, z: number): void;
  84592. /**
  84593. * Adds a vec3 to the uniform buffer.
  84594. * @param name Name of the uniform, as used in the uniform block in the shader.
  84595. * @param color Define the vec3 from a Color
  84596. */
  84597. addColor3(name: string, color: Color3): void;
  84598. /**
  84599. * Adds a vec4 to the uniform buffer.
  84600. * @param name Name of the uniform, as used in the uniform block in the shader.
  84601. * @param color Define the rgb components from a Color
  84602. * @param alpha Define the a component of the vec4
  84603. */
  84604. addColor4(name: string, color: Color3, alpha: number): void;
  84605. /**
  84606. * Adds a vec3 to the uniform buffer.
  84607. * @param name Name of the uniform, as used in the uniform block in the shader.
  84608. * @param vector Define the vec3 components from a Vector
  84609. */
  84610. addVector3(name: string, vector: Vector3): void;
  84611. /**
  84612. * Adds a Matrix 3x3 to the uniform buffer.
  84613. * @param name Name of the uniform, as used in the uniform block in the shader.
  84614. */
  84615. addMatrix3x3(name: string): void;
  84616. /**
  84617. * Adds a Matrix 2x2 to the uniform buffer.
  84618. * @param name Name of the uniform, as used in the uniform block in the shader.
  84619. */
  84620. addMatrix2x2(name: string): void;
  84621. /**
  84622. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84623. */
  84624. create(): void;
  84625. /** @hidden */
  84626. _rebuild(): void;
  84627. /**
  84628. * Updates the WebGL Uniform Buffer on the GPU.
  84629. * If the `dynamic` flag is set to true, no cache comparison is done.
  84630. * Otherwise, the buffer will be updated only if the cache differs.
  84631. */
  84632. update(): void;
  84633. /**
  84634. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84635. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84636. * @param data Define the flattened data
  84637. * @param size Define the size of the data.
  84638. */
  84639. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84640. private _valueCache;
  84641. private _cacheMatrix;
  84642. private _updateMatrix3x3ForUniform;
  84643. private _updateMatrix3x3ForEffect;
  84644. private _updateMatrix2x2ForEffect;
  84645. private _updateMatrix2x2ForUniform;
  84646. private _updateFloatForEffect;
  84647. private _updateFloatForUniform;
  84648. private _updateFloat2ForEffect;
  84649. private _updateFloat2ForUniform;
  84650. private _updateFloat3ForEffect;
  84651. private _updateFloat3ForUniform;
  84652. private _updateFloat4ForEffect;
  84653. private _updateFloat4ForUniform;
  84654. private _updateMatrixForEffect;
  84655. private _updateMatrixForUniform;
  84656. private _updateVector3ForEffect;
  84657. private _updateVector3ForUniform;
  84658. private _updateVector4ForEffect;
  84659. private _updateVector4ForUniform;
  84660. private _updateColor3ForEffect;
  84661. private _updateColor3ForUniform;
  84662. private _updateColor4ForEffect;
  84663. private _updateColor4ForUniform;
  84664. /**
  84665. * Sets a sampler uniform on the effect.
  84666. * @param name Define the name of the sampler.
  84667. * @param texture Define the texture to set in the sampler
  84668. */
  84669. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84670. /**
  84671. * Directly updates the value of the uniform in the cache AND on the GPU.
  84672. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84673. * @param data Define the flattened data
  84674. */
  84675. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84676. /**
  84677. * Binds this uniform buffer to an effect.
  84678. * @param effect Define the effect to bind the buffer to
  84679. * @param name Name of the uniform block in the shader.
  84680. */
  84681. bindToEffect(effect: Effect, name: string): void;
  84682. /**
  84683. * Disposes the uniform buffer.
  84684. */
  84685. dispose(): void;
  84686. }
  84687. }
  84688. declare module BABYLON {
  84689. /**
  84690. * Enum that determines the text-wrapping mode to use.
  84691. */
  84692. export enum InspectableType {
  84693. /**
  84694. * Checkbox for booleans
  84695. */
  84696. Checkbox = 0,
  84697. /**
  84698. * Sliders for numbers
  84699. */
  84700. Slider = 1,
  84701. /**
  84702. * Vector3
  84703. */
  84704. Vector3 = 2,
  84705. /**
  84706. * Quaternions
  84707. */
  84708. Quaternion = 3,
  84709. /**
  84710. * Color3
  84711. */
  84712. Color3 = 4,
  84713. /**
  84714. * String
  84715. */
  84716. String = 5
  84717. }
  84718. /**
  84719. * Interface used to define custom inspectable properties.
  84720. * This interface is used by the inspector to display custom property grids
  84721. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84722. */
  84723. export interface IInspectable {
  84724. /**
  84725. * Gets the label to display
  84726. */
  84727. label: string;
  84728. /**
  84729. * Gets the name of the property to edit
  84730. */
  84731. propertyName: string;
  84732. /**
  84733. * Gets the type of the editor to use
  84734. */
  84735. type: InspectableType;
  84736. /**
  84737. * Gets the minimum value of the property when using in "slider" mode
  84738. */
  84739. min?: number;
  84740. /**
  84741. * Gets the maximum value of the property when using in "slider" mode
  84742. */
  84743. max?: number;
  84744. /**
  84745. * Gets the setp to use when using in "slider" mode
  84746. */
  84747. step?: number;
  84748. }
  84749. }
  84750. declare module BABYLON {
  84751. /**
  84752. * Class used to provide helper for timing
  84753. */
  84754. export class TimingTools {
  84755. /**
  84756. * Polyfill for setImmediate
  84757. * @param action defines the action to execute after the current execution block
  84758. */
  84759. static SetImmediate(action: () => void): void;
  84760. }
  84761. }
  84762. declare module BABYLON {
  84763. /**
  84764. * Class used to enable instatition of objects by class name
  84765. */
  84766. export class InstantiationTools {
  84767. /**
  84768. * Use this object to register external classes like custom textures or material
  84769. * to allow the laoders to instantiate them
  84770. */
  84771. static RegisteredExternalClasses: {
  84772. [key: string]: Object;
  84773. };
  84774. /**
  84775. * Tries to instantiate a new object from a given class name
  84776. * @param className defines the class name to instantiate
  84777. * @returns the new object or null if the system was not able to do the instantiation
  84778. */
  84779. static Instantiate(className: string): any;
  84780. }
  84781. }
  84782. declare module BABYLON {
  84783. /**
  84784. * Define options used to create a depth texture
  84785. */
  84786. export class DepthTextureCreationOptions {
  84787. /** Specifies whether or not a stencil should be allocated in the texture */
  84788. generateStencil?: boolean;
  84789. /** Specifies whether or not bilinear filtering is enable on the texture */
  84790. bilinearFiltering?: boolean;
  84791. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84792. comparisonFunction?: number;
  84793. /** Specifies if the created texture is a cube texture */
  84794. isCube?: boolean;
  84795. }
  84796. }
  84797. declare module BABYLON {
  84798. interface ThinEngine {
  84799. /**
  84800. * Creates a depth stencil cube texture.
  84801. * This is only available in WebGL 2.
  84802. * @param size The size of face edge in the cube texture.
  84803. * @param options The options defining the cube texture.
  84804. * @returns The cube texture
  84805. */
  84806. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  84807. /**
  84808. * Creates a cube texture
  84809. * @param rootUrl defines the url where the files to load is located
  84810. * @param scene defines the current scene
  84811. * @param files defines the list of files to load (1 per face)
  84812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84813. * @param onLoad defines an optional callback raised when the texture is loaded
  84814. * @param onError defines an optional callback raised if there is an issue to load the texture
  84815. * @param format defines the format of the data
  84816. * @param forcedExtension defines the extension to use to pick the right loader
  84817. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84818. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84819. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84820. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84821. * @returns the cube texture as an InternalTexture
  84822. */
  84823. 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;
  84824. /**
  84825. * Creates a cube texture
  84826. * @param rootUrl defines the url where the files to load is located
  84827. * @param scene defines the current scene
  84828. * @param files defines the list of files to load (1 per face)
  84829. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84830. * @param onLoad defines an optional callback raised when the texture is loaded
  84831. * @param onError defines an optional callback raised if there is an issue to load the texture
  84832. * @param format defines the format of the data
  84833. * @param forcedExtension defines the extension to use to pick the right loader
  84834. * @returns the cube texture as an InternalTexture
  84835. */
  84836. 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;
  84837. /**
  84838. * Creates a cube texture
  84839. * @param rootUrl defines the url where the files to load is located
  84840. * @param scene defines the current scene
  84841. * @param files defines the list of files to load (1 per face)
  84842. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84843. * @param onLoad defines an optional callback raised when the texture is loaded
  84844. * @param onError defines an optional callback raised if there is an issue to load the texture
  84845. * @param format defines the format of the data
  84846. * @param forcedExtension defines the extension to use to pick the right loader
  84847. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84850. * @returns the cube texture as an InternalTexture
  84851. */
  84852. 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;
  84853. /** @hidden */
  84854. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  84855. /** @hidden */
  84856. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  84857. /** @hidden */
  84858. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84859. /** @hidden */
  84860. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84861. /**
  84862. * @hidden
  84863. */
  84864. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84865. }
  84866. }
  84867. declare module BABYLON {
  84868. /**
  84869. * Class for creating a cube texture
  84870. */
  84871. export class CubeTexture extends BaseTexture {
  84872. private _delayedOnLoad;
  84873. /**
  84874. * Observable triggered once the texture has been loaded.
  84875. */
  84876. onLoadObservable: Observable<CubeTexture>;
  84877. /**
  84878. * The url of the texture
  84879. */
  84880. url: string;
  84881. /**
  84882. * Gets or sets the center of the bounding box associated with the cube texture.
  84883. * It must define where the camera used to render the texture was set
  84884. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  84885. */
  84886. boundingBoxPosition: Vector3;
  84887. private _boundingBoxSize;
  84888. /**
  84889. * Gets or sets the size of the bounding box associated with the cube texture
  84890. * When defined, the cubemap will switch to local mode
  84891. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84892. * @example https://www.babylonjs-playground.com/#RNASML
  84893. */
  84894. set boundingBoxSize(value: Vector3);
  84895. /**
  84896. * Returns the bounding box size
  84897. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  84898. */
  84899. get boundingBoxSize(): Vector3;
  84900. protected _rotationY: number;
  84901. /**
  84902. * Sets texture matrix rotation angle around Y axis in radians.
  84903. */
  84904. set rotationY(value: number);
  84905. /**
  84906. * Gets texture matrix rotation angle around Y axis radians.
  84907. */
  84908. get rotationY(): number;
  84909. /**
  84910. * Are mip maps generated for this texture or not.
  84911. */
  84912. get noMipmap(): boolean;
  84913. private _noMipmap;
  84914. private _files;
  84915. protected _forcedExtension: Nullable<string>;
  84916. private _extensions;
  84917. private _textureMatrix;
  84918. private _format;
  84919. private _createPolynomials;
  84920. /**
  84921. * Creates a cube texture from an array of image urls
  84922. * @param files defines an array of image urls
  84923. * @param scene defines the hosting scene
  84924. * @param noMipmap specifies if mip maps are not used
  84925. * @returns a cube texture
  84926. */
  84927. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  84928. /**
  84929. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  84930. * @param url defines the url of the prefiltered texture
  84931. * @param scene defines the scene the texture is attached to
  84932. * @param forcedExtension defines the extension of the file if different from the url
  84933. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  84934. * @return the prefiltered texture
  84935. */
  84936. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  84937. /**
  84938. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  84939. * as prefiltered data.
  84940. * @param rootUrl defines the url of the texture or the root name of the six images
  84941. * @param null defines the scene or engine the texture is attached to
  84942. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  84943. * @param noMipmap defines if mipmaps should be created or not
  84944. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  84945. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  84946. * @param onError defines a callback triggered in case of error during load
  84947. * @param format defines the internal format to use for the texture once loaded
  84948. * @param prefiltered defines whether or not the texture is created from prefiltered data
  84949. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  84950. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  84951. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84952. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84953. * @return the cube texture
  84954. */
  84955. 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);
  84956. /**
  84957. * Get the current class name of the texture useful for serialization or dynamic coding.
  84958. * @returns "CubeTexture"
  84959. */
  84960. getClassName(): string;
  84961. /**
  84962. * Update the url (and optional buffer) of this texture if url was null during construction.
  84963. * @param url the url of the texture
  84964. * @param forcedExtension defines the extension to use
  84965. * @param onLoad callback called when the texture is loaded (defaults to null)
  84966. * @param prefiltered Defines whether the updated texture is prefiltered or not
  84967. */
  84968. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  84969. /**
  84970. * Delays loading of the cube texture
  84971. * @param forcedExtension defines the extension to use
  84972. */
  84973. delayLoad(forcedExtension?: string): void;
  84974. /**
  84975. * Returns the reflection texture matrix
  84976. * @returns the reflection texture matrix
  84977. */
  84978. getReflectionTextureMatrix(): Matrix;
  84979. /**
  84980. * Sets the reflection texture matrix
  84981. * @param value Reflection texture matrix
  84982. */
  84983. setReflectionTextureMatrix(value: Matrix): void;
  84984. /**
  84985. * Parses text to create a cube texture
  84986. * @param parsedTexture define the serialized text to read from
  84987. * @param scene defines the hosting scene
  84988. * @param rootUrl defines the root url of the cube texture
  84989. * @returns a cube texture
  84990. */
  84991. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  84992. /**
  84993. * Makes a clone, or deep copy, of the cube texture
  84994. * @returns a new cube texture
  84995. */
  84996. clone(): CubeTexture;
  84997. }
  84998. }
  84999. declare module BABYLON {
  85000. /**
  85001. * Manages the defines for the Material
  85002. */
  85003. export class MaterialDefines {
  85004. /** @hidden */
  85005. protected _keys: string[];
  85006. private _isDirty;
  85007. /** @hidden */
  85008. _renderId: number;
  85009. /** @hidden */
  85010. _areLightsDirty: boolean;
  85011. /** @hidden */
  85012. _areLightsDisposed: boolean;
  85013. /** @hidden */
  85014. _areAttributesDirty: boolean;
  85015. /** @hidden */
  85016. _areTexturesDirty: boolean;
  85017. /** @hidden */
  85018. _areFresnelDirty: boolean;
  85019. /** @hidden */
  85020. _areMiscDirty: boolean;
  85021. /** @hidden */
  85022. _areImageProcessingDirty: boolean;
  85023. /** @hidden */
  85024. _normals: boolean;
  85025. /** @hidden */
  85026. _uvs: boolean;
  85027. /** @hidden */
  85028. _needNormals: boolean;
  85029. /** @hidden */
  85030. _needUVs: boolean;
  85031. [id: string]: any;
  85032. /**
  85033. * Specifies if the material needs to be re-calculated
  85034. */
  85035. get isDirty(): boolean;
  85036. /**
  85037. * Marks the material to indicate that it has been re-calculated
  85038. */
  85039. markAsProcessed(): void;
  85040. /**
  85041. * Marks the material to indicate that it needs to be re-calculated
  85042. */
  85043. markAsUnprocessed(): void;
  85044. /**
  85045. * Marks the material to indicate all of its defines need to be re-calculated
  85046. */
  85047. markAllAsDirty(): void;
  85048. /**
  85049. * Marks the material to indicate that image processing needs to be re-calculated
  85050. */
  85051. markAsImageProcessingDirty(): void;
  85052. /**
  85053. * Marks the material to indicate the lights need to be re-calculated
  85054. * @param disposed Defines whether the light is dirty due to dispose or not
  85055. */
  85056. markAsLightDirty(disposed?: boolean): void;
  85057. /**
  85058. * Marks the attribute state as changed
  85059. */
  85060. markAsAttributesDirty(): void;
  85061. /**
  85062. * Marks the texture state as changed
  85063. */
  85064. markAsTexturesDirty(): void;
  85065. /**
  85066. * Marks the fresnel state as changed
  85067. */
  85068. markAsFresnelDirty(): void;
  85069. /**
  85070. * Marks the misc state as changed
  85071. */
  85072. markAsMiscDirty(): void;
  85073. /**
  85074. * Rebuilds the material defines
  85075. */
  85076. rebuild(): void;
  85077. /**
  85078. * Specifies if two material defines are equal
  85079. * @param other - A material define instance to compare to
  85080. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  85081. */
  85082. isEqual(other: MaterialDefines): boolean;
  85083. /**
  85084. * Clones this instance's defines to another instance
  85085. * @param other - material defines to clone values to
  85086. */
  85087. cloneTo(other: MaterialDefines): void;
  85088. /**
  85089. * Resets the material define values
  85090. */
  85091. reset(): void;
  85092. /**
  85093. * Converts the material define values to a string
  85094. * @returns - String of material define information
  85095. */
  85096. toString(): string;
  85097. }
  85098. }
  85099. declare module BABYLON {
  85100. /**
  85101. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85102. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85103. * 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;
  85104. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85105. */
  85106. export class ColorCurves {
  85107. private _dirty;
  85108. private _tempColor;
  85109. private _globalCurve;
  85110. private _highlightsCurve;
  85111. private _midtonesCurve;
  85112. private _shadowsCurve;
  85113. private _positiveCurve;
  85114. private _negativeCurve;
  85115. private _globalHue;
  85116. private _globalDensity;
  85117. private _globalSaturation;
  85118. private _globalExposure;
  85119. /**
  85120. * Gets the global Hue value.
  85121. * 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).
  85122. */
  85123. get globalHue(): number;
  85124. /**
  85125. * Sets the global Hue value.
  85126. * 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).
  85127. */
  85128. set globalHue(value: number);
  85129. /**
  85130. * Gets the global Density value.
  85131. * 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.
  85132. * Values less than zero provide a filter of opposite hue.
  85133. */
  85134. get globalDensity(): number;
  85135. /**
  85136. * Sets the global Density value.
  85137. * 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.
  85138. * Values less than zero provide a filter of opposite hue.
  85139. */
  85140. set globalDensity(value: number);
  85141. /**
  85142. * Gets the global Saturation value.
  85143. * 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.
  85144. */
  85145. get globalSaturation(): number;
  85146. /**
  85147. * Sets the global Saturation value.
  85148. * 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.
  85149. */
  85150. set globalSaturation(value: number);
  85151. /**
  85152. * Gets the global Exposure value.
  85153. * 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.
  85154. */
  85155. get globalExposure(): number;
  85156. /**
  85157. * Sets the global Exposure value.
  85158. * 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.
  85159. */
  85160. set globalExposure(value: number);
  85161. private _highlightsHue;
  85162. private _highlightsDensity;
  85163. private _highlightsSaturation;
  85164. private _highlightsExposure;
  85165. /**
  85166. * Gets the highlights Hue value.
  85167. * 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).
  85168. */
  85169. get highlightsHue(): number;
  85170. /**
  85171. * Sets the highlights Hue value.
  85172. * 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).
  85173. */
  85174. set highlightsHue(value: number);
  85175. /**
  85176. * Gets the highlights Density value.
  85177. * 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.
  85178. * Values less than zero provide a filter of opposite hue.
  85179. */
  85180. get highlightsDensity(): number;
  85181. /**
  85182. * Sets the highlights Density value.
  85183. * 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.
  85184. * Values less than zero provide a filter of opposite hue.
  85185. */
  85186. set highlightsDensity(value: number);
  85187. /**
  85188. * Gets the highlights Saturation value.
  85189. * 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.
  85190. */
  85191. get highlightsSaturation(): number;
  85192. /**
  85193. * Sets the highlights Saturation value.
  85194. * 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.
  85195. */
  85196. set highlightsSaturation(value: number);
  85197. /**
  85198. * Gets the highlights Exposure value.
  85199. * 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.
  85200. */
  85201. get highlightsExposure(): number;
  85202. /**
  85203. * Sets the highlights Exposure value.
  85204. * 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.
  85205. */
  85206. set highlightsExposure(value: number);
  85207. private _midtonesHue;
  85208. private _midtonesDensity;
  85209. private _midtonesSaturation;
  85210. private _midtonesExposure;
  85211. /**
  85212. * Gets the midtones Hue value.
  85213. * 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).
  85214. */
  85215. get midtonesHue(): number;
  85216. /**
  85217. * Sets the midtones Hue value.
  85218. * 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).
  85219. */
  85220. set midtonesHue(value: number);
  85221. /**
  85222. * Gets the midtones Density value.
  85223. * 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.
  85224. * Values less than zero provide a filter of opposite hue.
  85225. */
  85226. get midtonesDensity(): number;
  85227. /**
  85228. * Sets the midtones Density value.
  85229. * 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.
  85230. * Values less than zero provide a filter of opposite hue.
  85231. */
  85232. set midtonesDensity(value: number);
  85233. /**
  85234. * Gets the midtones Saturation value.
  85235. * 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.
  85236. */
  85237. get midtonesSaturation(): number;
  85238. /**
  85239. * Sets the midtones Saturation value.
  85240. * 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.
  85241. */
  85242. set midtonesSaturation(value: number);
  85243. /**
  85244. * Gets the midtones Exposure value.
  85245. * 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.
  85246. */
  85247. get midtonesExposure(): number;
  85248. /**
  85249. * Sets the midtones Exposure value.
  85250. * 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.
  85251. */
  85252. set midtonesExposure(value: number);
  85253. private _shadowsHue;
  85254. private _shadowsDensity;
  85255. private _shadowsSaturation;
  85256. private _shadowsExposure;
  85257. /**
  85258. * Gets the shadows Hue value.
  85259. * 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).
  85260. */
  85261. get shadowsHue(): number;
  85262. /**
  85263. * Sets the shadows Hue value.
  85264. * 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).
  85265. */
  85266. set shadowsHue(value: number);
  85267. /**
  85268. * Gets the shadows Density value.
  85269. * 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.
  85270. * Values less than zero provide a filter of opposite hue.
  85271. */
  85272. get shadowsDensity(): number;
  85273. /**
  85274. * Sets the shadows Density value.
  85275. * 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.
  85276. * Values less than zero provide a filter of opposite hue.
  85277. */
  85278. set shadowsDensity(value: number);
  85279. /**
  85280. * Gets the shadows Saturation value.
  85281. * 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.
  85282. */
  85283. get shadowsSaturation(): number;
  85284. /**
  85285. * Sets the shadows Saturation value.
  85286. * 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.
  85287. */
  85288. set shadowsSaturation(value: number);
  85289. /**
  85290. * Gets the shadows Exposure value.
  85291. * 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.
  85292. */
  85293. get shadowsExposure(): number;
  85294. /**
  85295. * Sets the shadows Exposure value.
  85296. * 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.
  85297. */
  85298. set shadowsExposure(value: number);
  85299. /**
  85300. * Returns the class name
  85301. * @returns The class name
  85302. */
  85303. getClassName(): string;
  85304. /**
  85305. * Binds the color curves to the shader.
  85306. * @param colorCurves The color curve to bind
  85307. * @param effect The effect to bind to
  85308. * @param positiveUniform The positive uniform shader parameter
  85309. * @param neutralUniform The neutral uniform shader parameter
  85310. * @param negativeUniform The negative uniform shader parameter
  85311. */
  85312. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85313. /**
  85314. * Prepare the list of uniforms associated with the ColorCurves effects.
  85315. * @param uniformsList The list of uniforms used in the effect
  85316. */
  85317. static PrepareUniforms(uniformsList: string[]): void;
  85318. /**
  85319. * Returns color grading data based on a hue, density, saturation and exposure value.
  85320. * @param filterHue The hue of the color filter.
  85321. * @param filterDensity The density of the color filter.
  85322. * @param saturation The saturation.
  85323. * @param exposure The exposure.
  85324. * @param result The result data container.
  85325. */
  85326. private getColorGradingDataToRef;
  85327. /**
  85328. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85329. * @param value The input slider value in range [-100,100].
  85330. * @returns Adjusted value.
  85331. */
  85332. private static applyColorGradingSliderNonlinear;
  85333. /**
  85334. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85335. * @param hue The hue (H) input.
  85336. * @param saturation The saturation (S) input.
  85337. * @param brightness The brightness (B) input.
  85338. * @result An RGBA color represented as Vector4.
  85339. */
  85340. private static fromHSBToRef;
  85341. /**
  85342. * Returns a value clamped between min and max
  85343. * @param value The value to clamp
  85344. * @param min The minimum of value
  85345. * @param max The maximum of value
  85346. * @returns The clamped value.
  85347. */
  85348. private static clamp;
  85349. /**
  85350. * Clones the current color curve instance.
  85351. * @return The cloned curves
  85352. */
  85353. clone(): ColorCurves;
  85354. /**
  85355. * Serializes the current color curve instance to a json representation.
  85356. * @return a JSON representation
  85357. */
  85358. serialize(): any;
  85359. /**
  85360. * Parses the color curve from a json representation.
  85361. * @param source the JSON source to parse
  85362. * @return The parsed curves
  85363. */
  85364. static Parse(source: any): ColorCurves;
  85365. }
  85366. }
  85367. declare module BABYLON {
  85368. /**
  85369. * Interface to follow in your material defines to integrate easily the
  85370. * Image proccessing functions.
  85371. * @hidden
  85372. */
  85373. export interface IImageProcessingConfigurationDefines {
  85374. IMAGEPROCESSING: boolean;
  85375. VIGNETTE: boolean;
  85376. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85377. VIGNETTEBLENDMODEOPAQUE: boolean;
  85378. TONEMAPPING: boolean;
  85379. TONEMAPPING_ACES: boolean;
  85380. CONTRAST: boolean;
  85381. EXPOSURE: boolean;
  85382. COLORCURVES: boolean;
  85383. COLORGRADING: boolean;
  85384. COLORGRADING3D: boolean;
  85385. SAMPLER3DGREENDEPTH: boolean;
  85386. SAMPLER3DBGRMAP: boolean;
  85387. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85388. }
  85389. /**
  85390. * @hidden
  85391. */
  85392. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85393. IMAGEPROCESSING: boolean;
  85394. VIGNETTE: boolean;
  85395. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85396. VIGNETTEBLENDMODEOPAQUE: boolean;
  85397. TONEMAPPING: boolean;
  85398. TONEMAPPING_ACES: boolean;
  85399. CONTRAST: boolean;
  85400. COLORCURVES: boolean;
  85401. COLORGRADING: boolean;
  85402. COLORGRADING3D: boolean;
  85403. SAMPLER3DGREENDEPTH: boolean;
  85404. SAMPLER3DBGRMAP: boolean;
  85405. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85406. EXPOSURE: boolean;
  85407. constructor();
  85408. }
  85409. /**
  85410. * This groups together the common properties used for image processing either in direct forward pass
  85411. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85412. * or not.
  85413. */
  85414. export class ImageProcessingConfiguration {
  85415. /**
  85416. * Default tone mapping applied in BabylonJS.
  85417. */
  85418. static readonly TONEMAPPING_STANDARD: number;
  85419. /**
  85420. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85421. * to other engines rendering to increase portability.
  85422. */
  85423. static readonly TONEMAPPING_ACES: number;
  85424. /**
  85425. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85426. */
  85427. colorCurves: Nullable<ColorCurves>;
  85428. private _colorCurvesEnabled;
  85429. /**
  85430. * Gets wether the color curves effect is enabled.
  85431. */
  85432. get colorCurvesEnabled(): boolean;
  85433. /**
  85434. * Sets wether the color curves effect is enabled.
  85435. */
  85436. set colorCurvesEnabled(value: boolean);
  85437. private _colorGradingTexture;
  85438. /**
  85439. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85440. */
  85441. get colorGradingTexture(): Nullable<BaseTexture>;
  85442. /**
  85443. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85444. */
  85445. set colorGradingTexture(value: Nullable<BaseTexture>);
  85446. private _colorGradingEnabled;
  85447. /**
  85448. * Gets wether the color grading effect is enabled.
  85449. */
  85450. get colorGradingEnabled(): boolean;
  85451. /**
  85452. * Sets wether the color grading effect is enabled.
  85453. */
  85454. set colorGradingEnabled(value: boolean);
  85455. private _colorGradingWithGreenDepth;
  85456. /**
  85457. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85458. */
  85459. get colorGradingWithGreenDepth(): boolean;
  85460. /**
  85461. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85462. */
  85463. set colorGradingWithGreenDepth(value: boolean);
  85464. private _colorGradingBGR;
  85465. /**
  85466. * Gets wether the color grading texture contains BGR values.
  85467. */
  85468. get colorGradingBGR(): boolean;
  85469. /**
  85470. * Sets wether the color grading texture contains BGR values.
  85471. */
  85472. set colorGradingBGR(value: boolean);
  85473. /** @hidden */
  85474. _exposure: number;
  85475. /**
  85476. * Gets the Exposure used in the effect.
  85477. */
  85478. get exposure(): number;
  85479. /**
  85480. * Sets the Exposure used in the effect.
  85481. */
  85482. set exposure(value: number);
  85483. private _toneMappingEnabled;
  85484. /**
  85485. * Gets wether the tone mapping effect is enabled.
  85486. */
  85487. get toneMappingEnabled(): boolean;
  85488. /**
  85489. * Sets wether the tone mapping effect is enabled.
  85490. */
  85491. set toneMappingEnabled(value: boolean);
  85492. private _toneMappingType;
  85493. /**
  85494. * Gets the type of tone mapping effect.
  85495. */
  85496. get toneMappingType(): number;
  85497. /**
  85498. * Sets the type of tone mapping effect used in BabylonJS.
  85499. */
  85500. set toneMappingType(value: number);
  85501. protected _contrast: number;
  85502. /**
  85503. * Gets the contrast used in the effect.
  85504. */
  85505. get contrast(): number;
  85506. /**
  85507. * Sets the contrast used in the effect.
  85508. */
  85509. set contrast(value: number);
  85510. /**
  85511. * Vignette stretch size.
  85512. */
  85513. vignetteStretch: number;
  85514. /**
  85515. * Vignette centre X Offset.
  85516. */
  85517. vignetteCentreX: number;
  85518. /**
  85519. * Vignette centre Y Offset.
  85520. */
  85521. vignetteCentreY: number;
  85522. /**
  85523. * Vignette weight or intensity of the vignette effect.
  85524. */
  85525. vignetteWeight: number;
  85526. /**
  85527. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85528. * if vignetteEnabled is set to true.
  85529. */
  85530. vignetteColor: Color4;
  85531. /**
  85532. * Camera field of view used by the Vignette effect.
  85533. */
  85534. vignetteCameraFov: number;
  85535. private _vignetteBlendMode;
  85536. /**
  85537. * Gets the vignette blend mode allowing different kind of effect.
  85538. */
  85539. get vignetteBlendMode(): number;
  85540. /**
  85541. * Sets the vignette blend mode allowing different kind of effect.
  85542. */
  85543. set vignetteBlendMode(value: number);
  85544. private _vignetteEnabled;
  85545. /**
  85546. * Gets wether the vignette effect is enabled.
  85547. */
  85548. get vignetteEnabled(): boolean;
  85549. /**
  85550. * Sets wether the vignette effect is enabled.
  85551. */
  85552. set vignetteEnabled(value: boolean);
  85553. private _applyByPostProcess;
  85554. /**
  85555. * Gets wether the image processing is applied through a post process or not.
  85556. */
  85557. get applyByPostProcess(): boolean;
  85558. /**
  85559. * Sets wether the image processing is applied through a post process or not.
  85560. */
  85561. set applyByPostProcess(value: boolean);
  85562. private _isEnabled;
  85563. /**
  85564. * Gets wether the image processing is enabled or not.
  85565. */
  85566. get isEnabled(): boolean;
  85567. /**
  85568. * Sets wether the image processing is enabled or not.
  85569. */
  85570. set isEnabled(value: boolean);
  85571. /**
  85572. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85573. */
  85574. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85575. /**
  85576. * Method called each time the image processing information changes requires to recompile the effect.
  85577. */
  85578. protected _updateParameters(): void;
  85579. /**
  85580. * Gets the current class name.
  85581. * @return "ImageProcessingConfiguration"
  85582. */
  85583. getClassName(): string;
  85584. /**
  85585. * Prepare the list of uniforms associated with the Image Processing effects.
  85586. * @param uniforms The list of uniforms used in the effect
  85587. * @param defines the list of defines currently in use
  85588. */
  85589. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85590. /**
  85591. * Prepare the list of samplers associated with the Image Processing effects.
  85592. * @param samplersList The list of uniforms used in the effect
  85593. * @param defines the list of defines currently in use
  85594. */
  85595. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85596. /**
  85597. * Prepare the list of defines associated to the shader.
  85598. * @param defines the list of defines to complete
  85599. * @param forPostProcess Define if we are currently in post process mode or not
  85600. */
  85601. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85602. /**
  85603. * Returns true if all the image processing information are ready.
  85604. * @returns True if ready, otherwise, false
  85605. */
  85606. isReady(): boolean;
  85607. /**
  85608. * Binds the image processing to the shader.
  85609. * @param effect The effect to bind to
  85610. * @param overrideAspectRatio Override the aspect ratio of the effect
  85611. */
  85612. bind(effect: Effect, overrideAspectRatio?: number): void;
  85613. /**
  85614. * Clones the current image processing instance.
  85615. * @return The cloned image processing
  85616. */
  85617. clone(): ImageProcessingConfiguration;
  85618. /**
  85619. * Serializes the current image processing instance to a json representation.
  85620. * @return a JSON representation
  85621. */
  85622. serialize(): any;
  85623. /**
  85624. * Parses the image processing from a json representation.
  85625. * @param source the JSON source to parse
  85626. * @return The parsed image processing
  85627. */
  85628. static Parse(source: any): ImageProcessingConfiguration;
  85629. private static _VIGNETTEMODE_MULTIPLY;
  85630. private static _VIGNETTEMODE_OPAQUE;
  85631. /**
  85632. * Used to apply the vignette as a mix with the pixel color.
  85633. */
  85634. static get VIGNETTEMODE_MULTIPLY(): number;
  85635. /**
  85636. * Used to apply the vignette as a replacement of the pixel color.
  85637. */
  85638. static get VIGNETTEMODE_OPAQUE(): number;
  85639. }
  85640. }
  85641. declare module BABYLON {
  85642. /** @hidden */
  85643. export var postprocessVertexShader: {
  85644. name: string;
  85645. shader: string;
  85646. };
  85647. }
  85648. declare module BABYLON {
  85649. interface ThinEngine {
  85650. /**
  85651. * Creates a new render target texture
  85652. * @param size defines the size of the texture
  85653. * @param options defines the options used to create the texture
  85654. * @returns a new render target texture stored in an InternalTexture
  85655. */
  85656. createRenderTargetTexture(size: number | {
  85657. width: number;
  85658. height: number;
  85659. layers?: number;
  85660. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85661. /**
  85662. * Creates a depth stencil texture.
  85663. * This is only available in WebGL 2 or with the depth texture extension available.
  85664. * @param size The size of face edge in the texture.
  85665. * @param options The options defining the texture.
  85666. * @returns The texture
  85667. */
  85668. createDepthStencilTexture(size: number | {
  85669. width: number;
  85670. height: number;
  85671. layers?: number;
  85672. }, options: DepthTextureCreationOptions): InternalTexture;
  85673. /** @hidden */
  85674. _createDepthStencilTexture(size: number | {
  85675. width: number;
  85676. height: number;
  85677. layers?: number;
  85678. }, options: DepthTextureCreationOptions): InternalTexture;
  85679. }
  85680. }
  85681. declare module BABYLON {
  85682. /**
  85683. * Defines the kind of connection point for node based material
  85684. */
  85685. export enum NodeMaterialBlockConnectionPointTypes {
  85686. /** Float */
  85687. Float = 1,
  85688. /** Int */
  85689. Int = 2,
  85690. /** Vector2 */
  85691. Vector2 = 4,
  85692. /** Vector3 */
  85693. Vector3 = 8,
  85694. /** Vector4 */
  85695. Vector4 = 16,
  85696. /** Color3 */
  85697. Color3 = 32,
  85698. /** Color4 */
  85699. Color4 = 64,
  85700. /** Matrix */
  85701. Matrix = 128,
  85702. /** Custom object */
  85703. Object = 256,
  85704. /** Detect type based on connection */
  85705. AutoDetect = 1024,
  85706. /** Output type that will be defined by input type */
  85707. BasedOnInput = 2048
  85708. }
  85709. }
  85710. declare module BABYLON {
  85711. /**
  85712. * Enum used to define the target of a block
  85713. */
  85714. export enum NodeMaterialBlockTargets {
  85715. /** Vertex shader */
  85716. Vertex = 1,
  85717. /** Fragment shader */
  85718. Fragment = 2,
  85719. /** Neutral */
  85720. Neutral = 4,
  85721. /** Vertex and Fragment */
  85722. VertexAndFragment = 3
  85723. }
  85724. }
  85725. declare module BABYLON {
  85726. /**
  85727. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  85728. */
  85729. export enum NodeMaterialBlockConnectionPointMode {
  85730. /** Value is an uniform */
  85731. Uniform = 0,
  85732. /** Value is a mesh attribute */
  85733. Attribute = 1,
  85734. /** Value is a varying between vertex and fragment shaders */
  85735. Varying = 2,
  85736. /** Mode is undefined */
  85737. Undefined = 3
  85738. }
  85739. }
  85740. declare module BABYLON {
  85741. /**
  85742. * Enum used to define system values e.g. values automatically provided by the system
  85743. */
  85744. export enum NodeMaterialSystemValues {
  85745. /** World */
  85746. World = 1,
  85747. /** View */
  85748. View = 2,
  85749. /** Projection */
  85750. Projection = 3,
  85751. /** ViewProjection */
  85752. ViewProjection = 4,
  85753. /** WorldView */
  85754. WorldView = 5,
  85755. /** WorldViewProjection */
  85756. WorldViewProjection = 6,
  85757. /** CameraPosition */
  85758. CameraPosition = 7,
  85759. /** Fog Color */
  85760. FogColor = 8,
  85761. /** Delta time */
  85762. DeltaTime = 9
  85763. }
  85764. }
  85765. declare module BABYLON {
  85766. /** Defines supported spaces */
  85767. export enum Space {
  85768. /** Local (object) space */
  85769. LOCAL = 0,
  85770. /** World space */
  85771. WORLD = 1,
  85772. /** Bone space */
  85773. BONE = 2
  85774. }
  85775. /** Defines the 3 main axes */
  85776. export class Axis {
  85777. /** X axis */
  85778. static X: Vector3;
  85779. /** Y axis */
  85780. static Y: Vector3;
  85781. /** Z axis */
  85782. static Z: Vector3;
  85783. }
  85784. }
  85785. declare module BABYLON {
  85786. /**
  85787. * Represents a camera frustum
  85788. */
  85789. export class Frustum {
  85790. /**
  85791. * Gets the planes representing the frustum
  85792. * @param transform matrix to be applied to the returned planes
  85793. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85794. */
  85795. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85796. /**
  85797. * Gets the near frustum plane transformed by the transform matrix
  85798. * @param transform transformation matrix to be applied to the resulting frustum plane
  85799. * @param frustumPlane the resuling frustum plane
  85800. */
  85801. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85802. /**
  85803. * Gets the far frustum plane transformed by the transform matrix
  85804. * @param transform transformation matrix to be applied to the resulting frustum plane
  85805. * @param frustumPlane the resuling frustum plane
  85806. */
  85807. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85808. /**
  85809. * Gets the left frustum plane transformed by the transform matrix
  85810. * @param transform transformation matrix to be applied to the resulting frustum plane
  85811. * @param frustumPlane the resuling frustum plane
  85812. */
  85813. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85814. /**
  85815. * Gets the right frustum plane transformed by the transform matrix
  85816. * @param transform transformation matrix to be applied to the resulting frustum plane
  85817. * @param frustumPlane the resuling frustum plane
  85818. */
  85819. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85820. /**
  85821. * Gets the top frustum plane transformed by the transform matrix
  85822. * @param transform transformation matrix to be applied to the resulting frustum plane
  85823. * @param frustumPlane the resuling frustum plane
  85824. */
  85825. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85826. /**
  85827. * Gets the bottom frustum plane transformed by the transform matrix
  85828. * @param transform transformation matrix to be applied to the resulting frustum plane
  85829. * @param frustumPlane the resuling frustum plane
  85830. */
  85831. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85832. /**
  85833. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85834. * @param transform transformation matrix to be applied to the resulting frustum planes
  85835. * @param frustumPlanes the resuling frustum planes
  85836. */
  85837. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85838. }
  85839. }
  85840. declare module BABYLON {
  85841. /**
  85842. * Interface for the size containing width and height
  85843. */
  85844. export interface ISize {
  85845. /**
  85846. * Width
  85847. */
  85848. width: number;
  85849. /**
  85850. * Heighht
  85851. */
  85852. height: number;
  85853. }
  85854. /**
  85855. * Size containing widht and height
  85856. */
  85857. export class Size implements ISize {
  85858. /**
  85859. * Width
  85860. */
  85861. width: number;
  85862. /**
  85863. * Height
  85864. */
  85865. height: number;
  85866. /**
  85867. * Creates a Size object from the given width and height (floats).
  85868. * @param width width of the new size
  85869. * @param height height of the new size
  85870. */
  85871. constructor(width: number, height: number);
  85872. /**
  85873. * Returns a string with the Size width and height
  85874. * @returns a string with the Size width and height
  85875. */
  85876. toString(): string;
  85877. /**
  85878. * "Size"
  85879. * @returns the string "Size"
  85880. */
  85881. getClassName(): string;
  85882. /**
  85883. * Returns the Size hash code.
  85884. * @returns a hash code for a unique width and height
  85885. */
  85886. getHashCode(): number;
  85887. /**
  85888. * Updates the current size from the given one.
  85889. * @param src the given size
  85890. */
  85891. copyFrom(src: Size): void;
  85892. /**
  85893. * Updates in place the current Size from the given floats.
  85894. * @param width width of the new size
  85895. * @param height height of the new size
  85896. * @returns the updated Size.
  85897. */
  85898. copyFromFloats(width: number, height: number): Size;
  85899. /**
  85900. * Updates in place the current Size from the given floats.
  85901. * @param width width to set
  85902. * @param height height to set
  85903. * @returns the updated Size.
  85904. */
  85905. set(width: number, height: number): Size;
  85906. /**
  85907. * Multiplies the width and height by numbers
  85908. * @param w factor to multiple the width by
  85909. * @param h factor to multiple the height by
  85910. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85911. */
  85912. multiplyByFloats(w: number, h: number): Size;
  85913. /**
  85914. * Clones the size
  85915. * @returns a new Size copied from the given one.
  85916. */
  85917. clone(): Size;
  85918. /**
  85919. * True if the current Size and the given one width and height are strictly equal.
  85920. * @param other the other size to compare against
  85921. * @returns True if the current Size and the given one width and height are strictly equal.
  85922. */
  85923. equals(other: Size): boolean;
  85924. /**
  85925. * The surface of the Size : width * height (float).
  85926. */
  85927. get surface(): number;
  85928. /**
  85929. * Create a new size of zero
  85930. * @returns a new Size set to (0.0, 0.0)
  85931. */
  85932. static Zero(): Size;
  85933. /**
  85934. * Sums the width and height of two sizes
  85935. * @param otherSize size to add to this size
  85936. * @returns a new Size set as the addition result of the current Size and the given one.
  85937. */
  85938. add(otherSize: Size): Size;
  85939. /**
  85940. * Subtracts the width and height of two
  85941. * @param otherSize size to subtract to this size
  85942. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85943. */
  85944. subtract(otherSize: Size): Size;
  85945. /**
  85946. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85947. * @param start starting size to lerp between
  85948. * @param end end size to lerp between
  85949. * @param amount amount to lerp between the start and end values
  85950. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85951. */
  85952. static Lerp(start: Size, end: Size, amount: number): Size;
  85953. }
  85954. }
  85955. declare module BABYLON {
  85956. /**
  85957. * Contains position and normal vectors for a vertex
  85958. */
  85959. export class PositionNormalVertex {
  85960. /** the position of the vertex (defaut: 0,0,0) */
  85961. position: Vector3;
  85962. /** the normal of the vertex (defaut: 0,1,0) */
  85963. normal: Vector3;
  85964. /**
  85965. * Creates a PositionNormalVertex
  85966. * @param position the position of the vertex (defaut: 0,0,0)
  85967. * @param normal the normal of the vertex (defaut: 0,1,0)
  85968. */
  85969. constructor(
  85970. /** the position of the vertex (defaut: 0,0,0) */
  85971. position?: Vector3,
  85972. /** the normal of the vertex (defaut: 0,1,0) */
  85973. normal?: Vector3);
  85974. /**
  85975. * Clones the PositionNormalVertex
  85976. * @returns the cloned PositionNormalVertex
  85977. */
  85978. clone(): PositionNormalVertex;
  85979. }
  85980. /**
  85981. * Contains position, normal and uv vectors for a vertex
  85982. */
  85983. export class PositionNormalTextureVertex {
  85984. /** the position of the vertex (defaut: 0,0,0) */
  85985. position: Vector3;
  85986. /** the normal of the vertex (defaut: 0,1,0) */
  85987. normal: Vector3;
  85988. /** the uv of the vertex (default: 0,0) */
  85989. uv: Vector2;
  85990. /**
  85991. * Creates a PositionNormalTextureVertex
  85992. * @param position the position of the vertex (defaut: 0,0,0)
  85993. * @param normal the normal of the vertex (defaut: 0,1,0)
  85994. * @param uv the uv of the vertex (default: 0,0)
  85995. */
  85996. constructor(
  85997. /** the position of the vertex (defaut: 0,0,0) */
  85998. position?: Vector3,
  85999. /** the normal of the vertex (defaut: 0,1,0) */
  86000. normal?: Vector3,
  86001. /** the uv of the vertex (default: 0,0) */
  86002. uv?: Vector2);
  86003. /**
  86004. * Clones the PositionNormalTextureVertex
  86005. * @returns the cloned PositionNormalTextureVertex
  86006. */
  86007. clone(): PositionNormalTextureVertex;
  86008. }
  86009. }
  86010. declare module BABYLON {
  86011. /**
  86012. * Enum defining the type of animations supported by InputBlock
  86013. */
  86014. export enum AnimatedInputBlockTypes {
  86015. /** No animation */
  86016. None = 0,
  86017. /** Time based animation. Will only work for floats */
  86018. Time = 1
  86019. }
  86020. }
  86021. declare module BABYLON {
  86022. /**
  86023. * Interface describing all the common properties and methods a shadow light needs to implement.
  86024. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  86025. * as well as binding the different shadow properties to the effects.
  86026. */
  86027. export interface IShadowLight extends Light {
  86028. /**
  86029. * The light id in the scene (used in scene.findLighById for instance)
  86030. */
  86031. id: string;
  86032. /**
  86033. * The position the shdow will be casted from.
  86034. */
  86035. position: Vector3;
  86036. /**
  86037. * In 2d mode (needCube being false), the direction used to cast the shadow.
  86038. */
  86039. direction: Vector3;
  86040. /**
  86041. * The transformed position. Position of the light in world space taking parenting in account.
  86042. */
  86043. transformedPosition: Vector3;
  86044. /**
  86045. * The transformed direction. Direction of the light in world space taking parenting in account.
  86046. */
  86047. transformedDirection: Vector3;
  86048. /**
  86049. * The friendly name of the light in the scene.
  86050. */
  86051. name: string;
  86052. /**
  86053. * Defines the shadow projection clipping minimum z value.
  86054. */
  86055. shadowMinZ: number;
  86056. /**
  86057. * Defines the shadow projection clipping maximum z value.
  86058. */
  86059. shadowMaxZ: number;
  86060. /**
  86061. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86062. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86063. */
  86064. computeTransformedInformation(): boolean;
  86065. /**
  86066. * Gets the scene the light belongs to.
  86067. * @returns The scene
  86068. */
  86069. getScene(): Scene;
  86070. /**
  86071. * Callback defining a custom Projection Matrix Builder.
  86072. * This can be used to override the default projection matrix computation.
  86073. */
  86074. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86075. /**
  86076. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86077. * @param matrix The materix to updated with the projection information
  86078. * @param viewMatrix The transform matrix of the light
  86079. * @param renderList The list of mesh to render in the map
  86080. * @returns The current light
  86081. */
  86082. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86083. /**
  86084. * Gets the current depth scale used in ESM.
  86085. * @returns The scale
  86086. */
  86087. getDepthScale(): number;
  86088. /**
  86089. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86090. * @returns true if a cube texture needs to be use
  86091. */
  86092. needCube(): boolean;
  86093. /**
  86094. * Detects if the projection matrix requires to be recomputed this frame.
  86095. * @returns true if it requires to be recomputed otherwise, false.
  86096. */
  86097. needProjectionMatrixCompute(): boolean;
  86098. /**
  86099. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86100. */
  86101. forceProjectionMatrixCompute(): void;
  86102. /**
  86103. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86104. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86105. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86106. */
  86107. getShadowDirection(faceIndex?: number): Vector3;
  86108. /**
  86109. * Gets the minZ used for shadow according to both the scene and the light.
  86110. * @param activeCamera The camera we are returning the min for
  86111. * @returns the depth min z
  86112. */
  86113. getDepthMinZ(activeCamera: Camera): number;
  86114. /**
  86115. * Gets the maxZ used for shadow according to both the scene and the light.
  86116. * @param activeCamera The camera we are returning the max for
  86117. * @returns the depth max z
  86118. */
  86119. getDepthMaxZ(activeCamera: Camera): number;
  86120. }
  86121. /**
  86122. * Base implementation IShadowLight
  86123. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  86124. */
  86125. export abstract class ShadowLight extends Light implements IShadowLight {
  86126. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  86127. protected _position: Vector3;
  86128. protected _setPosition(value: Vector3): void;
  86129. /**
  86130. * Sets the position the shadow will be casted from. Also use as the light position for both
  86131. * point and spot lights.
  86132. */
  86133. get position(): Vector3;
  86134. /**
  86135. * Sets the position the shadow will be casted from. Also use as the light position for both
  86136. * point and spot lights.
  86137. */
  86138. set position(value: Vector3);
  86139. protected _direction: Vector3;
  86140. protected _setDirection(value: Vector3): void;
  86141. /**
  86142. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  86143. * Also use as the light direction on spot and directional lights.
  86144. */
  86145. get direction(): Vector3;
  86146. /**
  86147. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  86148. * Also use as the light direction on spot and directional lights.
  86149. */
  86150. set direction(value: Vector3);
  86151. protected _shadowMinZ: number;
  86152. /**
  86153. * Gets the shadow projection clipping minimum z value.
  86154. */
  86155. get shadowMinZ(): number;
  86156. /**
  86157. * Sets the shadow projection clipping minimum z value.
  86158. */
  86159. set shadowMinZ(value: number);
  86160. protected _shadowMaxZ: number;
  86161. /**
  86162. * Sets the shadow projection clipping maximum z value.
  86163. */
  86164. get shadowMaxZ(): number;
  86165. /**
  86166. * Gets the shadow projection clipping maximum z value.
  86167. */
  86168. set shadowMaxZ(value: number);
  86169. /**
  86170. * Callback defining a custom Projection Matrix Builder.
  86171. * This can be used to override the default projection matrix computation.
  86172. */
  86173. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86174. /**
  86175. * The transformed position. Position of the light in world space taking parenting in account.
  86176. */
  86177. transformedPosition: Vector3;
  86178. /**
  86179. * The transformed direction. Direction of the light in world space taking parenting in account.
  86180. */
  86181. transformedDirection: Vector3;
  86182. private _needProjectionMatrixCompute;
  86183. /**
  86184. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86185. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86186. */
  86187. computeTransformedInformation(): boolean;
  86188. /**
  86189. * Return the depth scale used for the shadow map.
  86190. * @returns the depth scale.
  86191. */
  86192. getDepthScale(): number;
  86193. /**
  86194. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86195. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86196. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86197. */
  86198. getShadowDirection(faceIndex?: number): Vector3;
  86199. /**
  86200. * Returns the ShadowLight absolute position in the World.
  86201. * @returns the position vector in world space
  86202. */
  86203. getAbsolutePosition(): Vector3;
  86204. /**
  86205. * Sets the ShadowLight direction toward the passed target.
  86206. * @param target The point to target in local space
  86207. * @returns the updated ShadowLight direction
  86208. */
  86209. setDirectionToTarget(target: Vector3): Vector3;
  86210. /**
  86211. * Returns the light rotation in euler definition.
  86212. * @returns the x y z rotation in local space.
  86213. */
  86214. getRotation(): Vector3;
  86215. /**
  86216. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86217. * @returns true if a cube texture needs to be use
  86218. */
  86219. needCube(): boolean;
  86220. /**
  86221. * Detects if the projection matrix requires to be recomputed this frame.
  86222. * @returns true if it requires to be recomputed otherwise, false.
  86223. */
  86224. needProjectionMatrixCompute(): boolean;
  86225. /**
  86226. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86227. */
  86228. forceProjectionMatrixCompute(): void;
  86229. /** @hidden */
  86230. _initCache(): void;
  86231. /** @hidden */
  86232. _isSynchronized(): boolean;
  86233. /**
  86234. * Computes the world matrix of the node
  86235. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86236. * @returns the world matrix
  86237. */
  86238. computeWorldMatrix(force?: boolean): Matrix;
  86239. /**
  86240. * Gets the minZ used for shadow according to both the scene and the light.
  86241. * @param activeCamera The camera we are returning the min for
  86242. * @returns the depth min z
  86243. */
  86244. getDepthMinZ(activeCamera: Camera): number;
  86245. /**
  86246. * Gets the maxZ used for shadow according to both the scene and the light.
  86247. * @param activeCamera The camera we are returning the max for
  86248. * @returns the depth max z
  86249. */
  86250. getDepthMaxZ(activeCamera: Camera): number;
  86251. /**
  86252. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86253. * @param matrix The materix to updated with the projection information
  86254. * @param viewMatrix The transform matrix of the light
  86255. * @param renderList The list of mesh to render in the map
  86256. * @returns The current light
  86257. */
  86258. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86259. }
  86260. }
  86261. declare module BABYLON {
  86262. /** @hidden */
  86263. export var packingFunctions: {
  86264. name: string;
  86265. shader: string;
  86266. };
  86267. }
  86268. declare module BABYLON {
  86269. /** @hidden */
  86270. export var bayerDitherFunctions: {
  86271. name: string;
  86272. shader: string;
  86273. };
  86274. }
  86275. declare module BABYLON {
  86276. /** @hidden */
  86277. export var shadowMapFragmentDeclaration: {
  86278. name: string;
  86279. shader: string;
  86280. };
  86281. }
  86282. declare module BABYLON {
  86283. /** @hidden */
  86284. export var clipPlaneFragmentDeclaration: {
  86285. name: string;
  86286. shader: string;
  86287. };
  86288. }
  86289. declare module BABYLON {
  86290. /** @hidden */
  86291. export var clipPlaneFragment: {
  86292. name: string;
  86293. shader: string;
  86294. };
  86295. }
  86296. declare module BABYLON {
  86297. /** @hidden */
  86298. export var shadowMapFragment: {
  86299. name: string;
  86300. shader: string;
  86301. };
  86302. }
  86303. declare module BABYLON {
  86304. /** @hidden */
  86305. export var shadowMapPixelShader: {
  86306. name: string;
  86307. shader: string;
  86308. };
  86309. }
  86310. declare module BABYLON {
  86311. /** @hidden */
  86312. export var bonesDeclaration: {
  86313. name: string;
  86314. shader: string;
  86315. };
  86316. }
  86317. declare module BABYLON {
  86318. /** @hidden */
  86319. export var morphTargetsVertexGlobalDeclaration: {
  86320. name: string;
  86321. shader: string;
  86322. };
  86323. }
  86324. declare module BABYLON {
  86325. /** @hidden */
  86326. export var morphTargetsVertexDeclaration: {
  86327. name: string;
  86328. shader: string;
  86329. };
  86330. }
  86331. declare module BABYLON {
  86332. /** @hidden */
  86333. export var instancesDeclaration: {
  86334. name: string;
  86335. shader: string;
  86336. };
  86337. }
  86338. declare module BABYLON {
  86339. /** @hidden */
  86340. export var helperFunctions: {
  86341. name: string;
  86342. shader: string;
  86343. };
  86344. }
  86345. declare module BABYLON {
  86346. /** @hidden */
  86347. export var shadowMapVertexDeclaration: {
  86348. name: string;
  86349. shader: string;
  86350. };
  86351. }
  86352. declare module BABYLON {
  86353. /** @hidden */
  86354. export var clipPlaneVertexDeclaration: {
  86355. name: string;
  86356. shader: string;
  86357. };
  86358. }
  86359. declare module BABYLON {
  86360. /** @hidden */
  86361. export var morphTargetsVertex: {
  86362. name: string;
  86363. shader: string;
  86364. };
  86365. }
  86366. declare module BABYLON {
  86367. /** @hidden */
  86368. export var instancesVertex: {
  86369. name: string;
  86370. shader: string;
  86371. };
  86372. }
  86373. declare module BABYLON {
  86374. /** @hidden */
  86375. export var bonesVertex: {
  86376. name: string;
  86377. shader: string;
  86378. };
  86379. }
  86380. declare module BABYLON {
  86381. /** @hidden */
  86382. export var shadowMapVertexNormalBias: {
  86383. name: string;
  86384. shader: string;
  86385. };
  86386. }
  86387. declare module BABYLON {
  86388. /** @hidden */
  86389. export var shadowMapVertexMetric: {
  86390. name: string;
  86391. shader: string;
  86392. };
  86393. }
  86394. declare module BABYLON {
  86395. /** @hidden */
  86396. export var clipPlaneVertex: {
  86397. name: string;
  86398. shader: string;
  86399. };
  86400. }
  86401. declare module BABYLON {
  86402. /** @hidden */
  86403. export var shadowMapVertexShader: {
  86404. name: string;
  86405. shader: string;
  86406. };
  86407. }
  86408. declare module BABYLON {
  86409. /** @hidden */
  86410. export var depthBoxBlurPixelShader: {
  86411. name: string;
  86412. shader: string;
  86413. };
  86414. }
  86415. declare module BABYLON {
  86416. /** @hidden */
  86417. export var shadowMapFragmentSoftTransparentShadow: {
  86418. name: string;
  86419. shader: string;
  86420. };
  86421. }
  86422. declare module BABYLON {
  86423. /**
  86424. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86425. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86426. */
  86427. export class EffectFallbacks implements IEffectFallbacks {
  86428. private _defines;
  86429. private _currentRank;
  86430. private _maxRank;
  86431. private _mesh;
  86432. /**
  86433. * Removes the fallback from the bound mesh.
  86434. */
  86435. unBindMesh(): void;
  86436. /**
  86437. * Adds a fallback on the specified property.
  86438. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86439. * @param define The name of the define in the shader
  86440. */
  86441. addFallback(rank: number, define: string): void;
  86442. /**
  86443. * Sets the mesh to use CPU skinning when needing to fallback.
  86444. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86445. * @param mesh The mesh to use the fallbacks.
  86446. */
  86447. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86448. /**
  86449. * Checks to see if more fallbacks are still availible.
  86450. */
  86451. get hasMoreFallbacks(): boolean;
  86452. /**
  86453. * Removes the defines that should be removed when falling back.
  86454. * @param currentDefines defines the current define statements for the shader.
  86455. * @param effect defines the current effect we try to compile
  86456. * @returns The resulting defines with defines of the current rank removed.
  86457. */
  86458. reduce(currentDefines: string, effect: Effect): string;
  86459. }
  86460. }
  86461. declare module BABYLON {
  86462. /**
  86463. * Interface used to define Action
  86464. */
  86465. export interface IAction {
  86466. /**
  86467. * Trigger for the action
  86468. */
  86469. trigger: number;
  86470. /** Options of the trigger */
  86471. triggerOptions: any;
  86472. /**
  86473. * Gets the trigger parameters
  86474. * @returns the trigger parameters
  86475. */
  86476. getTriggerParameter(): any;
  86477. /**
  86478. * Internal only - executes current action event
  86479. * @hidden
  86480. */
  86481. _executeCurrent(evt?: ActionEvent): void;
  86482. /**
  86483. * Serialize placeholder for child classes
  86484. * @param parent of child
  86485. * @returns the serialized object
  86486. */
  86487. serialize(parent: any): any;
  86488. /**
  86489. * Internal only
  86490. * @hidden
  86491. */
  86492. _prepare(): void;
  86493. /**
  86494. * Internal only - manager for action
  86495. * @hidden
  86496. */
  86497. _actionManager: AbstractActionManager;
  86498. /**
  86499. * Adds action to chain of actions, may be a DoNothingAction
  86500. * @param action defines the next action to execute
  86501. * @returns The action passed in
  86502. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86503. */
  86504. then(action: IAction): IAction;
  86505. }
  86506. /**
  86507. * The action to be carried out following a trigger
  86508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  86509. */
  86510. export class Action implements IAction {
  86511. /** the trigger, with or without parameters, for the action */
  86512. triggerOptions: any;
  86513. /**
  86514. * Trigger for the action
  86515. */
  86516. trigger: number;
  86517. /**
  86518. * Internal only - manager for action
  86519. * @hidden
  86520. */
  86521. _actionManager: ActionManager;
  86522. private _nextActiveAction;
  86523. private _child;
  86524. private _condition?;
  86525. private _triggerParameter;
  86526. /**
  86527. * An event triggered prior to action being executed.
  86528. */
  86529. onBeforeExecuteObservable: Observable<Action>;
  86530. /**
  86531. * Creates a new Action
  86532. * @param triggerOptions the trigger, with or without parameters, for the action
  86533. * @param condition an optional determinant of action
  86534. */
  86535. constructor(
  86536. /** the trigger, with or without parameters, for the action */
  86537. triggerOptions: any, condition?: Condition);
  86538. /**
  86539. * Internal only
  86540. * @hidden
  86541. */
  86542. _prepare(): void;
  86543. /**
  86544. * Gets the trigger parameters
  86545. * @returns the trigger parameters
  86546. */
  86547. getTriggerParameter(): any;
  86548. /**
  86549. * Internal only - executes current action event
  86550. * @hidden
  86551. */
  86552. _executeCurrent(evt?: ActionEvent): void;
  86553. /**
  86554. * Execute placeholder for child classes
  86555. * @param evt optional action event
  86556. */
  86557. execute(evt?: ActionEvent): void;
  86558. /**
  86559. * Skips to next active action
  86560. */
  86561. skipToNextActiveAction(): void;
  86562. /**
  86563. * Adds action to chain of actions, may be a DoNothingAction
  86564. * @param action defines the next action to execute
  86565. * @returns The action passed in
  86566. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86567. */
  86568. then(action: Action): Action;
  86569. /**
  86570. * Internal only
  86571. * @hidden
  86572. */
  86573. _getProperty(propertyPath: string): string;
  86574. /**
  86575. * Internal only
  86576. * @hidden
  86577. */
  86578. _getEffectiveTarget(target: any, propertyPath: string): any;
  86579. /**
  86580. * Serialize placeholder for child classes
  86581. * @param parent of child
  86582. * @returns the serialized object
  86583. */
  86584. serialize(parent: any): any;
  86585. /**
  86586. * Internal only called by serialize
  86587. * @hidden
  86588. */
  86589. protected _serialize(serializedAction: any, parent?: any): any;
  86590. /**
  86591. * Internal only
  86592. * @hidden
  86593. */
  86594. static _SerializeValueAsString: (value: any) => string;
  86595. /**
  86596. * Internal only
  86597. * @hidden
  86598. */
  86599. static _GetTargetProperty: (target: Node | Scene) => {
  86600. name: string;
  86601. targetType: string;
  86602. value: string;
  86603. };
  86604. }
  86605. }
  86606. declare module BABYLON {
  86607. /**
  86608. * A Condition applied to an Action
  86609. */
  86610. export class Condition {
  86611. /**
  86612. * Internal only - manager for action
  86613. * @hidden
  86614. */
  86615. _actionManager: ActionManager;
  86616. /**
  86617. * Internal only
  86618. * @hidden
  86619. */
  86620. _evaluationId: number;
  86621. /**
  86622. * Internal only
  86623. * @hidden
  86624. */
  86625. _currentResult: boolean;
  86626. /**
  86627. * Creates a new Condition
  86628. * @param actionManager the manager of the action the condition is applied to
  86629. */
  86630. constructor(actionManager: ActionManager);
  86631. /**
  86632. * Check if the current condition is valid
  86633. * @returns a boolean
  86634. */
  86635. isValid(): boolean;
  86636. /**
  86637. * Internal only
  86638. * @hidden
  86639. */
  86640. _getProperty(propertyPath: string): string;
  86641. /**
  86642. * Internal only
  86643. * @hidden
  86644. */
  86645. _getEffectiveTarget(target: any, propertyPath: string): any;
  86646. /**
  86647. * Serialize placeholder for child classes
  86648. * @returns the serialized object
  86649. */
  86650. serialize(): any;
  86651. /**
  86652. * Internal only
  86653. * @hidden
  86654. */
  86655. protected _serialize(serializedCondition: any): any;
  86656. }
  86657. /**
  86658. * Defines specific conditional operators as extensions of Condition
  86659. */
  86660. export class ValueCondition extends Condition {
  86661. /** path to specify the property of the target the conditional operator uses */
  86662. propertyPath: string;
  86663. /** the value compared by the conditional operator against the current value of the property */
  86664. value: any;
  86665. /** the conditional operator, default ValueCondition.IsEqual */
  86666. operator: number;
  86667. /**
  86668. * Internal only
  86669. * @hidden
  86670. */
  86671. private static _IsEqual;
  86672. /**
  86673. * Internal only
  86674. * @hidden
  86675. */
  86676. private static _IsDifferent;
  86677. /**
  86678. * Internal only
  86679. * @hidden
  86680. */
  86681. private static _IsGreater;
  86682. /**
  86683. * Internal only
  86684. * @hidden
  86685. */
  86686. private static _IsLesser;
  86687. /**
  86688. * returns the number for IsEqual
  86689. */
  86690. static get IsEqual(): number;
  86691. /**
  86692. * Returns the number for IsDifferent
  86693. */
  86694. static get IsDifferent(): number;
  86695. /**
  86696. * Returns the number for IsGreater
  86697. */
  86698. static get IsGreater(): number;
  86699. /**
  86700. * Returns the number for IsLesser
  86701. */
  86702. static get IsLesser(): number;
  86703. /**
  86704. * Internal only The action manager for the condition
  86705. * @hidden
  86706. */
  86707. _actionManager: ActionManager;
  86708. /**
  86709. * Internal only
  86710. * @hidden
  86711. */
  86712. private _target;
  86713. /**
  86714. * Internal only
  86715. * @hidden
  86716. */
  86717. private _effectiveTarget;
  86718. /**
  86719. * Internal only
  86720. * @hidden
  86721. */
  86722. private _property;
  86723. /**
  86724. * Creates a new ValueCondition
  86725. * @param actionManager manager for the action the condition applies to
  86726. * @param target for the action
  86727. * @param propertyPath path to specify the property of the target the conditional operator uses
  86728. * @param value the value compared by the conditional operator against the current value of the property
  86729. * @param operator the conditional operator, default ValueCondition.IsEqual
  86730. */
  86731. constructor(actionManager: ActionManager, target: any,
  86732. /** path to specify the property of the target the conditional operator uses */
  86733. propertyPath: string,
  86734. /** the value compared by the conditional operator against the current value of the property */
  86735. value: any,
  86736. /** the conditional operator, default ValueCondition.IsEqual */
  86737. operator?: number);
  86738. /**
  86739. * Compares the given value with the property value for the specified conditional operator
  86740. * @returns the result of the comparison
  86741. */
  86742. isValid(): boolean;
  86743. /**
  86744. * Serialize the ValueCondition into a JSON compatible object
  86745. * @returns serialization object
  86746. */
  86747. serialize(): any;
  86748. /**
  86749. * Gets the name of the conditional operator for the ValueCondition
  86750. * @param operator the conditional operator
  86751. * @returns the name
  86752. */
  86753. static GetOperatorName(operator: number): string;
  86754. }
  86755. /**
  86756. * Defines a predicate condition as an extension of Condition
  86757. */
  86758. export class PredicateCondition extends Condition {
  86759. /** defines the predicate function used to validate the condition */
  86760. predicate: () => boolean;
  86761. /**
  86762. * Internal only - manager for action
  86763. * @hidden
  86764. */
  86765. _actionManager: ActionManager;
  86766. /**
  86767. * Creates a new PredicateCondition
  86768. * @param actionManager manager for the action the condition applies to
  86769. * @param predicate defines the predicate function used to validate the condition
  86770. */
  86771. constructor(actionManager: ActionManager,
  86772. /** defines the predicate function used to validate the condition */
  86773. predicate: () => boolean);
  86774. /**
  86775. * @returns the validity of the predicate condition
  86776. */
  86777. isValid(): boolean;
  86778. }
  86779. /**
  86780. * Defines a state condition as an extension of Condition
  86781. */
  86782. export class StateCondition extends Condition {
  86783. /** Value to compare with target state */
  86784. value: string;
  86785. /**
  86786. * Internal only - manager for action
  86787. * @hidden
  86788. */
  86789. _actionManager: ActionManager;
  86790. /**
  86791. * Internal only
  86792. * @hidden
  86793. */
  86794. private _target;
  86795. /**
  86796. * Creates a new StateCondition
  86797. * @param actionManager manager for the action the condition applies to
  86798. * @param target of the condition
  86799. * @param value to compare with target state
  86800. */
  86801. constructor(actionManager: ActionManager, target: any,
  86802. /** Value to compare with target state */
  86803. value: string);
  86804. /**
  86805. * Gets a boolean indicating if the current condition is met
  86806. * @returns the validity of the state
  86807. */
  86808. isValid(): boolean;
  86809. /**
  86810. * Serialize the StateCondition into a JSON compatible object
  86811. * @returns serialization object
  86812. */
  86813. serialize(): any;
  86814. }
  86815. }
  86816. declare module BABYLON {
  86817. /**
  86818. * This defines an action responsible to toggle a boolean once triggered.
  86819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86820. */
  86821. export class SwitchBooleanAction extends Action {
  86822. /**
  86823. * The path to the boolean property in the target object
  86824. */
  86825. propertyPath: string;
  86826. private _target;
  86827. private _effectiveTarget;
  86828. private _property;
  86829. /**
  86830. * Instantiate the action
  86831. * @param triggerOptions defines the trigger options
  86832. * @param target defines the object containing the boolean
  86833. * @param propertyPath defines the path to the boolean property in the target object
  86834. * @param condition defines the trigger related conditions
  86835. */
  86836. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  86837. /** @hidden */
  86838. _prepare(): void;
  86839. /**
  86840. * Execute the action toggle the boolean value.
  86841. */
  86842. execute(): void;
  86843. /**
  86844. * Serializes the actions and its related information.
  86845. * @param parent defines the object to serialize in
  86846. * @returns the serialized object
  86847. */
  86848. serialize(parent: any): any;
  86849. }
  86850. /**
  86851. * This defines an action responsible to set a the state field of the target
  86852. * to a desired value once triggered.
  86853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86854. */
  86855. export class SetStateAction extends Action {
  86856. /**
  86857. * The value to store in the state field.
  86858. */
  86859. value: string;
  86860. private _target;
  86861. /**
  86862. * Instantiate the action
  86863. * @param triggerOptions defines the trigger options
  86864. * @param target defines the object containing the state property
  86865. * @param value defines the value to store in the state field
  86866. * @param condition defines the trigger related conditions
  86867. */
  86868. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  86869. /**
  86870. * Execute the action and store the value on the target state property.
  86871. */
  86872. execute(): void;
  86873. /**
  86874. * Serializes the actions and its related information.
  86875. * @param parent defines the object to serialize in
  86876. * @returns the serialized object
  86877. */
  86878. serialize(parent: any): any;
  86879. }
  86880. /**
  86881. * This defines an action responsible to set a property of the target
  86882. * to a desired value once triggered.
  86883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86884. */
  86885. export class SetValueAction extends Action {
  86886. /**
  86887. * The path of the property to set in the target.
  86888. */
  86889. propertyPath: string;
  86890. /**
  86891. * The value to set in the property
  86892. */
  86893. value: any;
  86894. private _target;
  86895. private _effectiveTarget;
  86896. private _property;
  86897. /**
  86898. * Instantiate the action
  86899. * @param triggerOptions defines the trigger options
  86900. * @param target defines the object containing the property
  86901. * @param propertyPath defines the path of the property to set in the target
  86902. * @param value defines the value to set in the property
  86903. * @param condition defines the trigger related conditions
  86904. */
  86905. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  86906. /** @hidden */
  86907. _prepare(): void;
  86908. /**
  86909. * Execute the action and set the targetted property to the desired value.
  86910. */
  86911. execute(): void;
  86912. /**
  86913. * Serializes the actions and its related information.
  86914. * @param parent defines the object to serialize in
  86915. * @returns the serialized object
  86916. */
  86917. serialize(parent: any): any;
  86918. }
  86919. /**
  86920. * This defines an action responsible to increment the target value
  86921. * to a desired value once triggered.
  86922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86923. */
  86924. export class IncrementValueAction extends Action {
  86925. /**
  86926. * The path of the property to increment in the target.
  86927. */
  86928. propertyPath: string;
  86929. /**
  86930. * The value we should increment the property by.
  86931. */
  86932. value: any;
  86933. private _target;
  86934. private _effectiveTarget;
  86935. private _property;
  86936. /**
  86937. * Instantiate the action
  86938. * @param triggerOptions defines the trigger options
  86939. * @param target defines the object containing the property
  86940. * @param propertyPath defines the path of the property to increment in the target
  86941. * @param value defines the value value we should increment the property by
  86942. * @param condition defines the trigger related conditions
  86943. */
  86944. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  86945. /** @hidden */
  86946. _prepare(): void;
  86947. /**
  86948. * Execute the action and increment the target of the value amount.
  86949. */
  86950. execute(): void;
  86951. /**
  86952. * Serializes the actions and its related information.
  86953. * @param parent defines the object to serialize in
  86954. * @returns the serialized object
  86955. */
  86956. serialize(parent: any): any;
  86957. }
  86958. /**
  86959. * This defines an action responsible to start an animation once triggered.
  86960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86961. */
  86962. export class PlayAnimationAction extends Action {
  86963. /**
  86964. * Where the animation should start (animation frame)
  86965. */
  86966. from: number;
  86967. /**
  86968. * Where the animation should stop (animation frame)
  86969. */
  86970. to: number;
  86971. /**
  86972. * Define if the animation should loop or stop after the first play.
  86973. */
  86974. loop?: boolean;
  86975. private _target;
  86976. /**
  86977. * Instantiate the action
  86978. * @param triggerOptions defines the trigger options
  86979. * @param target defines the target animation or animation name
  86980. * @param from defines from where the animation should start (animation frame)
  86981. * @param end defines where the animation should stop (animation frame)
  86982. * @param loop defines if the animation should loop or stop after the first play
  86983. * @param condition defines the trigger related conditions
  86984. */
  86985. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  86986. /** @hidden */
  86987. _prepare(): void;
  86988. /**
  86989. * Execute the action and play the animation.
  86990. */
  86991. execute(): void;
  86992. /**
  86993. * Serializes the actions and its related information.
  86994. * @param parent defines the object to serialize in
  86995. * @returns the serialized object
  86996. */
  86997. serialize(parent: any): any;
  86998. }
  86999. /**
  87000. * This defines an action responsible to stop an animation once triggered.
  87001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87002. */
  87003. export class StopAnimationAction extends Action {
  87004. private _target;
  87005. /**
  87006. * Instantiate the action
  87007. * @param triggerOptions defines the trigger options
  87008. * @param target defines the target animation or animation name
  87009. * @param condition defines the trigger related conditions
  87010. */
  87011. constructor(triggerOptions: any, target: any, condition?: Condition);
  87012. /** @hidden */
  87013. _prepare(): void;
  87014. /**
  87015. * Execute the action and stop the animation.
  87016. */
  87017. execute(): void;
  87018. /**
  87019. * Serializes the actions and its related information.
  87020. * @param parent defines the object to serialize in
  87021. * @returns the serialized object
  87022. */
  87023. serialize(parent: any): any;
  87024. }
  87025. /**
  87026. * This defines an action responsible that does nothing once triggered.
  87027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87028. */
  87029. export class DoNothingAction extends Action {
  87030. /**
  87031. * Instantiate the action
  87032. * @param triggerOptions defines the trigger options
  87033. * @param condition defines the trigger related conditions
  87034. */
  87035. constructor(triggerOptions?: any, condition?: Condition);
  87036. /**
  87037. * Execute the action and do nothing.
  87038. */
  87039. execute(): void;
  87040. /**
  87041. * Serializes the actions and its related information.
  87042. * @param parent defines the object to serialize in
  87043. * @returns the serialized object
  87044. */
  87045. serialize(parent: any): any;
  87046. }
  87047. /**
  87048. * This defines an action responsible to trigger several actions once triggered.
  87049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87050. */
  87051. export class CombineAction extends Action {
  87052. /**
  87053. * The list of aggregated animations to run.
  87054. */
  87055. children: Action[];
  87056. /**
  87057. * Instantiate the action
  87058. * @param triggerOptions defines the trigger options
  87059. * @param children defines the list of aggregated animations to run
  87060. * @param condition defines the trigger related conditions
  87061. */
  87062. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  87063. /** @hidden */
  87064. _prepare(): void;
  87065. /**
  87066. * Execute the action and executes all the aggregated actions.
  87067. */
  87068. execute(evt: ActionEvent): void;
  87069. /**
  87070. * Serializes the actions and its related information.
  87071. * @param parent defines the object to serialize in
  87072. * @returns the serialized object
  87073. */
  87074. serialize(parent: any): any;
  87075. }
  87076. /**
  87077. * This defines an action responsible to run code (external event) once triggered.
  87078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87079. */
  87080. export class ExecuteCodeAction extends Action {
  87081. /**
  87082. * The callback function to run.
  87083. */
  87084. func: (evt: ActionEvent) => void;
  87085. /**
  87086. * Instantiate the action
  87087. * @param triggerOptions defines the trigger options
  87088. * @param func defines the callback function to run
  87089. * @param condition defines the trigger related conditions
  87090. */
  87091. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  87092. /**
  87093. * Execute the action and run the attached code.
  87094. */
  87095. execute(evt: ActionEvent): void;
  87096. }
  87097. /**
  87098. * This defines an action responsible to set the parent property of the target once triggered.
  87099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87100. */
  87101. export class SetParentAction extends Action {
  87102. private _parent;
  87103. private _target;
  87104. /**
  87105. * Instantiate the action
  87106. * @param triggerOptions defines the trigger options
  87107. * @param target defines the target containing the parent property
  87108. * @param parent defines from where the animation should start (animation frame)
  87109. * @param condition defines the trigger related conditions
  87110. */
  87111. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  87112. /** @hidden */
  87113. _prepare(): void;
  87114. /**
  87115. * Execute the action and set the parent property.
  87116. */
  87117. execute(): void;
  87118. /**
  87119. * Serializes the actions and its related information.
  87120. * @param parent defines the object to serialize in
  87121. * @returns the serialized object
  87122. */
  87123. serialize(parent: any): any;
  87124. }
  87125. }
  87126. declare module BABYLON {
  87127. /**
  87128. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  87129. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  87130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87131. */
  87132. export class ActionManager extends AbstractActionManager {
  87133. /**
  87134. * Nothing
  87135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87136. */
  87137. static readonly NothingTrigger: number;
  87138. /**
  87139. * On pick
  87140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87141. */
  87142. static readonly OnPickTrigger: number;
  87143. /**
  87144. * On left pick
  87145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87146. */
  87147. static readonly OnLeftPickTrigger: number;
  87148. /**
  87149. * On right pick
  87150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87151. */
  87152. static readonly OnRightPickTrigger: number;
  87153. /**
  87154. * On center pick
  87155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87156. */
  87157. static readonly OnCenterPickTrigger: number;
  87158. /**
  87159. * On pick down
  87160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87161. */
  87162. static readonly OnPickDownTrigger: number;
  87163. /**
  87164. * On double pick
  87165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87166. */
  87167. static readonly OnDoublePickTrigger: number;
  87168. /**
  87169. * On pick up
  87170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87171. */
  87172. static readonly OnPickUpTrigger: number;
  87173. /**
  87174. * On pick out.
  87175. * This trigger will only be raised if you also declared a OnPickDown
  87176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87177. */
  87178. static readonly OnPickOutTrigger: number;
  87179. /**
  87180. * On long press
  87181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87182. */
  87183. static readonly OnLongPressTrigger: number;
  87184. /**
  87185. * On pointer over
  87186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87187. */
  87188. static readonly OnPointerOverTrigger: number;
  87189. /**
  87190. * On pointer out
  87191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87192. */
  87193. static readonly OnPointerOutTrigger: number;
  87194. /**
  87195. * On every frame
  87196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87197. */
  87198. static readonly OnEveryFrameTrigger: number;
  87199. /**
  87200. * On intersection enter
  87201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87202. */
  87203. static readonly OnIntersectionEnterTrigger: number;
  87204. /**
  87205. * On intersection exit
  87206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87207. */
  87208. static readonly OnIntersectionExitTrigger: number;
  87209. /**
  87210. * On key down
  87211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87212. */
  87213. static readonly OnKeyDownTrigger: number;
  87214. /**
  87215. * On key up
  87216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87217. */
  87218. static readonly OnKeyUpTrigger: number;
  87219. private _scene;
  87220. /**
  87221. * Creates a new action manager
  87222. * @param scene defines the hosting scene
  87223. */
  87224. constructor(scene: Scene);
  87225. /**
  87226. * Releases all associated resources
  87227. */
  87228. dispose(): void;
  87229. /**
  87230. * Gets hosting scene
  87231. * @returns the hosting scene
  87232. */
  87233. getScene(): Scene;
  87234. /**
  87235. * Does this action manager handles actions of any of the given triggers
  87236. * @param triggers defines the triggers to be tested
  87237. * @return a boolean indicating whether one (or more) of the triggers is handled
  87238. */
  87239. hasSpecificTriggers(triggers: number[]): boolean;
  87240. /**
  87241. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87242. * speed.
  87243. * @param triggerA defines the trigger to be tested
  87244. * @param triggerB defines the trigger to be tested
  87245. * @return a boolean indicating whether one (or more) of the triggers is handled
  87246. */
  87247. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87248. /**
  87249. * Does this action manager handles actions of a given trigger
  87250. * @param trigger defines the trigger to be tested
  87251. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87252. * @return whether the trigger is handled
  87253. */
  87254. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87255. /**
  87256. * Does this action manager has pointer triggers
  87257. */
  87258. get hasPointerTriggers(): boolean;
  87259. /**
  87260. * Does this action manager has pick triggers
  87261. */
  87262. get hasPickTriggers(): boolean;
  87263. /**
  87264. * Registers an action to this action manager
  87265. * @param action defines the action to be registered
  87266. * @return the action amended (prepared) after registration
  87267. */
  87268. registerAction(action: IAction): Nullable<IAction>;
  87269. /**
  87270. * Unregisters an action to this action manager
  87271. * @param action defines the action to be unregistered
  87272. * @return a boolean indicating whether the action has been unregistered
  87273. */
  87274. unregisterAction(action: IAction): Boolean;
  87275. /**
  87276. * Process a specific trigger
  87277. * @param trigger defines the trigger to process
  87278. * @param evt defines the event details to be processed
  87279. */
  87280. processTrigger(trigger: number, evt?: IActionEvent): void;
  87281. /** @hidden */
  87282. _getEffectiveTarget(target: any, propertyPath: string): any;
  87283. /** @hidden */
  87284. _getProperty(propertyPath: string): string;
  87285. /**
  87286. * Serialize this manager to a JSON object
  87287. * @param name defines the property name to store this manager
  87288. * @returns a JSON representation of this manager
  87289. */
  87290. serialize(name: string): any;
  87291. /**
  87292. * Creates a new ActionManager from a JSON data
  87293. * @param parsedActions defines the JSON data to read from
  87294. * @param object defines the hosting mesh
  87295. * @param scene defines the hosting scene
  87296. */
  87297. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87298. /**
  87299. * Get a trigger name by index
  87300. * @param trigger defines the trigger index
  87301. * @returns a trigger name
  87302. */
  87303. static GetTriggerName(trigger: number): string;
  87304. }
  87305. }
  87306. declare module BABYLON {
  87307. /**
  87308. * Class used to represent a sprite
  87309. * @see http://doc.babylonjs.com/babylon101/sprites
  87310. */
  87311. export class Sprite implements IAnimatable {
  87312. /** defines the name */
  87313. name: string;
  87314. /** Gets or sets the current world position */
  87315. position: Vector3;
  87316. /** Gets or sets the main color */
  87317. color: Color4;
  87318. /** Gets or sets the width */
  87319. width: number;
  87320. /** Gets or sets the height */
  87321. height: number;
  87322. /** Gets or sets rotation angle */
  87323. angle: number;
  87324. /** Gets or sets the cell index in the sprite sheet */
  87325. cellIndex: number;
  87326. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  87327. cellRef: string;
  87328. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  87329. invertU: boolean;
  87330. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  87331. invertV: boolean;
  87332. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  87333. disposeWhenFinishedAnimating: boolean;
  87334. /** Gets the list of attached animations */
  87335. animations: Nullable<Array<Animation>>;
  87336. /** Gets or sets a boolean indicating if the sprite can be picked */
  87337. isPickable: boolean;
  87338. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  87339. useAlphaForPicking: boolean;
  87340. /** @hidden */
  87341. _xOffset: number;
  87342. /** @hidden */
  87343. _yOffset: number;
  87344. /** @hidden */
  87345. _xSize: number;
  87346. /** @hidden */
  87347. _ySize: number;
  87348. /**
  87349. * Gets or sets the associated action manager
  87350. */
  87351. actionManager: Nullable<ActionManager>;
  87352. /**
  87353. * An event triggered when the control has been disposed
  87354. */
  87355. onDisposeObservable: Observable<Sprite>;
  87356. private _animationStarted;
  87357. private _loopAnimation;
  87358. private _fromIndex;
  87359. private _toIndex;
  87360. private _delay;
  87361. private _direction;
  87362. private _manager;
  87363. private _time;
  87364. private _onAnimationEnd;
  87365. /**
  87366. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  87367. */
  87368. isVisible: boolean;
  87369. /**
  87370. * Gets or sets the sprite size
  87371. */
  87372. get size(): number;
  87373. set size(value: number);
  87374. /**
  87375. * Returns a boolean indicating if the animation is started
  87376. */
  87377. get animationStarted(): boolean;
  87378. /**
  87379. * Gets or sets the unique id of the sprite
  87380. */
  87381. uniqueId: number;
  87382. /**
  87383. * Gets the manager of this sprite
  87384. */
  87385. get manager(): ISpriteManager;
  87386. /**
  87387. * Creates a new Sprite
  87388. * @param name defines the name
  87389. * @param manager defines the manager
  87390. */
  87391. constructor(
  87392. /** defines the name */
  87393. name: string, manager: ISpriteManager);
  87394. /**
  87395. * Returns the string "Sprite"
  87396. * @returns "Sprite"
  87397. */
  87398. getClassName(): string;
  87399. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  87400. get fromIndex(): number;
  87401. set fromIndex(value: number);
  87402. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  87403. get toIndex(): number;
  87404. set toIndex(value: number);
  87405. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  87406. get loopAnimation(): boolean;
  87407. set loopAnimation(value: boolean);
  87408. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  87409. get delay(): number;
  87410. set delay(value: number);
  87411. /**
  87412. * Starts an animation
  87413. * @param from defines the initial key
  87414. * @param to defines the end key
  87415. * @param loop defines if the animation must loop
  87416. * @param delay defines the start delay (in ms)
  87417. * @param onAnimationEnd defines a callback to call when animation ends
  87418. */
  87419. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  87420. /** Stops current animation (if any) */
  87421. stopAnimation(): void;
  87422. /** @hidden */
  87423. _animate(deltaTime: number): void;
  87424. /** Release associated resources */
  87425. dispose(): void;
  87426. /**
  87427. * Serializes the sprite to a JSON object
  87428. * @returns the JSON object
  87429. */
  87430. serialize(): any;
  87431. /**
  87432. * Parses a JSON object to create a new sprite
  87433. * @param parsedSprite The JSON object to parse
  87434. * @param manager defines the hosting manager
  87435. * @returns the new sprite
  87436. */
  87437. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  87438. }
  87439. }
  87440. declare module BABYLON {
  87441. /**
  87442. * Information about the result of picking within a scene
  87443. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  87444. */
  87445. export class PickingInfo {
  87446. /** @hidden */
  87447. _pickingUnavailable: boolean;
  87448. /**
  87449. * If the pick collided with an object
  87450. */
  87451. hit: boolean;
  87452. /**
  87453. * Distance away where the pick collided
  87454. */
  87455. distance: number;
  87456. /**
  87457. * The location of pick collision
  87458. */
  87459. pickedPoint: Nullable<Vector3>;
  87460. /**
  87461. * The mesh corresponding the the pick collision
  87462. */
  87463. pickedMesh: Nullable<AbstractMesh>;
  87464. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  87465. bu: number;
  87466. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  87467. bv: number;
  87468. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  87469. faceId: number;
  87470. /** Id of the the submesh that was picked */
  87471. subMeshId: number;
  87472. /** If a sprite was picked, this will be the sprite the pick collided with */
  87473. pickedSprite: Nullable<Sprite>;
  87474. /**
  87475. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  87476. */
  87477. originMesh: Nullable<AbstractMesh>;
  87478. /**
  87479. * The ray that was used to perform the picking.
  87480. */
  87481. ray: Nullable<Ray>;
  87482. /**
  87483. * Gets the normal correspodning to the face the pick collided with
  87484. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  87485. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  87486. * @returns The normal correspodning to the face the pick collided with
  87487. */
  87488. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  87489. /**
  87490. * Gets the texture coordinates of where the pick occured
  87491. * @returns the vector containing the coordnates of the texture
  87492. */
  87493. getTextureCoordinates(): Nullable<Vector2>;
  87494. }
  87495. }
  87496. declare module BABYLON {
  87497. /**
  87498. * Class representing a ray with position and direction
  87499. */
  87500. export class Ray {
  87501. /** origin point */
  87502. origin: Vector3;
  87503. /** direction */
  87504. direction: Vector3;
  87505. /** length of the ray */
  87506. length: number;
  87507. private static readonly TmpVector3;
  87508. private _tmpRay;
  87509. /**
  87510. * Creates a new ray
  87511. * @param origin origin point
  87512. * @param direction direction
  87513. * @param length length of the ray
  87514. */
  87515. constructor(
  87516. /** origin point */
  87517. origin: Vector3,
  87518. /** direction */
  87519. direction: Vector3,
  87520. /** length of the ray */
  87521. length?: number);
  87522. /**
  87523. * Checks if the ray intersects a box
  87524. * This does not account for the ray lenght by design to improve perfs.
  87525. * @param minimum bound of the box
  87526. * @param maximum bound of the box
  87527. * @param intersectionTreshold extra extend to be added to the box in all direction
  87528. * @returns if the box was hit
  87529. */
  87530. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  87531. /**
  87532. * Checks if the ray intersects a box
  87533. * This does not account for the ray lenght by design to improve perfs.
  87534. * @param box the bounding box to check
  87535. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  87536. * @returns if the box was hit
  87537. */
  87538. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  87539. /**
  87540. * If the ray hits a sphere
  87541. * @param sphere the bounding sphere to check
  87542. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  87543. * @returns true if it hits the sphere
  87544. */
  87545. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  87546. /**
  87547. * If the ray hits a triange
  87548. * @param vertex0 triangle vertex
  87549. * @param vertex1 triangle vertex
  87550. * @param vertex2 triangle vertex
  87551. * @returns intersection information if hit
  87552. */
  87553. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  87554. /**
  87555. * Checks if ray intersects a plane
  87556. * @param plane the plane to check
  87557. * @returns the distance away it was hit
  87558. */
  87559. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  87560. /**
  87561. * Calculate the intercept of a ray on a given axis
  87562. * @param axis to check 'x' | 'y' | 'z'
  87563. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  87564. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  87565. */
  87566. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  87567. /**
  87568. * Checks if ray intersects a mesh
  87569. * @param mesh the mesh to check
  87570. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87571. * @returns picking info of the intersecton
  87572. */
  87573. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  87574. /**
  87575. * Checks if ray intersects a mesh
  87576. * @param meshes the meshes to check
  87577. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87578. * @param results array to store result in
  87579. * @returns Array of picking infos
  87580. */
  87581. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  87582. private _comparePickingInfo;
  87583. private static smallnum;
  87584. private static rayl;
  87585. /**
  87586. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  87587. * @param sega the first point of the segment to test the intersection against
  87588. * @param segb the second point of the segment to test the intersection against
  87589. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  87590. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  87591. */
  87592. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  87593. /**
  87594. * Update the ray from viewport position
  87595. * @param x position
  87596. * @param y y position
  87597. * @param viewportWidth viewport width
  87598. * @param viewportHeight viewport height
  87599. * @param world world matrix
  87600. * @param view view matrix
  87601. * @param projection projection matrix
  87602. * @returns this ray updated
  87603. */
  87604. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87605. /**
  87606. * Creates a ray with origin and direction of 0,0,0
  87607. * @returns the new ray
  87608. */
  87609. static Zero(): Ray;
  87610. /**
  87611. * Creates a new ray from screen space and viewport
  87612. * @param x position
  87613. * @param y y position
  87614. * @param viewportWidth viewport width
  87615. * @param viewportHeight viewport height
  87616. * @param world world matrix
  87617. * @param view view matrix
  87618. * @param projection projection matrix
  87619. * @returns new ray
  87620. */
  87621. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87622. /**
  87623. * 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
  87624. * transformed to the given world matrix.
  87625. * @param origin The origin point
  87626. * @param end The end point
  87627. * @param world a matrix to transform the ray to. Default is the identity matrix.
  87628. * @returns the new ray
  87629. */
  87630. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  87631. /**
  87632. * Transforms a ray by a matrix
  87633. * @param ray ray to transform
  87634. * @param matrix matrix to apply
  87635. * @returns the resulting new ray
  87636. */
  87637. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  87638. /**
  87639. * Transforms a ray by a matrix
  87640. * @param ray ray to transform
  87641. * @param matrix matrix to apply
  87642. * @param result ray to store result in
  87643. */
  87644. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  87645. /**
  87646. * Unproject a ray from screen space to object space
  87647. * @param sourceX defines the screen space x coordinate to use
  87648. * @param sourceY defines the screen space y coordinate to use
  87649. * @param viewportWidth defines the current width of the viewport
  87650. * @param viewportHeight defines the current height of the viewport
  87651. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  87652. * @param view defines the view matrix to use
  87653. * @param projection defines the projection matrix to use
  87654. */
  87655. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  87656. }
  87657. /**
  87658. * Type used to define predicate used to select faces when a mesh intersection is detected
  87659. */
  87660. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  87661. interface Scene {
  87662. /** @hidden */
  87663. _tempPickingRay: Nullable<Ray>;
  87664. /** @hidden */
  87665. _cachedRayForTransform: Ray;
  87666. /** @hidden */
  87667. _pickWithRayInverseMatrix: Matrix;
  87668. /** @hidden */
  87669. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  87670. /** @hidden */
  87671. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  87672. }
  87673. }
  87674. declare module BABYLON {
  87675. /**
  87676. * Groups all the scene component constants in one place to ease maintenance.
  87677. * @hidden
  87678. */
  87679. export class SceneComponentConstants {
  87680. static readonly NAME_EFFECTLAYER: string;
  87681. static readonly NAME_LAYER: string;
  87682. static readonly NAME_LENSFLARESYSTEM: string;
  87683. static readonly NAME_BOUNDINGBOXRENDERER: string;
  87684. static readonly NAME_PARTICLESYSTEM: string;
  87685. static readonly NAME_GAMEPAD: string;
  87686. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  87687. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  87688. static readonly NAME_DEPTHRENDERER: string;
  87689. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  87690. static readonly NAME_SPRITE: string;
  87691. static readonly NAME_OUTLINERENDERER: string;
  87692. static readonly NAME_PROCEDURALTEXTURE: string;
  87693. static readonly NAME_SHADOWGENERATOR: string;
  87694. static readonly NAME_OCTREE: string;
  87695. static readonly NAME_PHYSICSENGINE: string;
  87696. static readonly NAME_AUDIO: string;
  87697. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  87698. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87699. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  87700. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87701. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  87702. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  87703. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  87704. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  87705. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  87706. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  87707. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  87708. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  87709. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  87710. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  87711. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  87712. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  87713. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  87714. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  87715. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  87716. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  87717. static readonly STEP_AFTERRENDER_AUDIO: number;
  87718. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  87719. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  87720. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  87721. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  87722. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  87723. static readonly STEP_POINTERMOVE_SPRITE: number;
  87724. static readonly STEP_POINTERDOWN_SPRITE: number;
  87725. static readonly STEP_POINTERUP_SPRITE: number;
  87726. }
  87727. /**
  87728. * This represents a scene component.
  87729. *
  87730. * This is used to decouple the dependency the scene is having on the different workloads like
  87731. * layers, post processes...
  87732. */
  87733. export interface ISceneComponent {
  87734. /**
  87735. * The name of the component. Each component must have a unique name.
  87736. */
  87737. name: string;
  87738. /**
  87739. * The scene the component belongs to.
  87740. */
  87741. scene: Scene;
  87742. /**
  87743. * Register the component to one instance of a scene.
  87744. */
  87745. register(): void;
  87746. /**
  87747. * Rebuilds the elements related to this component in case of
  87748. * context lost for instance.
  87749. */
  87750. rebuild(): void;
  87751. /**
  87752. * Disposes the component and the associated ressources.
  87753. */
  87754. dispose(): void;
  87755. }
  87756. /**
  87757. * This represents a SERIALIZABLE scene component.
  87758. *
  87759. * This extends Scene Component to add Serialization methods on top.
  87760. */
  87761. export interface ISceneSerializableComponent extends ISceneComponent {
  87762. /**
  87763. * Adds all the elements from the container to the scene
  87764. * @param container the container holding the elements
  87765. */
  87766. addFromContainer(container: AbstractScene): void;
  87767. /**
  87768. * Removes all the elements in the container from the scene
  87769. * @param container contains the elements to remove
  87770. * @param dispose if the removed element should be disposed (default: false)
  87771. */
  87772. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  87773. /**
  87774. * Serializes the component data to the specified json object
  87775. * @param serializationObject The object to serialize to
  87776. */
  87777. serialize(serializationObject: any): void;
  87778. }
  87779. /**
  87780. * Strong typing of a Mesh related stage step action
  87781. */
  87782. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  87783. /**
  87784. * Strong typing of a Evaluate Sub Mesh related stage step action
  87785. */
  87786. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  87787. /**
  87788. * Strong typing of a Active Mesh related stage step action
  87789. */
  87790. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  87791. /**
  87792. * Strong typing of a Camera related stage step action
  87793. */
  87794. export type CameraStageAction = (camera: Camera) => void;
  87795. /**
  87796. * Strong typing of a Camera Frame buffer related stage step action
  87797. */
  87798. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  87799. /**
  87800. * Strong typing of a Render Target related stage step action
  87801. */
  87802. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  87803. /**
  87804. * Strong typing of a RenderingGroup related stage step action
  87805. */
  87806. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  87807. /**
  87808. * Strong typing of a Mesh Render related stage step action
  87809. */
  87810. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  87811. /**
  87812. * Strong typing of a simple stage step action
  87813. */
  87814. export type SimpleStageAction = () => void;
  87815. /**
  87816. * Strong typing of a render target action.
  87817. */
  87818. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  87819. /**
  87820. * Strong typing of a pointer move action.
  87821. */
  87822. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  87823. /**
  87824. * Strong typing of a pointer up/down action.
  87825. */
  87826. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  87827. /**
  87828. * Representation of a stage in the scene (Basically a list of ordered steps)
  87829. * @hidden
  87830. */
  87831. export class Stage<T extends Function> extends Array<{
  87832. index: number;
  87833. component: ISceneComponent;
  87834. action: T;
  87835. }> {
  87836. /**
  87837. * Hide ctor from the rest of the world.
  87838. * @param items The items to add.
  87839. */
  87840. private constructor();
  87841. /**
  87842. * Creates a new Stage.
  87843. * @returns A new instance of a Stage
  87844. */
  87845. static Create<T extends Function>(): Stage<T>;
  87846. /**
  87847. * Registers a step in an ordered way in the targeted stage.
  87848. * @param index Defines the position to register the step in
  87849. * @param component Defines the component attached to the step
  87850. * @param action Defines the action to launch during the step
  87851. */
  87852. registerStep(index: number, component: ISceneComponent, action: T): void;
  87853. /**
  87854. * Clears all the steps from the stage.
  87855. */
  87856. clear(): void;
  87857. }
  87858. }
  87859. declare module BABYLON {
  87860. interface Scene {
  87861. /** @hidden */
  87862. _pointerOverSprite: Nullable<Sprite>;
  87863. /** @hidden */
  87864. _pickedDownSprite: Nullable<Sprite>;
  87865. /** @hidden */
  87866. _tempSpritePickingRay: Nullable<Ray>;
  87867. /**
  87868. * All of the sprite managers added to this scene
  87869. * @see http://doc.babylonjs.com/babylon101/sprites
  87870. */
  87871. spriteManagers: Array<ISpriteManager>;
  87872. /**
  87873. * An event triggered when sprites rendering is about to start
  87874. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  87875. */
  87876. onBeforeSpritesRenderingObservable: Observable<Scene>;
  87877. /**
  87878. * An event triggered when sprites rendering is done
  87879. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  87880. */
  87881. onAfterSpritesRenderingObservable: Observable<Scene>;
  87882. /** @hidden */
  87883. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87884. /** Launch a ray to try to pick a sprite in the scene
  87885. * @param x position on screen
  87886. * @param y position on screen
  87887. * @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
  87888. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87889. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  87890. * @returns a PickingInfo
  87891. */
  87892. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87893. /** Use the given ray to pick a sprite in the scene
  87894. * @param ray The ray (in world space) to use to pick meshes
  87895. * @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
  87896. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87897. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  87898. * @returns a PickingInfo
  87899. */
  87900. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87901. /** @hidden */
  87902. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87903. /** Launch a ray to try to pick sprites in the scene
  87904. * @param x position on screen
  87905. * @param y position on screen
  87906. * @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
  87907. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  87908. * @returns a PickingInfo array
  87909. */
  87910. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87911. /** Use the given ray to pick sprites in the scene
  87912. * @param ray The ray (in world space) to use to pick meshes
  87913. * @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
  87914. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  87915. * @returns a PickingInfo array
  87916. */
  87917. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87918. /**
  87919. * Force the sprite under the pointer
  87920. * @param sprite defines the sprite to use
  87921. */
  87922. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  87923. /**
  87924. * Gets the sprite under the pointer
  87925. * @returns a Sprite or null if no sprite is under the pointer
  87926. */
  87927. getPointerOverSprite(): Nullable<Sprite>;
  87928. }
  87929. /**
  87930. * Defines the sprite scene component responsible to manage sprites
  87931. * in a given scene.
  87932. */
  87933. export class SpriteSceneComponent implements ISceneComponent {
  87934. /**
  87935. * The component name helpfull to identify the component in the list of scene components.
  87936. */
  87937. readonly name: string;
  87938. /**
  87939. * The scene the component belongs to.
  87940. */
  87941. scene: Scene;
  87942. /** @hidden */
  87943. private _spritePredicate;
  87944. /**
  87945. * Creates a new instance of the component for the given scene
  87946. * @param scene Defines the scene to register the component in
  87947. */
  87948. constructor(scene: Scene);
  87949. /**
  87950. * Registers the component in a given scene
  87951. */
  87952. register(): void;
  87953. /**
  87954. * Rebuilds the elements related to this component in case of
  87955. * context lost for instance.
  87956. */
  87957. rebuild(): void;
  87958. /**
  87959. * Disposes the component and the associated ressources.
  87960. */
  87961. dispose(): void;
  87962. private _pickSpriteButKeepRay;
  87963. private _pointerMove;
  87964. private _pointerDown;
  87965. private _pointerUp;
  87966. }
  87967. }
  87968. declare module BABYLON {
  87969. /** @hidden */
  87970. export var fogFragmentDeclaration: {
  87971. name: string;
  87972. shader: string;
  87973. };
  87974. }
  87975. declare module BABYLON {
  87976. /** @hidden */
  87977. export var fogFragment: {
  87978. name: string;
  87979. shader: string;
  87980. };
  87981. }
  87982. declare module BABYLON {
  87983. /** @hidden */
  87984. export var spritesPixelShader: {
  87985. name: string;
  87986. shader: string;
  87987. };
  87988. }
  87989. declare module BABYLON {
  87990. /** @hidden */
  87991. export var fogVertexDeclaration: {
  87992. name: string;
  87993. shader: string;
  87994. };
  87995. }
  87996. declare module BABYLON {
  87997. /** @hidden */
  87998. export var spritesVertexShader: {
  87999. name: string;
  88000. shader: string;
  88001. };
  88002. }
  88003. declare module BABYLON {
  88004. /**
  88005. * Defines the minimum interface to fullfil in order to be a sprite manager.
  88006. */
  88007. export interface ISpriteManager extends IDisposable {
  88008. /**
  88009. * Gets manager's name
  88010. */
  88011. name: string;
  88012. /**
  88013. * Restricts the camera to viewing objects with the same layerMask.
  88014. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  88015. */
  88016. layerMask: number;
  88017. /**
  88018. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  88019. */
  88020. isPickable: boolean;
  88021. /**
  88022. * Gets the hosting scene
  88023. */
  88024. scene: Scene;
  88025. /**
  88026. * Specifies the rendering group id for this mesh (0 by default)
  88027. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  88028. */
  88029. renderingGroupId: number;
  88030. /**
  88031. * Defines the list of sprites managed by the manager.
  88032. */
  88033. sprites: Array<Sprite>;
  88034. /**
  88035. * Gets or sets the spritesheet texture
  88036. */
  88037. texture: Texture;
  88038. /** Defines the default width of a cell in the spritesheet */
  88039. cellWidth: number;
  88040. /** Defines the default height of a cell in the spritesheet */
  88041. cellHeight: number;
  88042. /**
  88043. * Tests the intersection of a sprite with a specific ray.
  88044. * @param ray The ray we are sending to test the collision
  88045. * @param camera The camera space we are sending rays in
  88046. * @param predicate A predicate allowing excluding sprites from the list of object to test
  88047. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88048. * @returns picking info or null.
  88049. */
  88050. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88051. /**
  88052. * Intersects the sprites with a ray
  88053. * @param ray defines the ray to intersect with
  88054. * @param camera defines the current active camera
  88055. * @param predicate defines a predicate used to select candidate sprites
  88056. * @returns null if no hit or a PickingInfo array
  88057. */
  88058. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88059. /**
  88060. * Renders the list of sprites on screen.
  88061. */
  88062. render(): void;
  88063. }
  88064. /**
  88065. * Class used to manage multiple sprites on the same spritesheet
  88066. * @see http://doc.babylonjs.com/babylon101/sprites
  88067. */
  88068. export class SpriteManager implements ISpriteManager {
  88069. /** defines the manager's name */
  88070. name: string;
  88071. /** Define the Url to load snippets */
  88072. static SnippetUrl: string;
  88073. /** Snippet ID if the manager was created from the snippet server */
  88074. snippetId: string;
  88075. /** Gets the list of sprites */
  88076. sprites: Sprite[];
  88077. /** Gets or sets the rendering group id (0 by default) */
  88078. renderingGroupId: number;
  88079. /** Gets or sets camera layer mask */
  88080. layerMask: number;
  88081. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  88082. fogEnabled: boolean;
  88083. /** Gets or sets a boolean indicating if the sprites are pickable */
  88084. isPickable: boolean;
  88085. /** Defines the default width of a cell in the spritesheet */
  88086. cellWidth: number;
  88087. /** Defines the default height of a cell in the spritesheet */
  88088. cellHeight: number;
  88089. /** Associative array from JSON sprite data file */
  88090. private _cellData;
  88091. /** Array of sprite names from JSON sprite data file */
  88092. private _spriteMap;
  88093. /** True when packed cell data from JSON file is ready*/
  88094. private _packedAndReady;
  88095. private _textureContent;
  88096. /**
  88097. * An event triggered when the manager is disposed.
  88098. */
  88099. onDisposeObservable: Observable<SpriteManager>;
  88100. private _onDisposeObserver;
  88101. /**
  88102. * Callback called when the manager is disposed
  88103. */
  88104. set onDispose(callback: () => void);
  88105. private _capacity;
  88106. private _fromPacked;
  88107. private _spriteTexture;
  88108. private _epsilon;
  88109. private _scene;
  88110. private _vertexData;
  88111. private _buffer;
  88112. private _vertexBuffers;
  88113. private _indexBuffer;
  88114. private _effectBase;
  88115. private _effectFog;
  88116. /**
  88117. * Gets or sets the unique id of the sprite
  88118. */
  88119. uniqueId: number;
  88120. /**
  88121. * Gets the array of sprites
  88122. */
  88123. get children(): Sprite[];
  88124. /**
  88125. * Gets the hosting scene
  88126. */
  88127. get scene(): Scene;
  88128. /**
  88129. * Gets the capacity of the manager
  88130. */
  88131. get capacity(): number;
  88132. /**
  88133. * Gets or sets the spritesheet texture
  88134. */
  88135. get texture(): Texture;
  88136. set texture(value: Texture);
  88137. private _blendMode;
  88138. /**
  88139. * Blend mode use to render the particle, it can be any of
  88140. * the static Constants.ALPHA_x properties provided in this class.
  88141. * Default value is Constants.ALPHA_COMBINE
  88142. */
  88143. get blendMode(): number;
  88144. set blendMode(blendMode: number);
  88145. /** Disables writing to the depth buffer when rendering the sprites.
  88146. * It can be handy to disable depth writing when using textures without alpha channel
  88147. * and setting some specific blend modes.
  88148. */
  88149. disableDepthWrite: boolean;
  88150. /**
  88151. * Creates a new sprite manager
  88152. * @param name defines the manager's name
  88153. * @param imgUrl defines the sprite sheet url
  88154. * @param capacity defines the maximum allowed number of sprites
  88155. * @param cellSize defines the size of a sprite cell
  88156. * @param scene defines the hosting scene
  88157. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  88158. * @param samplingMode defines the smapling mode to use with spritesheet
  88159. * @param fromPacked set to false; do not alter
  88160. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  88161. */
  88162. constructor(
  88163. /** defines the manager's name */
  88164. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  88165. /**
  88166. * Returns the string "SpriteManager"
  88167. * @returns "SpriteManager"
  88168. */
  88169. getClassName(): string;
  88170. private _makePacked;
  88171. private _appendSpriteVertex;
  88172. private _checkTextureAlpha;
  88173. /**
  88174. * Intersects the sprites with a ray
  88175. * @param ray defines the ray to intersect with
  88176. * @param camera defines the current active camera
  88177. * @param predicate defines a predicate used to select candidate sprites
  88178. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  88179. * @returns null if no hit or a PickingInfo
  88180. */
  88181. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88182. /**
  88183. * Intersects the sprites with a ray
  88184. * @param ray defines the ray to intersect with
  88185. * @param camera defines the current active camera
  88186. * @param predicate defines a predicate used to select candidate sprites
  88187. * @returns null if no hit or a PickingInfo array
  88188. */
  88189. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88190. /**
  88191. * Render all child sprites
  88192. */
  88193. render(): void;
  88194. /**
  88195. * Release associated resources
  88196. */
  88197. dispose(): void;
  88198. /**
  88199. * Serializes the sprite manager to a JSON object
  88200. * @param serializeTexture defines if the texture must be serialized as well
  88201. * @returns the JSON object
  88202. */
  88203. serialize(serializeTexture?: boolean): any;
  88204. /**
  88205. * Parses a JSON object to create a new sprite manager.
  88206. * @param parsedManager The JSON object to parse
  88207. * @param scene The scene to create the sprite managerin
  88208. * @param rootUrl The root url to use to load external dependencies like texture
  88209. * @returns the new sprite manager
  88210. */
  88211. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  88212. /**
  88213. * Creates a sprite manager from a snippet saved in a remote file
  88214. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  88215. * @param url defines the url to load from
  88216. * @param scene defines the hosting scene
  88217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88218. * @returns a promise that will resolve to the new sprite manager
  88219. */
  88220. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88221. /**
  88222. * Creates a sprite manager from a snippet saved by the sprite editor
  88223. * @param snippetId defines the snippet to load
  88224. * @param scene defines the hosting scene
  88225. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88226. * @returns a promise that will resolve to the new sprite manager
  88227. */
  88228. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88229. }
  88230. }
  88231. declare module BABYLON {
  88232. /** Interface used by value gradients (color, factor, ...) */
  88233. export interface IValueGradient {
  88234. /**
  88235. * Gets or sets the gradient value (between 0 and 1)
  88236. */
  88237. gradient: number;
  88238. }
  88239. /** Class used to store color4 gradient */
  88240. export class ColorGradient implements IValueGradient {
  88241. /**
  88242. * Gets or sets the gradient value (between 0 and 1)
  88243. */
  88244. gradient: number;
  88245. /**
  88246. * Gets or sets first associated color
  88247. */
  88248. color1: Color4;
  88249. /**
  88250. * Gets or sets second associated color
  88251. */
  88252. color2?: Color4 | undefined;
  88253. /**
  88254. * Creates a new color4 gradient
  88255. * @param gradient gets or sets the gradient value (between 0 and 1)
  88256. * @param color1 gets or sets first associated color
  88257. * @param color2 gets or sets first second color
  88258. */
  88259. constructor(
  88260. /**
  88261. * Gets or sets the gradient value (between 0 and 1)
  88262. */
  88263. gradient: number,
  88264. /**
  88265. * Gets or sets first associated color
  88266. */
  88267. color1: Color4,
  88268. /**
  88269. * Gets or sets second associated color
  88270. */
  88271. color2?: Color4 | undefined);
  88272. /**
  88273. * Will get a color picked randomly between color1 and color2.
  88274. * If color2 is undefined then color1 will be used
  88275. * @param result defines the target Color4 to store the result in
  88276. */
  88277. getColorToRef(result: Color4): void;
  88278. }
  88279. /** Class used to store color 3 gradient */
  88280. export class Color3Gradient implements IValueGradient {
  88281. /**
  88282. * Gets or sets the gradient value (between 0 and 1)
  88283. */
  88284. gradient: number;
  88285. /**
  88286. * Gets or sets the associated color
  88287. */
  88288. color: Color3;
  88289. /**
  88290. * Creates a new color3 gradient
  88291. * @param gradient gets or sets the gradient value (between 0 and 1)
  88292. * @param color gets or sets associated color
  88293. */
  88294. constructor(
  88295. /**
  88296. * Gets or sets the gradient value (between 0 and 1)
  88297. */
  88298. gradient: number,
  88299. /**
  88300. * Gets or sets the associated color
  88301. */
  88302. color: Color3);
  88303. }
  88304. /** Class used to store factor gradient */
  88305. export class FactorGradient implements IValueGradient {
  88306. /**
  88307. * Gets or sets the gradient value (between 0 and 1)
  88308. */
  88309. gradient: number;
  88310. /**
  88311. * Gets or sets first associated factor
  88312. */
  88313. factor1: number;
  88314. /**
  88315. * Gets or sets second associated factor
  88316. */
  88317. factor2?: number | undefined;
  88318. /**
  88319. * Creates a new factor gradient
  88320. * @param gradient gets or sets the gradient value (between 0 and 1)
  88321. * @param factor1 gets or sets first associated factor
  88322. * @param factor2 gets or sets second associated factor
  88323. */
  88324. constructor(
  88325. /**
  88326. * Gets or sets the gradient value (between 0 and 1)
  88327. */
  88328. gradient: number,
  88329. /**
  88330. * Gets or sets first associated factor
  88331. */
  88332. factor1: number,
  88333. /**
  88334. * Gets or sets second associated factor
  88335. */
  88336. factor2?: number | undefined);
  88337. /**
  88338. * Will get a number picked randomly between factor1 and factor2.
  88339. * If factor2 is undefined then factor1 will be used
  88340. * @returns the picked number
  88341. */
  88342. getFactor(): number;
  88343. }
  88344. /**
  88345. * Helper used to simplify some generic gradient tasks
  88346. */
  88347. export class GradientHelper {
  88348. /**
  88349. * Gets the current gradient from an array of IValueGradient
  88350. * @param ratio defines the current ratio to get
  88351. * @param gradients defines the array of IValueGradient
  88352. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88353. */
  88354. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88355. }
  88356. }
  88357. declare module BABYLON {
  88358. interface ThinEngine {
  88359. /**
  88360. * Creates a dynamic texture
  88361. * @param width defines the width of the texture
  88362. * @param height defines the height of the texture
  88363. * @param generateMipMaps defines if the engine should generate the mip levels
  88364. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88365. * @returns the dynamic texture inside an InternalTexture
  88366. */
  88367. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88368. /**
  88369. * Update the content of a dynamic texture
  88370. * @param texture defines the texture to update
  88371. * @param canvas defines the canvas containing the source
  88372. * @param invertY defines if data must be stored with Y axis inverted
  88373. * @param premulAlpha defines if alpha is stored as premultiplied
  88374. * @param format defines the format of the data
  88375. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88376. */
  88377. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88378. }
  88379. }
  88380. declare module BABYLON {
  88381. /**
  88382. * Helper class used to generate a canvas to manipulate images
  88383. */
  88384. export class CanvasGenerator {
  88385. /**
  88386. * Create a new canvas (or offscreen canvas depending on the context)
  88387. * @param width defines the expected width
  88388. * @param height defines the expected height
  88389. * @return a new canvas or offscreen canvas
  88390. */
  88391. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88392. }
  88393. }
  88394. declare module BABYLON {
  88395. /**
  88396. * A class extending Texture allowing drawing on a texture
  88397. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88398. */
  88399. export class DynamicTexture extends Texture {
  88400. private _generateMipMaps;
  88401. private _canvas;
  88402. private _context;
  88403. /**
  88404. * Creates a DynamicTexture
  88405. * @param name defines the name of the texture
  88406. * @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
  88407. * @param scene defines the scene where you want the texture
  88408. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88409. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88410. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88411. */
  88412. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88413. /**
  88414. * Get the current class name of the texture useful for serialization or dynamic coding.
  88415. * @returns "DynamicTexture"
  88416. */
  88417. getClassName(): string;
  88418. /**
  88419. * Gets the current state of canRescale
  88420. */
  88421. get canRescale(): boolean;
  88422. private _recreate;
  88423. /**
  88424. * Scales the texture
  88425. * @param ratio the scale factor to apply to both width and height
  88426. */
  88427. scale(ratio: number): void;
  88428. /**
  88429. * Resizes the texture
  88430. * @param width the new width
  88431. * @param height the new height
  88432. */
  88433. scaleTo(width: number, height: number): void;
  88434. /**
  88435. * Gets the context of the canvas used by the texture
  88436. * @returns the canvas context of the dynamic texture
  88437. */
  88438. getContext(): CanvasRenderingContext2D;
  88439. /**
  88440. * Clears the texture
  88441. */
  88442. clear(): void;
  88443. /**
  88444. * Updates the texture
  88445. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88446. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88447. */
  88448. update(invertY?: boolean, premulAlpha?: boolean): void;
  88449. /**
  88450. * Draws text onto the texture
  88451. * @param text defines the text to be drawn
  88452. * @param x defines the placement of the text from the left
  88453. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  88454. * @param font defines the font to be used with font-style, font-size, font-name
  88455. * @param color defines the color used for the text
  88456. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  88457. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88458. * @param update defines whether texture is immediately update (default is true)
  88459. */
  88460. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  88461. /**
  88462. * Clones the texture
  88463. * @returns the clone of the texture.
  88464. */
  88465. clone(): DynamicTexture;
  88466. /**
  88467. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  88468. * @returns a serialized dynamic texture object
  88469. */
  88470. serialize(): any;
  88471. /** @hidden */
  88472. _rebuild(): void;
  88473. }
  88474. }
  88475. declare module BABYLON {
  88476. interface ThinEngine {
  88477. /**
  88478. * Creates a raw texture
  88479. * @param data defines the data to store in the texture
  88480. * @param width defines the width of the texture
  88481. * @param height defines the height of the texture
  88482. * @param format defines the format of the data
  88483. * @param generateMipMaps defines if the engine should generate the mip levels
  88484. * @param invertY defines if data must be stored with Y axis inverted
  88485. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88486. * @param compression defines the compression used (null by default)
  88487. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88488. * @returns the raw texture inside an InternalTexture
  88489. */
  88490. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  88491. /**
  88492. * Update a raw texture
  88493. * @param texture defines the texture to update
  88494. * @param data defines the data to store in the texture
  88495. * @param format defines the format of the data
  88496. * @param invertY defines if data must be stored with Y axis inverted
  88497. */
  88498. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88499. /**
  88500. * Update a raw texture
  88501. * @param texture defines the texture to update
  88502. * @param data defines the data to store in the texture
  88503. * @param format defines the format of the data
  88504. * @param invertY defines if data must be stored with Y axis inverted
  88505. * @param compression defines the compression used (null by default)
  88506. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88507. */
  88508. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  88509. /**
  88510. * Creates a new raw cube texture
  88511. * @param data defines the array of data to use to create each face
  88512. * @param size defines the size of the textures
  88513. * @param format defines the format of the data
  88514. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88515. * @param generateMipMaps defines if the engine should generate the mip levels
  88516. * @param invertY defines if data must be stored with Y axis inverted
  88517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88518. * @param compression defines the compression used (null by default)
  88519. * @returns the cube texture as an InternalTexture
  88520. */
  88521. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  88522. /**
  88523. * Update a raw cube texture
  88524. * @param texture defines the texture to udpdate
  88525. * @param data defines the data to store
  88526. * @param format defines the data format
  88527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88528. * @param invertY defines if data must be stored with Y axis inverted
  88529. */
  88530. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  88531. /**
  88532. * Update a raw cube texture
  88533. * @param texture defines the texture to udpdate
  88534. * @param data defines the data to store
  88535. * @param format defines the data format
  88536. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88537. * @param invertY defines if data must be stored with Y axis inverted
  88538. * @param compression defines the compression used (null by default)
  88539. */
  88540. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  88541. /**
  88542. * Update a raw cube texture
  88543. * @param texture defines the texture to udpdate
  88544. * @param data defines the data to store
  88545. * @param format defines the data format
  88546. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88547. * @param invertY defines if data must be stored with Y axis inverted
  88548. * @param compression defines the compression used (null by default)
  88549. * @param level defines which level of the texture to update
  88550. */
  88551. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  88552. /**
  88553. * Creates a new raw cube texture from a specified url
  88554. * @param url defines the url where the data is located
  88555. * @param scene defines the current scene
  88556. * @param size defines the size of the textures
  88557. * @param format defines the format of the data
  88558. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88559. * @param noMipmap defines if the engine should avoid generating the mip levels
  88560. * @param callback defines a callback used to extract texture data from loaded data
  88561. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88562. * @param onLoad defines a callback called when texture is loaded
  88563. * @param onError defines a callback called if there is an error
  88564. * @returns the cube texture as an InternalTexture
  88565. */
  88566. 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;
  88567. /**
  88568. * Creates a new raw cube texture from a specified url
  88569. * @param url defines the url where the data is located
  88570. * @param scene defines the current scene
  88571. * @param size defines the size of the textures
  88572. * @param format defines the format of the data
  88573. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88574. * @param noMipmap defines if the engine should avoid generating the mip levels
  88575. * @param callback defines a callback used to extract texture data from loaded data
  88576. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88577. * @param onLoad defines a callback called when texture is loaded
  88578. * @param onError defines a callback called if there is an error
  88579. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88580. * @param invertY defines if data must be stored with Y axis inverted
  88581. * @returns the cube texture as an InternalTexture
  88582. */
  88583. 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;
  88584. /**
  88585. * Creates a new raw 3D texture
  88586. * @param data defines the data used to create the texture
  88587. * @param width defines the width of the texture
  88588. * @param height defines the height of the texture
  88589. * @param depth defines the depth of the texture
  88590. * @param format defines the format of the texture
  88591. * @param generateMipMaps defines if the engine must generate mip levels
  88592. * @param invertY defines if data must be stored with Y axis inverted
  88593. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88594. * @param compression defines the compressed used (can be null)
  88595. * @param textureType defines the compressed used (can be null)
  88596. * @returns a new raw 3D texture (stored in an InternalTexture)
  88597. */
  88598. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88599. /**
  88600. * Update a raw 3D texture
  88601. * @param texture defines the texture to update
  88602. * @param data defines the data to store
  88603. * @param format defines the data format
  88604. * @param invertY defines if data must be stored with Y axis inverted
  88605. */
  88606. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88607. /**
  88608. * Update a raw 3D texture
  88609. * @param texture defines the texture to update
  88610. * @param data defines the data to store
  88611. * @param format defines the data format
  88612. * @param invertY defines if data must be stored with Y axis inverted
  88613. * @param compression defines the used compression (can be null)
  88614. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88615. */
  88616. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88617. /**
  88618. * Creates a new raw 2D array texture
  88619. * @param data defines the data used to create the texture
  88620. * @param width defines the width of the texture
  88621. * @param height defines the height of the texture
  88622. * @param depth defines the number of layers of the texture
  88623. * @param format defines the format of the texture
  88624. * @param generateMipMaps defines if the engine must generate mip levels
  88625. * @param invertY defines if data must be stored with Y axis inverted
  88626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88627. * @param compression defines the compressed used (can be null)
  88628. * @param textureType defines the compressed used (can be null)
  88629. * @returns a new raw 2D array texture (stored in an InternalTexture)
  88630. */
  88631. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88632. /**
  88633. * Update a raw 2D array texture
  88634. * @param texture defines the texture to update
  88635. * @param data defines the data to store
  88636. * @param format defines the data format
  88637. * @param invertY defines if data must be stored with Y axis inverted
  88638. */
  88639. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88640. /**
  88641. * Update a raw 2D array texture
  88642. * @param texture defines the texture to update
  88643. * @param data defines the data to store
  88644. * @param format defines the data format
  88645. * @param invertY defines if data must be stored with Y axis inverted
  88646. * @param compression defines the used compression (can be null)
  88647. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88648. */
  88649. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88650. }
  88651. }
  88652. declare module BABYLON {
  88653. /**
  88654. * Raw texture can help creating a texture directly from an array of data.
  88655. * This can be super useful if you either get the data from an uncompressed source or
  88656. * if you wish to create your texture pixel by pixel.
  88657. */
  88658. export class RawTexture extends Texture {
  88659. /**
  88660. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88661. */
  88662. format: number;
  88663. /**
  88664. * Instantiates a new RawTexture.
  88665. * Raw texture can help creating a texture directly from an array of data.
  88666. * This can be super useful if you either get the data from an uncompressed source or
  88667. * if you wish to create your texture pixel by pixel.
  88668. * @param data define the array of data to use to create the texture
  88669. * @param width define the width of the texture
  88670. * @param height define the height of the texture
  88671. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88672. * @param scene define the scene the texture belongs to
  88673. * @param generateMipMaps define whether mip maps should be generated or not
  88674. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88675. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88676. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88677. */
  88678. constructor(data: ArrayBufferView, width: number, height: number,
  88679. /**
  88680. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88681. */
  88682. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  88683. /**
  88684. * Updates the texture underlying data.
  88685. * @param data Define the new data of the texture
  88686. */
  88687. update(data: ArrayBufferView): void;
  88688. /**
  88689. * Creates a luminance texture from some data.
  88690. * @param data Define the texture data
  88691. * @param width Define the width of the texture
  88692. * @param height Define the height of the texture
  88693. * @param scene Define the scene the texture belongs to
  88694. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88695. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88696. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88697. * @returns the luminance texture
  88698. */
  88699. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88700. /**
  88701. * Creates a luminance alpha texture from some data.
  88702. * @param data Define the texture data
  88703. * @param width Define the width of the texture
  88704. * @param height Define the height of the texture
  88705. * @param scene Define the scene the texture belongs to
  88706. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88707. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88708. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88709. * @returns the luminance alpha texture
  88710. */
  88711. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88712. /**
  88713. * Creates an alpha texture from some data.
  88714. * @param data Define the texture data
  88715. * @param width Define the width of the texture
  88716. * @param height Define the height of the texture
  88717. * @param scene Define the scene the texture belongs to
  88718. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88719. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88720. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88721. * @returns the alpha texture
  88722. */
  88723. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88724. /**
  88725. * Creates a RGB texture from some data.
  88726. * @param data Define the texture data
  88727. * @param width Define the width of the texture
  88728. * @param height Define the height of the texture
  88729. * @param scene Define the scene the texture belongs to
  88730. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88731. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88732. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88733. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88734. * @returns the RGB alpha texture
  88735. */
  88736. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88737. /**
  88738. * Creates a RGBA texture from some data.
  88739. * @param data Define the texture data
  88740. * @param width Define the width of the texture
  88741. * @param height Define the height of the texture
  88742. * @param scene Define the scene the texture belongs to
  88743. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88744. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88745. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88746. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88747. * @returns the RGBA texture
  88748. */
  88749. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88750. /**
  88751. * Creates a R texture from some data.
  88752. * @param data Define the texture data
  88753. * @param width Define the width of the texture
  88754. * @param height Define the height of the texture
  88755. * @param scene Define the scene the texture belongs to
  88756. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88757. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88758. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88759. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88760. * @returns the R texture
  88761. */
  88762. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88763. }
  88764. }
  88765. declare module BABYLON {
  88766. interface AbstractScene {
  88767. /**
  88768. * The list of procedural textures added to the scene
  88769. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88770. */
  88771. proceduralTextures: Array<ProceduralTexture>;
  88772. }
  88773. /**
  88774. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  88775. * in a given scene.
  88776. */
  88777. export class ProceduralTextureSceneComponent implements ISceneComponent {
  88778. /**
  88779. * The component name helpfull to identify the component in the list of scene components.
  88780. */
  88781. readonly name: string;
  88782. /**
  88783. * The scene the component belongs to.
  88784. */
  88785. scene: Scene;
  88786. /**
  88787. * Creates a new instance of the component for the given scene
  88788. * @param scene Defines the scene to register the component in
  88789. */
  88790. constructor(scene: Scene);
  88791. /**
  88792. * Registers the component in a given scene
  88793. */
  88794. register(): void;
  88795. /**
  88796. * Rebuilds the elements related to this component in case of
  88797. * context lost for instance.
  88798. */
  88799. rebuild(): void;
  88800. /**
  88801. * Disposes the component and the associated ressources.
  88802. */
  88803. dispose(): void;
  88804. private _beforeClear;
  88805. }
  88806. }
  88807. declare module BABYLON {
  88808. interface ThinEngine {
  88809. /**
  88810. * Creates a new render target cube texture
  88811. * @param size defines the size of the texture
  88812. * @param options defines the options used to create the texture
  88813. * @returns a new render target cube texture stored in an InternalTexture
  88814. */
  88815. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  88816. }
  88817. }
  88818. declare module BABYLON {
  88819. /** @hidden */
  88820. export var proceduralVertexShader: {
  88821. name: string;
  88822. shader: string;
  88823. };
  88824. }
  88825. declare module BABYLON {
  88826. /**
  88827. * 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.
  88828. * This is the base class of any Procedural texture and contains most of the shareable code.
  88829. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88830. */
  88831. export class ProceduralTexture extends Texture {
  88832. isCube: boolean;
  88833. /**
  88834. * Define if the texture is enabled or not (disabled texture will not render)
  88835. */
  88836. isEnabled: boolean;
  88837. /**
  88838. * Define if the texture must be cleared before rendering (default is true)
  88839. */
  88840. autoClear: boolean;
  88841. /**
  88842. * Callback called when the texture is generated
  88843. */
  88844. onGenerated: () => void;
  88845. /**
  88846. * Event raised when the texture is generated
  88847. */
  88848. onGeneratedObservable: Observable<ProceduralTexture>;
  88849. /** @hidden */
  88850. _generateMipMaps: boolean;
  88851. /** @hidden **/
  88852. _effect: Effect;
  88853. /** @hidden */
  88854. _textures: {
  88855. [key: string]: Texture;
  88856. };
  88857. /** @hidden */
  88858. protected _fallbackTexture: Nullable<Texture>;
  88859. private _size;
  88860. private _currentRefreshId;
  88861. private _frameId;
  88862. private _refreshRate;
  88863. private _vertexBuffers;
  88864. private _indexBuffer;
  88865. private _uniforms;
  88866. private _samplers;
  88867. private _fragment;
  88868. private _floats;
  88869. private _ints;
  88870. private _floatsArrays;
  88871. private _colors3;
  88872. private _colors4;
  88873. private _vectors2;
  88874. private _vectors3;
  88875. private _matrices;
  88876. private _fallbackTextureUsed;
  88877. private _fullEngine;
  88878. private _cachedDefines;
  88879. private _contentUpdateId;
  88880. private _contentData;
  88881. /**
  88882. * Instantiates a new procedural texture.
  88883. * 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.
  88884. * This is the base class of any Procedural texture and contains most of the shareable code.
  88885. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88886. * @param name Define the name of the texture
  88887. * @param size Define the size of the texture to create
  88888. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  88889. * @param scene Define the scene the texture belongs to
  88890. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  88891. * @param generateMipMaps Define if the texture should creates mip maps or not
  88892. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  88893. */
  88894. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  88895. /**
  88896. * The effect that is created when initializing the post process.
  88897. * @returns The created effect corresponding the the postprocess.
  88898. */
  88899. getEffect(): Effect;
  88900. /**
  88901. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  88902. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  88903. */
  88904. getContent(): Nullable<ArrayBufferView>;
  88905. private _createIndexBuffer;
  88906. /** @hidden */
  88907. _rebuild(): void;
  88908. /**
  88909. * Resets the texture in order to recreate its associated resources.
  88910. * This can be called in case of context loss
  88911. */
  88912. reset(): void;
  88913. protected _getDefines(): string;
  88914. /**
  88915. * Is the texture ready to be used ? (rendered at least once)
  88916. * @returns true if ready, otherwise, false.
  88917. */
  88918. isReady(): boolean;
  88919. /**
  88920. * Resets the refresh counter of the texture and start bak from scratch.
  88921. * Could be useful to regenerate the texture if it is setup to render only once.
  88922. */
  88923. resetRefreshCounter(): void;
  88924. /**
  88925. * Set the fragment shader to use in order to render the texture.
  88926. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  88927. */
  88928. setFragment(fragment: any): void;
  88929. /**
  88930. * Define the refresh rate of the texture or the rendering frequency.
  88931. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88932. */
  88933. get refreshRate(): number;
  88934. set refreshRate(value: number);
  88935. /** @hidden */
  88936. _shouldRender(): boolean;
  88937. /**
  88938. * Get the size the texture is rendering at.
  88939. * @returns the size (texture is always squared)
  88940. */
  88941. getRenderSize(): number;
  88942. /**
  88943. * Resize the texture to new value.
  88944. * @param size Define the new size the texture should have
  88945. * @param generateMipMaps Define whether the new texture should create mip maps
  88946. */
  88947. resize(size: number, generateMipMaps: boolean): void;
  88948. private _checkUniform;
  88949. /**
  88950. * Set a texture in the shader program used to render.
  88951. * @param name Define the name of the uniform samplers as defined in the shader
  88952. * @param texture Define the texture to bind to this sampler
  88953. * @return the texture itself allowing "fluent" like uniform updates
  88954. */
  88955. setTexture(name: string, texture: Texture): ProceduralTexture;
  88956. /**
  88957. * Set a float in the shader.
  88958. * @param name Define the name of the uniform as defined in the shader
  88959. * @param value Define the value to give to the uniform
  88960. * @return the texture itself allowing "fluent" like uniform updates
  88961. */
  88962. setFloat(name: string, value: number): ProceduralTexture;
  88963. /**
  88964. * Set a int in the shader.
  88965. * @param name Define the name of the uniform as defined in the shader
  88966. * @param value Define the value to give to the uniform
  88967. * @return the texture itself allowing "fluent" like uniform updates
  88968. */
  88969. setInt(name: string, value: number): ProceduralTexture;
  88970. /**
  88971. * Set an array of floats in the shader.
  88972. * @param name Define the name of the uniform as defined in the shader
  88973. * @param value Define the value to give to the uniform
  88974. * @return the texture itself allowing "fluent" like uniform updates
  88975. */
  88976. setFloats(name: string, value: number[]): ProceduralTexture;
  88977. /**
  88978. * Set a vec3 in the shader from a Color3.
  88979. * @param name Define the name of the uniform as defined in the shader
  88980. * @param value Define the value to give to the uniform
  88981. * @return the texture itself allowing "fluent" like uniform updates
  88982. */
  88983. setColor3(name: string, value: Color3): ProceduralTexture;
  88984. /**
  88985. * Set a vec4 in the shader from a Color4.
  88986. * @param name Define the name of the uniform as defined in the shader
  88987. * @param value Define the value to give to the uniform
  88988. * @return the texture itself allowing "fluent" like uniform updates
  88989. */
  88990. setColor4(name: string, value: Color4): ProceduralTexture;
  88991. /**
  88992. * Set a vec2 in the shader from a Vector2.
  88993. * @param name Define the name of the uniform as defined in the shader
  88994. * @param value Define the value to give to the uniform
  88995. * @return the texture itself allowing "fluent" like uniform updates
  88996. */
  88997. setVector2(name: string, value: Vector2): ProceduralTexture;
  88998. /**
  88999. * Set a vec3 in the shader from a Vector3.
  89000. * @param name Define the name of the uniform as defined in the shader
  89001. * @param value Define the value to give to the uniform
  89002. * @return the texture itself allowing "fluent" like uniform updates
  89003. */
  89004. setVector3(name: string, value: Vector3): ProceduralTexture;
  89005. /**
  89006. * Set a mat4 in the shader from a MAtrix.
  89007. * @param name Define the name of the uniform as defined in the shader
  89008. * @param value Define the value to give to the uniform
  89009. * @return the texture itself allowing "fluent" like uniform updates
  89010. */
  89011. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89012. /**
  89013. * Render the texture to its associated render target.
  89014. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89015. */
  89016. render(useCameraPostProcess?: boolean): void;
  89017. /**
  89018. * Clone the texture.
  89019. * @returns the cloned texture
  89020. */
  89021. clone(): ProceduralTexture;
  89022. /**
  89023. * Dispose the texture and release its asoociated resources.
  89024. */
  89025. dispose(): void;
  89026. }
  89027. }
  89028. declare module BABYLON {
  89029. /**
  89030. * This represents the base class for particle system in Babylon.
  89031. * 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.
  89032. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89033. * @example https://doc.babylonjs.com/babylon101/particles
  89034. */
  89035. export class BaseParticleSystem {
  89036. /**
  89037. * Source color is added to the destination color without alpha affecting the result
  89038. */
  89039. static BLENDMODE_ONEONE: number;
  89040. /**
  89041. * Blend current color and particle color using particle’s alpha
  89042. */
  89043. static BLENDMODE_STANDARD: number;
  89044. /**
  89045. * Add current color and particle color multiplied by particle’s alpha
  89046. */
  89047. static BLENDMODE_ADD: number;
  89048. /**
  89049. * Multiply current color with particle color
  89050. */
  89051. static BLENDMODE_MULTIPLY: number;
  89052. /**
  89053. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89054. */
  89055. static BLENDMODE_MULTIPLYADD: number;
  89056. /**
  89057. * List of animations used by the particle system.
  89058. */
  89059. animations: Animation[];
  89060. /**
  89061. * Gets or sets the unique id of the particle system
  89062. */
  89063. uniqueId: number;
  89064. /**
  89065. * The id of the Particle system.
  89066. */
  89067. id: string;
  89068. /**
  89069. * The friendly name of the Particle system.
  89070. */
  89071. name: string;
  89072. /**
  89073. * Snippet ID if the particle system was created from the snippet server
  89074. */
  89075. snippetId: string;
  89076. /**
  89077. * The rendering group used by the Particle system to chose when to render.
  89078. */
  89079. renderingGroupId: number;
  89080. /**
  89081. * The emitter represents the Mesh or position we are attaching the particle system to.
  89082. */
  89083. emitter: Nullable<AbstractMesh | Vector3>;
  89084. /**
  89085. * The maximum number of particles to emit per frame
  89086. */
  89087. emitRate: number;
  89088. /**
  89089. * If you want to launch only a few particles at once, that can be done, as well.
  89090. */
  89091. manualEmitCount: number;
  89092. /**
  89093. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89094. */
  89095. updateSpeed: number;
  89096. /**
  89097. * The amount of time the particle system is running (depends of the overall update speed).
  89098. */
  89099. targetStopDuration: number;
  89100. /**
  89101. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89102. */
  89103. disposeOnStop: boolean;
  89104. /**
  89105. * Minimum power of emitting particles.
  89106. */
  89107. minEmitPower: number;
  89108. /**
  89109. * Maximum power of emitting particles.
  89110. */
  89111. maxEmitPower: number;
  89112. /**
  89113. * Minimum life time of emitting particles.
  89114. */
  89115. minLifeTime: number;
  89116. /**
  89117. * Maximum life time of emitting particles.
  89118. */
  89119. maxLifeTime: number;
  89120. /**
  89121. * Minimum Size of emitting particles.
  89122. */
  89123. minSize: number;
  89124. /**
  89125. * Maximum Size of emitting particles.
  89126. */
  89127. maxSize: number;
  89128. /**
  89129. * Minimum scale of emitting particles on X axis.
  89130. */
  89131. minScaleX: number;
  89132. /**
  89133. * Maximum scale of emitting particles on X axis.
  89134. */
  89135. maxScaleX: number;
  89136. /**
  89137. * Minimum scale of emitting particles on Y axis.
  89138. */
  89139. minScaleY: number;
  89140. /**
  89141. * Maximum scale of emitting particles on Y axis.
  89142. */
  89143. maxScaleY: number;
  89144. /**
  89145. * Gets or sets the minimal initial rotation in radians.
  89146. */
  89147. minInitialRotation: number;
  89148. /**
  89149. * Gets or sets the maximal initial rotation in radians.
  89150. */
  89151. maxInitialRotation: number;
  89152. /**
  89153. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89154. */
  89155. minAngularSpeed: number;
  89156. /**
  89157. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89158. */
  89159. maxAngularSpeed: number;
  89160. /**
  89161. * The texture used to render each particle. (this can be a spritesheet)
  89162. */
  89163. particleTexture: Nullable<Texture>;
  89164. /**
  89165. * The layer mask we are rendering the particles through.
  89166. */
  89167. layerMask: number;
  89168. /**
  89169. * This can help using your own shader to render the particle system.
  89170. * The according effect will be created
  89171. */
  89172. customShader: any;
  89173. /**
  89174. * By default particle system starts as soon as they are created. This prevents the
  89175. * automatic start to happen and let you decide when to start emitting particles.
  89176. */
  89177. preventAutoStart: boolean;
  89178. private _noiseTexture;
  89179. /**
  89180. * Gets or sets a texture used to add random noise to particle positions
  89181. */
  89182. get noiseTexture(): Nullable<ProceduralTexture>;
  89183. set noiseTexture(value: Nullable<ProceduralTexture>);
  89184. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89185. noiseStrength: Vector3;
  89186. /**
  89187. * Callback triggered when the particle animation is ending.
  89188. */
  89189. onAnimationEnd: Nullable<() => void>;
  89190. /**
  89191. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89192. */
  89193. blendMode: number;
  89194. /**
  89195. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89196. * to override the particles.
  89197. */
  89198. forceDepthWrite: boolean;
  89199. /** 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 */
  89200. preWarmCycles: number;
  89201. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89202. preWarmStepOffset: number;
  89203. /**
  89204. * 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)
  89205. */
  89206. spriteCellChangeSpeed: number;
  89207. /**
  89208. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89209. */
  89210. startSpriteCellID: number;
  89211. /**
  89212. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89213. */
  89214. endSpriteCellID: number;
  89215. /**
  89216. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89217. */
  89218. spriteCellWidth: number;
  89219. /**
  89220. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89221. */
  89222. spriteCellHeight: number;
  89223. /**
  89224. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89225. */
  89226. spriteRandomStartCell: boolean;
  89227. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89228. translationPivot: Vector2;
  89229. /** @hidden */
  89230. protected _isAnimationSheetEnabled: boolean;
  89231. /**
  89232. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89233. */
  89234. beginAnimationOnStart: boolean;
  89235. /**
  89236. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89237. */
  89238. beginAnimationFrom: number;
  89239. /**
  89240. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89241. */
  89242. beginAnimationTo: number;
  89243. /**
  89244. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89245. */
  89246. beginAnimationLoop: boolean;
  89247. /**
  89248. * Gets or sets a world offset applied to all particles
  89249. */
  89250. worldOffset: Vector3;
  89251. /**
  89252. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89253. */
  89254. get isAnimationSheetEnabled(): boolean;
  89255. set isAnimationSheetEnabled(value: boolean);
  89256. /**
  89257. * Get hosting scene
  89258. * @returns the scene
  89259. */
  89260. getScene(): Scene;
  89261. /**
  89262. * You can use gravity if you want to give an orientation to your particles.
  89263. */
  89264. gravity: Vector3;
  89265. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89266. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89267. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89268. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89269. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89270. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89271. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89272. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89273. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89274. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89275. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89276. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89277. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89278. /**
  89279. * Defines the delay in milliseconds before starting the system (0 by default)
  89280. */
  89281. startDelay: number;
  89282. /**
  89283. * Gets the current list of drag gradients.
  89284. * You must use addDragGradient and removeDragGradient to udpate this list
  89285. * @returns the list of drag gradients
  89286. */
  89287. getDragGradients(): Nullable<Array<FactorGradient>>;
  89288. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89289. limitVelocityDamping: number;
  89290. /**
  89291. * Gets the current list of limit velocity gradients.
  89292. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89293. * @returns the list of limit velocity gradients
  89294. */
  89295. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89296. /**
  89297. * Gets the current list of color gradients.
  89298. * You must use addColorGradient and removeColorGradient to udpate this list
  89299. * @returns the list of color gradients
  89300. */
  89301. getColorGradients(): Nullable<Array<ColorGradient>>;
  89302. /**
  89303. * Gets the current list of size gradients.
  89304. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89305. * @returns the list of size gradients
  89306. */
  89307. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89308. /**
  89309. * Gets the current list of color remap gradients.
  89310. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89311. * @returns the list of color remap gradients
  89312. */
  89313. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89314. /**
  89315. * Gets the current list of alpha remap gradients.
  89316. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89317. * @returns the list of alpha remap gradients
  89318. */
  89319. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89320. /**
  89321. * Gets the current list of life time gradients.
  89322. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89323. * @returns the list of life time gradients
  89324. */
  89325. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89326. /**
  89327. * Gets the current list of angular speed gradients.
  89328. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89329. * @returns the list of angular speed gradients
  89330. */
  89331. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89332. /**
  89333. * Gets the current list of velocity gradients.
  89334. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89335. * @returns the list of velocity gradients
  89336. */
  89337. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89338. /**
  89339. * Gets the current list of start size gradients.
  89340. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89341. * @returns the list of start size gradients
  89342. */
  89343. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89344. /**
  89345. * Gets the current list of emit rate gradients.
  89346. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89347. * @returns the list of emit rate gradients
  89348. */
  89349. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89350. /**
  89351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89352. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89353. */
  89354. get direction1(): Vector3;
  89355. set direction1(value: Vector3);
  89356. /**
  89357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89358. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89359. */
  89360. get direction2(): Vector3;
  89361. set direction2(value: Vector3);
  89362. /**
  89363. * 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.
  89364. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89365. */
  89366. get minEmitBox(): Vector3;
  89367. set minEmitBox(value: Vector3);
  89368. /**
  89369. * 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.
  89370. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89371. */
  89372. get maxEmitBox(): Vector3;
  89373. set maxEmitBox(value: Vector3);
  89374. /**
  89375. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89376. */
  89377. color1: Color4;
  89378. /**
  89379. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89380. */
  89381. color2: Color4;
  89382. /**
  89383. * Color the particle will have at the end of its lifetime
  89384. */
  89385. colorDead: Color4;
  89386. /**
  89387. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89388. */
  89389. textureMask: Color4;
  89390. /**
  89391. * The particle emitter type defines the emitter used by the particle system.
  89392. * It can be for example box, sphere, or cone...
  89393. */
  89394. particleEmitterType: IParticleEmitterType;
  89395. /** @hidden */
  89396. _isSubEmitter: boolean;
  89397. /**
  89398. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89399. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89400. */
  89401. billboardMode: number;
  89402. protected _isBillboardBased: boolean;
  89403. /**
  89404. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89405. */
  89406. get isBillboardBased(): boolean;
  89407. set isBillboardBased(value: boolean);
  89408. /**
  89409. * The scene the particle system belongs to.
  89410. */
  89411. protected _scene: Scene;
  89412. /**
  89413. * Local cache of defines for image processing.
  89414. */
  89415. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89416. /**
  89417. * Default configuration related to image processing available in the standard Material.
  89418. */
  89419. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89420. /**
  89421. * Gets the image processing configuration used either in this material.
  89422. */
  89423. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89424. /**
  89425. * Sets the Default image processing configuration used either in the this material.
  89426. *
  89427. * If sets to null, the scene one is in use.
  89428. */
  89429. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89430. /**
  89431. * Attaches a new image processing configuration to the Standard Material.
  89432. * @param configuration
  89433. */
  89434. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89435. /** @hidden */
  89436. protected _reset(): void;
  89437. /** @hidden */
  89438. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89439. /**
  89440. * Instantiates a particle system.
  89441. * 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.
  89442. * @param name The name of the particle system
  89443. */
  89444. constructor(name: string);
  89445. /**
  89446. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89449. * @returns the emitter
  89450. */
  89451. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89452. /**
  89453. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89454. * @param radius The radius of the hemisphere to emit from
  89455. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89456. * @returns the emitter
  89457. */
  89458. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89459. /**
  89460. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89461. * @param radius The radius of the sphere to emit from
  89462. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89463. * @returns the emitter
  89464. */
  89465. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89466. /**
  89467. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89468. * @param radius The radius of the sphere to emit from
  89469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89471. * @returns the emitter
  89472. */
  89473. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89474. /**
  89475. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89476. * @param radius The radius of the emission cylinder
  89477. * @param height The height of the emission cylinder
  89478. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89479. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89480. * @returns the emitter
  89481. */
  89482. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89483. /**
  89484. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89485. * @param radius The radius of the cylinder to emit from
  89486. * @param height The height of the emission cylinder
  89487. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89490. * @returns the emitter
  89491. */
  89492. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89493. /**
  89494. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89495. * @param radius The radius of the cone to emit from
  89496. * @param angle The base angle of the cone
  89497. * @returns the emitter
  89498. */
  89499. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89500. /**
  89501. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89502. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89503. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89504. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89505. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89506. * @returns the emitter
  89507. */
  89508. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89509. }
  89510. }
  89511. declare module BABYLON {
  89512. /**
  89513. * Type of sub emitter
  89514. */
  89515. export enum SubEmitterType {
  89516. /**
  89517. * Attached to the particle over it's lifetime
  89518. */
  89519. ATTACHED = 0,
  89520. /**
  89521. * Created when the particle dies
  89522. */
  89523. END = 1
  89524. }
  89525. /**
  89526. * Sub emitter class used to emit particles from an existing particle
  89527. */
  89528. export class SubEmitter {
  89529. /**
  89530. * the particle system to be used by the sub emitter
  89531. */
  89532. particleSystem: ParticleSystem;
  89533. /**
  89534. * Type of the submitter (Default: END)
  89535. */
  89536. type: SubEmitterType;
  89537. /**
  89538. * 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)
  89539. * Note: This only is supported when using an emitter of type Mesh
  89540. */
  89541. inheritDirection: boolean;
  89542. /**
  89543. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89544. */
  89545. inheritedVelocityAmount: number;
  89546. /**
  89547. * Creates a sub emitter
  89548. * @param particleSystem the particle system to be used by the sub emitter
  89549. */
  89550. constructor(
  89551. /**
  89552. * the particle system to be used by the sub emitter
  89553. */
  89554. particleSystem: ParticleSystem);
  89555. /**
  89556. * Clones the sub emitter
  89557. * @returns the cloned sub emitter
  89558. */
  89559. clone(): SubEmitter;
  89560. /**
  89561. * Serialize current object to a JSON object
  89562. * @returns the serialized object
  89563. */
  89564. serialize(): any;
  89565. /** @hidden */
  89566. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89567. /**
  89568. * Creates a new SubEmitter from a serialized JSON version
  89569. * @param serializationObject defines the JSON object to read from
  89570. * @param scene defines the hosting scene
  89571. * @param rootUrl defines the rootUrl for data loading
  89572. * @returns a new SubEmitter
  89573. */
  89574. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  89575. /** Release associated resources */
  89576. dispose(): void;
  89577. }
  89578. }
  89579. declare module BABYLON {
  89580. /** @hidden */
  89581. export var imageProcessingDeclaration: {
  89582. name: string;
  89583. shader: string;
  89584. };
  89585. }
  89586. declare module BABYLON {
  89587. /** @hidden */
  89588. export var imageProcessingFunctions: {
  89589. name: string;
  89590. shader: string;
  89591. };
  89592. }
  89593. declare module BABYLON {
  89594. /** @hidden */
  89595. export var particlesPixelShader: {
  89596. name: string;
  89597. shader: string;
  89598. };
  89599. }
  89600. declare module BABYLON {
  89601. /** @hidden */
  89602. export var particlesVertexShader: {
  89603. name: string;
  89604. shader: string;
  89605. };
  89606. }
  89607. declare module BABYLON {
  89608. /**
  89609. * This represents a particle system in Babylon.
  89610. * 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.
  89611. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89612. * @example https://doc.babylonjs.com/babylon101/particles
  89613. */
  89614. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  89615. /**
  89616. * Billboard mode will only apply to Y axis
  89617. */
  89618. static readonly BILLBOARDMODE_Y: number;
  89619. /**
  89620. * Billboard mode will apply to all axes
  89621. */
  89622. static readonly BILLBOARDMODE_ALL: number;
  89623. /**
  89624. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  89625. */
  89626. static readonly BILLBOARDMODE_STRETCHED: number;
  89627. /**
  89628. * This function can be defined to provide custom update for active particles.
  89629. * This function will be called instead of regular update (age, position, color, etc.).
  89630. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  89631. */
  89632. updateFunction: (particles: Particle[]) => void;
  89633. private _emitterWorldMatrix;
  89634. /**
  89635. * This function can be defined to specify initial direction for every new particle.
  89636. * It by default use the emitterType defined function
  89637. */
  89638. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89639. /**
  89640. * This function can be defined to specify initial position for every new particle.
  89641. * It by default use the emitterType defined function
  89642. */
  89643. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89644. /**
  89645. * @hidden
  89646. */
  89647. _inheritedVelocityOffset: Vector3;
  89648. /**
  89649. * An event triggered when the system is disposed
  89650. */
  89651. onDisposeObservable: Observable<IParticleSystem>;
  89652. private _onDisposeObserver;
  89653. /**
  89654. * Sets a callback that will be triggered when the system is disposed
  89655. */
  89656. set onDispose(callback: () => void);
  89657. private _particles;
  89658. private _epsilon;
  89659. private _capacity;
  89660. private _stockParticles;
  89661. private _newPartsExcess;
  89662. private _vertexData;
  89663. private _vertexBuffer;
  89664. private _vertexBuffers;
  89665. private _spriteBuffer;
  89666. private _indexBuffer;
  89667. private _effect;
  89668. private _customEffect;
  89669. private _cachedDefines;
  89670. private _scaledColorStep;
  89671. private _colorDiff;
  89672. private _scaledDirection;
  89673. private _scaledGravity;
  89674. private _currentRenderId;
  89675. private _alive;
  89676. private _useInstancing;
  89677. private _started;
  89678. private _stopped;
  89679. private _actualFrame;
  89680. private _scaledUpdateSpeed;
  89681. private _vertexBufferSize;
  89682. /** @hidden */
  89683. _currentEmitRateGradient: Nullable<FactorGradient>;
  89684. /** @hidden */
  89685. _currentEmitRate1: number;
  89686. /** @hidden */
  89687. _currentEmitRate2: number;
  89688. /** @hidden */
  89689. _currentStartSizeGradient: Nullable<FactorGradient>;
  89690. /** @hidden */
  89691. _currentStartSize1: number;
  89692. /** @hidden */
  89693. _currentStartSize2: number;
  89694. private readonly _rawTextureWidth;
  89695. private _rampGradientsTexture;
  89696. private _useRampGradients;
  89697. /** Gets or sets a boolean indicating that ramp gradients must be used
  89698. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89699. */
  89700. get useRampGradients(): boolean;
  89701. set useRampGradients(value: boolean);
  89702. /**
  89703. * 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.
  89704. * 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: [])
  89705. */
  89706. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  89707. private _subEmitters;
  89708. /**
  89709. * @hidden
  89710. * If the particle systems emitter should be disposed when the particle system is disposed
  89711. */
  89712. _disposeEmitterOnDispose: boolean;
  89713. /**
  89714. * The current active Sub-systems, this property is used by the root particle system only.
  89715. */
  89716. activeSubSystems: Array<ParticleSystem>;
  89717. /**
  89718. * Specifies if the particles are updated in emitter local space or world space
  89719. */
  89720. isLocal: boolean;
  89721. private _rootParticleSystem;
  89722. /**
  89723. * Gets the current list of active particles
  89724. */
  89725. get particles(): Particle[];
  89726. /**
  89727. * Gets the number of particles active at the same time.
  89728. * @returns The number of active particles.
  89729. */
  89730. getActiveCount(): number;
  89731. /**
  89732. * Returns the string "ParticleSystem"
  89733. * @returns a string containing the class name
  89734. */
  89735. getClassName(): string;
  89736. /**
  89737. * Gets a boolean indicating that the system is stopping
  89738. * @returns true if the system is currently stopping
  89739. */
  89740. isStopping(): boolean;
  89741. /**
  89742. * Gets the custom effect used to render the particles
  89743. * @param blendMode Blend mode for which the effect should be retrieved
  89744. * @returns The effect
  89745. */
  89746. getCustomEffect(blendMode?: number): Nullable<Effect>;
  89747. /**
  89748. * Sets the custom effect used to render the particles
  89749. * @param effect The effect to set
  89750. * @param blendMode Blend mode for which the effect should be set
  89751. */
  89752. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  89753. /** @hidden */
  89754. private _onBeforeDrawParticlesObservable;
  89755. /**
  89756. * Observable that will be called just before the particles are drawn
  89757. */
  89758. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  89759. /**
  89760. * Gets the name of the particle vertex shader
  89761. */
  89762. get vertexShaderName(): string;
  89763. /**
  89764. * Instantiates a particle system.
  89765. * 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.
  89766. * @param name The name of the particle system
  89767. * @param capacity The max number of particles alive at the same time
  89768. * @param scene The scene the particle system belongs to
  89769. * @param customEffect a custom effect used to change the way particles are rendered by default
  89770. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  89771. * @param epsilon Offset used to render the particles
  89772. */
  89773. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  89774. private _addFactorGradient;
  89775. private _removeFactorGradient;
  89776. /**
  89777. * Adds a new life time gradient
  89778. * @param gradient defines the gradient to use (between 0 and 1)
  89779. * @param factor defines the life time factor to affect to the specified gradient
  89780. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89781. * @returns the current particle system
  89782. */
  89783. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89784. /**
  89785. * Remove a specific life time gradient
  89786. * @param gradient defines the gradient to remove
  89787. * @returns the current particle system
  89788. */
  89789. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89790. /**
  89791. * Adds a new size gradient
  89792. * @param gradient defines the gradient to use (between 0 and 1)
  89793. * @param factor defines the size factor to affect to the specified gradient
  89794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89795. * @returns the current particle system
  89796. */
  89797. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89798. /**
  89799. * Remove a specific size gradient
  89800. * @param gradient defines the gradient to remove
  89801. * @returns the current particle system
  89802. */
  89803. removeSizeGradient(gradient: number): IParticleSystem;
  89804. /**
  89805. * Adds a new color remap gradient
  89806. * @param gradient defines the gradient to use (between 0 and 1)
  89807. * @param min defines the color remap minimal range
  89808. * @param max defines the color remap maximal range
  89809. * @returns the current particle system
  89810. */
  89811. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89812. /**
  89813. * Remove a specific color remap gradient
  89814. * @param gradient defines the gradient to remove
  89815. * @returns the current particle system
  89816. */
  89817. removeColorRemapGradient(gradient: number): IParticleSystem;
  89818. /**
  89819. * Adds a new alpha remap gradient
  89820. * @param gradient defines the gradient to use (between 0 and 1)
  89821. * @param min defines the alpha remap minimal range
  89822. * @param max defines the alpha remap maximal range
  89823. * @returns the current particle system
  89824. */
  89825. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89826. /**
  89827. * Remove a specific alpha remap gradient
  89828. * @param gradient defines the gradient to remove
  89829. * @returns the current particle system
  89830. */
  89831. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  89832. /**
  89833. * Adds a new angular speed gradient
  89834. * @param gradient defines the gradient to use (between 0 and 1)
  89835. * @param factor defines the angular speed to affect to the specified gradient
  89836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89837. * @returns the current particle system
  89838. */
  89839. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89840. /**
  89841. * Remove a specific angular speed gradient
  89842. * @param gradient defines the gradient to remove
  89843. * @returns the current particle system
  89844. */
  89845. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89846. /**
  89847. * Adds a new velocity gradient
  89848. * @param gradient defines the gradient to use (between 0 and 1)
  89849. * @param factor defines the velocity to affect to the specified gradient
  89850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89851. * @returns the current particle system
  89852. */
  89853. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89854. /**
  89855. * Remove a specific velocity gradient
  89856. * @param gradient defines the gradient to remove
  89857. * @returns the current particle system
  89858. */
  89859. removeVelocityGradient(gradient: number): IParticleSystem;
  89860. /**
  89861. * Adds a new limit velocity gradient
  89862. * @param gradient defines the gradient to use (between 0 and 1)
  89863. * @param factor defines the limit velocity value to affect to the specified gradient
  89864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89865. * @returns the current particle system
  89866. */
  89867. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89868. /**
  89869. * Remove a specific limit velocity gradient
  89870. * @param gradient defines the gradient to remove
  89871. * @returns the current particle system
  89872. */
  89873. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89874. /**
  89875. * Adds a new drag gradient
  89876. * @param gradient defines the gradient to use (between 0 and 1)
  89877. * @param factor defines the drag value to affect to the specified gradient
  89878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89879. * @returns the current particle system
  89880. */
  89881. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89882. /**
  89883. * Remove a specific drag gradient
  89884. * @param gradient defines the gradient to remove
  89885. * @returns the current particle system
  89886. */
  89887. removeDragGradient(gradient: number): IParticleSystem;
  89888. /**
  89889. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89890. * @param gradient defines the gradient to use (between 0 and 1)
  89891. * @param factor defines the emit rate value to affect to the specified gradient
  89892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89893. * @returns the current particle system
  89894. */
  89895. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89896. /**
  89897. * Remove a specific emit rate gradient
  89898. * @param gradient defines the gradient to remove
  89899. * @returns the current particle system
  89900. */
  89901. removeEmitRateGradient(gradient: number): IParticleSystem;
  89902. /**
  89903. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89904. * @param gradient defines the gradient to use (between 0 and 1)
  89905. * @param factor defines the start size value to affect to the specified gradient
  89906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89907. * @returns the current particle system
  89908. */
  89909. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89910. /**
  89911. * Remove a specific start size gradient
  89912. * @param gradient defines the gradient to remove
  89913. * @returns the current particle system
  89914. */
  89915. removeStartSizeGradient(gradient: number): IParticleSystem;
  89916. private _createRampGradientTexture;
  89917. /**
  89918. * Gets the current list of ramp gradients.
  89919. * You must use addRampGradient and removeRampGradient to udpate this list
  89920. * @returns the list of ramp gradients
  89921. */
  89922. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89923. /** Force the system to rebuild all gradients that need to be resync */
  89924. forceRefreshGradients(): void;
  89925. private _syncRampGradientTexture;
  89926. /**
  89927. * Adds a new ramp gradient used to remap particle colors
  89928. * @param gradient defines the gradient to use (between 0 and 1)
  89929. * @param color defines the color to affect to the specified gradient
  89930. * @returns the current particle system
  89931. */
  89932. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  89933. /**
  89934. * Remove a specific ramp gradient
  89935. * @param gradient defines the gradient to remove
  89936. * @returns the current particle system
  89937. */
  89938. removeRampGradient(gradient: number): ParticleSystem;
  89939. /**
  89940. * Adds a new color gradient
  89941. * @param gradient defines the gradient to use (between 0 and 1)
  89942. * @param color1 defines the color to affect to the specified gradient
  89943. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89944. * @returns this particle system
  89945. */
  89946. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89947. /**
  89948. * Remove a specific color gradient
  89949. * @param gradient defines the gradient to remove
  89950. * @returns this particle system
  89951. */
  89952. removeColorGradient(gradient: number): IParticleSystem;
  89953. private _fetchR;
  89954. protected _reset(): void;
  89955. private _resetEffect;
  89956. private _createVertexBuffers;
  89957. private _createIndexBuffer;
  89958. /**
  89959. * Gets the maximum number of particles active at the same time.
  89960. * @returns The max number of active particles.
  89961. */
  89962. getCapacity(): number;
  89963. /**
  89964. * Gets whether there are still active particles in the system.
  89965. * @returns True if it is alive, otherwise false.
  89966. */
  89967. isAlive(): boolean;
  89968. /**
  89969. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89970. * @returns True if it has been started, otherwise false.
  89971. */
  89972. isStarted(): boolean;
  89973. private _prepareSubEmitterInternalArray;
  89974. /**
  89975. * Starts the particle system and begins to emit
  89976. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  89977. */
  89978. start(delay?: number): void;
  89979. /**
  89980. * Stops the particle system.
  89981. * @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.
  89982. */
  89983. stop(stopSubEmitters?: boolean): void;
  89984. /**
  89985. * Remove all active particles
  89986. */
  89987. reset(): void;
  89988. /**
  89989. * @hidden (for internal use only)
  89990. */
  89991. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  89992. /**
  89993. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  89994. * Its lifetime will start back at 0.
  89995. */
  89996. recycleParticle: (particle: Particle) => void;
  89997. private _stopSubEmitters;
  89998. private _createParticle;
  89999. private _removeFromRoot;
  90000. private _emitFromParticle;
  90001. private _update;
  90002. /** @hidden */
  90003. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90004. /** @hidden */
  90005. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90006. /**
  90007. * Fill the defines array according to the current settings of the particle system
  90008. * @param defines Array to be updated
  90009. * @param blendMode blend mode to take into account when updating the array
  90010. */
  90011. fillDefines(defines: Array<string>, blendMode: number): void;
  90012. /**
  90013. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90014. * @param uniforms Uniforms array to fill
  90015. * @param attributes Attributes array to fill
  90016. * @param samplers Samplers array to fill
  90017. */
  90018. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90019. /** @hidden */
  90020. private _getEffect;
  90021. /**
  90022. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90023. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90024. */
  90025. animate(preWarmOnly?: boolean): void;
  90026. private _appendParticleVertices;
  90027. /**
  90028. * Rebuilds the particle system.
  90029. */
  90030. rebuild(): void;
  90031. /**
  90032. * Is this system ready to be used/rendered
  90033. * @return true if the system is ready
  90034. */
  90035. isReady(): boolean;
  90036. private _render;
  90037. /**
  90038. * Renders the particle system in its current state.
  90039. * @returns the current number of particles
  90040. */
  90041. render(): number;
  90042. /**
  90043. * Disposes the particle system and free the associated resources
  90044. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90045. */
  90046. dispose(disposeTexture?: boolean): void;
  90047. /**
  90048. * Clones the particle system.
  90049. * @param name The name of the cloned object
  90050. * @param newEmitter The new emitter to use
  90051. * @returns the cloned particle system
  90052. */
  90053. clone(name: string, newEmitter: any): ParticleSystem;
  90054. /**
  90055. * Serializes the particle system to a JSON object
  90056. * @param serializeTexture defines if the texture must be serialized as well
  90057. * @returns the JSON object
  90058. */
  90059. serialize(serializeTexture?: boolean): any;
  90060. /** @hidden */
  90061. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  90062. /** @hidden */
  90063. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90064. /**
  90065. * Parses a JSON object to create a particle system.
  90066. * @param parsedParticleSystem The JSON object to parse
  90067. * @param scene The scene to create the particle system in
  90068. * @param rootUrl The root url to use to load external dependencies like texture
  90069. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90070. * @returns the Parsed particle system
  90071. */
  90072. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90073. }
  90074. }
  90075. declare module BABYLON {
  90076. /**
  90077. * A particle represents one of the element emitted by a particle system.
  90078. * This is mainly define by its coordinates, direction, velocity and age.
  90079. */
  90080. export class Particle {
  90081. /**
  90082. * The particle system the particle belongs to.
  90083. */
  90084. particleSystem: ParticleSystem;
  90085. private static _Count;
  90086. /**
  90087. * Unique ID of the particle
  90088. */
  90089. id: number;
  90090. /**
  90091. * The world position of the particle in the scene.
  90092. */
  90093. position: Vector3;
  90094. /**
  90095. * The world direction of the particle in the scene.
  90096. */
  90097. direction: Vector3;
  90098. /**
  90099. * The color of the particle.
  90100. */
  90101. color: Color4;
  90102. /**
  90103. * The color change of the particle per step.
  90104. */
  90105. colorStep: Color4;
  90106. /**
  90107. * Defines how long will the life of the particle be.
  90108. */
  90109. lifeTime: number;
  90110. /**
  90111. * The current age of the particle.
  90112. */
  90113. age: number;
  90114. /**
  90115. * The current size of the particle.
  90116. */
  90117. size: number;
  90118. /**
  90119. * The current scale of the particle.
  90120. */
  90121. scale: Vector2;
  90122. /**
  90123. * The current angle of the particle.
  90124. */
  90125. angle: number;
  90126. /**
  90127. * Defines how fast is the angle changing.
  90128. */
  90129. angularSpeed: number;
  90130. /**
  90131. * Defines the cell index used by the particle to be rendered from a sprite.
  90132. */
  90133. cellIndex: number;
  90134. /**
  90135. * The information required to support color remapping
  90136. */
  90137. remapData: Vector4;
  90138. /** @hidden */
  90139. _randomCellOffset?: number;
  90140. /** @hidden */
  90141. _initialDirection: Nullable<Vector3>;
  90142. /** @hidden */
  90143. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90144. /** @hidden */
  90145. _initialStartSpriteCellID: number;
  90146. /** @hidden */
  90147. _initialEndSpriteCellID: number;
  90148. /** @hidden */
  90149. _currentColorGradient: Nullable<ColorGradient>;
  90150. /** @hidden */
  90151. _currentColor1: Color4;
  90152. /** @hidden */
  90153. _currentColor2: Color4;
  90154. /** @hidden */
  90155. _currentSizeGradient: Nullable<FactorGradient>;
  90156. /** @hidden */
  90157. _currentSize1: number;
  90158. /** @hidden */
  90159. _currentSize2: number;
  90160. /** @hidden */
  90161. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90162. /** @hidden */
  90163. _currentAngularSpeed1: number;
  90164. /** @hidden */
  90165. _currentAngularSpeed2: number;
  90166. /** @hidden */
  90167. _currentVelocityGradient: Nullable<FactorGradient>;
  90168. /** @hidden */
  90169. _currentVelocity1: number;
  90170. /** @hidden */
  90171. _currentVelocity2: number;
  90172. /** @hidden */
  90173. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90174. /** @hidden */
  90175. _currentLimitVelocity1: number;
  90176. /** @hidden */
  90177. _currentLimitVelocity2: number;
  90178. /** @hidden */
  90179. _currentDragGradient: Nullable<FactorGradient>;
  90180. /** @hidden */
  90181. _currentDrag1: number;
  90182. /** @hidden */
  90183. _currentDrag2: number;
  90184. /** @hidden */
  90185. _randomNoiseCoordinates1: Vector3;
  90186. /** @hidden */
  90187. _randomNoiseCoordinates2: Vector3;
  90188. /** @hidden */
  90189. _localPosition?: Vector3;
  90190. /**
  90191. * Creates a new instance Particle
  90192. * @param particleSystem the particle system the particle belongs to
  90193. */
  90194. constructor(
  90195. /**
  90196. * The particle system the particle belongs to.
  90197. */
  90198. particleSystem: ParticleSystem);
  90199. private updateCellInfoFromSystem;
  90200. /**
  90201. * Defines how the sprite cell index is updated for the particle
  90202. */
  90203. updateCellIndex(): void;
  90204. /** @hidden */
  90205. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90206. /** @hidden */
  90207. _inheritParticleInfoToSubEmitters(): void;
  90208. /** @hidden */
  90209. _reset(): void;
  90210. /**
  90211. * Copy the properties of particle to another one.
  90212. * @param other the particle to copy the information to.
  90213. */
  90214. copyTo(other: Particle): void;
  90215. }
  90216. }
  90217. declare module BABYLON {
  90218. /**
  90219. * Particle emitter represents a volume emitting particles.
  90220. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90221. */
  90222. export interface IParticleEmitterType {
  90223. /**
  90224. * Called by the particle System when the direction is computed for the created particle.
  90225. * @param worldMatrix is the world matrix of the particle system
  90226. * @param directionToUpdate is the direction vector to update with the result
  90227. * @param particle is the particle we are computed the direction for
  90228. * @param isLocal defines if the direction should be set in local space
  90229. */
  90230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90231. /**
  90232. * Called by the particle System when the position is computed for the created particle.
  90233. * @param worldMatrix is the world matrix of the particle system
  90234. * @param positionToUpdate is the position vector to update with the result
  90235. * @param particle is the particle we are computed the position for
  90236. * @param isLocal defines if the position should be set in local space
  90237. */
  90238. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90239. /**
  90240. * Clones the current emitter and returns a copy of it
  90241. * @returns the new emitter
  90242. */
  90243. clone(): IParticleEmitterType;
  90244. /**
  90245. * Called by the GPUParticleSystem to setup the update shader
  90246. * @param effect defines the update shader
  90247. */
  90248. applyToShader(effect: Effect): void;
  90249. /**
  90250. * Returns a string to use to update the GPU particles update shader
  90251. * @returns the effect defines string
  90252. */
  90253. getEffectDefines(): string;
  90254. /**
  90255. * Returns a string representing the class name
  90256. * @returns a string containing the class name
  90257. */
  90258. getClassName(): string;
  90259. /**
  90260. * Serializes the particle system to a JSON object.
  90261. * @returns the JSON object
  90262. */
  90263. serialize(): any;
  90264. /**
  90265. * Parse properties from a JSON object
  90266. * @param serializationObject defines the JSON object
  90267. * @param scene defines the hosting scene
  90268. */
  90269. parse(serializationObject: any, scene: Scene): void;
  90270. }
  90271. }
  90272. declare module BABYLON {
  90273. /**
  90274. * Particle emitter emitting particles from the inside of a box.
  90275. * It emits the particles randomly between 2 given directions.
  90276. */
  90277. export class BoxParticleEmitter implements IParticleEmitterType {
  90278. /**
  90279. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90280. */
  90281. direction1: Vector3;
  90282. /**
  90283. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90284. */
  90285. direction2: Vector3;
  90286. /**
  90287. * 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.
  90288. */
  90289. minEmitBox: Vector3;
  90290. /**
  90291. * 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.
  90292. */
  90293. maxEmitBox: Vector3;
  90294. /**
  90295. * Creates a new instance BoxParticleEmitter
  90296. */
  90297. constructor();
  90298. /**
  90299. * Called by the particle System when the direction is computed for the created particle.
  90300. * @param worldMatrix is the world matrix of the particle system
  90301. * @param directionToUpdate is the direction vector to update with the result
  90302. * @param particle is the particle we are computed the direction for
  90303. * @param isLocal defines if the direction should be set in local space
  90304. */
  90305. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90306. /**
  90307. * Called by the particle System when the position is computed for the created particle.
  90308. * @param worldMatrix is the world matrix of the particle system
  90309. * @param positionToUpdate is the position vector to update with the result
  90310. * @param particle is the particle we are computed the position for
  90311. * @param isLocal defines if the position should be set in local space
  90312. */
  90313. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90314. /**
  90315. * Clones the current emitter and returns a copy of it
  90316. * @returns the new emitter
  90317. */
  90318. clone(): BoxParticleEmitter;
  90319. /**
  90320. * Called by the GPUParticleSystem to setup the update shader
  90321. * @param effect defines the update shader
  90322. */
  90323. applyToShader(effect: Effect): void;
  90324. /**
  90325. * Returns a string to use to update the GPU particles update shader
  90326. * @returns a string containng the defines string
  90327. */
  90328. getEffectDefines(): string;
  90329. /**
  90330. * Returns the string "BoxParticleEmitter"
  90331. * @returns a string containing the class name
  90332. */
  90333. getClassName(): string;
  90334. /**
  90335. * Serializes the particle system to a JSON object.
  90336. * @returns the JSON object
  90337. */
  90338. serialize(): any;
  90339. /**
  90340. * Parse properties from a JSON object
  90341. * @param serializationObject defines the JSON object
  90342. */
  90343. parse(serializationObject: any): void;
  90344. }
  90345. }
  90346. declare module BABYLON {
  90347. /**
  90348. * Particle emitter emitting particles from the inside of a cone.
  90349. * It emits the particles alongside the cone volume from the base to the particle.
  90350. * The emission direction might be randomized.
  90351. */
  90352. export class ConeParticleEmitter implements IParticleEmitterType {
  90353. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90354. directionRandomizer: number;
  90355. private _radius;
  90356. private _angle;
  90357. private _height;
  90358. /**
  90359. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90360. */
  90361. radiusRange: number;
  90362. /**
  90363. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90364. */
  90365. heightRange: number;
  90366. /**
  90367. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90368. */
  90369. emitFromSpawnPointOnly: boolean;
  90370. /**
  90371. * Gets or sets the radius of the emission cone
  90372. */
  90373. get radius(): number;
  90374. set radius(value: number);
  90375. /**
  90376. * Gets or sets the angle of the emission cone
  90377. */
  90378. get angle(): number;
  90379. set angle(value: number);
  90380. private _buildHeight;
  90381. /**
  90382. * Creates a new instance ConeParticleEmitter
  90383. * @param radius the radius of the emission cone (1 by default)
  90384. * @param angle the cone base angle (PI by default)
  90385. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90386. */
  90387. constructor(radius?: number, angle?: number,
  90388. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90389. directionRandomizer?: number);
  90390. /**
  90391. * Called by the particle System when the direction is computed for the created particle.
  90392. * @param worldMatrix is the world matrix of the particle system
  90393. * @param directionToUpdate is the direction vector to update with the result
  90394. * @param particle is the particle we are computed the direction for
  90395. * @param isLocal defines if the direction should be set in local space
  90396. */
  90397. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90398. /**
  90399. * Called by the particle System when the position is computed for the created particle.
  90400. * @param worldMatrix is the world matrix of the particle system
  90401. * @param positionToUpdate is the position vector to update with the result
  90402. * @param particle is the particle we are computed the position for
  90403. * @param isLocal defines if the position should be set in local space
  90404. */
  90405. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90406. /**
  90407. * Clones the current emitter and returns a copy of it
  90408. * @returns the new emitter
  90409. */
  90410. clone(): ConeParticleEmitter;
  90411. /**
  90412. * Called by the GPUParticleSystem to setup the update shader
  90413. * @param effect defines the update shader
  90414. */
  90415. applyToShader(effect: Effect): void;
  90416. /**
  90417. * Returns a string to use to update the GPU particles update shader
  90418. * @returns a string containng the defines string
  90419. */
  90420. getEffectDefines(): string;
  90421. /**
  90422. * Returns the string "ConeParticleEmitter"
  90423. * @returns a string containing the class name
  90424. */
  90425. getClassName(): string;
  90426. /**
  90427. * Serializes the particle system to a JSON object.
  90428. * @returns the JSON object
  90429. */
  90430. serialize(): any;
  90431. /**
  90432. * Parse properties from a JSON object
  90433. * @param serializationObject defines the JSON object
  90434. */
  90435. parse(serializationObject: any): void;
  90436. }
  90437. }
  90438. declare module BABYLON {
  90439. /**
  90440. * Particle emitter emitting particles from the inside of a cylinder.
  90441. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90442. */
  90443. export class CylinderParticleEmitter implements IParticleEmitterType {
  90444. /**
  90445. * The radius of the emission cylinder.
  90446. */
  90447. radius: number;
  90448. /**
  90449. * The height of the emission cylinder.
  90450. */
  90451. height: number;
  90452. /**
  90453. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90454. */
  90455. radiusRange: number;
  90456. /**
  90457. * How much to randomize the particle direction [0-1].
  90458. */
  90459. directionRandomizer: number;
  90460. /**
  90461. * Creates a new instance CylinderParticleEmitter
  90462. * @param radius the radius of the emission cylinder (1 by default)
  90463. * @param height the height of the emission cylinder (1 by default)
  90464. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90465. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90466. */
  90467. constructor(
  90468. /**
  90469. * The radius of the emission cylinder.
  90470. */
  90471. radius?: number,
  90472. /**
  90473. * The height of the emission cylinder.
  90474. */
  90475. height?: number,
  90476. /**
  90477. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90478. */
  90479. radiusRange?: number,
  90480. /**
  90481. * How much to randomize the particle direction [0-1].
  90482. */
  90483. directionRandomizer?: number);
  90484. /**
  90485. * Called by the particle System when the direction is computed for the created particle.
  90486. * @param worldMatrix is the world matrix of the particle system
  90487. * @param directionToUpdate is the direction vector to update with the result
  90488. * @param particle is the particle we are computed the direction for
  90489. * @param isLocal defines if the direction should be set in local space
  90490. */
  90491. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90492. /**
  90493. * Called by the particle System when the position is computed for the created particle.
  90494. * @param worldMatrix is the world matrix of the particle system
  90495. * @param positionToUpdate is the position vector to update with the result
  90496. * @param particle is the particle we are computed the position for
  90497. * @param isLocal defines if the position should be set in local space
  90498. */
  90499. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90500. /**
  90501. * Clones the current emitter and returns a copy of it
  90502. * @returns the new emitter
  90503. */
  90504. clone(): CylinderParticleEmitter;
  90505. /**
  90506. * Called by the GPUParticleSystem to setup the update shader
  90507. * @param effect defines the update shader
  90508. */
  90509. applyToShader(effect: Effect): void;
  90510. /**
  90511. * Returns a string to use to update the GPU particles update shader
  90512. * @returns a string containng the defines string
  90513. */
  90514. getEffectDefines(): string;
  90515. /**
  90516. * Returns the string "CylinderParticleEmitter"
  90517. * @returns a string containing the class name
  90518. */
  90519. getClassName(): string;
  90520. /**
  90521. * Serializes the particle system to a JSON object.
  90522. * @returns the JSON object
  90523. */
  90524. serialize(): any;
  90525. /**
  90526. * Parse properties from a JSON object
  90527. * @param serializationObject defines the JSON object
  90528. */
  90529. parse(serializationObject: any): void;
  90530. }
  90531. /**
  90532. * Particle emitter emitting particles from the inside of a cylinder.
  90533. * It emits the particles randomly between two vectors.
  90534. */
  90535. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90536. /**
  90537. * The min limit of the emission direction.
  90538. */
  90539. direction1: Vector3;
  90540. /**
  90541. * The max limit of the emission direction.
  90542. */
  90543. direction2: Vector3;
  90544. /**
  90545. * Creates a new instance CylinderDirectedParticleEmitter
  90546. * @param radius the radius of the emission cylinder (1 by default)
  90547. * @param height the height of the emission cylinder (1 by default)
  90548. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90549. * @param direction1 the min limit of the emission direction (up vector by default)
  90550. * @param direction2 the max limit of the emission direction (up vector by default)
  90551. */
  90552. constructor(radius?: number, height?: number, radiusRange?: number,
  90553. /**
  90554. * The min limit of the emission direction.
  90555. */
  90556. direction1?: Vector3,
  90557. /**
  90558. * The max limit of the emission direction.
  90559. */
  90560. direction2?: Vector3);
  90561. /**
  90562. * Called by the particle System when the direction is computed for the created particle.
  90563. * @param worldMatrix is the world matrix of the particle system
  90564. * @param directionToUpdate is the direction vector to update with the result
  90565. * @param particle is the particle we are computed the direction for
  90566. */
  90567. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90568. /**
  90569. * Clones the current emitter and returns a copy of it
  90570. * @returns the new emitter
  90571. */
  90572. clone(): CylinderDirectedParticleEmitter;
  90573. /**
  90574. * Called by the GPUParticleSystem to setup the update shader
  90575. * @param effect defines the update shader
  90576. */
  90577. applyToShader(effect: Effect): void;
  90578. /**
  90579. * Returns a string to use to update the GPU particles update shader
  90580. * @returns a string containng the defines string
  90581. */
  90582. getEffectDefines(): string;
  90583. /**
  90584. * Returns the string "CylinderDirectedParticleEmitter"
  90585. * @returns a string containing the class name
  90586. */
  90587. getClassName(): string;
  90588. /**
  90589. * Serializes the particle system to a JSON object.
  90590. * @returns the JSON object
  90591. */
  90592. serialize(): any;
  90593. /**
  90594. * Parse properties from a JSON object
  90595. * @param serializationObject defines the JSON object
  90596. */
  90597. parse(serializationObject: any): void;
  90598. }
  90599. }
  90600. declare module BABYLON {
  90601. /**
  90602. * Particle emitter emitting particles from the inside of a hemisphere.
  90603. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  90604. */
  90605. export class HemisphericParticleEmitter implements IParticleEmitterType {
  90606. /**
  90607. * The radius of the emission hemisphere.
  90608. */
  90609. radius: number;
  90610. /**
  90611. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90612. */
  90613. radiusRange: number;
  90614. /**
  90615. * How much to randomize the particle direction [0-1].
  90616. */
  90617. directionRandomizer: number;
  90618. /**
  90619. * Creates a new instance HemisphericParticleEmitter
  90620. * @param radius the radius of the emission hemisphere (1 by default)
  90621. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90622. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90623. */
  90624. constructor(
  90625. /**
  90626. * The radius of the emission hemisphere.
  90627. */
  90628. radius?: number,
  90629. /**
  90630. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90631. */
  90632. radiusRange?: number,
  90633. /**
  90634. * How much to randomize the particle direction [0-1].
  90635. */
  90636. directionRandomizer?: number);
  90637. /**
  90638. * Called by the particle System when the direction is computed for the created particle.
  90639. * @param worldMatrix is the world matrix of the particle system
  90640. * @param directionToUpdate is the direction vector to update with the result
  90641. * @param particle is the particle we are computed the direction for
  90642. * @param isLocal defines if the direction should be set in local space
  90643. */
  90644. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90645. /**
  90646. * Called by the particle System when the position is computed for the created particle.
  90647. * @param worldMatrix is the world matrix of the particle system
  90648. * @param positionToUpdate is the position vector to update with the result
  90649. * @param particle is the particle we are computed the position for
  90650. * @param isLocal defines if the position should be set in local space
  90651. */
  90652. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90653. /**
  90654. * Clones the current emitter and returns a copy of it
  90655. * @returns the new emitter
  90656. */
  90657. clone(): HemisphericParticleEmitter;
  90658. /**
  90659. * Called by the GPUParticleSystem to setup the update shader
  90660. * @param effect defines the update shader
  90661. */
  90662. applyToShader(effect: Effect): void;
  90663. /**
  90664. * Returns a string to use to update the GPU particles update shader
  90665. * @returns a string containng the defines string
  90666. */
  90667. getEffectDefines(): string;
  90668. /**
  90669. * Returns the string "HemisphericParticleEmitter"
  90670. * @returns a string containing the class name
  90671. */
  90672. getClassName(): string;
  90673. /**
  90674. * Serializes the particle system to a JSON object.
  90675. * @returns the JSON object
  90676. */
  90677. serialize(): any;
  90678. /**
  90679. * Parse properties from a JSON object
  90680. * @param serializationObject defines the JSON object
  90681. */
  90682. parse(serializationObject: any): void;
  90683. }
  90684. }
  90685. declare module BABYLON {
  90686. /**
  90687. * Particle emitter emitting particles from a point.
  90688. * It emits the particles randomly between 2 given directions.
  90689. */
  90690. export class PointParticleEmitter implements IParticleEmitterType {
  90691. /**
  90692. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90693. */
  90694. direction1: Vector3;
  90695. /**
  90696. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90697. */
  90698. direction2: Vector3;
  90699. /**
  90700. * Creates a new instance PointParticleEmitter
  90701. */
  90702. constructor();
  90703. /**
  90704. * Called by the particle System when the direction is computed for the created particle.
  90705. * @param worldMatrix is the world matrix of the particle system
  90706. * @param directionToUpdate is the direction vector to update with the result
  90707. * @param particle is the particle we are computed the direction for
  90708. * @param isLocal defines if the direction should be set in local space
  90709. */
  90710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90711. /**
  90712. * Called by the particle System when the position is computed for the created particle.
  90713. * @param worldMatrix is the world matrix of the particle system
  90714. * @param positionToUpdate is the position vector to update with the result
  90715. * @param particle is the particle we are computed the position for
  90716. * @param isLocal defines if the position should be set in local space
  90717. */
  90718. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90719. /**
  90720. * Clones the current emitter and returns a copy of it
  90721. * @returns the new emitter
  90722. */
  90723. clone(): PointParticleEmitter;
  90724. /**
  90725. * Called by the GPUParticleSystem to setup the update shader
  90726. * @param effect defines the update shader
  90727. */
  90728. applyToShader(effect: Effect): void;
  90729. /**
  90730. * Returns a string to use to update the GPU particles update shader
  90731. * @returns a string containng the defines string
  90732. */
  90733. getEffectDefines(): string;
  90734. /**
  90735. * Returns the string "PointParticleEmitter"
  90736. * @returns a string containing the class name
  90737. */
  90738. getClassName(): string;
  90739. /**
  90740. * Serializes the particle system to a JSON object.
  90741. * @returns the JSON object
  90742. */
  90743. serialize(): any;
  90744. /**
  90745. * Parse properties from a JSON object
  90746. * @param serializationObject defines the JSON object
  90747. */
  90748. parse(serializationObject: any): void;
  90749. }
  90750. }
  90751. declare module BABYLON {
  90752. /**
  90753. * Particle emitter emitting particles from the inside of a sphere.
  90754. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  90755. */
  90756. export class SphereParticleEmitter implements IParticleEmitterType {
  90757. /**
  90758. * The radius of the emission sphere.
  90759. */
  90760. radius: number;
  90761. /**
  90762. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90763. */
  90764. radiusRange: number;
  90765. /**
  90766. * How much to randomize the particle direction [0-1].
  90767. */
  90768. directionRandomizer: number;
  90769. /**
  90770. * Creates a new instance SphereParticleEmitter
  90771. * @param radius the radius of the emission sphere (1 by default)
  90772. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90773. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90774. */
  90775. constructor(
  90776. /**
  90777. * The radius of the emission sphere.
  90778. */
  90779. radius?: number,
  90780. /**
  90781. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90782. */
  90783. radiusRange?: number,
  90784. /**
  90785. * How much to randomize the particle direction [0-1].
  90786. */
  90787. directionRandomizer?: number);
  90788. /**
  90789. * Called by the particle System when the direction is computed for the created particle.
  90790. * @param worldMatrix is the world matrix of the particle system
  90791. * @param directionToUpdate is the direction vector to update with the result
  90792. * @param particle is the particle we are computed the direction for
  90793. * @param isLocal defines if the direction should be set in local space
  90794. */
  90795. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90796. /**
  90797. * Called by the particle System when the position is computed for the created particle.
  90798. * @param worldMatrix is the world matrix of the particle system
  90799. * @param positionToUpdate is the position vector to update with the result
  90800. * @param particle is the particle we are computed the position for
  90801. * @param isLocal defines if the position should be set in local space
  90802. */
  90803. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90804. /**
  90805. * Clones the current emitter and returns a copy of it
  90806. * @returns the new emitter
  90807. */
  90808. clone(): SphereParticleEmitter;
  90809. /**
  90810. * Called by the GPUParticleSystem to setup the update shader
  90811. * @param effect defines the update shader
  90812. */
  90813. applyToShader(effect: Effect): void;
  90814. /**
  90815. * Returns a string to use to update the GPU particles update shader
  90816. * @returns a string containng the defines string
  90817. */
  90818. getEffectDefines(): string;
  90819. /**
  90820. * Returns the string "SphereParticleEmitter"
  90821. * @returns a string containing the class name
  90822. */
  90823. getClassName(): string;
  90824. /**
  90825. * Serializes the particle system to a JSON object.
  90826. * @returns the JSON object
  90827. */
  90828. serialize(): any;
  90829. /**
  90830. * Parse properties from a JSON object
  90831. * @param serializationObject defines the JSON object
  90832. */
  90833. parse(serializationObject: any): void;
  90834. }
  90835. /**
  90836. * Particle emitter emitting particles from the inside of a sphere.
  90837. * It emits the particles randomly between two vectors.
  90838. */
  90839. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  90840. /**
  90841. * The min limit of the emission direction.
  90842. */
  90843. direction1: Vector3;
  90844. /**
  90845. * The max limit of the emission direction.
  90846. */
  90847. direction2: Vector3;
  90848. /**
  90849. * Creates a new instance SphereDirectedParticleEmitter
  90850. * @param radius the radius of the emission sphere (1 by default)
  90851. * @param direction1 the min limit of the emission direction (up vector by default)
  90852. * @param direction2 the max limit of the emission direction (up vector by default)
  90853. */
  90854. constructor(radius?: number,
  90855. /**
  90856. * The min limit of the emission direction.
  90857. */
  90858. direction1?: Vector3,
  90859. /**
  90860. * The max limit of the emission direction.
  90861. */
  90862. direction2?: Vector3);
  90863. /**
  90864. * Called by the particle System when the direction is computed for the created particle.
  90865. * @param worldMatrix is the world matrix of the particle system
  90866. * @param directionToUpdate is the direction vector to update with the result
  90867. * @param particle is the particle we are computed the direction for
  90868. */
  90869. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90870. /**
  90871. * Clones the current emitter and returns a copy of it
  90872. * @returns the new emitter
  90873. */
  90874. clone(): SphereDirectedParticleEmitter;
  90875. /**
  90876. * Called by the GPUParticleSystem to setup the update shader
  90877. * @param effect defines the update shader
  90878. */
  90879. applyToShader(effect: Effect): void;
  90880. /**
  90881. * Returns a string to use to update the GPU particles update shader
  90882. * @returns a string containng the defines string
  90883. */
  90884. getEffectDefines(): string;
  90885. /**
  90886. * Returns the string "SphereDirectedParticleEmitter"
  90887. * @returns a string containing the class name
  90888. */
  90889. getClassName(): string;
  90890. /**
  90891. * Serializes the particle system to a JSON object.
  90892. * @returns the JSON object
  90893. */
  90894. serialize(): any;
  90895. /**
  90896. * Parse properties from a JSON object
  90897. * @param serializationObject defines the JSON object
  90898. */
  90899. parse(serializationObject: any): void;
  90900. }
  90901. }
  90902. declare module BABYLON {
  90903. /**
  90904. * Particle emitter emitting particles from a custom list of positions.
  90905. */
  90906. export class CustomParticleEmitter implements IParticleEmitterType {
  90907. /**
  90908. * Gets or sets the position generator that will create the inital position of each particle.
  90909. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  90910. */
  90911. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  90912. /**
  90913. * Gets or sets the destination generator that will create the final destination of each particle.
  90914. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  90915. */
  90916. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  90917. /**
  90918. * Creates a new instance CustomParticleEmitter
  90919. */
  90920. constructor();
  90921. /**
  90922. * Called by the particle System when the direction is computed for the created particle.
  90923. * @param worldMatrix is the world matrix of the particle system
  90924. * @param directionToUpdate is the direction vector to update with the result
  90925. * @param particle is the particle we are computed the direction for
  90926. * @param isLocal defines if the direction should be set in local space
  90927. */
  90928. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90929. /**
  90930. * Called by the particle System when the position is computed for the created particle.
  90931. * @param worldMatrix is the world matrix of the particle system
  90932. * @param positionToUpdate is the position vector to update with the result
  90933. * @param particle is the particle we are computed the position for
  90934. * @param isLocal defines if the position should be set in local space
  90935. */
  90936. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90937. /**
  90938. * Clones the current emitter and returns a copy of it
  90939. * @returns the new emitter
  90940. */
  90941. clone(): CustomParticleEmitter;
  90942. /**
  90943. * Called by the GPUParticleSystem to setup the update shader
  90944. * @param effect defines the update shader
  90945. */
  90946. applyToShader(effect: Effect): void;
  90947. /**
  90948. * Returns a string to use to update the GPU particles update shader
  90949. * @returns a string containng the defines string
  90950. */
  90951. getEffectDefines(): string;
  90952. /**
  90953. * Returns the string "PointParticleEmitter"
  90954. * @returns a string containing the class name
  90955. */
  90956. getClassName(): string;
  90957. /**
  90958. * Serializes the particle system to a JSON object.
  90959. * @returns the JSON object
  90960. */
  90961. serialize(): any;
  90962. /**
  90963. * Parse properties from a JSON object
  90964. * @param serializationObject defines the JSON object
  90965. */
  90966. parse(serializationObject: any): void;
  90967. }
  90968. }
  90969. declare module BABYLON {
  90970. /**
  90971. * Particle emitter emitting particles from the inside of a box.
  90972. * It emits the particles randomly between 2 given directions.
  90973. */
  90974. export class MeshParticleEmitter implements IParticleEmitterType {
  90975. private _indices;
  90976. private _positions;
  90977. private _normals;
  90978. private _storedNormal;
  90979. private _mesh;
  90980. /**
  90981. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90982. */
  90983. direction1: Vector3;
  90984. /**
  90985. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90986. */
  90987. direction2: Vector3;
  90988. /**
  90989. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  90990. */
  90991. useMeshNormalsForDirection: boolean;
  90992. /** Defines the mesh to use as source */
  90993. get mesh(): Nullable<AbstractMesh>;
  90994. set mesh(value: Nullable<AbstractMesh>);
  90995. /**
  90996. * Creates a new instance MeshParticleEmitter
  90997. * @param mesh defines the mesh to use as source
  90998. */
  90999. constructor(mesh?: Nullable<AbstractMesh>);
  91000. /**
  91001. * Called by the particle System when the direction is computed for the created particle.
  91002. * @param worldMatrix is the world matrix of the particle system
  91003. * @param directionToUpdate is the direction vector to update with the result
  91004. * @param particle is the particle we are computed the direction for
  91005. * @param isLocal defines if the direction should be set in local space
  91006. */
  91007. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91008. /**
  91009. * Called by the particle System when the position is computed for the created particle.
  91010. * @param worldMatrix is the world matrix of the particle system
  91011. * @param positionToUpdate is the position vector to update with the result
  91012. * @param particle is the particle we are computed the position for
  91013. * @param isLocal defines if the position should be set in local space
  91014. */
  91015. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91016. /**
  91017. * Clones the current emitter and returns a copy of it
  91018. * @returns the new emitter
  91019. */
  91020. clone(): MeshParticleEmitter;
  91021. /**
  91022. * Called by the GPUParticleSystem to setup the update shader
  91023. * @param effect defines the update shader
  91024. */
  91025. applyToShader(effect: Effect): void;
  91026. /**
  91027. * Returns a string to use to update the GPU particles update shader
  91028. * @returns a string containng the defines string
  91029. */
  91030. getEffectDefines(): string;
  91031. /**
  91032. * Returns the string "BoxParticleEmitter"
  91033. * @returns a string containing the class name
  91034. */
  91035. getClassName(): string;
  91036. /**
  91037. * Serializes the particle system to a JSON object.
  91038. * @returns the JSON object
  91039. */
  91040. serialize(): any;
  91041. /**
  91042. * Parse properties from a JSON object
  91043. * @param serializationObject defines the JSON object
  91044. * @param scene defines the hosting scene
  91045. */
  91046. parse(serializationObject: any, scene: Scene): void;
  91047. }
  91048. }
  91049. declare module BABYLON {
  91050. /**
  91051. * Interface representing a particle system in Babylon.js.
  91052. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91053. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91054. */
  91055. export interface IParticleSystem {
  91056. /**
  91057. * List of animations used by the particle system.
  91058. */
  91059. animations: Animation[];
  91060. /**
  91061. * The id of the Particle system.
  91062. */
  91063. id: string;
  91064. /**
  91065. * The name of the Particle system.
  91066. */
  91067. name: string;
  91068. /**
  91069. * The emitter represents the Mesh or position we are attaching the particle system to.
  91070. */
  91071. emitter: Nullable<AbstractMesh | Vector3>;
  91072. /**
  91073. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91074. */
  91075. isBillboardBased: boolean;
  91076. /**
  91077. * The rendering group used by the Particle system to chose when to render.
  91078. */
  91079. renderingGroupId: number;
  91080. /**
  91081. * The layer mask we are rendering the particles through.
  91082. */
  91083. layerMask: number;
  91084. /**
  91085. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91086. */
  91087. updateSpeed: number;
  91088. /**
  91089. * The amount of time the particle system is running (depends of the overall update speed).
  91090. */
  91091. targetStopDuration: number;
  91092. /**
  91093. * The texture used to render each particle. (this can be a spritesheet)
  91094. */
  91095. particleTexture: Nullable<Texture>;
  91096. /**
  91097. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91098. */
  91099. blendMode: number;
  91100. /**
  91101. * Minimum life time of emitting particles.
  91102. */
  91103. minLifeTime: number;
  91104. /**
  91105. * Maximum life time of emitting particles.
  91106. */
  91107. maxLifeTime: number;
  91108. /**
  91109. * Minimum Size of emitting particles.
  91110. */
  91111. minSize: number;
  91112. /**
  91113. * Maximum Size of emitting particles.
  91114. */
  91115. maxSize: number;
  91116. /**
  91117. * Minimum scale of emitting particles on X axis.
  91118. */
  91119. minScaleX: number;
  91120. /**
  91121. * Maximum scale of emitting particles on X axis.
  91122. */
  91123. maxScaleX: number;
  91124. /**
  91125. * Minimum scale of emitting particles on Y axis.
  91126. */
  91127. minScaleY: number;
  91128. /**
  91129. * Maximum scale of emitting particles on Y axis.
  91130. */
  91131. maxScaleY: number;
  91132. /**
  91133. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91134. */
  91135. color1: Color4;
  91136. /**
  91137. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91138. */
  91139. color2: Color4;
  91140. /**
  91141. * Color the particle will have at the end of its lifetime.
  91142. */
  91143. colorDead: Color4;
  91144. /**
  91145. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91146. */
  91147. emitRate: number;
  91148. /**
  91149. * You can use gravity if you want to give an orientation to your particles.
  91150. */
  91151. gravity: Vector3;
  91152. /**
  91153. * Minimum power of emitting particles.
  91154. */
  91155. minEmitPower: number;
  91156. /**
  91157. * Maximum power of emitting particles.
  91158. */
  91159. maxEmitPower: number;
  91160. /**
  91161. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91162. */
  91163. minAngularSpeed: number;
  91164. /**
  91165. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91166. */
  91167. maxAngularSpeed: number;
  91168. /**
  91169. * Gets or sets the minimal initial rotation in radians.
  91170. */
  91171. minInitialRotation: number;
  91172. /**
  91173. * Gets or sets the maximal initial rotation in radians.
  91174. */
  91175. maxInitialRotation: number;
  91176. /**
  91177. * The particle emitter type defines the emitter used by the particle system.
  91178. * It can be for example box, sphere, or cone...
  91179. */
  91180. particleEmitterType: Nullable<IParticleEmitterType>;
  91181. /**
  91182. * Defines the delay in milliseconds before starting the system (0 by default)
  91183. */
  91184. startDelay: number;
  91185. /**
  91186. * 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
  91187. */
  91188. preWarmCycles: number;
  91189. /**
  91190. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91191. */
  91192. preWarmStepOffset: number;
  91193. /**
  91194. * 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)
  91195. */
  91196. spriteCellChangeSpeed: number;
  91197. /**
  91198. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91199. */
  91200. startSpriteCellID: number;
  91201. /**
  91202. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91203. */
  91204. endSpriteCellID: number;
  91205. /**
  91206. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91207. */
  91208. spriteCellWidth: number;
  91209. /**
  91210. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91211. */
  91212. spriteCellHeight: number;
  91213. /**
  91214. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91215. */
  91216. spriteRandomStartCell: boolean;
  91217. /**
  91218. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91219. */
  91220. isAnimationSheetEnabled: boolean;
  91221. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91222. translationPivot: Vector2;
  91223. /**
  91224. * Gets or sets a texture used to add random noise to particle positions
  91225. */
  91226. noiseTexture: Nullable<BaseTexture>;
  91227. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91228. noiseStrength: Vector3;
  91229. /**
  91230. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91231. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91232. */
  91233. billboardMode: number;
  91234. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91235. limitVelocityDamping: number;
  91236. /**
  91237. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91238. */
  91239. beginAnimationOnStart: boolean;
  91240. /**
  91241. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91242. */
  91243. beginAnimationFrom: number;
  91244. /**
  91245. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91246. */
  91247. beginAnimationTo: number;
  91248. /**
  91249. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91250. */
  91251. beginAnimationLoop: boolean;
  91252. /**
  91253. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91254. */
  91255. disposeOnStop: boolean;
  91256. /**
  91257. * Specifies if the particles are updated in emitter local space or world space
  91258. */
  91259. isLocal: boolean;
  91260. /** Snippet ID if the particle system was created from the snippet server */
  91261. snippetId: string;
  91262. /**
  91263. * Gets the maximum number of particles active at the same time.
  91264. * @returns The max number of active particles.
  91265. */
  91266. getCapacity(): number;
  91267. /**
  91268. * Gets the number of particles active at the same time.
  91269. * @returns The number of active particles.
  91270. */
  91271. getActiveCount(): number;
  91272. /**
  91273. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91274. * @returns True if it has been started, otherwise false.
  91275. */
  91276. isStarted(): boolean;
  91277. /**
  91278. * Animates the particle system for this frame.
  91279. */
  91280. animate(): void;
  91281. /**
  91282. * Renders the particle system in its current state.
  91283. * @returns the current number of particles
  91284. */
  91285. render(): number;
  91286. /**
  91287. * Dispose the particle system and frees its associated resources.
  91288. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91289. */
  91290. dispose(disposeTexture?: boolean): void;
  91291. /**
  91292. * An event triggered when the system is disposed
  91293. */
  91294. onDisposeObservable: Observable<IParticleSystem>;
  91295. /**
  91296. * Clones the particle system.
  91297. * @param name The name of the cloned object
  91298. * @param newEmitter The new emitter to use
  91299. * @returns the cloned particle system
  91300. */
  91301. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91302. /**
  91303. * Serializes the particle system to a JSON object
  91304. * @param serializeTexture defines if the texture must be serialized as well
  91305. * @returns the JSON object
  91306. */
  91307. serialize(serializeTexture: boolean): any;
  91308. /**
  91309. * Rebuild the particle system
  91310. */
  91311. rebuild(): void;
  91312. /** Force the system to rebuild all gradients that need to be resync */
  91313. forceRefreshGradients(): void;
  91314. /**
  91315. * Starts the particle system and begins to emit
  91316. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91317. */
  91318. start(delay?: number): void;
  91319. /**
  91320. * Stops the particle system.
  91321. */
  91322. stop(): void;
  91323. /**
  91324. * Remove all active particles
  91325. */
  91326. reset(): void;
  91327. /**
  91328. * Gets a boolean indicating that the system is stopping
  91329. * @returns true if the system is currently stopping
  91330. */
  91331. isStopping(): boolean;
  91332. /**
  91333. * Is this system ready to be used/rendered
  91334. * @return true if the system is ready
  91335. */
  91336. isReady(): boolean;
  91337. /**
  91338. * Returns the string "ParticleSystem"
  91339. * @returns a string containing the class name
  91340. */
  91341. getClassName(): string;
  91342. /**
  91343. * Gets the custom effect used to render the particles
  91344. * @param blendMode Blend mode for which the effect should be retrieved
  91345. * @returns The effect
  91346. */
  91347. getCustomEffect(blendMode: number): Nullable<Effect>;
  91348. /**
  91349. * Sets the custom effect used to render the particles
  91350. * @param effect The effect to set
  91351. * @param blendMode Blend mode for which the effect should be set
  91352. */
  91353. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91354. /**
  91355. * Fill the defines array according to the current settings of the particle system
  91356. * @param defines Array to be updated
  91357. * @param blendMode blend mode to take into account when updating the array
  91358. */
  91359. fillDefines(defines: Array<string>, blendMode: number): void;
  91360. /**
  91361. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91362. * @param uniforms Uniforms array to fill
  91363. * @param attributes Attributes array to fill
  91364. * @param samplers Samplers array to fill
  91365. */
  91366. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91367. /**
  91368. * Observable that will be called just before the particles are drawn
  91369. */
  91370. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91371. /**
  91372. * Gets the name of the particle vertex shader
  91373. */
  91374. vertexShaderName: string;
  91375. /**
  91376. * Adds a new color gradient
  91377. * @param gradient defines the gradient to use (between 0 and 1)
  91378. * @param color1 defines the color to affect to the specified gradient
  91379. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91380. * @returns the current particle system
  91381. */
  91382. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91383. /**
  91384. * Remove a specific color gradient
  91385. * @param gradient defines the gradient to remove
  91386. * @returns the current particle system
  91387. */
  91388. removeColorGradient(gradient: number): IParticleSystem;
  91389. /**
  91390. * Adds a new size gradient
  91391. * @param gradient defines the gradient to use (between 0 and 1)
  91392. * @param factor defines the size factor to affect to the specified gradient
  91393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91394. * @returns the current particle system
  91395. */
  91396. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91397. /**
  91398. * Remove a specific size gradient
  91399. * @param gradient defines the gradient to remove
  91400. * @returns the current particle system
  91401. */
  91402. removeSizeGradient(gradient: number): IParticleSystem;
  91403. /**
  91404. * Gets the current list of color gradients.
  91405. * You must use addColorGradient and removeColorGradient to udpate this list
  91406. * @returns the list of color gradients
  91407. */
  91408. getColorGradients(): Nullable<Array<ColorGradient>>;
  91409. /**
  91410. * Gets the current list of size gradients.
  91411. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91412. * @returns the list of size gradients
  91413. */
  91414. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91415. /**
  91416. * Gets the current list of angular speed gradients.
  91417. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91418. * @returns the list of angular speed gradients
  91419. */
  91420. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91421. /**
  91422. * Adds a new angular speed gradient
  91423. * @param gradient defines the gradient to use (between 0 and 1)
  91424. * @param factor defines the angular speed to affect to the specified gradient
  91425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91426. * @returns the current particle system
  91427. */
  91428. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91429. /**
  91430. * Remove a specific angular speed gradient
  91431. * @param gradient defines the gradient to remove
  91432. * @returns the current particle system
  91433. */
  91434. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91435. /**
  91436. * Gets the current list of velocity gradients.
  91437. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91438. * @returns the list of velocity gradients
  91439. */
  91440. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91441. /**
  91442. * Adds a new velocity gradient
  91443. * @param gradient defines the gradient to use (between 0 and 1)
  91444. * @param factor defines the velocity to affect to the specified gradient
  91445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91446. * @returns the current particle system
  91447. */
  91448. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91449. /**
  91450. * Remove a specific velocity gradient
  91451. * @param gradient defines the gradient to remove
  91452. * @returns the current particle system
  91453. */
  91454. removeVelocityGradient(gradient: number): IParticleSystem;
  91455. /**
  91456. * Gets the current list of limit velocity gradients.
  91457. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91458. * @returns the list of limit velocity gradients
  91459. */
  91460. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91461. /**
  91462. * Adds a new limit velocity gradient
  91463. * @param gradient defines the gradient to use (between 0 and 1)
  91464. * @param factor defines the limit velocity to affect to the specified gradient
  91465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91466. * @returns the current particle system
  91467. */
  91468. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91469. /**
  91470. * Remove a specific limit velocity gradient
  91471. * @param gradient defines the gradient to remove
  91472. * @returns the current particle system
  91473. */
  91474. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91475. /**
  91476. * Adds a new drag gradient
  91477. * @param gradient defines the gradient to use (between 0 and 1)
  91478. * @param factor defines the drag to affect to the specified gradient
  91479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91480. * @returns the current particle system
  91481. */
  91482. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91483. /**
  91484. * Remove a specific drag gradient
  91485. * @param gradient defines the gradient to remove
  91486. * @returns the current particle system
  91487. */
  91488. removeDragGradient(gradient: number): IParticleSystem;
  91489. /**
  91490. * Gets the current list of drag gradients.
  91491. * You must use addDragGradient and removeDragGradient to udpate this list
  91492. * @returns the list of drag gradients
  91493. */
  91494. getDragGradients(): Nullable<Array<FactorGradient>>;
  91495. /**
  91496. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91497. * @param gradient defines the gradient to use (between 0 and 1)
  91498. * @param factor defines the emit rate to affect to the specified gradient
  91499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91500. * @returns the current particle system
  91501. */
  91502. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91503. /**
  91504. * Remove a specific emit rate gradient
  91505. * @param gradient defines the gradient to remove
  91506. * @returns the current particle system
  91507. */
  91508. removeEmitRateGradient(gradient: number): IParticleSystem;
  91509. /**
  91510. * Gets the current list of emit rate gradients.
  91511. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91512. * @returns the list of emit rate gradients
  91513. */
  91514. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91515. /**
  91516. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91517. * @param gradient defines the gradient to use (between 0 and 1)
  91518. * @param factor defines the start size to affect to the specified gradient
  91519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91520. * @returns the current particle system
  91521. */
  91522. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91523. /**
  91524. * Remove a specific start size gradient
  91525. * @param gradient defines the gradient to remove
  91526. * @returns the current particle system
  91527. */
  91528. removeStartSizeGradient(gradient: number): IParticleSystem;
  91529. /**
  91530. * Gets the current list of start size gradients.
  91531. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91532. * @returns the list of start size gradients
  91533. */
  91534. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91535. /**
  91536. * Adds a new life time gradient
  91537. * @param gradient defines the gradient to use (between 0 and 1)
  91538. * @param factor defines the life time factor to affect to the specified gradient
  91539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91540. * @returns the current particle system
  91541. */
  91542. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91543. /**
  91544. * Remove a specific life time gradient
  91545. * @param gradient defines the gradient to remove
  91546. * @returns the current particle system
  91547. */
  91548. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91549. /**
  91550. * Gets the current list of life time gradients.
  91551. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91552. * @returns the list of life time gradients
  91553. */
  91554. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91555. /**
  91556. * Gets the current list of color gradients.
  91557. * You must use addColorGradient and removeColorGradient to udpate this list
  91558. * @returns the list of color gradients
  91559. */
  91560. getColorGradients(): Nullable<Array<ColorGradient>>;
  91561. /**
  91562. * Adds a new ramp gradient used to remap particle colors
  91563. * @param gradient defines the gradient to use (between 0 and 1)
  91564. * @param color defines the color to affect to the specified gradient
  91565. * @returns the current particle system
  91566. */
  91567. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91568. /**
  91569. * Gets the current list of ramp gradients.
  91570. * You must use addRampGradient and removeRampGradient to udpate this list
  91571. * @returns the list of ramp gradients
  91572. */
  91573. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91574. /** Gets or sets a boolean indicating that ramp gradients must be used
  91575. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91576. */
  91577. useRampGradients: boolean;
  91578. /**
  91579. * Adds a new color remap gradient
  91580. * @param gradient defines the gradient to use (between 0 and 1)
  91581. * @param min defines the color remap minimal range
  91582. * @param max defines the color remap maximal range
  91583. * @returns the current particle system
  91584. */
  91585. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91586. /**
  91587. * Gets the current list of color remap gradients.
  91588. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91589. * @returns the list of color remap gradients
  91590. */
  91591. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91592. /**
  91593. * Adds a new alpha remap gradient
  91594. * @param gradient defines the gradient to use (between 0 and 1)
  91595. * @param min defines the alpha remap minimal range
  91596. * @param max defines the alpha remap maximal range
  91597. * @returns the current particle system
  91598. */
  91599. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91600. /**
  91601. * Gets the current list of alpha remap gradients.
  91602. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91603. * @returns the list of alpha remap gradients
  91604. */
  91605. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91606. /**
  91607. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91610. * @returns the emitter
  91611. */
  91612. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91613. /**
  91614. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91615. * @param radius The radius of the hemisphere to emit from
  91616. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91617. * @returns the emitter
  91618. */
  91619. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  91620. /**
  91621. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91622. * @param radius The radius of the sphere to emit from
  91623. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91624. * @returns the emitter
  91625. */
  91626. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  91627. /**
  91628. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91629. * @param radius The radius of the sphere to emit from
  91630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91632. * @returns the emitter
  91633. */
  91634. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91635. /**
  91636. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91637. * @param radius The radius of the emission cylinder
  91638. * @param height The height of the emission cylinder
  91639. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91640. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91641. * @returns the emitter
  91642. */
  91643. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  91644. /**
  91645. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91646. * @param radius The radius of the cylinder to emit from
  91647. * @param height The height of the emission cylinder
  91648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91651. * @returns the emitter
  91652. */
  91653. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91654. /**
  91655. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91656. * @param radius The radius of the cone to emit from
  91657. * @param angle The base angle of the cone
  91658. * @returns the emitter
  91659. */
  91660. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  91661. /**
  91662. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91665. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91666. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91667. * @returns the emitter
  91668. */
  91669. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91670. /**
  91671. * Get hosting scene
  91672. * @returns the scene
  91673. */
  91674. getScene(): Scene;
  91675. }
  91676. }
  91677. declare module BABYLON {
  91678. /**
  91679. * 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.
  91680. * @see https://doc.babylonjs.com/how_to/transformnode
  91681. */
  91682. export class TransformNode extends Node {
  91683. /**
  91684. * Object will not rotate to face the camera
  91685. */
  91686. static BILLBOARDMODE_NONE: number;
  91687. /**
  91688. * Object will rotate to face the camera but only on the x axis
  91689. */
  91690. static BILLBOARDMODE_X: number;
  91691. /**
  91692. * Object will rotate to face the camera but only on the y axis
  91693. */
  91694. static BILLBOARDMODE_Y: number;
  91695. /**
  91696. * Object will rotate to face the camera but only on the z axis
  91697. */
  91698. static BILLBOARDMODE_Z: number;
  91699. /**
  91700. * Object will rotate to face the camera
  91701. */
  91702. static BILLBOARDMODE_ALL: number;
  91703. /**
  91704. * Object will rotate to face the camera's position instead of orientation
  91705. */
  91706. static BILLBOARDMODE_USE_POSITION: number;
  91707. private _forward;
  91708. private _forwardInverted;
  91709. private _up;
  91710. private _right;
  91711. private _rightInverted;
  91712. private _position;
  91713. private _rotation;
  91714. private _rotationQuaternion;
  91715. protected _scaling: Vector3;
  91716. protected _isDirty: boolean;
  91717. private _transformToBoneReferal;
  91718. private _isAbsoluteSynced;
  91719. private _billboardMode;
  91720. /**
  91721. * Gets or sets the billboard mode. Default is 0.
  91722. *
  91723. * | Value | Type | Description |
  91724. * | --- | --- | --- |
  91725. * | 0 | BILLBOARDMODE_NONE | |
  91726. * | 1 | BILLBOARDMODE_X | |
  91727. * | 2 | BILLBOARDMODE_Y | |
  91728. * | 4 | BILLBOARDMODE_Z | |
  91729. * | 7 | BILLBOARDMODE_ALL | |
  91730. *
  91731. */
  91732. get billboardMode(): number;
  91733. set billboardMode(value: number);
  91734. private _preserveParentRotationForBillboard;
  91735. /**
  91736. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  91737. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  91738. */
  91739. get preserveParentRotationForBillboard(): boolean;
  91740. set preserveParentRotationForBillboard(value: boolean);
  91741. /**
  91742. * 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
  91743. */
  91744. scalingDeterminant: number;
  91745. private _infiniteDistance;
  91746. /**
  91747. * Gets or sets the distance of the object to max, often used by skybox
  91748. */
  91749. get infiniteDistance(): boolean;
  91750. set infiniteDistance(value: boolean);
  91751. /**
  91752. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  91753. * By default the system will update normals to compensate
  91754. */
  91755. ignoreNonUniformScaling: boolean;
  91756. /**
  91757. * 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
  91758. */
  91759. reIntegrateRotationIntoRotationQuaternion: boolean;
  91760. /** @hidden */
  91761. _poseMatrix: Nullable<Matrix>;
  91762. /** @hidden */
  91763. _localMatrix: Matrix;
  91764. private _usePivotMatrix;
  91765. private _absolutePosition;
  91766. private _absoluteScaling;
  91767. private _absoluteRotationQuaternion;
  91768. private _pivotMatrix;
  91769. private _pivotMatrixInverse;
  91770. protected _postMultiplyPivotMatrix: boolean;
  91771. protected _isWorldMatrixFrozen: boolean;
  91772. /** @hidden */
  91773. _indexInSceneTransformNodesArray: number;
  91774. /**
  91775. * An event triggered after the world matrix is updated
  91776. */
  91777. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  91778. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  91779. /**
  91780. * Gets a string identifying the name of the class
  91781. * @returns "TransformNode" string
  91782. */
  91783. getClassName(): string;
  91784. /**
  91785. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  91786. */
  91787. get position(): Vector3;
  91788. set position(newPosition: Vector3);
  91789. /**
  91790. * 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)).
  91791. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  91792. */
  91793. get rotation(): Vector3;
  91794. set rotation(newRotation: Vector3);
  91795. /**
  91796. * 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)).
  91797. */
  91798. get scaling(): Vector3;
  91799. set scaling(newScaling: Vector3);
  91800. /**
  91801. * 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).
  91802. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  91803. */
  91804. get rotationQuaternion(): Nullable<Quaternion>;
  91805. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  91806. /**
  91807. * The forward direction of that transform in world space.
  91808. */
  91809. get forward(): Vector3;
  91810. /**
  91811. * The up direction of that transform in world space.
  91812. */
  91813. get up(): Vector3;
  91814. /**
  91815. * The right direction of that transform in world space.
  91816. */
  91817. get right(): Vector3;
  91818. /**
  91819. * Copies the parameter passed Matrix into the mesh Pose matrix.
  91820. * @param matrix the matrix to copy the pose from
  91821. * @returns this TransformNode.
  91822. */
  91823. updatePoseMatrix(matrix: Matrix): TransformNode;
  91824. /**
  91825. * Returns the mesh Pose matrix.
  91826. * @returns the pose matrix
  91827. */
  91828. getPoseMatrix(): Matrix;
  91829. /** @hidden */
  91830. _isSynchronized(): boolean;
  91831. /** @hidden */
  91832. _initCache(): void;
  91833. /**
  91834. * Flag the transform node as dirty (Forcing it to update everything)
  91835. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  91836. * @returns this transform node
  91837. */
  91838. markAsDirty(property: string): TransformNode;
  91839. /**
  91840. * Returns the current mesh absolute position.
  91841. * Returns a Vector3.
  91842. */
  91843. get absolutePosition(): Vector3;
  91844. /**
  91845. * Returns the current mesh absolute scaling.
  91846. * Returns a Vector3.
  91847. */
  91848. get absoluteScaling(): Vector3;
  91849. /**
  91850. * Returns the current mesh absolute rotation.
  91851. * Returns a Quaternion.
  91852. */
  91853. get absoluteRotationQuaternion(): Quaternion;
  91854. /**
  91855. * Sets a new matrix to apply before all other transformation
  91856. * @param matrix defines the transform matrix
  91857. * @returns the current TransformNode
  91858. */
  91859. setPreTransformMatrix(matrix: Matrix): TransformNode;
  91860. /**
  91861. * Sets a new pivot matrix to the current node
  91862. * @param matrix defines the new pivot matrix to use
  91863. * @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
  91864. * @returns the current TransformNode
  91865. */
  91866. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  91867. /**
  91868. * Returns the mesh pivot matrix.
  91869. * Default : Identity.
  91870. * @returns the matrix
  91871. */
  91872. getPivotMatrix(): Matrix;
  91873. /**
  91874. * Instantiate (when possible) or clone that node with its hierarchy
  91875. * @param newParent defines the new parent to use for the instance (or clone)
  91876. * @param options defines options to configure how copy is done
  91877. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  91878. * @returns an instance (or a clone) of the current node with its hiearchy
  91879. */
  91880. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91881. doNotInstantiate: boolean;
  91882. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91883. /**
  91884. * Prevents the World matrix to be computed any longer
  91885. * @param newWorldMatrix defines an optional matrix to use as world matrix
  91886. * @returns the TransformNode.
  91887. */
  91888. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  91889. /**
  91890. * Allows back the World matrix computation.
  91891. * @returns the TransformNode.
  91892. */
  91893. unfreezeWorldMatrix(): this;
  91894. /**
  91895. * True if the World matrix has been frozen.
  91896. */
  91897. get isWorldMatrixFrozen(): boolean;
  91898. /**
  91899. * Retuns the mesh absolute position in the World.
  91900. * @returns a Vector3.
  91901. */
  91902. getAbsolutePosition(): Vector3;
  91903. /**
  91904. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  91905. * @param absolutePosition the absolute position to set
  91906. * @returns the TransformNode.
  91907. */
  91908. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91909. /**
  91910. * Sets the mesh position in its local space.
  91911. * @param vector3 the position to set in localspace
  91912. * @returns the TransformNode.
  91913. */
  91914. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  91915. /**
  91916. * Returns the mesh position in the local space from the current World matrix values.
  91917. * @returns a new Vector3.
  91918. */
  91919. getPositionExpressedInLocalSpace(): Vector3;
  91920. /**
  91921. * Translates the mesh along the passed Vector3 in its local space.
  91922. * @param vector3 the distance to translate in localspace
  91923. * @returns the TransformNode.
  91924. */
  91925. locallyTranslate(vector3: Vector3): TransformNode;
  91926. private static _lookAtVectorCache;
  91927. /**
  91928. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  91929. * @param targetPoint the position (must be in same space as current mesh) to look at
  91930. * @param yawCor optional yaw (y-axis) correction in radians
  91931. * @param pitchCor optional pitch (x-axis) correction in radians
  91932. * @param rollCor optional roll (z-axis) correction in radians
  91933. * @param space the choosen space of the target
  91934. * @returns the TransformNode.
  91935. */
  91936. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  91937. /**
  91938. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91939. * This Vector3 is expressed in the World space.
  91940. * @param localAxis axis to rotate
  91941. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91942. */
  91943. getDirection(localAxis: Vector3): Vector3;
  91944. /**
  91945. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  91946. * localAxis is expressed in the mesh local space.
  91947. * result is computed in the Wordl space from the mesh World matrix.
  91948. * @param localAxis axis to rotate
  91949. * @param result the resulting transformnode
  91950. * @returns this TransformNode.
  91951. */
  91952. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  91953. /**
  91954. * Sets this transform node rotation to the given local axis.
  91955. * @param localAxis the axis in local space
  91956. * @param yawCor optional yaw (y-axis) correction in radians
  91957. * @param pitchCor optional pitch (x-axis) correction in radians
  91958. * @param rollCor optional roll (z-axis) correction in radians
  91959. * @returns this TransformNode
  91960. */
  91961. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  91962. /**
  91963. * Sets a new pivot point to the current node
  91964. * @param point defines the new pivot point to use
  91965. * @param space defines if the point is in world or local space (local by default)
  91966. * @returns the current TransformNode
  91967. */
  91968. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  91969. /**
  91970. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  91971. * @returns the pivot point
  91972. */
  91973. getPivotPoint(): Vector3;
  91974. /**
  91975. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  91976. * @param result the vector3 to store the result
  91977. * @returns this TransformNode.
  91978. */
  91979. getPivotPointToRef(result: Vector3): TransformNode;
  91980. /**
  91981. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  91982. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  91983. */
  91984. getAbsolutePivotPoint(): Vector3;
  91985. /**
  91986. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  91987. * @param result vector3 to store the result
  91988. * @returns this TransformNode.
  91989. */
  91990. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  91991. /**
  91992. * Defines the passed node as the parent of the current node.
  91993. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  91994. * @see https://doc.babylonjs.com/how_to/parenting
  91995. * @param node the node ot set as the parent
  91996. * @returns this TransformNode.
  91997. */
  91998. setParent(node: Nullable<Node>): TransformNode;
  91999. private _nonUniformScaling;
  92000. /**
  92001. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92002. */
  92003. get nonUniformScaling(): boolean;
  92004. /** @hidden */
  92005. _updateNonUniformScalingState(value: boolean): boolean;
  92006. /**
  92007. * Attach the current TransformNode to another TransformNode associated with a bone
  92008. * @param bone Bone affecting the TransformNode
  92009. * @param affectedTransformNode TransformNode associated with the bone
  92010. * @returns this object
  92011. */
  92012. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92013. /**
  92014. * Detach the transform node if its associated with a bone
  92015. * @returns this object
  92016. */
  92017. detachFromBone(): TransformNode;
  92018. private static _rotationAxisCache;
  92019. /**
  92020. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92021. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92022. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92023. * The passed axis is also normalized.
  92024. * @param axis the axis to rotate around
  92025. * @param amount the amount to rotate in radians
  92026. * @param space Space to rotate in (Default: local)
  92027. * @returns the TransformNode.
  92028. */
  92029. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92030. /**
  92031. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92032. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92033. * The passed axis is also normalized. .
  92034. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92035. * @param point the point to rotate around
  92036. * @param axis the axis to rotate around
  92037. * @param amount the amount to rotate in radians
  92038. * @returns the TransformNode
  92039. */
  92040. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92041. /**
  92042. * Translates the mesh along the axis vector for the passed distance in the given space.
  92043. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92044. * @param axis the axis to translate in
  92045. * @param distance the distance to translate
  92046. * @param space Space to rotate in (Default: local)
  92047. * @returns the TransformNode.
  92048. */
  92049. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92050. /**
  92051. * Adds a rotation step to the mesh current rotation.
  92052. * x, y, z are Euler angles expressed in radians.
  92053. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92054. * This means this rotation is made in the mesh local space only.
  92055. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92056. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92057. * ```javascript
  92058. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92059. * ```
  92060. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92061. * 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.
  92062. * @param x Rotation to add
  92063. * @param y Rotation to add
  92064. * @param z Rotation to add
  92065. * @returns the TransformNode.
  92066. */
  92067. addRotation(x: number, y: number, z: number): TransformNode;
  92068. /**
  92069. * @hidden
  92070. */
  92071. protected _getEffectiveParent(): Nullable<Node>;
  92072. /**
  92073. * Computes the world matrix of the node
  92074. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92075. * @returns the world matrix
  92076. */
  92077. computeWorldMatrix(force?: boolean): Matrix;
  92078. /**
  92079. * Resets this nodeTransform's local matrix to Matrix.Identity().
  92080. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  92081. */
  92082. resetLocalMatrix(independentOfChildren?: boolean): void;
  92083. protected _afterComputeWorldMatrix(): void;
  92084. /**
  92085. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  92086. * @param func callback function to add
  92087. *
  92088. * @returns the TransformNode.
  92089. */
  92090. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92091. /**
  92092. * Removes a registered callback function.
  92093. * @param func callback function to remove
  92094. * @returns the TransformNode.
  92095. */
  92096. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92097. /**
  92098. * Gets the position of the current mesh in camera space
  92099. * @param camera defines the camera to use
  92100. * @returns a position
  92101. */
  92102. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  92103. /**
  92104. * Returns the distance from the mesh to the active camera
  92105. * @param camera defines the camera to use
  92106. * @returns the distance
  92107. */
  92108. getDistanceToCamera(camera?: Nullable<Camera>): number;
  92109. /**
  92110. * Clone the current transform node
  92111. * @param name Name of the new clone
  92112. * @param newParent New parent for the clone
  92113. * @param doNotCloneChildren Do not clone children hierarchy
  92114. * @returns the new transform node
  92115. */
  92116. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  92117. /**
  92118. * Serializes the objects information.
  92119. * @param currentSerializationObject defines the object to serialize in
  92120. * @returns the serialized object
  92121. */
  92122. serialize(currentSerializationObject?: any): any;
  92123. /**
  92124. * Returns a new TransformNode object parsed from the source provided.
  92125. * @param parsedTransformNode is the source.
  92126. * @param scene the scne the object belongs to
  92127. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  92128. * @returns a new TransformNode object parsed from the source provided.
  92129. */
  92130. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  92131. /**
  92132. * Get all child-transformNodes of this node
  92133. * @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
  92134. * @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
  92135. * @returns an array of TransformNode
  92136. */
  92137. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  92138. /**
  92139. * Releases resources associated with this transform node.
  92140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92142. */
  92143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92144. /**
  92145. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92146. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92147. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92148. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92149. * @returns the current mesh
  92150. */
  92151. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  92152. private _syncAbsoluteScalingAndRotation;
  92153. }
  92154. }
  92155. declare module BABYLON {
  92156. /**
  92157. * Class used to override all child animations of a given target
  92158. */
  92159. export class AnimationPropertiesOverride {
  92160. /**
  92161. * Gets or sets a value indicating if animation blending must be used
  92162. */
  92163. enableBlending: boolean;
  92164. /**
  92165. * Gets or sets the blending speed to use when enableBlending is true
  92166. */
  92167. blendingSpeed: number;
  92168. /**
  92169. * Gets or sets the default loop mode to use
  92170. */
  92171. loopMode: number;
  92172. }
  92173. }
  92174. declare module BABYLON {
  92175. /**
  92176. * Class used to store bone information
  92177. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92178. */
  92179. export class Bone extends Node {
  92180. /**
  92181. * defines the bone name
  92182. */
  92183. name: string;
  92184. private static _tmpVecs;
  92185. private static _tmpQuat;
  92186. private static _tmpMats;
  92187. /**
  92188. * Gets the list of child bones
  92189. */
  92190. children: Bone[];
  92191. /** Gets the animations associated with this bone */
  92192. animations: Animation[];
  92193. /**
  92194. * Gets or sets bone length
  92195. */
  92196. length: number;
  92197. /**
  92198. * @hidden Internal only
  92199. * Set this value to map this bone to a different index in the transform matrices
  92200. * Set this value to -1 to exclude the bone from the transform matrices
  92201. */
  92202. _index: Nullable<number>;
  92203. private _skeleton;
  92204. private _localMatrix;
  92205. private _restPose;
  92206. private _baseMatrix;
  92207. private _absoluteTransform;
  92208. private _invertedAbsoluteTransform;
  92209. private _parent;
  92210. private _scalingDeterminant;
  92211. private _worldTransform;
  92212. private _localScaling;
  92213. private _localRotation;
  92214. private _localPosition;
  92215. private _needToDecompose;
  92216. private _needToCompose;
  92217. /** @hidden */
  92218. _linkedTransformNode: Nullable<TransformNode>;
  92219. /** @hidden */
  92220. _waitingTransformNodeId: Nullable<string>;
  92221. /** @hidden */
  92222. get _matrix(): Matrix;
  92223. /** @hidden */
  92224. set _matrix(value: Matrix);
  92225. /**
  92226. * Create a new bone
  92227. * @param name defines the bone name
  92228. * @param skeleton defines the parent skeleton
  92229. * @param parentBone defines the parent (can be null if the bone is the root)
  92230. * @param localMatrix defines the local matrix
  92231. * @param restPose defines the rest pose matrix
  92232. * @param baseMatrix defines the base matrix
  92233. * @param index defines index of the bone in the hiearchy
  92234. */
  92235. constructor(
  92236. /**
  92237. * defines the bone name
  92238. */
  92239. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  92240. /**
  92241. * Gets the current object class name.
  92242. * @return the class name
  92243. */
  92244. getClassName(): string;
  92245. /**
  92246. * Gets the parent skeleton
  92247. * @returns a skeleton
  92248. */
  92249. getSkeleton(): Skeleton;
  92250. /**
  92251. * Gets parent bone
  92252. * @returns a bone or null if the bone is the root of the bone hierarchy
  92253. */
  92254. getParent(): Nullable<Bone>;
  92255. /**
  92256. * Returns an array containing the root bones
  92257. * @returns an array containing the root bones
  92258. */
  92259. getChildren(): Array<Bone>;
  92260. /**
  92261. * Gets the node index in matrix array generated for rendering
  92262. * @returns the node index
  92263. */
  92264. getIndex(): number;
  92265. /**
  92266. * Sets the parent bone
  92267. * @param parent defines the parent (can be null if the bone is the root)
  92268. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92269. */
  92270. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  92271. /**
  92272. * Gets the local matrix
  92273. * @returns a matrix
  92274. */
  92275. getLocalMatrix(): Matrix;
  92276. /**
  92277. * Gets the base matrix (initial matrix which remains unchanged)
  92278. * @returns a matrix
  92279. */
  92280. getBaseMatrix(): Matrix;
  92281. /**
  92282. * Gets the rest pose matrix
  92283. * @returns a matrix
  92284. */
  92285. getRestPose(): Matrix;
  92286. /**
  92287. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92288. */
  92289. getWorldMatrix(): Matrix;
  92290. /**
  92291. * Sets the local matrix to rest pose matrix
  92292. */
  92293. returnToRest(): void;
  92294. /**
  92295. * Gets the inverse of the absolute transform matrix.
  92296. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92297. * @returns a matrix
  92298. */
  92299. getInvertedAbsoluteTransform(): Matrix;
  92300. /**
  92301. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92302. * @returns a matrix
  92303. */
  92304. getAbsoluteTransform(): Matrix;
  92305. /**
  92306. * Links with the given transform node.
  92307. * The local matrix of this bone is copied from the transform node every frame.
  92308. * @param transformNode defines the transform node to link to
  92309. */
  92310. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92311. /**
  92312. * Gets the node used to drive the bone's transformation
  92313. * @returns a transform node or null
  92314. */
  92315. getTransformNode(): Nullable<TransformNode>;
  92316. /** Gets or sets current position (in local space) */
  92317. get position(): Vector3;
  92318. set position(newPosition: Vector3);
  92319. /** Gets or sets current rotation (in local space) */
  92320. get rotation(): Vector3;
  92321. set rotation(newRotation: Vector3);
  92322. /** Gets or sets current rotation quaternion (in local space) */
  92323. get rotationQuaternion(): Quaternion;
  92324. set rotationQuaternion(newRotation: Quaternion);
  92325. /** Gets or sets current scaling (in local space) */
  92326. get scaling(): Vector3;
  92327. set scaling(newScaling: Vector3);
  92328. /**
  92329. * Gets the animation properties override
  92330. */
  92331. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92332. private _decompose;
  92333. private _compose;
  92334. /**
  92335. * Update the base and local matrices
  92336. * @param matrix defines the new base or local matrix
  92337. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92338. * @param updateLocalMatrix defines if the local matrix should be updated
  92339. */
  92340. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92341. /** @hidden */
  92342. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92343. /**
  92344. * Flag the bone as dirty (Forcing it to update everything)
  92345. */
  92346. markAsDirty(): void;
  92347. /** @hidden */
  92348. _markAsDirtyAndCompose(): void;
  92349. private _markAsDirtyAndDecompose;
  92350. /**
  92351. * Translate the bone in local or world space
  92352. * @param vec The amount to translate the bone
  92353. * @param space The space that the translation is in
  92354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92355. */
  92356. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92357. /**
  92358. * Set the postion of the bone in local or world space
  92359. * @param position The position to set the bone
  92360. * @param space The space that the position is in
  92361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92362. */
  92363. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92364. /**
  92365. * Set the absolute position of the bone (world space)
  92366. * @param position The position to set the bone
  92367. * @param mesh The mesh that this bone is attached to
  92368. */
  92369. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92370. /**
  92371. * Scale the bone on the x, y and z axes (in local space)
  92372. * @param x The amount to scale the bone on the x axis
  92373. * @param y The amount to scale the bone on the y axis
  92374. * @param z The amount to scale the bone on the z axis
  92375. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92376. */
  92377. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92378. /**
  92379. * Set the bone scaling in local space
  92380. * @param scale defines the scaling vector
  92381. */
  92382. setScale(scale: Vector3): void;
  92383. /**
  92384. * Gets the current scaling in local space
  92385. * @returns the current scaling vector
  92386. */
  92387. getScale(): Vector3;
  92388. /**
  92389. * Gets the current scaling in local space and stores it in a target vector
  92390. * @param result defines the target vector
  92391. */
  92392. getScaleToRef(result: Vector3): void;
  92393. /**
  92394. * Set the yaw, pitch, and roll of the bone in local or world space
  92395. * @param yaw The rotation of the bone on the y axis
  92396. * @param pitch The rotation of the bone on the x axis
  92397. * @param roll The rotation of the bone on the z axis
  92398. * @param space The space that the axes of rotation are in
  92399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92400. */
  92401. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92402. /**
  92403. * Add a rotation to the bone on an axis in local or world space
  92404. * @param axis The axis to rotate the bone on
  92405. * @param amount The amount to rotate the bone
  92406. * @param space The space that the axis is in
  92407. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92408. */
  92409. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92410. /**
  92411. * Set the rotation of the bone to a particular axis angle in local or world space
  92412. * @param axis The axis to rotate the bone on
  92413. * @param angle The angle that the bone should be rotated to
  92414. * @param space The space that the axis is in
  92415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92416. */
  92417. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92418. /**
  92419. * Set the euler rotation of the bone in local of world space
  92420. * @param rotation The euler rotation that the bone should be set to
  92421. * @param space The space that the rotation is in
  92422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92423. */
  92424. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92425. /**
  92426. * Set the quaternion rotation of the bone in local of world space
  92427. * @param quat The quaternion rotation that the bone should be set to
  92428. * @param space The space that the rotation is in
  92429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92430. */
  92431. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  92432. /**
  92433. * Set the rotation matrix of the bone in local of world space
  92434. * @param rotMat The rotation matrix that the bone should be set to
  92435. * @param space The space that the rotation is in
  92436. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92437. */
  92438. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  92439. private _rotateWithMatrix;
  92440. private _getNegativeRotationToRef;
  92441. /**
  92442. * Get the position of the bone in local or world space
  92443. * @param space The space that the returned position is in
  92444. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92445. * @returns The position of the bone
  92446. */
  92447. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92448. /**
  92449. * Copy the position of the bone to a vector3 in local or world space
  92450. * @param space The space that the returned position is in
  92451. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92452. * @param result The vector3 to copy the position to
  92453. */
  92454. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  92455. /**
  92456. * Get the absolute position of the bone (world space)
  92457. * @param mesh The mesh that this bone is attached to
  92458. * @returns The absolute position of the bone
  92459. */
  92460. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  92461. /**
  92462. * Copy the absolute position of the bone (world space) to the result param
  92463. * @param mesh The mesh that this bone is attached to
  92464. * @param result The vector3 to copy the absolute position to
  92465. */
  92466. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  92467. /**
  92468. * Compute the absolute transforms of this bone and its children
  92469. */
  92470. computeAbsoluteTransforms(): void;
  92471. /**
  92472. * Get the world direction from an axis that is in the local space of the bone
  92473. * @param localAxis The local direction that is used to compute the world direction
  92474. * @param mesh The mesh that this bone is attached to
  92475. * @returns The world direction
  92476. */
  92477. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92478. /**
  92479. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  92480. * @param localAxis The local direction that is used to compute the world direction
  92481. * @param mesh The mesh that this bone is attached to
  92482. * @param result The vector3 that the world direction will be copied to
  92483. */
  92484. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92485. /**
  92486. * Get the euler rotation of the bone in local or world space
  92487. * @param space The space that the rotation should be in
  92488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92489. * @returns The euler rotation
  92490. */
  92491. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92492. /**
  92493. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  92494. * @param space The space that the rotation should be in
  92495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92496. * @param result The vector3 that the rotation should be copied to
  92497. */
  92498. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92499. /**
  92500. * Get the quaternion rotation of the bone in either local or world space
  92501. * @param space The space that the rotation should be in
  92502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92503. * @returns The quaternion rotation
  92504. */
  92505. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  92506. /**
  92507. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  92508. * @param space The space that the rotation should be in
  92509. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92510. * @param result The quaternion that the rotation should be copied to
  92511. */
  92512. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  92513. /**
  92514. * Get the rotation matrix of the bone in local or world space
  92515. * @param space The space that the rotation should be in
  92516. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92517. * @returns The rotation matrix
  92518. */
  92519. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  92520. /**
  92521. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  92522. * @param space The space that the rotation should be in
  92523. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92524. * @param result The quaternion that the rotation should be copied to
  92525. */
  92526. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  92527. /**
  92528. * Get the world position of a point that is in the local space of the bone
  92529. * @param position The local position
  92530. * @param mesh The mesh that this bone is attached to
  92531. * @returns The world position
  92532. */
  92533. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92534. /**
  92535. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  92536. * @param position The local position
  92537. * @param mesh The mesh that this bone is attached to
  92538. * @param result The vector3 that the world position should be copied to
  92539. */
  92540. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92541. /**
  92542. * Get the local position of a point that is in world space
  92543. * @param position The world position
  92544. * @param mesh The mesh that this bone is attached to
  92545. * @returns The local position
  92546. */
  92547. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92548. /**
  92549. * Get the local position of a point that is in world space and copy it to the result param
  92550. * @param position The world position
  92551. * @param mesh The mesh that this bone is attached to
  92552. * @param result The vector3 that the local position should be copied to
  92553. */
  92554. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92555. }
  92556. }
  92557. declare module BABYLON {
  92558. /**
  92559. * Defines a runtime animation
  92560. */
  92561. export class RuntimeAnimation {
  92562. private _events;
  92563. /**
  92564. * The current frame of the runtime animation
  92565. */
  92566. private _currentFrame;
  92567. /**
  92568. * The animation used by the runtime animation
  92569. */
  92570. private _animation;
  92571. /**
  92572. * The target of the runtime animation
  92573. */
  92574. private _target;
  92575. /**
  92576. * The initiating animatable
  92577. */
  92578. private _host;
  92579. /**
  92580. * The original value of the runtime animation
  92581. */
  92582. private _originalValue;
  92583. /**
  92584. * The original blend value of the runtime animation
  92585. */
  92586. private _originalBlendValue;
  92587. /**
  92588. * The offsets cache of the runtime animation
  92589. */
  92590. private _offsetsCache;
  92591. /**
  92592. * The high limits cache of the runtime animation
  92593. */
  92594. private _highLimitsCache;
  92595. /**
  92596. * Specifies if the runtime animation has been stopped
  92597. */
  92598. private _stopped;
  92599. /**
  92600. * The blending factor of the runtime animation
  92601. */
  92602. private _blendingFactor;
  92603. /**
  92604. * The BabylonJS scene
  92605. */
  92606. private _scene;
  92607. /**
  92608. * The current value of the runtime animation
  92609. */
  92610. private _currentValue;
  92611. /** @hidden */
  92612. _animationState: _IAnimationState;
  92613. /**
  92614. * The active target of the runtime animation
  92615. */
  92616. private _activeTargets;
  92617. private _currentActiveTarget;
  92618. private _directTarget;
  92619. /**
  92620. * The target path of the runtime animation
  92621. */
  92622. private _targetPath;
  92623. /**
  92624. * The weight of the runtime animation
  92625. */
  92626. private _weight;
  92627. /**
  92628. * The ratio offset of the runtime animation
  92629. */
  92630. private _ratioOffset;
  92631. /**
  92632. * The previous delay of the runtime animation
  92633. */
  92634. private _previousDelay;
  92635. /**
  92636. * The previous ratio of the runtime animation
  92637. */
  92638. private _previousRatio;
  92639. private _enableBlending;
  92640. private _keys;
  92641. private _minFrame;
  92642. private _maxFrame;
  92643. private _minValue;
  92644. private _maxValue;
  92645. private _targetIsArray;
  92646. /**
  92647. * Gets the current frame of the runtime animation
  92648. */
  92649. get currentFrame(): number;
  92650. /**
  92651. * Gets the weight of the runtime animation
  92652. */
  92653. get weight(): number;
  92654. /**
  92655. * Gets the current value of the runtime animation
  92656. */
  92657. get currentValue(): any;
  92658. /**
  92659. * Gets the target path of the runtime animation
  92660. */
  92661. get targetPath(): string;
  92662. /**
  92663. * Gets the actual target of the runtime animation
  92664. */
  92665. get target(): any;
  92666. /**
  92667. * Gets the additive state of the runtime animation
  92668. */
  92669. get isAdditive(): boolean;
  92670. /** @hidden */
  92671. _onLoop: () => void;
  92672. /**
  92673. * Create a new RuntimeAnimation object
  92674. * @param target defines the target of the animation
  92675. * @param animation defines the source animation object
  92676. * @param scene defines the hosting scene
  92677. * @param host defines the initiating Animatable
  92678. */
  92679. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  92680. private _preparePath;
  92681. /**
  92682. * Gets the animation from the runtime animation
  92683. */
  92684. get animation(): Animation;
  92685. /**
  92686. * Resets the runtime animation to the beginning
  92687. * @param restoreOriginal defines whether to restore the target property to the original value
  92688. */
  92689. reset(restoreOriginal?: boolean): void;
  92690. /**
  92691. * Specifies if the runtime animation is stopped
  92692. * @returns Boolean specifying if the runtime animation is stopped
  92693. */
  92694. isStopped(): boolean;
  92695. /**
  92696. * Disposes of the runtime animation
  92697. */
  92698. dispose(): void;
  92699. /**
  92700. * Apply the interpolated value to the target
  92701. * @param currentValue defines the value computed by the animation
  92702. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  92703. */
  92704. setValue(currentValue: any, weight: number): void;
  92705. private _getOriginalValues;
  92706. private _setValue;
  92707. /**
  92708. * Gets the loop pmode of the runtime animation
  92709. * @returns Loop Mode
  92710. */
  92711. private _getCorrectLoopMode;
  92712. /**
  92713. * Move the current animation to a given frame
  92714. * @param frame defines the frame to move to
  92715. */
  92716. goToFrame(frame: number): void;
  92717. /**
  92718. * @hidden Internal use only
  92719. */
  92720. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  92721. /**
  92722. * Execute the current animation
  92723. * @param delay defines the delay to add to the current frame
  92724. * @param from defines the lower bound of the animation range
  92725. * @param to defines the upper bound of the animation range
  92726. * @param loop defines if the current animation must loop
  92727. * @param speedRatio defines the current speed ratio
  92728. * @param weight defines the weight of the animation (default is -1 so no weight)
  92729. * @param onLoop optional callback called when animation loops
  92730. * @returns a boolean indicating if the animation is running
  92731. */
  92732. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  92733. }
  92734. }
  92735. declare module BABYLON {
  92736. /**
  92737. * Class used to store an actual running animation
  92738. */
  92739. export class Animatable {
  92740. /** defines the target object */
  92741. target: any;
  92742. /** defines the starting frame number (default is 0) */
  92743. fromFrame: number;
  92744. /** defines the ending frame number (default is 100) */
  92745. toFrame: number;
  92746. /** defines if the animation must loop (default is false) */
  92747. loopAnimation: boolean;
  92748. /** defines a callback to call when animation ends if it is not looping */
  92749. onAnimationEnd?: (() => void) | null | undefined;
  92750. /** defines a callback to call when animation loops */
  92751. onAnimationLoop?: (() => void) | null | undefined;
  92752. /** defines whether the animation should be evaluated additively */
  92753. isAdditive: boolean;
  92754. private _localDelayOffset;
  92755. private _pausedDelay;
  92756. private _runtimeAnimations;
  92757. private _paused;
  92758. private _scene;
  92759. private _speedRatio;
  92760. private _weight;
  92761. private _syncRoot;
  92762. /**
  92763. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  92764. * This will only apply for non looping animation (default is true)
  92765. */
  92766. disposeOnEnd: boolean;
  92767. /**
  92768. * Gets a boolean indicating if the animation has started
  92769. */
  92770. animationStarted: boolean;
  92771. /**
  92772. * Observer raised when the animation ends
  92773. */
  92774. onAnimationEndObservable: Observable<Animatable>;
  92775. /**
  92776. * Observer raised when the animation loops
  92777. */
  92778. onAnimationLoopObservable: Observable<Animatable>;
  92779. /**
  92780. * Gets the root Animatable used to synchronize and normalize animations
  92781. */
  92782. get syncRoot(): Nullable<Animatable>;
  92783. /**
  92784. * Gets the current frame of the first RuntimeAnimation
  92785. * Used to synchronize Animatables
  92786. */
  92787. get masterFrame(): number;
  92788. /**
  92789. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  92790. */
  92791. get weight(): number;
  92792. set weight(value: number);
  92793. /**
  92794. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  92795. */
  92796. get speedRatio(): number;
  92797. set speedRatio(value: number);
  92798. /**
  92799. * Creates a new Animatable
  92800. * @param scene defines the hosting scene
  92801. * @param target defines the target object
  92802. * @param fromFrame defines the starting frame number (default is 0)
  92803. * @param toFrame defines the ending frame number (default is 100)
  92804. * @param loopAnimation defines if the animation must loop (default is false)
  92805. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  92806. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  92807. * @param animations defines a group of animation to add to the new Animatable
  92808. * @param onAnimationLoop defines a callback to call when animation loops
  92809. * @param isAdditive defines whether the animation should be evaluated additively
  92810. */
  92811. constructor(scene: Scene,
  92812. /** defines the target object */
  92813. target: any,
  92814. /** defines the starting frame number (default is 0) */
  92815. fromFrame?: number,
  92816. /** defines the ending frame number (default is 100) */
  92817. toFrame?: number,
  92818. /** defines if the animation must loop (default is false) */
  92819. loopAnimation?: boolean, speedRatio?: number,
  92820. /** defines a callback to call when animation ends if it is not looping */
  92821. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  92822. /** defines a callback to call when animation loops */
  92823. onAnimationLoop?: (() => void) | null | undefined,
  92824. /** defines whether the animation should be evaluated additively */
  92825. isAdditive?: boolean);
  92826. /**
  92827. * Synchronize and normalize current Animatable with a source Animatable
  92828. * This is useful when using animation weights and when animations are not of the same length
  92829. * @param root defines the root Animatable to synchronize with
  92830. * @returns the current Animatable
  92831. */
  92832. syncWith(root: Animatable): Animatable;
  92833. /**
  92834. * Gets the list of runtime animations
  92835. * @returns an array of RuntimeAnimation
  92836. */
  92837. getAnimations(): RuntimeAnimation[];
  92838. /**
  92839. * Adds more animations to the current animatable
  92840. * @param target defines the target of the animations
  92841. * @param animations defines the new animations to add
  92842. */
  92843. appendAnimations(target: any, animations: Animation[]): void;
  92844. /**
  92845. * Gets the source animation for a specific property
  92846. * @param property defines the propertyu to look for
  92847. * @returns null or the source animation for the given property
  92848. */
  92849. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  92850. /**
  92851. * Gets the runtime animation for a specific property
  92852. * @param property defines the propertyu to look for
  92853. * @returns null or the runtime animation for the given property
  92854. */
  92855. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  92856. /**
  92857. * Resets the animatable to its original state
  92858. */
  92859. reset(): void;
  92860. /**
  92861. * Allows the animatable to blend with current running animations
  92862. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92863. * @param blendingSpeed defines the blending speed to use
  92864. */
  92865. enableBlending(blendingSpeed: number): void;
  92866. /**
  92867. * Disable animation blending
  92868. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92869. */
  92870. disableBlending(): void;
  92871. /**
  92872. * Jump directly to a given frame
  92873. * @param frame defines the frame to jump to
  92874. */
  92875. goToFrame(frame: number): void;
  92876. /**
  92877. * Pause the animation
  92878. */
  92879. pause(): void;
  92880. /**
  92881. * Restart the animation
  92882. */
  92883. restart(): void;
  92884. private _raiseOnAnimationEnd;
  92885. /**
  92886. * Stop and delete the current animation
  92887. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  92888. * @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)
  92889. */
  92890. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  92891. /**
  92892. * Wait asynchronously for the animation to end
  92893. * @returns a promise which will be fullfilled when the animation ends
  92894. */
  92895. waitAsync(): Promise<Animatable>;
  92896. /** @hidden */
  92897. _animate(delay: number): boolean;
  92898. }
  92899. interface Scene {
  92900. /** @hidden */
  92901. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  92902. /** @hidden */
  92903. _processLateAnimationBindingsForMatrices(holder: {
  92904. totalWeight: number;
  92905. totalAdditiveWeight: number;
  92906. animations: RuntimeAnimation[];
  92907. additiveAnimations: RuntimeAnimation[];
  92908. originalValue: Matrix;
  92909. }): any;
  92910. /** @hidden */
  92911. _processLateAnimationBindingsForQuaternions(holder: {
  92912. totalWeight: number;
  92913. totalAdditiveWeight: number;
  92914. animations: RuntimeAnimation[];
  92915. additiveAnimations: RuntimeAnimation[];
  92916. originalValue: Quaternion;
  92917. }, refQuaternion: Quaternion): Quaternion;
  92918. /** @hidden */
  92919. _processLateAnimationBindings(): void;
  92920. /**
  92921. * Will start the animation sequence of a given target
  92922. * @param target defines the target
  92923. * @param from defines from which frame should animation start
  92924. * @param to defines until which frame should animation run.
  92925. * @param weight defines the weight to apply to the animation (1.0 by default)
  92926. * @param loop defines if the animation loops
  92927. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92928. * @param onAnimationEnd defines the function to be executed when the animation ends
  92929. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92930. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  92931. * @param onAnimationLoop defines the callback to call when an animation loops
  92932. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92933. * @returns the animatable object created for this animation
  92934. */
  92935. 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;
  92936. /**
  92937. * Will start the animation sequence of a given target
  92938. * @param target defines the target
  92939. * @param from defines from which frame should animation start
  92940. * @param to defines until which frame should animation run.
  92941. * @param loop defines if the animation loops
  92942. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92943. * @param onAnimationEnd defines the function to be executed when the animation ends
  92944. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92945. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  92946. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  92947. * @param onAnimationLoop defines the callback to call when an animation loops
  92948. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92949. * @returns the animatable object created for this animation
  92950. */
  92951. 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;
  92952. /**
  92953. * Will start the animation sequence of a given target and its hierarchy
  92954. * @param target defines the target
  92955. * @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.
  92956. * @param from defines from which frame should animation start
  92957. * @param to defines until which frame should animation run.
  92958. * @param loop defines if the animation loops
  92959. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92960. * @param onAnimationEnd defines the function to be executed when the animation ends
  92961. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92962. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  92963. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  92964. * @param onAnimationLoop defines the callback to call when an animation loops
  92965. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92966. * @returns the list of created animatables
  92967. */
  92968. 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[];
  92969. /**
  92970. * Begin a new animation on a given node
  92971. * @param target defines the target where the animation will take place
  92972. * @param animations defines the list of animations to start
  92973. * @param from defines the initial value
  92974. * @param to defines the final value
  92975. * @param loop defines if you want animation to loop (off by default)
  92976. * @param speedRatio defines the speed ratio to apply to all animations
  92977. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92978. * @param onAnimationLoop defines the callback to call when an animation loops
  92979. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92980. * @returns the list of created animatables
  92981. */
  92982. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  92983. /**
  92984. * Begin a new animation on a given node and its hierarchy
  92985. * @param target defines the root node where the animation will take place
  92986. * @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.
  92987. * @param animations defines the list of animations to start
  92988. * @param from defines the initial value
  92989. * @param to defines the final value
  92990. * @param loop defines if you want animation to loop (off by default)
  92991. * @param speedRatio defines the speed ratio to apply to all animations
  92992. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92993. * @param onAnimationLoop defines the callback to call when an animation loops
  92994. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92995. * @returns the list of animatables created for all nodes
  92996. */
  92997. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  92998. /**
  92999. * Gets the animatable associated with a specific target
  93000. * @param target defines the target of the animatable
  93001. * @returns the required animatable if found
  93002. */
  93003. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93004. /**
  93005. * Gets all animatables associated with a given target
  93006. * @param target defines the target to look animatables for
  93007. * @returns an array of Animatables
  93008. */
  93009. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93010. /**
  93011. * Stops and removes all animations that have been applied to the scene
  93012. */
  93013. stopAllAnimations(): void;
  93014. /**
  93015. * Gets the current delta time used by animation engine
  93016. */
  93017. deltaTime: number;
  93018. }
  93019. interface Bone {
  93020. /**
  93021. * Copy an animation range from another bone
  93022. * @param source defines the source bone
  93023. * @param rangeName defines the range name to copy
  93024. * @param frameOffset defines the frame offset
  93025. * @param rescaleAsRequired defines if rescaling must be applied if required
  93026. * @param skelDimensionsRatio defines the scaling ratio
  93027. * @returns true if operation was successful
  93028. */
  93029. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93030. }
  93031. }
  93032. declare module BABYLON {
  93033. /**
  93034. * Class used to handle skinning animations
  93035. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93036. */
  93037. export class Skeleton implements IAnimatable {
  93038. /** defines the skeleton name */
  93039. name: string;
  93040. /** defines the skeleton Id */
  93041. id: string;
  93042. /**
  93043. * Defines the list of child bones
  93044. */
  93045. bones: Bone[];
  93046. /**
  93047. * Defines an estimate of the dimension of the skeleton at rest
  93048. */
  93049. dimensionsAtRest: Vector3;
  93050. /**
  93051. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  93052. */
  93053. needInitialSkinMatrix: boolean;
  93054. /**
  93055. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  93056. */
  93057. overrideMesh: Nullable<AbstractMesh>;
  93058. /**
  93059. * Gets the list of animations attached to this skeleton
  93060. */
  93061. animations: Array<Animation>;
  93062. private _scene;
  93063. private _isDirty;
  93064. private _transformMatrices;
  93065. private _transformMatrixTexture;
  93066. private _meshesWithPoseMatrix;
  93067. private _animatables;
  93068. private _identity;
  93069. private _synchronizedWithMesh;
  93070. private _ranges;
  93071. private _lastAbsoluteTransformsUpdateId;
  93072. private _canUseTextureForBones;
  93073. private _uniqueId;
  93074. /** @hidden */
  93075. _numBonesWithLinkedTransformNode: number;
  93076. /** @hidden */
  93077. _hasWaitingData: Nullable<boolean>;
  93078. /**
  93079. * Specifies if the skeleton should be serialized
  93080. */
  93081. doNotSerialize: boolean;
  93082. private _useTextureToStoreBoneMatrices;
  93083. /**
  93084. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  93085. * Please note that this option is not available if the hardware does not support it
  93086. */
  93087. get useTextureToStoreBoneMatrices(): boolean;
  93088. set useTextureToStoreBoneMatrices(value: boolean);
  93089. private _animationPropertiesOverride;
  93090. /**
  93091. * Gets or sets the animation properties override
  93092. */
  93093. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93094. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93095. /**
  93096. * List of inspectable custom properties (used by the Inspector)
  93097. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93098. */
  93099. inspectableCustomProperties: IInspectable[];
  93100. /**
  93101. * An observable triggered before computing the skeleton's matrices
  93102. */
  93103. onBeforeComputeObservable: Observable<Skeleton>;
  93104. /**
  93105. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  93106. */
  93107. get isUsingTextureForMatrices(): boolean;
  93108. /**
  93109. * Gets the unique ID of this skeleton
  93110. */
  93111. get uniqueId(): number;
  93112. /**
  93113. * Creates a new skeleton
  93114. * @param name defines the skeleton name
  93115. * @param id defines the skeleton Id
  93116. * @param scene defines the hosting scene
  93117. */
  93118. constructor(
  93119. /** defines the skeleton name */
  93120. name: string,
  93121. /** defines the skeleton Id */
  93122. id: string, scene: Scene);
  93123. /**
  93124. * Gets the current object class name.
  93125. * @return the class name
  93126. */
  93127. getClassName(): string;
  93128. /**
  93129. * Returns an array containing the root bones
  93130. * @returns an array containing the root bones
  93131. */
  93132. getChildren(): Array<Bone>;
  93133. /**
  93134. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  93135. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93136. * @returns a Float32Array containing matrices data
  93137. */
  93138. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  93139. /**
  93140. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  93141. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93142. * @returns a raw texture containing the data
  93143. */
  93144. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  93145. /**
  93146. * Gets the current hosting scene
  93147. * @returns a scene object
  93148. */
  93149. getScene(): Scene;
  93150. /**
  93151. * Gets a string representing the current skeleton data
  93152. * @param fullDetails defines a boolean indicating if we want a verbose version
  93153. * @returns a string representing the current skeleton data
  93154. */
  93155. toString(fullDetails?: boolean): string;
  93156. /**
  93157. * Get bone's index searching by name
  93158. * @param name defines bone's name to search for
  93159. * @return the indice of the bone. Returns -1 if not found
  93160. */
  93161. getBoneIndexByName(name: string): number;
  93162. /**
  93163. * Creater a new animation range
  93164. * @param name defines the name of the range
  93165. * @param from defines the start key
  93166. * @param to defines the end key
  93167. */
  93168. createAnimationRange(name: string, from: number, to: number): void;
  93169. /**
  93170. * Delete a specific animation range
  93171. * @param name defines the name of the range
  93172. * @param deleteFrames defines if frames must be removed as well
  93173. */
  93174. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93175. /**
  93176. * Gets a specific animation range
  93177. * @param name defines the name of the range to look for
  93178. * @returns the requested animation range or null if not found
  93179. */
  93180. getAnimationRange(name: string): Nullable<AnimationRange>;
  93181. /**
  93182. * Gets the list of all animation ranges defined on this skeleton
  93183. * @returns an array
  93184. */
  93185. getAnimationRanges(): Nullable<AnimationRange>[];
  93186. /**
  93187. * Copy animation range from a source skeleton.
  93188. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  93189. * @param source defines the source skeleton
  93190. * @param name defines the name of the range to copy
  93191. * @param rescaleAsRequired defines if rescaling must be applied if required
  93192. * @returns true if operation was successful
  93193. */
  93194. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  93195. /**
  93196. * Forces the skeleton to go to rest pose
  93197. */
  93198. returnToRest(): void;
  93199. private _getHighestAnimationFrame;
  93200. /**
  93201. * Begin a specific animation range
  93202. * @param name defines the name of the range to start
  93203. * @param loop defines if looping must be turned on (false by default)
  93204. * @param speedRatio defines the speed ratio to apply (1 by default)
  93205. * @param onAnimationEnd defines a callback which will be called when animation will end
  93206. * @returns a new animatable
  93207. */
  93208. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93209. /**
  93210. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  93211. * @param skeleton defines the Skeleton containing the animation range to convert
  93212. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  93213. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  93214. * @returns the original skeleton
  93215. */
  93216. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  93217. /** @hidden */
  93218. _markAsDirty(): void;
  93219. /** @hidden */
  93220. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93221. /** @hidden */
  93222. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93223. private _computeTransformMatrices;
  93224. /**
  93225. * Build all resources required to render a skeleton
  93226. */
  93227. prepare(): void;
  93228. /**
  93229. * Gets the list of animatables currently running for this skeleton
  93230. * @returns an array of animatables
  93231. */
  93232. getAnimatables(): IAnimatable[];
  93233. /**
  93234. * Clone the current skeleton
  93235. * @param name defines the name of the new skeleton
  93236. * @param id defines the id of the new skeleton
  93237. * @returns the new skeleton
  93238. */
  93239. clone(name: string, id?: string): Skeleton;
  93240. /**
  93241. * Enable animation blending for this skeleton
  93242. * @param blendingSpeed defines the blending speed to apply
  93243. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93244. */
  93245. enableBlending(blendingSpeed?: number): void;
  93246. /**
  93247. * Releases all resources associated with the current skeleton
  93248. */
  93249. dispose(): void;
  93250. /**
  93251. * Serialize the skeleton in a JSON object
  93252. * @returns a JSON object
  93253. */
  93254. serialize(): any;
  93255. /**
  93256. * Creates a new skeleton from serialized data
  93257. * @param parsedSkeleton defines the serialized data
  93258. * @param scene defines the hosting scene
  93259. * @returns a new skeleton
  93260. */
  93261. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  93262. /**
  93263. * Compute all node absolute transforms
  93264. * @param forceUpdate defines if computation must be done even if cache is up to date
  93265. */
  93266. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  93267. /**
  93268. * Gets the root pose matrix
  93269. * @returns a matrix
  93270. */
  93271. getPoseMatrix(): Nullable<Matrix>;
  93272. /**
  93273. * Sorts bones per internal index
  93274. */
  93275. sortBones(): void;
  93276. private _sortBones;
  93277. }
  93278. }
  93279. declare module BABYLON {
  93280. /**
  93281. * Creates an instance based on a source mesh.
  93282. */
  93283. export class InstancedMesh extends AbstractMesh {
  93284. private _sourceMesh;
  93285. private _currentLOD;
  93286. /** @hidden */
  93287. _indexInSourceMeshInstanceArray: number;
  93288. constructor(name: string, source: Mesh);
  93289. /**
  93290. * Returns the string "InstancedMesh".
  93291. */
  93292. getClassName(): string;
  93293. /** Gets the list of lights affecting that mesh */
  93294. get lightSources(): Light[];
  93295. _resyncLightSources(): void;
  93296. _resyncLightSource(light: Light): void;
  93297. _removeLightSource(light: Light, dispose: boolean): void;
  93298. /**
  93299. * If the source mesh receives shadows
  93300. */
  93301. get receiveShadows(): boolean;
  93302. /**
  93303. * The material of the source mesh
  93304. */
  93305. get material(): Nullable<Material>;
  93306. /**
  93307. * Visibility of the source mesh
  93308. */
  93309. get visibility(): number;
  93310. /**
  93311. * Skeleton of the source mesh
  93312. */
  93313. get skeleton(): Nullable<Skeleton>;
  93314. /**
  93315. * Rendering ground id of the source mesh
  93316. */
  93317. get renderingGroupId(): number;
  93318. set renderingGroupId(value: number);
  93319. /**
  93320. * Returns the total number of vertices (integer).
  93321. */
  93322. getTotalVertices(): number;
  93323. /**
  93324. * Returns a positive integer : the total number of indices in this mesh geometry.
  93325. * @returns the numner of indices or zero if the mesh has no geometry.
  93326. */
  93327. getTotalIndices(): number;
  93328. /**
  93329. * The source mesh of the instance
  93330. */
  93331. get sourceMesh(): Mesh;
  93332. /**
  93333. * Creates a new InstancedMesh object from the mesh model.
  93334. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93335. * @param name defines the name of the new instance
  93336. * @returns a new InstancedMesh
  93337. */
  93338. createInstance(name: string): InstancedMesh;
  93339. /**
  93340. * Is this node ready to be used/rendered
  93341. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93342. * @return {boolean} is it ready
  93343. */
  93344. isReady(completeCheck?: boolean): boolean;
  93345. /**
  93346. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93347. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93348. * @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.
  93349. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93350. */
  93351. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93352. /**
  93353. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93354. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93355. * The `data` are either a numeric array either a Float32Array.
  93356. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93357. * 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).
  93358. * Note that a new underlying VertexBuffer object is created each call.
  93359. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93360. *
  93361. * Possible `kind` values :
  93362. * - VertexBuffer.PositionKind
  93363. * - VertexBuffer.UVKind
  93364. * - VertexBuffer.UV2Kind
  93365. * - VertexBuffer.UV3Kind
  93366. * - VertexBuffer.UV4Kind
  93367. * - VertexBuffer.UV5Kind
  93368. * - VertexBuffer.UV6Kind
  93369. * - VertexBuffer.ColorKind
  93370. * - VertexBuffer.MatricesIndicesKind
  93371. * - VertexBuffer.MatricesIndicesExtraKind
  93372. * - VertexBuffer.MatricesWeightsKind
  93373. * - VertexBuffer.MatricesWeightsExtraKind
  93374. *
  93375. * Returns the Mesh.
  93376. */
  93377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93378. /**
  93379. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93380. * If the mesh has no geometry, it is simply returned as it is.
  93381. * The `data` are either a numeric array either a Float32Array.
  93382. * No new underlying VertexBuffer object is created.
  93383. * 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.
  93384. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93385. *
  93386. * Possible `kind` values :
  93387. * - VertexBuffer.PositionKind
  93388. * - VertexBuffer.UVKind
  93389. * - VertexBuffer.UV2Kind
  93390. * - VertexBuffer.UV3Kind
  93391. * - VertexBuffer.UV4Kind
  93392. * - VertexBuffer.UV5Kind
  93393. * - VertexBuffer.UV6Kind
  93394. * - VertexBuffer.ColorKind
  93395. * - VertexBuffer.MatricesIndicesKind
  93396. * - VertexBuffer.MatricesIndicesExtraKind
  93397. * - VertexBuffer.MatricesWeightsKind
  93398. * - VertexBuffer.MatricesWeightsExtraKind
  93399. *
  93400. * Returns the Mesh.
  93401. */
  93402. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93403. /**
  93404. * Sets the mesh indices.
  93405. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93406. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93407. * This method creates a new index buffer each call.
  93408. * Returns the Mesh.
  93409. */
  93410. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93411. /**
  93412. * Boolean : True if the mesh owns the requested kind of data.
  93413. */
  93414. isVerticesDataPresent(kind: string): boolean;
  93415. /**
  93416. * Returns an array of indices (IndicesArray).
  93417. */
  93418. getIndices(): Nullable<IndicesArray>;
  93419. get _positions(): Nullable<Vector3[]>;
  93420. /**
  93421. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93422. * This means the mesh underlying bounding box and sphere are recomputed.
  93423. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93424. * @returns the current mesh
  93425. */
  93426. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93427. /** @hidden */
  93428. _preActivate(): InstancedMesh;
  93429. /** @hidden */
  93430. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93431. /** @hidden */
  93432. _postActivate(): void;
  93433. getWorldMatrix(): Matrix;
  93434. get isAnInstance(): boolean;
  93435. /**
  93436. * Returns the current associated LOD AbstractMesh.
  93437. */
  93438. getLOD(camera: Camera): AbstractMesh;
  93439. /** @hidden */
  93440. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93441. /** @hidden */
  93442. _syncSubMeshes(): InstancedMesh;
  93443. /** @hidden */
  93444. _generatePointsArray(): boolean;
  93445. /**
  93446. * Creates a new InstancedMesh from the current mesh.
  93447. * - name (string) : the cloned mesh name
  93448. * - newParent (optional Node) : the optional Node to parent the clone to.
  93449. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  93450. *
  93451. * Returns the clone.
  93452. */
  93453. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  93454. /**
  93455. * Disposes the InstancedMesh.
  93456. * Returns nothing.
  93457. */
  93458. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93459. }
  93460. interface Mesh {
  93461. /**
  93462. * Register a custom buffer that will be instanced
  93463. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93464. * @param kind defines the buffer kind
  93465. * @param stride defines the stride in floats
  93466. */
  93467. registerInstancedBuffer(kind: string, stride: number): void;
  93468. /** @hidden */
  93469. _userInstancedBuffersStorage: {
  93470. data: {
  93471. [key: string]: Float32Array;
  93472. };
  93473. sizes: {
  93474. [key: string]: number;
  93475. };
  93476. vertexBuffers: {
  93477. [key: string]: Nullable<VertexBuffer>;
  93478. };
  93479. strides: {
  93480. [key: string]: number;
  93481. };
  93482. };
  93483. }
  93484. interface AbstractMesh {
  93485. /**
  93486. * Object used to store instanced buffers defined by user
  93487. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93488. */
  93489. instancedBuffers: {
  93490. [key: string]: any;
  93491. };
  93492. }
  93493. }
  93494. declare module BABYLON {
  93495. /**
  93496. * Defines the options associated with the creation of a shader material.
  93497. */
  93498. export interface IShaderMaterialOptions {
  93499. /**
  93500. * Does the material work in alpha blend mode
  93501. */
  93502. needAlphaBlending: boolean;
  93503. /**
  93504. * Does the material work in alpha test mode
  93505. */
  93506. needAlphaTesting: boolean;
  93507. /**
  93508. * The list of attribute names used in the shader
  93509. */
  93510. attributes: string[];
  93511. /**
  93512. * The list of unifrom names used in the shader
  93513. */
  93514. uniforms: string[];
  93515. /**
  93516. * The list of UBO names used in the shader
  93517. */
  93518. uniformBuffers: string[];
  93519. /**
  93520. * The list of sampler names used in the shader
  93521. */
  93522. samplers: string[];
  93523. /**
  93524. * The list of defines used in the shader
  93525. */
  93526. defines: string[];
  93527. }
  93528. /**
  93529. * 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.
  93530. *
  93531. * This returned material effects how the mesh will look based on the code in the shaders.
  93532. *
  93533. * @see http://doc.babylonjs.com/how_to/shader_material
  93534. */
  93535. export class ShaderMaterial extends Material {
  93536. private _shaderPath;
  93537. private _options;
  93538. private _textures;
  93539. private _textureArrays;
  93540. private _floats;
  93541. private _ints;
  93542. private _floatsArrays;
  93543. private _colors3;
  93544. private _colors3Arrays;
  93545. private _colors4;
  93546. private _colors4Arrays;
  93547. private _vectors2;
  93548. private _vectors3;
  93549. private _vectors4;
  93550. private _matrices;
  93551. private _matrixArrays;
  93552. private _matrices3x3;
  93553. private _matrices2x2;
  93554. private _vectors2Arrays;
  93555. private _vectors3Arrays;
  93556. private _vectors4Arrays;
  93557. private _cachedWorldViewMatrix;
  93558. private _cachedWorldViewProjectionMatrix;
  93559. private _renderId;
  93560. private _multiview;
  93561. private _cachedDefines;
  93562. /**
  93563. * Instantiate a new shader material.
  93564. * 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.
  93565. * This returned material effects how the mesh will look based on the code in the shaders.
  93566. * @see http://doc.babylonjs.com/how_to/shader_material
  93567. * @param name Define the name of the material in the scene
  93568. * @param scene Define the scene the material belongs to
  93569. * @param shaderPath Defines the route to the shader code in one of three ways:
  93570. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  93571. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  93572. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  93573. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  93574. * @param options Define the options used to create the shader
  93575. */
  93576. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  93577. /**
  93578. * Gets the shader path used to define the shader code
  93579. * It can be modified to trigger a new compilation
  93580. */
  93581. get shaderPath(): any;
  93582. /**
  93583. * Sets the shader path used to define the shader code
  93584. * It can be modified to trigger a new compilation
  93585. */
  93586. set shaderPath(shaderPath: any);
  93587. /**
  93588. * Gets the options used to compile the shader.
  93589. * They can be modified to trigger a new compilation
  93590. */
  93591. get options(): IShaderMaterialOptions;
  93592. /**
  93593. * Gets the current class name of the material e.g. "ShaderMaterial"
  93594. * Mainly use in serialization.
  93595. * @returns the class name
  93596. */
  93597. getClassName(): string;
  93598. /**
  93599. * Specifies if the material will require alpha blending
  93600. * @returns a boolean specifying if alpha blending is needed
  93601. */
  93602. needAlphaBlending(): boolean;
  93603. /**
  93604. * Specifies if this material should be rendered in alpha test mode
  93605. * @returns a boolean specifying if an alpha test is needed.
  93606. */
  93607. needAlphaTesting(): boolean;
  93608. private _checkUniform;
  93609. /**
  93610. * Set a texture in the shader.
  93611. * @param name Define the name of the uniform samplers as defined in the shader
  93612. * @param texture Define the texture to bind to this sampler
  93613. * @return the material itself allowing "fluent" like uniform updates
  93614. */
  93615. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  93616. /**
  93617. * Set a texture array in the shader.
  93618. * @param name Define the name of the uniform sampler array as defined in the shader
  93619. * @param textures Define the list of textures to bind to this sampler
  93620. * @return the material itself allowing "fluent" like uniform updates
  93621. */
  93622. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  93623. /**
  93624. * Set a float in the shader.
  93625. * @param name Define the name of the uniform as defined in the shader
  93626. * @param value Define the value to give to the uniform
  93627. * @return the material itself allowing "fluent" like uniform updates
  93628. */
  93629. setFloat(name: string, value: number): ShaderMaterial;
  93630. /**
  93631. * Set a int in the shader.
  93632. * @param name Define the name of the uniform as defined in the shader
  93633. * @param value Define the value to give to the uniform
  93634. * @return the material itself allowing "fluent" like uniform updates
  93635. */
  93636. setInt(name: string, value: number): ShaderMaterial;
  93637. /**
  93638. * Set an array of floats in the shader.
  93639. * @param name Define the name of the uniform as defined in the shader
  93640. * @param value Define the value to give to the uniform
  93641. * @return the material itself allowing "fluent" like uniform updates
  93642. */
  93643. setFloats(name: string, value: number[]): ShaderMaterial;
  93644. /**
  93645. * Set a vec3 in the shader from a Color3.
  93646. * @param name Define the name of the uniform as defined in the shader
  93647. * @param value Define the value to give to the uniform
  93648. * @return the material itself allowing "fluent" like uniform updates
  93649. */
  93650. setColor3(name: string, value: Color3): ShaderMaterial;
  93651. /**
  93652. * Set a vec3 array in the shader from a Color3 array.
  93653. * @param name Define the name of the uniform as defined in the shader
  93654. * @param value Define the value to give to the uniform
  93655. * @return the material itself allowing "fluent" like uniform updates
  93656. */
  93657. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  93658. /**
  93659. * Set a vec4 in the shader from a Color4.
  93660. * @param name Define the name of the uniform as defined in the shader
  93661. * @param value Define the value to give to the uniform
  93662. * @return the material itself allowing "fluent" like uniform updates
  93663. */
  93664. setColor4(name: string, value: Color4): ShaderMaterial;
  93665. /**
  93666. * Set a vec4 array in the shader from a Color4 array.
  93667. * @param name Define the name of the uniform as defined in the shader
  93668. * @param value Define the value to give to the uniform
  93669. * @return the material itself allowing "fluent" like uniform updates
  93670. */
  93671. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  93672. /**
  93673. * Set a vec2 in the shader from a Vector2.
  93674. * @param name Define the name of the uniform as defined in the shader
  93675. * @param value Define the value to give to the uniform
  93676. * @return the material itself allowing "fluent" like uniform updates
  93677. */
  93678. setVector2(name: string, value: Vector2): ShaderMaterial;
  93679. /**
  93680. * Set a vec3 in the shader from a Vector3.
  93681. * @param name Define the name of the uniform as defined in the shader
  93682. * @param value Define the value to give to the uniform
  93683. * @return the material itself allowing "fluent" like uniform updates
  93684. */
  93685. setVector3(name: string, value: Vector3): ShaderMaterial;
  93686. /**
  93687. * Set a vec4 in the shader from a Vector4.
  93688. * @param name Define the name of the uniform as defined in the shader
  93689. * @param value Define the value to give to the uniform
  93690. * @return the material itself allowing "fluent" like uniform updates
  93691. */
  93692. setVector4(name: string, value: Vector4): ShaderMaterial;
  93693. /**
  93694. * Set a mat4 in the shader from a Matrix.
  93695. * @param name Define the name of the uniform as defined in the shader
  93696. * @param value Define the value to give to the uniform
  93697. * @return the material itself allowing "fluent" like uniform updates
  93698. */
  93699. setMatrix(name: string, value: Matrix): ShaderMaterial;
  93700. /**
  93701. * Set a float32Array in the shader from a matrix array.
  93702. * @param name Define the name of the uniform as defined in the shader
  93703. * @param value Define the value to give to the uniform
  93704. * @return the material itself allowing "fluent" like uniform updates
  93705. */
  93706. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  93707. /**
  93708. * Set a mat3 in the shader from a Float32Array.
  93709. * @param name Define the name of the uniform as defined in the shader
  93710. * @param value Define the value to give to the uniform
  93711. * @return the material itself allowing "fluent" like uniform updates
  93712. */
  93713. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  93714. /**
  93715. * Set a mat2 in the shader from a Float32Array.
  93716. * @param name Define the name of the uniform as defined in the shader
  93717. * @param value Define the value to give to the uniform
  93718. * @return the material itself allowing "fluent" like uniform updates
  93719. */
  93720. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  93721. /**
  93722. * Set a vec2 array in the shader from a number array.
  93723. * @param name Define the name of the uniform as defined in the shader
  93724. * @param value Define the value to give to the uniform
  93725. * @return the material itself allowing "fluent" like uniform updates
  93726. */
  93727. setArray2(name: string, value: number[]): ShaderMaterial;
  93728. /**
  93729. * Set a vec3 array in the shader from a number array.
  93730. * @param name Define the name of the uniform as defined in the shader
  93731. * @param value Define the value to give to the uniform
  93732. * @return the material itself allowing "fluent" like uniform updates
  93733. */
  93734. setArray3(name: string, value: number[]): ShaderMaterial;
  93735. /**
  93736. * Set a vec4 array in the shader from a number array.
  93737. * @param name Define the name of the uniform as defined in the shader
  93738. * @param value Define the value to give to the uniform
  93739. * @return the material itself allowing "fluent" like uniform updates
  93740. */
  93741. setArray4(name: string, value: number[]): ShaderMaterial;
  93742. private _checkCache;
  93743. /**
  93744. * Specifies that the submesh is ready to be used
  93745. * @param mesh defines the mesh to check
  93746. * @param subMesh defines which submesh to check
  93747. * @param useInstances specifies that instances should be used
  93748. * @returns a boolean indicating that the submesh is ready or not
  93749. */
  93750. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93751. /**
  93752. * Checks if the material is ready to render the requested mesh
  93753. * @param mesh Define the mesh to render
  93754. * @param useInstances Define whether or not the material is used with instances
  93755. * @returns true if ready, otherwise false
  93756. */
  93757. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93758. /**
  93759. * Binds the world matrix to the material
  93760. * @param world defines the world transformation matrix
  93761. * @param effectOverride - If provided, use this effect instead of internal effect
  93762. */
  93763. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  93764. /**
  93765. * Binds the submesh to this material by preparing the effect and shader to draw
  93766. * @param world defines the world transformation matrix
  93767. * @param mesh defines the mesh containing the submesh
  93768. * @param subMesh defines the submesh to bind the material to
  93769. */
  93770. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93771. /**
  93772. * Binds the material to the mesh
  93773. * @param world defines the world transformation matrix
  93774. * @param mesh defines the mesh to bind the material to
  93775. * @param effectOverride - If provided, use this effect instead of internal effect
  93776. */
  93777. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  93778. protected _afterBind(mesh?: Mesh): void;
  93779. /**
  93780. * Gets the active textures from the material
  93781. * @returns an array of textures
  93782. */
  93783. getActiveTextures(): BaseTexture[];
  93784. /**
  93785. * Specifies if the material uses a texture
  93786. * @param texture defines the texture to check against the material
  93787. * @returns a boolean specifying if the material uses the texture
  93788. */
  93789. hasTexture(texture: BaseTexture): boolean;
  93790. /**
  93791. * Makes a duplicate of the material, and gives it a new name
  93792. * @param name defines the new name for the duplicated material
  93793. * @returns the cloned material
  93794. */
  93795. clone(name: string): ShaderMaterial;
  93796. /**
  93797. * Disposes the material
  93798. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93799. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  93800. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  93801. */
  93802. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  93803. /**
  93804. * Serializes this material in a JSON representation
  93805. * @returns the serialized material object
  93806. */
  93807. serialize(): any;
  93808. /**
  93809. * Creates a shader material from parsed shader material data
  93810. * @param source defines the JSON represnetation of the material
  93811. * @param scene defines the hosting scene
  93812. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  93813. * @returns a new material
  93814. */
  93815. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  93816. }
  93817. }
  93818. declare module BABYLON {
  93819. /** @hidden */
  93820. export var colorPixelShader: {
  93821. name: string;
  93822. shader: string;
  93823. };
  93824. }
  93825. declare module BABYLON {
  93826. /** @hidden */
  93827. export var colorVertexShader: {
  93828. name: string;
  93829. shader: string;
  93830. };
  93831. }
  93832. declare module BABYLON {
  93833. /**
  93834. * Line mesh
  93835. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  93836. */
  93837. export class LinesMesh extends Mesh {
  93838. /**
  93839. * If vertex color should be applied to the mesh
  93840. */
  93841. readonly useVertexColor?: boolean | undefined;
  93842. /**
  93843. * If vertex alpha should be applied to the mesh
  93844. */
  93845. readonly useVertexAlpha?: boolean | undefined;
  93846. /**
  93847. * Color of the line (Default: White)
  93848. */
  93849. color: Color3;
  93850. /**
  93851. * Alpha of the line (Default: 1)
  93852. */
  93853. alpha: number;
  93854. /**
  93855. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93856. * This margin is expressed in world space coordinates, so its value may vary.
  93857. * Default value is 0.1
  93858. */
  93859. intersectionThreshold: number;
  93860. private _colorShader;
  93861. private color4;
  93862. /**
  93863. * Creates a new LinesMesh
  93864. * @param name defines the name
  93865. * @param scene defines the hosting scene
  93866. * @param parent defines the parent mesh if any
  93867. * @param source defines the optional source LinesMesh used to clone data from
  93868. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  93869. * When false, achieved by calling a clone(), also passing False.
  93870. * This will make creation of children, recursive.
  93871. * @param useVertexColor defines if this LinesMesh supports vertex color
  93872. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  93873. */
  93874. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  93875. /**
  93876. * If vertex color should be applied to the mesh
  93877. */
  93878. useVertexColor?: boolean | undefined,
  93879. /**
  93880. * If vertex alpha should be applied to the mesh
  93881. */
  93882. useVertexAlpha?: boolean | undefined);
  93883. private _addClipPlaneDefine;
  93884. private _removeClipPlaneDefine;
  93885. isReady(): boolean;
  93886. /**
  93887. * Returns the string "LineMesh"
  93888. */
  93889. getClassName(): string;
  93890. /**
  93891. * @hidden
  93892. */
  93893. get material(): Material;
  93894. /**
  93895. * @hidden
  93896. */
  93897. set material(value: Material);
  93898. /**
  93899. * @hidden
  93900. */
  93901. get checkCollisions(): boolean;
  93902. /** @hidden */
  93903. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93904. /** @hidden */
  93905. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93906. /**
  93907. * Disposes of the line mesh
  93908. * @param doNotRecurse If children should be disposed
  93909. */
  93910. dispose(doNotRecurse?: boolean): void;
  93911. /**
  93912. * Returns a new LineMesh object cloned from the current one.
  93913. */
  93914. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  93915. /**
  93916. * Creates a new InstancedLinesMesh object from the mesh model.
  93917. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93918. * @param name defines the name of the new instance
  93919. * @returns a new InstancedLinesMesh
  93920. */
  93921. createInstance(name: string): InstancedLinesMesh;
  93922. }
  93923. /**
  93924. * Creates an instance based on a source LinesMesh
  93925. */
  93926. export class InstancedLinesMesh extends InstancedMesh {
  93927. /**
  93928. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93929. * This margin is expressed in world space coordinates, so its value may vary.
  93930. * Initilized with the intersectionThreshold value of the source LinesMesh
  93931. */
  93932. intersectionThreshold: number;
  93933. constructor(name: string, source: LinesMesh);
  93934. /**
  93935. * Returns the string "InstancedLinesMesh".
  93936. */
  93937. getClassName(): string;
  93938. }
  93939. }
  93940. declare module BABYLON {
  93941. /** @hidden */
  93942. export var linePixelShader: {
  93943. name: string;
  93944. shader: string;
  93945. };
  93946. }
  93947. declare module BABYLON {
  93948. /** @hidden */
  93949. export var lineVertexShader: {
  93950. name: string;
  93951. shader: string;
  93952. };
  93953. }
  93954. declare module BABYLON {
  93955. interface AbstractMesh {
  93956. /**
  93957. * Gets the edgesRenderer associated with the mesh
  93958. */
  93959. edgesRenderer: Nullable<EdgesRenderer>;
  93960. }
  93961. interface LinesMesh {
  93962. /**
  93963. * Enables the edge rendering mode on the mesh.
  93964. * This mode makes the mesh edges visible
  93965. * @param epsilon defines the maximal distance between two angles to detect a face
  93966. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93967. * @returns the currentAbstractMesh
  93968. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93969. */
  93970. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93971. }
  93972. interface InstancedLinesMesh {
  93973. /**
  93974. * Enables the edge rendering mode on the mesh.
  93975. * This mode makes the mesh edges visible
  93976. * @param epsilon defines the maximal distance between two angles to detect a face
  93977. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93978. * @returns the current InstancedLinesMesh
  93979. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93980. */
  93981. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  93982. }
  93983. /**
  93984. * Defines the minimum contract an Edges renderer should follow.
  93985. */
  93986. export interface IEdgesRenderer extends IDisposable {
  93987. /**
  93988. * Gets or sets a boolean indicating if the edgesRenderer is active
  93989. */
  93990. isEnabled: boolean;
  93991. /**
  93992. * Renders the edges of the attached mesh,
  93993. */
  93994. render(): void;
  93995. /**
  93996. * Checks wether or not the edges renderer is ready to render.
  93997. * @return true if ready, otherwise false.
  93998. */
  93999. isReady(): boolean;
  94000. }
  94001. /**
  94002. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94003. */
  94004. export class EdgesRenderer implements IEdgesRenderer {
  94005. /**
  94006. * Define the size of the edges with an orthographic camera
  94007. */
  94008. edgesWidthScalerForOrthographic: number;
  94009. /**
  94010. * Define the size of the edges with a perspective camera
  94011. */
  94012. edgesWidthScalerForPerspective: number;
  94013. protected _source: AbstractMesh;
  94014. protected _linesPositions: number[];
  94015. protected _linesNormals: number[];
  94016. protected _linesIndices: number[];
  94017. protected _epsilon: number;
  94018. protected _indicesCount: number;
  94019. protected _lineShader: ShaderMaterial;
  94020. protected _ib: DataBuffer;
  94021. protected _buffers: {
  94022. [key: string]: Nullable<VertexBuffer>;
  94023. };
  94024. protected _checkVerticesInsteadOfIndices: boolean;
  94025. private _meshRebuildObserver;
  94026. private _meshDisposeObserver;
  94027. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  94028. isEnabled: boolean;
  94029. /**
  94030. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  94031. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  94032. * @param source Mesh used to create edges
  94033. * @param epsilon sum of angles in adjacency to check for edge
  94034. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  94035. * @param generateEdgesLines - should generate Lines or only prepare resources.
  94036. */
  94037. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  94038. protected _prepareRessources(): void;
  94039. /** @hidden */
  94040. _rebuild(): void;
  94041. /**
  94042. * Releases the required resources for the edges renderer
  94043. */
  94044. dispose(): void;
  94045. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  94046. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  94047. /**
  94048. * Checks if the pair of p0 and p1 is en edge
  94049. * @param faceIndex
  94050. * @param edge
  94051. * @param faceNormals
  94052. * @param p0
  94053. * @param p1
  94054. * @private
  94055. */
  94056. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  94057. /**
  94058. * push line into the position, normal and index buffer
  94059. * @protected
  94060. */
  94061. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  94062. /**
  94063. * Generates lines edges from adjacencjes
  94064. * @private
  94065. */
  94066. _generateEdgesLines(): void;
  94067. /**
  94068. * Checks wether or not the edges renderer is ready to render.
  94069. * @return true if ready, otherwise false.
  94070. */
  94071. isReady(): boolean;
  94072. /**
  94073. * Renders the edges of the attached mesh,
  94074. */
  94075. render(): void;
  94076. }
  94077. /**
  94078. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  94079. */
  94080. export class LineEdgesRenderer extends EdgesRenderer {
  94081. /**
  94082. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  94083. * @param source LineMesh used to generate edges
  94084. * @param epsilon not important (specified angle for edge detection)
  94085. * @param checkVerticesInsteadOfIndices not important for LineMesh
  94086. */
  94087. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  94088. /**
  94089. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  94090. */
  94091. _generateEdgesLines(): void;
  94092. }
  94093. }
  94094. declare module BABYLON {
  94095. /**
  94096. * This represents the object necessary to create a rendering group.
  94097. * This is exclusively used and created by the rendering manager.
  94098. * To modify the behavior, you use the available helpers in your scene or meshes.
  94099. * @hidden
  94100. */
  94101. export class RenderingGroup {
  94102. index: number;
  94103. private static _zeroVector;
  94104. private _scene;
  94105. private _opaqueSubMeshes;
  94106. private _transparentSubMeshes;
  94107. private _alphaTestSubMeshes;
  94108. private _depthOnlySubMeshes;
  94109. private _particleSystems;
  94110. private _spriteManagers;
  94111. private _opaqueSortCompareFn;
  94112. private _alphaTestSortCompareFn;
  94113. private _transparentSortCompareFn;
  94114. private _renderOpaque;
  94115. private _renderAlphaTest;
  94116. private _renderTransparent;
  94117. /** @hidden */
  94118. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  94119. onBeforeTransparentRendering: () => void;
  94120. /**
  94121. * Set the opaque sort comparison function.
  94122. * If null the sub meshes will be render in the order they were created
  94123. */
  94124. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94125. /**
  94126. * Set the alpha test sort comparison function.
  94127. * If null the sub meshes will be render in the order they were created
  94128. */
  94129. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94130. /**
  94131. * Set the transparent sort comparison function.
  94132. * If null the sub meshes will be render in the order they were created
  94133. */
  94134. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94135. /**
  94136. * Creates a new rendering group.
  94137. * @param index The rendering group index
  94138. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  94139. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  94140. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  94141. */
  94142. 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>);
  94143. /**
  94144. * Render all the sub meshes contained in the group.
  94145. * @param customRenderFunction Used to override the default render behaviour of the group.
  94146. * @returns true if rendered some submeshes.
  94147. */
  94148. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  94149. /**
  94150. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  94151. * @param subMeshes The submeshes to render
  94152. */
  94153. private renderOpaqueSorted;
  94154. /**
  94155. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  94156. * @param subMeshes The submeshes to render
  94157. */
  94158. private renderAlphaTestSorted;
  94159. /**
  94160. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  94161. * @param subMeshes The submeshes to render
  94162. */
  94163. private renderTransparentSorted;
  94164. /**
  94165. * Renders the submeshes in a specified order.
  94166. * @param subMeshes The submeshes to sort before render
  94167. * @param sortCompareFn The comparison function use to sort
  94168. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  94169. * @param transparent Specifies to activate blending if true
  94170. */
  94171. private static renderSorted;
  94172. /**
  94173. * Renders the submeshes in the order they were dispatched (no sort applied).
  94174. * @param subMeshes The submeshes to render
  94175. */
  94176. private static renderUnsorted;
  94177. /**
  94178. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94179. * are rendered back to front if in the same alpha index.
  94180. *
  94181. * @param a The first submesh
  94182. * @param b The second submesh
  94183. * @returns The result of the comparison
  94184. */
  94185. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  94186. /**
  94187. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94188. * are rendered back to front.
  94189. *
  94190. * @param a The first submesh
  94191. * @param b The second submesh
  94192. * @returns The result of the comparison
  94193. */
  94194. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  94195. /**
  94196. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94197. * are rendered front to back (prevent overdraw).
  94198. *
  94199. * @param a The first submesh
  94200. * @param b The second submesh
  94201. * @returns The result of the comparison
  94202. */
  94203. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  94204. /**
  94205. * Resets the different lists of submeshes to prepare a new frame.
  94206. */
  94207. prepare(): void;
  94208. dispose(): void;
  94209. /**
  94210. * Inserts the submesh in its correct queue depending on its material.
  94211. * @param subMesh The submesh to dispatch
  94212. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94213. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94214. */
  94215. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94216. dispatchSprites(spriteManager: ISpriteManager): void;
  94217. dispatchParticles(particleSystem: IParticleSystem): void;
  94218. private _renderParticles;
  94219. private _renderSprites;
  94220. }
  94221. }
  94222. declare module BABYLON {
  94223. /**
  94224. * Interface describing the different options available in the rendering manager
  94225. * regarding Auto Clear between groups.
  94226. */
  94227. export interface IRenderingManagerAutoClearSetup {
  94228. /**
  94229. * Defines whether or not autoclear is enable.
  94230. */
  94231. autoClear: boolean;
  94232. /**
  94233. * Defines whether or not to autoclear the depth buffer.
  94234. */
  94235. depth: boolean;
  94236. /**
  94237. * Defines whether or not to autoclear the stencil buffer.
  94238. */
  94239. stencil: boolean;
  94240. }
  94241. /**
  94242. * This class is used by the onRenderingGroupObservable
  94243. */
  94244. export class RenderingGroupInfo {
  94245. /**
  94246. * The Scene that being rendered
  94247. */
  94248. scene: Scene;
  94249. /**
  94250. * The camera currently used for the rendering pass
  94251. */
  94252. camera: Nullable<Camera>;
  94253. /**
  94254. * The ID of the renderingGroup being processed
  94255. */
  94256. renderingGroupId: number;
  94257. }
  94258. /**
  94259. * This is the manager responsible of all the rendering for meshes sprites and particles.
  94260. * It is enable to manage the different groups as well as the different necessary sort functions.
  94261. * This should not be used directly aside of the few static configurations
  94262. */
  94263. export class RenderingManager {
  94264. /**
  94265. * The max id used for rendering groups (not included)
  94266. */
  94267. static MAX_RENDERINGGROUPS: number;
  94268. /**
  94269. * The min id used for rendering groups (included)
  94270. */
  94271. static MIN_RENDERINGGROUPS: number;
  94272. /**
  94273. * Used to globally prevent autoclearing scenes.
  94274. */
  94275. static AUTOCLEAR: boolean;
  94276. /**
  94277. * @hidden
  94278. */
  94279. _useSceneAutoClearSetup: boolean;
  94280. private _scene;
  94281. private _renderingGroups;
  94282. private _depthStencilBufferAlreadyCleaned;
  94283. private _autoClearDepthStencil;
  94284. private _customOpaqueSortCompareFn;
  94285. private _customAlphaTestSortCompareFn;
  94286. private _customTransparentSortCompareFn;
  94287. private _renderingGroupInfo;
  94288. /**
  94289. * Instantiates a new rendering group for a particular scene
  94290. * @param scene Defines the scene the groups belongs to
  94291. */
  94292. constructor(scene: Scene);
  94293. private _clearDepthStencilBuffer;
  94294. /**
  94295. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94296. * @hidden
  94297. */
  94298. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94299. /**
  94300. * Resets the different information of the group to prepare a new frame
  94301. * @hidden
  94302. */
  94303. reset(): void;
  94304. /**
  94305. * Dispose and release the group and its associated resources.
  94306. * @hidden
  94307. */
  94308. dispose(): void;
  94309. /**
  94310. * Clear the info related to rendering groups preventing retention points during dispose.
  94311. */
  94312. freeRenderingGroups(): void;
  94313. private _prepareRenderingGroup;
  94314. /**
  94315. * Add a sprite manager to the rendering manager in order to render it this frame.
  94316. * @param spriteManager Define the sprite manager to render
  94317. */
  94318. dispatchSprites(spriteManager: ISpriteManager): void;
  94319. /**
  94320. * Add a particle system to the rendering manager in order to render it this frame.
  94321. * @param particleSystem Define the particle system to render
  94322. */
  94323. dispatchParticles(particleSystem: IParticleSystem): void;
  94324. /**
  94325. * Add a submesh to the manager in order to render it this frame
  94326. * @param subMesh The submesh to dispatch
  94327. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94328. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94329. */
  94330. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94331. /**
  94332. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94333. * This allowed control for front to back rendering or reversly depending of the special needs.
  94334. *
  94335. * @param renderingGroupId The rendering group id corresponding to its index
  94336. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94337. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94338. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94339. */
  94340. 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;
  94341. /**
  94342. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94343. *
  94344. * @param renderingGroupId The rendering group id corresponding to its index
  94345. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94346. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94347. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94348. */
  94349. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94350. /**
  94351. * Gets the current auto clear configuration for one rendering group of the rendering
  94352. * manager.
  94353. * @param index the rendering group index to get the information for
  94354. * @returns The auto clear setup for the requested rendering group
  94355. */
  94356. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94357. }
  94358. }
  94359. declare module BABYLON {
  94360. /**
  94361. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94362. */
  94363. export interface ICustomShaderOptions {
  94364. /**
  94365. * Gets or sets the custom shader name to use
  94366. */
  94367. shaderName: string;
  94368. /**
  94369. * The list of attribute names used in the shader
  94370. */
  94371. attributes?: string[];
  94372. /**
  94373. * The list of unifrom names used in the shader
  94374. */
  94375. uniforms?: string[];
  94376. /**
  94377. * The list of sampler names used in the shader
  94378. */
  94379. samplers?: string[];
  94380. /**
  94381. * The list of defines used in the shader
  94382. */
  94383. defines?: string[];
  94384. }
  94385. /**
  94386. * Interface to implement to create a shadow generator compatible with BJS.
  94387. */
  94388. export interface IShadowGenerator {
  94389. /**
  94390. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94391. * @returns The render target texture if present otherwise, null
  94392. */
  94393. getShadowMap(): Nullable<RenderTargetTexture>;
  94394. /**
  94395. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94396. * @param subMesh The submesh we want to render in the shadow map
  94397. * @param useInstances Defines wether will draw in the map using instances
  94398. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94399. * @returns true if ready otherwise, false
  94400. */
  94401. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94402. /**
  94403. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94404. * @param defines Defines of the material we want to update
  94405. * @param lightIndex Index of the light in the enabled light list of the material
  94406. */
  94407. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  94408. /**
  94409. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94410. * defined in the generator but impacting the effect).
  94411. * It implies the unifroms available on the materials are the standard BJS ones.
  94412. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94413. * @param effect The effect we are binfing the information for
  94414. */
  94415. bindShadowLight(lightIndex: string, effect: Effect): void;
  94416. /**
  94417. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94418. * (eq to shadow prjection matrix * light transform matrix)
  94419. * @returns The transform matrix used to create the shadow map
  94420. */
  94421. getTransformMatrix(): Matrix;
  94422. /**
  94423. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94424. * Cube and 2D textures for instance.
  94425. */
  94426. recreateShadowMap(): void;
  94427. /**
  94428. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94429. * @param onCompiled Callback triggered at the and of the effects compilation
  94430. * @param options Sets of optional options forcing the compilation with different modes
  94431. */
  94432. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94433. useInstances: boolean;
  94434. }>): void;
  94435. /**
  94436. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94437. * @param options Sets of optional options forcing the compilation with different modes
  94438. * @returns A promise that resolves when the compilation completes
  94439. */
  94440. forceCompilationAsync(options?: Partial<{
  94441. useInstances: boolean;
  94442. }>): Promise<void>;
  94443. /**
  94444. * Serializes the shadow generator setup to a json object.
  94445. * @returns The serialized JSON object
  94446. */
  94447. serialize(): any;
  94448. /**
  94449. * Disposes the Shadow map and related Textures and effects.
  94450. */
  94451. dispose(): void;
  94452. }
  94453. /**
  94454. * Default implementation IShadowGenerator.
  94455. * This is the main object responsible of generating shadows in the framework.
  94456. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  94457. */
  94458. export class ShadowGenerator implements IShadowGenerator {
  94459. /**
  94460. * Name of the shadow generator class
  94461. */
  94462. static CLASSNAME: string;
  94463. /**
  94464. * Shadow generator mode None: no filtering applied.
  94465. */
  94466. static readonly FILTER_NONE: number;
  94467. /**
  94468. * Shadow generator mode ESM: Exponential Shadow Mapping.
  94469. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94470. */
  94471. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  94472. /**
  94473. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  94474. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  94475. */
  94476. static readonly FILTER_POISSONSAMPLING: number;
  94477. /**
  94478. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  94479. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94480. */
  94481. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  94482. /**
  94483. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  94484. * edge artifacts on steep falloff.
  94485. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94486. */
  94487. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  94488. /**
  94489. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  94490. * edge artifacts on steep falloff.
  94491. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94492. */
  94493. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  94494. /**
  94495. * Shadow generator mode PCF: Percentage Closer Filtering
  94496. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94497. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  94498. */
  94499. static readonly FILTER_PCF: number;
  94500. /**
  94501. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  94502. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94503. * Contact Hardening
  94504. */
  94505. static readonly FILTER_PCSS: number;
  94506. /**
  94507. * Reserved for PCF and PCSS
  94508. * Highest Quality.
  94509. *
  94510. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  94511. *
  94512. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  94513. */
  94514. static readonly QUALITY_HIGH: number;
  94515. /**
  94516. * Reserved for PCF and PCSS
  94517. * Good tradeoff for quality/perf cross devices
  94518. *
  94519. * Execute PCF on a 3*3 kernel.
  94520. *
  94521. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  94522. */
  94523. static readonly QUALITY_MEDIUM: number;
  94524. /**
  94525. * Reserved for PCF and PCSS
  94526. * The lowest quality but the fastest.
  94527. *
  94528. * Execute PCF on a 1*1 kernel.
  94529. *
  94530. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  94531. */
  94532. static readonly QUALITY_LOW: number;
  94533. /** Gets or sets the custom shader name to use */
  94534. customShaderOptions: ICustomShaderOptions;
  94535. /**
  94536. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  94537. */
  94538. onBeforeShadowMapRenderObservable: Observable<Effect>;
  94539. /**
  94540. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  94541. */
  94542. onAfterShadowMapRenderObservable: Observable<Effect>;
  94543. /**
  94544. * Observable triggered before a mesh is rendered in the shadow map.
  94545. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  94546. */
  94547. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  94548. /**
  94549. * Observable triggered after a mesh is rendered in the shadow map.
  94550. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  94551. */
  94552. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  94553. protected _bias: number;
  94554. /**
  94555. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  94556. */
  94557. get bias(): number;
  94558. /**
  94559. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  94560. */
  94561. set bias(bias: number);
  94562. protected _normalBias: number;
  94563. /**
  94564. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94565. */
  94566. get normalBias(): number;
  94567. /**
  94568. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94569. */
  94570. set normalBias(normalBias: number);
  94571. protected _blurBoxOffset: number;
  94572. /**
  94573. * Gets the blur box offset: offset applied during the blur pass.
  94574. * Only useful if useKernelBlur = false
  94575. */
  94576. get blurBoxOffset(): number;
  94577. /**
  94578. * Sets the blur box offset: offset applied during the blur pass.
  94579. * Only useful if useKernelBlur = false
  94580. */
  94581. set blurBoxOffset(value: number);
  94582. protected _blurScale: number;
  94583. /**
  94584. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  94585. * 2 means half of the size.
  94586. */
  94587. get blurScale(): number;
  94588. /**
  94589. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  94590. * 2 means half of the size.
  94591. */
  94592. set blurScale(value: number);
  94593. protected _blurKernel: number;
  94594. /**
  94595. * Gets the blur kernel: kernel size of the blur pass.
  94596. * Only useful if useKernelBlur = true
  94597. */
  94598. get blurKernel(): number;
  94599. /**
  94600. * Sets the blur kernel: kernel size of the blur pass.
  94601. * Only useful if useKernelBlur = true
  94602. */
  94603. set blurKernel(value: number);
  94604. protected _useKernelBlur: boolean;
  94605. /**
  94606. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  94607. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94608. */
  94609. get useKernelBlur(): boolean;
  94610. /**
  94611. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  94612. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94613. */
  94614. set useKernelBlur(value: boolean);
  94615. protected _depthScale: number;
  94616. /**
  94617. * Gets the depth scale used in ESM mode.
  94618. */
  94619. get depthScale(): number;
  94620. /**
  94621. * Sets the depth scale used in ESM mode.
  94622. * This can override the scale stored on the light.
  94623. */
  94624. set depthScale(value: number);
  94625. protected _validateFilter(filter: number): number;
  94626. protected _filter: number;
  94627. /**
  94628. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  94629. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94630. */
  94631. get filter(): number;
  94632. /**
  94633. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  94634. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94635. */
  94636. set filter(value: number);
  94637. /**
  94638. * Gets if the current filter is set to Poisson Sampling.
  94639. */
  94640. get usePoissonSampling(): boolean;
  94641. /**
  94642. * Sets the current filter to Poisson Sampling.
  94643. */
  94644. set usePoissonSampling(value: boolean);
  94645. /**
  94646. * Gets if the current filter is set to ESM.
  94647. */
  94648. get useExponentialShadowMap(): boolean;
  94649. /**
  94650. * Sets the current filter is to ESM.
  94651. */
  94652. set useExponentialShadowMap(value: boolean);
  94653. /**
  94654. * Gets if the current filter is set to filtered ESM.
  94655. */
  94656. get useBlurExponentialShadowMap(): boolean;
  94657. /**
  94658. * Gets if the current filter is set to filtered ESM.
  94659. */
  94660. set useBlurExponentialShadowMap(value: boolean);
  94661. /**
  94662. * Gets if the current filter is set to "close ESM" (using the inverse of the
  94663. * exponential to prevent steep falloff artifacts).
  94664. */
  94665. get useCloseExponentialShadowMap(): boolean;
  94666. /**
  94667. * Sets the current filter to "close ESM" (using the inverse of the
  94668. * exponential to prevent steep falloff artifacts).
  94669. */
  94670. set useCloseExponentialShadowMap(value: boolean);
  94671. /**
  94672. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  94673. * exponential to prevent steep falloff artifacts).
  94674. */
  94675. get useBlurCloseExponentialShadowMap(): boolean;
  94676. /**
  94677. * Sets the current filter to filtered "close ESM" (using the inverse of the
  94678. * exponential to prevent steep falloff artifacts).
  94679. */
  94680. set useBlurCloseExponentialShadowMap(value: boolean);
  94681. /**
  94682. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  94683. */
  94684. get usePercentageCloserFiltering(): boolean;
  94685. /**
  94686. * Sets the current filter to "PCF" (percentage closer filtering).
  94687. */
  94688. set usePercentageCloserFiltering(value: boolean);
  94689. protected _filteringQuality: number;
  94690. /**
  94691. * Gets the PCF or PCSS Quality.
  94692. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94693. */
  94694. get filteringQuality(): number;
  94695. /**
  94696. * Sets the PCF or PCSS Quality.
  94697. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94698. */
  94699. set filteringQuality(filteringQuality: number);
  94700. /**
  94701. * Gets if the current filter is set to "PCSS" (contact hardening).
  94702. */
  94703. get useContactHardeningShadow(): boolean;
  94704. /**
  94705. * Sets the current filter to "PCSS" (contact hardening).
  94706. */
  94707. set useContactHardeningShadow(value: boolean);
  94708. protected _contactHardeningLightSizeUVRatio: number;
  94709. /**
  94710. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94711. * Using a ratio helps keeping shape stability independently of the map size.
  94712. *
  94713. * It does not account for the light projection as it was having too much
  94714. * instability during the light setup or during light position changes.
  94715. *
  94716. * Only valid if useContactHardeningShadow is true.
  94717. */
  94718. get contactHardeningLightSizeUVRatio(): number;
  94719. /**
  94720. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94721. * Using a ratio helps keeping shape stability independently of the map size.
  94722. *
  94723. * It does not account for the light projection as it was having too much
  94724. * instability during the light setup or during light position changes.
  94725. *
  94726. * Only valid if useContactHardeningShadow is true.
  94727. */
  94728. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  94729. protected _darkness: number;
  94730. /** Gets or sets the actual darkness of a shadow */
  94731. get darkness(): number;
  94732. set darkness(value: number);
  94733. /**
  94734. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  94735. * 0 means strongest and 1 would means no shadow.
  94736. * @returns the darkness.
  94737. */
  94738. getDarkness(): number;
  94739. /**
  94740. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  94741. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  94742. * @returns the shadow generator allowing fluent coding.
  94743. */
  94744. setDarkness(darkness: number): ShadowGenerator;
  94745. protected _transparencyShadow: boolean;
  94746. /** Gets or sets the ability to have transparent shadow */
  94747. get transparencyShadow(): boolean;
  94748. set transparencyShadow(value: boolean);
  94749. /**
  94750. * Sets the ability to have transparent shadow (boolean).
  94751. * @param transparent True if transparent else False
  94752. * @returns the shadow generator allowing fluent coding
  94753. */
  94754. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  94755. /**
  94756. * Enables or disables shadows with varying strength based on the transparency
  94757. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  94758. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  94759. * mesh.visibility * alphaTexture.a
  94760. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  94761. */
  94762. enableSoftTransparentShadow: boolean;
  94763. protected _shadowMap: Nullable<RenderTargetTexture>;
  94764. protected _shadowMap2: Nullable<RenderTargetTexture>;
  94765. /**
  94766. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94767. * @returns The render target texture if present otherwise, null
  94768. */
  94769. getShadowMap(): Nullable<RenderTargetTexture>;
  94770. /**
  94771. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  94772. * @returns The render target texture if the shadow map is present otherwise, null
  94773. */
  94774. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  94775. /**
  94776. * Gets the class name of that object
  94777. * @returns "ShadowGenerator"
  94778. */
  94779. getClassName(): string;
  94780. /**
  94781. * Helper function to add a mesh and its descendants to the list of shadow casters.
  94782. * @param mesh Mesh to add
  94783. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  94784. * @returns the Shadow Generator itself
  94785. */
  94786. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94787. /**
  94788. * Helper function to remove a mesh and its descendants from the list of shadow casters
  94789. * @param mesh Mesh to remove
  94790. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  94791. * @returns the Shadow Generator itself
  94792. */
  94793. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94794. /**
  94795. * Controls the extent to which the shadows fade out at the edge of the frustum
  94796. */
  94797. frustumEdgeFalloff: number;
  94798. protected _light: IShadowLight;
  94799. /**
  94800. * Returns the associated light object.
  94801. * @returns the light generating the shadow
  94802. */
  94803. getLight(): IShadowLight;
  94804. /**
  94805. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  94806. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  94807. * It might on the other hand introduce peter panning.
  94808. */
  94809. forceBackFacesOnly: boolean;
  94810. protected _scene: Scene;
  94811. protected _lightDirection: Vector3;
  94812. protected _effect: Effect;
  94813. protected _viewMatrix: Matrix;
  94814. protected _projectionMatrix: Matrix;
  94815. protected _transformMatrix: Matrix;
  94816. protected _cachedPosition: Vector3;
  94817. protected _cachedDirection: Vector3;
  94818. protected _cachedDefines: string;
  94819. protected _currentRenderID: number;
  94820. protected _boxBlurPostprocess: Nullable<PostProcess>;
  94821. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  94822. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  94823. protected _blurPostProcesses: PostProcess[];
  94824. protected _mapSize: number;
  94825. protected _currentFaceIndex: number;
  94826. protected _currentFaceIndexCache: number;
  94827. protected _textureType: number;
  94828. protected _defaultTextureMatrix: Matrix;
  94829. protected _storedUniqueId: Nullable<number>;
  94830. /** @hidden */
  94831. static _SceneComponentInitialization: (scene: Scene) => void;
  94832. /**
  94833. * Creates a ShadowGenerator object.
  94834. * A ShadowGenerator is the required tool to use the shadows.
  94835. * Each light casting shadows needs to use its own ShadowGenerator.
  94836. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  94837. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  94838. * @param light The light object generating the shadows.
  94839. * @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.
  94840. */
  94841. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  94842. protected _initializeGenerator(): void;
  94843. protected _createTargetRenderTexture(): void;
  94844. protected _initializeShadowMap(): void;
  94845. protected _initializeBlurRTTAndPostProcesses(): void;
  94846. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  94847. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  94848. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  94849. protected _applyFilterValues(): void;
  94850. /**
  94851. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94852. * @param onCompiled Callback triggered at the and of the effects compilation
  94853. * @param options Sets of optional options forcing the compilation with different modes
  94854. */
  94855. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94856. useInstances: boolean;
  94857. }>): void;
  94858. /**
  94859. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94860. * @param options Sets of optional options forcing the compilation with different modes
  94861. * @returns A promise that resolves when the compilation completes
  94862. */
  94863. forceCompilationAsync(options?: Partial<{
  94864. useInstances: boolean;
  94865. }>): Promise<void>;
  94866. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  94867. private _prepareShadowDefines;
  94868. /**
  94869. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94870. * @param subMesh The submesh we want to render in the shadow map
  94871. * @param useInstances Defines wether will draw in the map using instances
  94872. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94873. * @returns true if ready otherwise, false
  94874. */
  94875. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94876. /**
  94877. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94878. * @param defines Defines of the material we want to update
  94879. * @param lightIndex Index of the light in the enabled light list of the material
  94880. */
  94881. prepareDefines(defines: any, lightIndex: number): void;
  94882. /**
  94883. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94884. * defined in the generator but impacting the effect).
  94885. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94886. * @param effect The effect we are binfing the information for
  94887. */
  94888. bindShadowLight(lightIndex: string, effect: Effect): void;
  94889. /**
  94890. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94891. * (eq to shadow prjection matrix * light transform matrix)
  94892. * @returns The transform matrix used to create the shadow map
  94893. */
  94894. getTransformMatrix(): Matrix;
  94895. /**
  94896. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94897. * Cube and 2D textures for instance.
  94898. */
  94899. recreateShadowMap(): void;
  94900. protected _disposeBlurPostProcesses(): void;
  94901. protected _disposeRTTandPostProcesses(): void;
  94902. /**
  94903. * Disposes the ShadowGenerator.
  94904. * Returns nothing.
  94905. */
  94906. dispose(): void;
  94907. /**
  94908. * Serializes the shadow generator setup to a json object.
  94909. * @returns The serialized JSON object
  94910. */
  94911. serialize(): any;
  94912. /**
  94913. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  94914. * @param parsedShadowGenerator The JSON object to parse
  94915. * @param scene The scene to create the shadow map for
  94916. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  94917. * @returns The parsed shadow generator
  94918. */
  94919. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  94920. }
  94921. }
  94922. declare module BABYLON {
  94923. /**
  94924. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  94925. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  94926. * 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.
  94927. */
  94928. export abstract class Light extends Node {
  94929. /**
  94930. * Falloff Default: light is falling off following the material specification:
  94931. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  94932. */
  94933. static readonly FALLOFF_DEFAULT: number;
  94934. /**
  94935. * Falloff Physical: light is falling off following the inverse squared distance law.
  94936. */
  94937. static readonly FALLOFF_PHYSICAL: number;
  94938. /**
  94939. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  94940. * to enhance interoperability with other engines.
  94941. */
  94942. static readonly FALLOFF_GLTF: number;
  94943. /**
  94944. * Falloff Standard: light is falling off like in the standard material
  94945. * to enhance interoperability with other materials.
  94946. */
  94947. static readonly FALLOFF_STANDARD: number;
  94948. /**
  94949. * If every light affecting the material is in this lightmapMode,
  94950. * material.lightmapTexture adds or multiplies
  94951. * (depends on material.useLightmapAsShadowmap)
  94952. * after every other light calculations.
  94953. */
  94954. static readonly LIGHTMAP_DEFAULT: number;
  94955. /**
  94956. * material.lightmapTexture as only diffuse lighting from this light
  94957. * adds only specular lighting from this light
  94958. * adds dynamic shadows
  94959. */
  94960. static readonly LIGHTMAP_SPECULAR: number;
  94961. /**
  94962. * material.lightmapTexture as only lighting
  94963. * no light calculation from this light
  94964. * only adds dynamic shadows from this light
  94965. */
  94966. static readonly LIGHTMAP_SHADOWSONLY: number;
  94967. /**
  94968. * Each light type uses the default quantity according to its type:
  94969. * point/spot lights use luminous intensity
  94970. * directional lights use illuminance
  94971. */
  94972. static readonly INTENSITYMODE_AUTOMATIC: number;
  94973. /**
  94974. * lumen (lm)
  94975. */
  94976. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  94977. /**
  94978. * candela (lm/sr)
  94979. */
  94980. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  94981. /**
  94982. * lux (lm/m^2)
  94983. */
  94984. static readonly INTENSITYMODE_ILLUMINANCE: number;
  94985. /**
  94986. * nit (cd/m^2)
  94987. */
  94988. static readonly INTENSITYMODE_LUMINANCE: number;
  94989. /**
  94990. * Light type const id of the point light.
  94991. */
  94992. static readonly LIGHTTYPEID_POINTLIGHT: number;
  94993. /**
  94994. * Light type const id of the directional light.
  94995. */
  94996. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  94997. /**
  94998. * Light type const id of the spot light.
  94999. */
  95000. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  95001. /**
  95002. * Light type const id of the hemispheric light.
  95003. */
  95004. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  95005. /**
  95006. * Diffuse gives the basic color to an object.
  95007. */
  95008. diffuse: Color3;
  95009. /**
  95010. * Specular produces a highlight color on an object.
  95011. * Note: This is note affecting PBR materials.
  95012. */
  95013. specular: Color3;
  95014. /**
  95015. * Defines the falloff type for this light. This lets overrriding how punctual light are
  95016. * falling off base on range or angle.
  95017. * This can be set to any values in Light.FALLOFF_x.
  95018. *
  95019. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  95020. * other types of materials.
  95021. */
  95022. falloffType: number;
  95023. /**
  95024. * Strength of the light.
  95025. * Note: By default it is define in the framework own unit.
  95026. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  95027. */
  95028. intensity: number;
  95029. private _range;
  95030. protected _inverseSquaredRange: number;
  95031. /**
  95032. * Defines how far from the source the light is impacting in scene units.
  95033. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95034. */
  95035. get range(): number;
  95036. /**
  95037. * Defines how far from the source the light is impacting in scene units.
  95038. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95039. */
  95040. set range(value: number);
  95041. /**
  95042. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  95043. * of light.
  95044. */
  95045. private _photometricScale;
  95046. private _intensityMode;
  95047. /**
  95048. * Gets the photometric scale used to interpret the intensity.
  95049. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95050. */
  95051. get intensityMode(): number;
  95052. /**
  95053. * Sets the photometric scale used to interpret the intensity.
  95054. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95055. */
  95056. set intensityMode(value: number);
  95057. private _radius;
  95058. /**
  95059. * Gets the light radius used by PBR Materials to simulate soft area lights.
  95060. */
  95061. get radius(): number;
  95062. /**
  95063. * sets the light radius used by PBR Materials to simulate soft area lights.
  95064. */
  95065. set radius(value: number);
  95066. private _renderPriority;
  95067. /**
  95068. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  95069. * exceeding the number allowed of the materials.
  95070. */
  95071. renderPriority: number;
  95072. private _shadowEnabled;
  95073. /**
  95074. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95075. * the current shadow generator.
  95076. */
  95077. get shadowEnabled(): boolean;
  95078. /**
  95079. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95080. * the current shadow generator.
  95081. */
  95082. set shadowEnabled(value: boolean);
  95083. private _includedOnlyMeshes;
  95084. /**
  95085. * Gets the only meshes impacted by this light.
  95086. */
  95087. get includedOnlyMeshes(): AbstractMesh[];
  95088. /**
  95089. * Sets the only meshes impacted by this light.
  95090. */
  95091. set includedOnlyMeshes(value: AbstractMesh[]);
  95092. private _excludedMeshes;
  95093. /**
  95094. * Gets the meshes not impacted by this light.
  95095. */
  95096. get excludedMeshes(): AbstractMesh[];
  95097. /**
  95098. * Sets the meshes not impacted by this light.
  95099. */
  95100. set excludedMeshes(value: AbstractMesh[]);
  95101. private _excludeWithLayerMask;
  95102. /**
  95103. * Gets the layer id use to find what meshes are not impacted by the light.
  95104. * Inactive if 0
  95105. */
  95106. get excludeWithLayerMask(): number;
  95107. /**
  95108. * Sets the layer id use to find what meshes are not impacted by the light.
  95109. * Inactive if 0
  95110. */
  95111. set excludeWithLayerMask(value: number);
  95112. private _includeOnlyWithLayerMask;
  95113. /**
  95114. * Gets the layer id use to find what meshes are impacted by the light.
  95115. * Inactive if 0
  95116. */
  95117. get includeOnlyWithLayerMask(): number;
  95118. /**
  95119. * Sets the layer id use to find what meshes are impacted by the light.
  95120. * Inactive if 0
  95121. */
  95122. set includeOnlyWithLayerMask(value: number);
  95123. private _lightmapMode;
  95124. /**
  95125. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95126. */
  95127. get lightmapMode(): number;
  95128. /**
  95129. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95130. */
  95131. set lightmapMode(value: number);
  95132. /**
  95133. * Shadow generator associted to the light.
  95134. * @hidden Internal use only.
  95135. */
  95136. _shadowGenerator: Nullable<IShadowGenerator>;
  95137. /**
  95138. * @hidden Internal use only.
  95139. */
  95140. _excludedMeshesIds: string[];
  95141. /**
  95142. * @hidden Internal use only.
  95143. */
  95144. _includedOnlyMeshesIds: string[];
  95145. /**
  95146. * The current light unifom buffer.
  95147. * @hidden Internal use only.
  95148. */
  95149. _uniformBuffer: UniformBuffer;
  95150. /** @hidden */
  95151. _renderId: number;
  95152. /**
  95153. * Creates a Light object in the scene.
  95154. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95155. * @param name The firendly name of the light
  95156. * @param scene The scene the light belongs too
  95157. */
  95158. constructor(name: string, scene: Scene);
  95159. protected abstract _buildUniformLayout(): void;
  95160. /**
  95161. * Sets the passed Effect "effect" with the Light information.
  95162. * @param effect The effect to update
  95163. * @param lightIndex The index of the light in the effect to update
  95164. * @returns The light
  95165. */
  95166. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  95167. /**
  95168. * Sets the passed Effect "effect" with the Light textures.
  95169. * @param effect The effect to update
  95170. * @param lightIndex The index of the light in the effect to update
  95171. * @returns The light
  95172. */
  95173. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  95174. /**
  95175. * Binds the lights information from the scene to the effect for the given mesh.
  95176. * @param lightIndex Light index
  95177. * @param scene The scene where the light belongs to
  95178. * @param effect The effect we are binding the data to
  95179. * @param useSpecular Defines if specular is supported
  95180. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  95181. */
  95182. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  95183. /**
  95184. * Sets the passed Effect "effect" with the Light information.
  95185. * @param effect The effect to update
  95186. * @param lightDataUniformName The uniform used to store light data (position or direction)
  95187. * @returns The light
  95188. */
  95189. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  95190. /**
  95191. * Returns the string "Light".
  95192. * @returns the class name
  95193. */
  95194. getClassName(): string;
  95195. /** @hidden */
  95196. readonly _isLight: boolean;
  95197. /**
  95198. * Converts the light information to a readable string for debug purpose.
  95199. * @param fullDetails Supports for multiple levels of logging within scene loading
  95200. * @returns the human readable light info
  95201. */
  95202. toString(fullDetails?: boolean): string;
  95203. /** @hidden */
  95204. protected _syncParentEnabledState(): void;
  95205. /**
  95206. * Set the enabled state of this node.
  95207. * @param value - the new enabled state
  95208. */
  95209. setEnabled(value: boolean): void;
  95210. /**
  95211. * Returns the Light associated shadow generator if any.
  95212. * @return the associated shadow generator.
  95213. */
  95214. getShadowGenerator(): Nullable<IShadowGenerator>;
  95215. /**
  95216. * Returns a Vector3, the absolute light position in the World.
  95217. * @returns the world space position of the light
  95218. */
  95219. getAbsolutePosition(): Vector3;
  95220. /**
  95221. * Specifies if the light will affect the passed mesh.
  95222. * @param mesh The mesh to test against the light
  95223. * @return true the mesh is affected otherwise, false.
  95224. */
  95225. canAffectMesh(mesh: AbstractMesh): boolean;
  95226. /**
  95227. * Sort function to order lights for rendering.
  95228. * @param a First Light object to compare to second.
  95229. * @param b Second Light object to compare first.
  95230. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  95231. */
  95232. static CompareLightsPriority(a: Light, b: Light): number;
  95233. /**
  95234. * Releases resources associated with this node.
  95235. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95236. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95237. */
  95238. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95239. /**
  95240. * Returns the light type ID (integer).
  95241. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95242. */
  95243. getTypeID(): number;
  95244. /**
  95245. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  95246. * @returns the scaled intensity in intensity mode unit
  95247. */
  95248. getScaledIntensity(): number;
  95249. /**
  95250. * Returns a new Light object, named "name", from the current one.
  95251. * @param name The name of the cloned light
  95252. * @param newParent The parent of this light, if it has one
  95253. * @returns the new created light
  95254. */
  95255. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  95256. /**
  95257. * Serializes the current light into a Serialization object.
  95258. * @returns the serialized object.
  95259. */
  95260. serialize(): any;
  95261. /**
  95262. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  95263. * This new light is named "name" and added to the passed scene.
  95264. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  95265. * @param name The friendly name of the light
  95266. * @param scene The scene the new light will belong to
  95267. * @returns the constructor function
  95268. */
  95269. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  95270. /**
  95271. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  95272. * @param parsedLight The JSON representation of the light
  95273. * @param scene The scene to create the parsed light in
  95274. * @returns the created light after parsing
  95275. */
  95276. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  95277. private _hookArrayForExcluded;
  95278. private _hookArrayForIncludedOnly;
  95279. private _resyncMeshes;
  95280. /**
  95281. * Forces the meshes to update their light related information in their rendering used effects
  95282. * @hidden Internal Use Only
  95283. */
  95284. _markMeshesAsLightDirty(): void;
  95285. /**
  95286. * Recomputes the cached photometric scale if needed.
  95287. */
  95288. private _computePhotometricScale;
  95289. /**
  95290. * Returns the Photometric Scale according to the light type and intensity mode.
  95291. */
  95292. private _getPhotometricScale;
  95293. /**
  95294. * Reorder the light in the scene according to their defined priority.
  95295. * @hidden Internal Use Only
  95296. */
  95297. _reorderLightsInScene(): void;
  95298. /**
  95299. * Prepares the list of defines specific to the light type.
  95300. * @param defines the list of defines
  95301. * @param lightIndex defines the index of the light for the effect
  95302. */
  95303. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95304. }
  95305. }
  95306. declare module BABYLON {
  95307. /**
  95308. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95309. * This is the base of the follow, arc rotate cameras and Free camera
  95310. * @see http://doc.babylonjs.com/features/cameras
  95311. */
  95312. export class TargetCamera extends Camera {
  95313. private static _RigCamTransformMatrix;
  95314. private static _TargetTransformMatrix;
  95315. private static _TargetFocalPoint;
  95316. /**
  95317. * Define the current direction the camera is moving to
  95318. */
  95319. cameraDirection: Vector3;
  95320. /**
  95321. * Define the current rotation the camera is rotating to
  95322. */
  95323. cameraRotation: Vector2;
  95324. /**
  95325. * When set, the up vector of the camera will be updated by the rotation of the camera
  95326. */
  95327. updateUpVectorFromRotation: boolean;
  95328. private _tmpQuaternion;
  95329. /**
  95330. * Define the current rotation of the camera
  95331. */
  95332. rotation: Vector3;
  95333. /**
  95334. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95335. */
  95336. rotationQuaternion: Quaternion;
  95337. /**
  95338. * Define the current speed of the camera
  95339. */
  95340. speed: number;
  95341. /**
  95342. * Add constraint to the camera to prevent it to move freely in all directions and
  95343. * around all axis.
  95344. */
  95345. noRotationConstraint: boolean;
  95346. /**
  95347. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95348. * panning
  95349. */
  95350. invertRotation: boolean;
  95351. /**
  95352. * Speed multiplier for inverse camera panning
  95353. */
  95354. inverseRotationSpeed: number;
  95355. /**
  95356. * Define the current target of the camera as an object or a position.
  95357. */
  95358. lockedTarget: any;
  95359. /** @hidden */
  95360. _currentTarget: Vector3;
  95361. /** @hidden */
  95362. _initialFocalDistance: number;
  95363. /** @hidden */
  95364. _viewMatrix: Matrix;
  95365. /** @hidden */
  95366. _camMatrix: Matrix;
  95367. /** @hidden */
  95368. _cameraTransformMatrix: Matrix;
  95369. /** @hidden */
  95370. _cameraRotationMatrix: Matrix;
  95371. /** @hidden */
  95372. _referencePoint: Vector3;
  95373. /** @hidden */
  95374. _transformedReferencePoint: Vector3;
  95375. protected _globalCurrentTarget: Vector3;
  95376. protected _globalCurrentUpVector: Vector3;
  95377. /** @hidden */
  95378. _reset: () => void;
  95379. private _defaultUp;
  95380. /**
  95381. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95382. * This is the base of the follow, arc rotate cameras and Free camera
  95383. * @see http://doc.babylonjs.com/features/cameras
  95384. * @param name Defines the name of the camera in the scene
  95385. * @param position Defines the start position of the camera in the scene
  95386. * @param scene Defines the scene the camera belongs to
  95387. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95388. */
  95389. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95390. /**
  95391. * Gets the position in front of the camera at a given distance.
  95392. * @param distance The distance from the camera we want the position to be
  95393. * @returns the position
  95394. */
  95395. getFrontPosition(distance: number): Vector3;
  95396. /** @hidden */
  95397. _getLockedTargetPosition(): Nullable<Vector3>;
  95398. private _storedPosition;
  95399. private _storedRotation;
  95400. private _storedRotationQuaternion;
  95401. /**
  95402. * Store current camera state of the camera (fov, position, rotation, etc..)
  95403. * @returns the camera
  95404. */
  95405. storeState(): Camera;
  95406. /**
  95407. * Restored camera state. You must call storeState() first
  95408. * @returns whether it was successful or not
  95409. * @hidden
  95410. */
  95411. _restoreStateValues(): boolean;
  95412. /** @hidden */
  95413. _initCache(): void;
  95414. /** @hidden */
  95415. _updateCache(ignoreParentClass?: boolean): void;
  95416. /** @hidden */
  95417. _isSynchronizedViewMatrix(): boolean;
  95418. /** @hidden */
  95419. _computeLocalCameraSpeed(): number;
  95420. /**
  95421. * Defines the target the camera should look at.
  95422. * @param target Defines the new target as a Vector or a mesh
  95423. */
  95424. setTarget(target: Vector3): void;
  95425. /**
  95426. * Return the current target position of the camera. This value is expressed in local space.
  95427. * @returns the target position
  95428. */
  95429. getTarget(): Vector3;
  95430. /** @hidden */
  95431. _decideIfNeedsToMove(): boolean;
  95432. /** @hidden */
  95433. _updatePosition(): void;
  95434. /** @hidden */
  95435. _checkInputs(): void;
  95436. protected _updateCameraRotationMatrix(): void;
  95437. /**
  95438. * 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)
  95439. * @returns the current camera
  95440. */
  95441. private _rotateUpVectorWithCameraRotationMatrix;
  95442. private _cachedRotationZ;
  95443. private _cachedQuaternionRotationZ;
  95444. /** @hidden */
  95445. _getViewMatrix(): Matrix;
  95446. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  95447. /**
  95448. * @hidden
  95449. */
  95450. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  95451. /**
  95452. * @hidden
  95453. */
  95454. _updateRigCameras(): void;
  95455. private _getRigCamPositionAndTarget;
  95456. /**
  95457. * Gets the current object class name.
  95458. * @return the class name
  95459. */
  95460. getClassName(): string;
  95461. }
  95462. }
  95463. declare module BABYLON {
  95464. /**
  95465. * Gather the list of keyboard event types as constants.
  95466. */
  95467. export class KeyboardEventTypes {
  95468. /**
  95469. * The keydown event is fired when a key becomes active (pressed).
  95470. */
  95471. static readonly KEYDOWN: number;
  95472. /**
  95473. * The keyup event is fired when a key has been released.
  95474. */
  95475. static readonly KEYUP: number;
  95476. }
  95477. /**
  95478. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95479. */
  95480. export class KeyboardInfo {
  95481. /**
  95482. * Defines the type of event (KeyboardEventTypes)
  95483. */
  95484. type: number;
  95485. /**
  95486. * Defines the related dom event
  95487. */
  95488. event: KeyboardEvent;
  95489. /**
  95490. * Instantiates a new keyboard info.
  95491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95492. * @param type Defines the type of event (KeyboardEventTypes)
  95493. * @param event Defines the related dom event
  95494. */
  95495. constructor(
  95496. /**
  95497. * Defines the type of event (KeyboardEventTypes)
  95498. */
  95499. type: number,
  95500. /**
  95501. * Defines the related dom event
  95502. */
  95503. event: KeyboardEvent);
  95504. }
  95505. /**
  95506. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95507. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  95508. */
  95509. export class KeyboardInfoPre extends KeyboardInfo {
  95510. /**
  95511. * Defines the type of event (KeyboardEventTypes)
  95512. */
  95513. type: number;
  95514. /**
  95515. * Defines the related dom event
  95516. */
  95517. event: KeyboardEvent;
  95518. /**
  95519. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  95520. */
  95521. skipOnPointerObservable: boolean;
  95522. /**
  95523. * Instantiates a new keyboard pre info.
  95524. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95525. * @param type Defines the type of event (KeyboardEventTypes)
  95526. * @param event Defines the related dom event
  95527. */
  95528. constructor(
  95529. /**
  95530. * Defines the type of event (KeyboardEventTypes)
  95531. */
  95532. type: number,
  95533. /**
  95534. * Defines the related dom event
  95535. */
  95536. event: KeyboardEvent);
  95537. }
  95538. }
  95539. declare module BABYLON {
  95540. /**
  95541. * Manage the keyboard inputs to control the movement of a free camera.
  95542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95543. */
  95544. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  95545. /**
  95546. * Defines the camera the input is attached to.
  95547. */
  95548. camera: FreeCamera;
  95549. /**
  95550. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95551. */
  95552. keysUp: number[];
  95553. /**
  95554. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95555. */
  95556. keysUpward: number[];
  95557. /**
  95558. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95559. */
  95560. keysDown: number[];
  95561. /**
  95562. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95563. */
  95564. keysDownward: number[];
  95565. /**
  95566. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95567. */
  95568. keysLeft: number[];
  95569. /**
  95570. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95571. */
  95572. keysRight: number[];
  95573. private _keys;
  95574. private _onCanvasBlurObserver;
  95575. private _onKeyboardObserver;
  95576. private _engine;
  95577. private _scene;
  95578. /**
  95579. * Attach the input controls to a specific dom element to get the input from.
  95580. * @param element Defines the element the controls should be listened from
  95581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95582. */
  95583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95584. /**
  95585. * Detach the current controls from the specified dom element.
  95586. * @param element Defines the element to stop listening the inputs from
  95587. */
  95588. detachControl(element: Nullable<HTMLElement>): void;
  95589. /**
  95590. * Update the current camera state depending on the inputs that have been used this frame.
  95591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95592. */
  95593. checkInputs(): void;
  95594. /**
  95595. * Gets the class name of the current intput.
  95596. * @returns the class name
  95597. */
  95598. getClassName(): string;
  95599. /** @hidden */
  95600. _onLostFocus(): void;
  95601. /**
  95602. * Get the friendly name associated with the input class.
  95603. * @returns the input friendly name
  95604. */
  95605. getSimpleName(): string;
  95606. }
  95607. }
  95608. declare module BABYLON {
  95609. /**
  95610. * Gather the list of pointer event types as constants.
  95611. */
  95612. export class PointerEventTypes {
  95613. /**
  95614. * 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.
  95615. */
  95616. static readonly POINTERDOWN: number;
  95617. /**
  95618. * The pointerup event is fired when a pointer is no longer active.
  95619. */
  95620. static readonly POINTERUP: number;
  95621. /**
  95622. * The pointermove event is fired when a pointer changes coordinates.
  95623. */
  95624. static readonly POINTERMOVE: number;
  95625. /**
  95626. * The pointerwheel event is fired when a mouse wheel has been rotated.
  95627. */
  95628. static readonly POINTERWHEEL: number;
  95629. /**
  95630. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  95631. */
  95632. static readonly POINTERPICK: number;
  95633. /**
  95634. * The pointertap event is fired when a the object has been touched and released without drag.
  95635. */
  95636. static readonly POINTERTAP: number;
  95637. /**
  95638. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  95639. */
  95640. static readonly POINTERDOUBLETAP: number;
  95641. }
  95642. /**
  95643. * Base class of pointer info types.
  95644. */
  95645. export class PointerInfoBase {
  95646. /**
  95647. * Defines the type of event (PointerEventTypes)
  95648. */
  95649. type: number;
  95650. /**
  95651. * Defines the related dom event
  95652. */
  95653. event: PointerEvent | MouseWheelEvent;
  95654. /**
  95655. * Instantiates the base class of pointers info.
  95656. * @param type Defines the type of event (PointerEventTypes)
  95657. * @param event Defines the related dom event
  95658. */
  95659. constructor(
  95660. /**
  95661. * Defines the type of event (PointerEventTypes)
  95662. */
  95663. type: number,
  95664. /**
  95665. * Defines the related dom event
  95666. */
  95667. event: PointerEvent | MouseWheelEvent);
  95668. }
  95669. /**
  95670. * This class is used to store pointer related info for the onPrePointerObservable event.
  95671. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  95672. */
  95673. export class PointerInfoPre extends PointerInfoBase {
  95674. /**
  95675. * Ray from a pointer if availible (eg. 6dof controller)
  95676. */
  95677. ray: Nullable<Ray>;
  95678. /**
  95679. * Defines the local position of the pointer on the canvas.
  95680. */
  95681. localPosition: Vector2;
  95682. /**
  95683. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  95684. */
  95685. skipOnPointerObservable: boolean;
  95686. /**
  95687. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  95688. * @param type Defines the type of event (PointerEventTypes)
  95689. * @param event Defines the related dom event
  95690. * @param localX Defines the local x coordinates of the pointer when the event occured
  95691. * @param localY Defines the local y coordinates of the pointer when the event occured
  95692. */
  95693. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  95694. }
  95695. /**
  95696. * This type contains all the data related to a pointer event in Babylon.js.
  95697. * 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.
  95698. */
  95699. export class PointerInfo extends PointerInfoBase {
  95700. /**
  95701. * Defines the picking info associated to the info (if any)\
  95702. */
  95703. pickInfo: Nullable<PickingInfo>;
  95704. /**
  95705. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  95706. * @param type Defines the type of event (PointerEventTypes)
  95707. * @param event Defines the related dom event
  95708. * @param pickInfo Defines the picking info associated to the info (if any)\
  95709. */
  95710. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  95711. /**
  95712. * Defines the picking info associated to the info (if any)\
  95713. */
  95714. pickInfo: Nullable<PickingInfo>);
  95715. }
  95716. /**
  95717. * Data relating to a touch event on the screen.
  95718. */
  95719. export interface PointerTouch {
  95720. /**
  95721. * X coordinate of touch.
  95722. */
  95723. x: number;
  95724. /**
  95725. * Y coordinate of touch.
  95726. */
  95727. y: number;
  95728. /**
  95729. * Id of touch. Unique for each finger.
  95730. */
  95731. pointerId: number;
  95732. /**
  95733. * Event type passed from DOM.
  95734. */
  95735. type: any;
  95736. }
  95737. }
  95738. declare module BABYLON {
  95739. /**
  95740. * Manage the mouse inputs to control the movement of a free camera.
  95741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95742. */
  95743. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  95744. /**
  95745. * Define if touch is enabled in the mouse input
  95746. */
  95747. touchEnabled: boolean;
  95748. /**
  95749. * Defines the camera the input is attached to.
  95750. */
  95751. camera: FreeCamera;
  95752. /**
  95753. * Defines the buttons associated with the input to handle camera move.
  95754. */
  95755. buttons: number[];
  95756. /**
  95757. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  95758. */
  95759. angularSensibility: number;
  95760. private _pointerInput;
  95761. private _onMouseMove;
  95762. private _observer;
  95763. private previousPosition;
  95764. /**
  95765. * Observable for when a pointer move event occurs containing the move offset
  95766. */
  95767. onPointerMovedObservable: Observable<{
  95768. offsetX: number;
  95769. offsetY: number;
  95770. }>;
  95771. /**
  95772. * @hidden
  95773. * If the camera should be rotated automatically based on pointer movement
  95774. */
  95775. _allowCameraRotation: boolean;
  95776. /**
  95777. * Manage the mouse inputs to control the movement of a free camera.
  95778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95779. * @param touchEnabled Defines if touch is enabled or not
  95780. */
  95781. constructor(
  95782. /**
  95783. * Define if touch is enabled in the mouse input
  95784. */
  95785. touchEnabled?: boolean);
  95786. /**
  95787. * Attach the input controls to a specific dom element to get the input from.
  95788. * @param element Defines the element the controls should be listened from
  95789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95790. */
  95791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95792. /**
  95793. * Called on JS contextmenu event.
  95794. * Override this method to provide functionality.
  95795. */
  95796. protected onContextMenu(evt: PointerEvent): void;
  95797. /**
  95798. * Detach the current controls from the specified dom element.
  95799. * @param element Defines the element to stop listening the inputs from
  95800. */
  95801. detachControl(element: Nullable<HTMLElement>): void;
  95802. /**
  95803. * Gets the class name of the current intput.
  95804. * @returns the class name
  95805. */
  95806. getClassName(): string;
  95807. /**
  95808. * Get the friendly name associated with the input class.
  95809. * @returns the input friendly name
  95810. */
  95811. getSimpleName(): string;
  95812. }
  95813. }
  95814. declare module BABYLON {
  95815. /**
  95816. * Manage the touch inputs to control the movement of a free camera.
  95817. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95818. */
  95819. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  95820. /**
  95821. * Defines the camera the input is attached to.
  95822. */
  95823. camera: FreeCamera;
  95824. /**
  95825. * Defines the touch sensibility for rotation.
  95826. * The higher the faster.
  95827. */
  95828. touchAngularSensibility: number;
  95829. /**
  95830. * Defines the touch sensibility for move.
  95831. * The higher the faster.
  95832. */
  95833. touchMoveSensibility: number;
  95834. private _offsetX;
  95835. private _offsetY;
  95836. private _pointerPressed;
  95837. private _pointerInput;
  95838. private _observer;
  95839. private _onLostFocus;
  95840. /**
  95841. * Attach the input controls to a specific dom element to get the input from.
  95842. * @param element Defines the element the controls should be listened from
  95843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95844. */
  95845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95846. /**
  95847. * Detach the current controls from the specified dom element.
  95848. * @param element Defines the element to stop listening the inputs from
  95849. */
  95850. detachControl(element: Nullable<HTMLElement>): void;
  95851. /**
  95852. * Update the current camera state depending on the inputs that have been used this frame.
  95853. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95854. */
  95855. checkInputs(): void;
  95856. /**
  95857. * Gets the class name of the current intput.
  95858. * @returns the class name
  95859. */
  95860. getClassName(): string;
  95861. /**
  95862. * Get the friendly name associated with the input class.
  95863. * @returns the input friendly name
  95864. */
  95865. getSimpleName(): string;
  95866. }
  95867. }
  95868. declare module BABYLON {
  95869. /**
  95870. * Default Inputs manager for the FreeCamera.
  95871. * It groups all the default supported inputs for ease of use.
  95872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95873. */
  95874. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  95875. /**
  95876. * @hidden
  95877. */
  95878. _mouseInput: Nullable<FreeCameraMouseInput>;
  95879. /**
  95880. * Instantiates a new FreeCameraInputsManager.
  95881. * @param camera Defines the camera the inputs belong to
  95882. */
  95883. constructor(camera: FreeCamera);
  95884. /**
  95885. * Add keyboard input support to the input manager.
  95886. * @returns the current input manager
  95887. */
  95888. addKeyboard(): FreeCameraInputsManager;
  95889. /**
  95890. * Add mouse input support to the input manager.
  95891. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  95892. * @returns the current input manager
  95893. */
  95894. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  95895. /**
  95896. * Removes the mouse input support from the manager
  95897. * @returns the current input manager
  95898. */
  95899. removeMouse(): FreeCameraInputsManager;
  95900. /**
  95901. * Add touch input support to the input manager.
  95902. * @returns the current input manager
  95903. */
  95904. addTouch(): FreeCameraInputsManager;
  95905. /**
  95906. * Remove all attached input methods from a camera
  95907. */
  95908. clear(): void;
  95909. }
  95910. }
  95911. declare module BABYLON {
  95912. /**
  95913. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95914. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  95915. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95916. */
  95917. export class FreeCamera extends TargetCamera {
  95918. /**
  95919. * Define the collision ellipsoid of the camera.
  95920. * This is helpful to simulate a camera body like the player body around the camera
  95921. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95922. */
  95923. ellipsoid: Vector3;
  95924. /**
  95925. * Define an offset for the position of the ellipsoid around the camera.
  95926. * This can be helpful to determine the center of the body near the gravity center of the body
  95927. * instead of its head.
  95928. */
  95929. ellipsoidOffset: Vector3;
  95930. /**
  95931. * Enable or disable collisions of the camera with the rest of the scene objects.
  95932. */
  95933. checkCollisions: boolean;
  95934. /**
  95935. * Enable or disable gravity on the camera.
  95936. */
  95937. applyGravity: boolean;
  95938. /**
  95939. * Define the input manager associated to the camera.
  95940. */
  95941. inputs: FreeCameraInputsManager;
  95942. /**
  95943. * Gets the input sensibility for a mouse input. (default is 2000.0)
  95944. * Higher values reduce sensitivity.
  95945. */
  95946. get angularSensibility(): number;
  95947. /**
  95948. * Sets the input sensibility for a mouse input. (default is 2000.0)
  95949. * Higher values reduce sensitivity.
  95950. */
  95951. set angularSensibility(value: number);
  95952. /**
  95953. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95954. */
  95955. get keysUp(): number[];
  95956. set keysUp(value: number[]);
  95957. /**
  95958. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95959. */
  95960. get keysUpward(): number[];
  95961. set keysUpward(value: number[]);
  95962. /**
  95963. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95964. */
  95965. get keysDown(): number[];
  95966. set keysDown(value: number[]);
  95967. /**
  95968. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95969. */
  95970. get keysDownward(): number[];
  95971. set keysDownward(value: number[]);
  95972. /**
  95973. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95974. */
  95975. get keysLeft(): number[];
  95976. set keysLeft(value: number[]);
  95977. /**
  95978. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95979. */
  95980. get keysRight(): number[];
  95981. set keysRight(value: number[]);
  95982. /**
  95983. * Event raised when the camera collide with a mesh in the scene.
  95984. */
  95985. onCollide: (collidedMesh: AbstractMesh) => void;
  95986. private _collider;
  95987. private _needMoveForGravity;
  95988. private _oldPosition;
  95989. private _diffPosition;
  95990. private _newPosition;
  95991. /** @hidden */
  95992. _localDirection: Vector3;
  95993. /** @hidden */
  95994. _transformedDirection: Vector3;
  95995. /**
  95996. * Instantiates a Free Camera.
  95997. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95998. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  95999. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96000. * @param name Define the name of the camera in the scene
  96001. * @param position Define the start position of the camera in the scene
  96002. * @param scene Define the scene the camera belongs to
  96003. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96004. */
  96005. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96006. /**
  96007. * Attached controls to the current camera.
  96008. * @param element Defines the element the controls should be listened from
  96009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96010. */
  96011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96012. /**
  96013. * Detach the current controls from the camera.
  96014. * The camera will stop reacting to inputs.
  96015. * @param element Defines the element to stop listening the inputs from
  96016. */
  96017. detachControl(element: HTMLElement): void;
  96018. private _collisionMask;
  96019. /**
  96020. * Define a collision mask to limit the list of object the camera can collide with
  96021. */
  96022. get collisionMask(): number;
  96023. set collisionMask(mask: number);
  96024. /** @hidden */
  96025. _collideWithWorld(displacement: Vector3): void;
  96026. private _onCollisionPositionChange;
  96027. /** @hidden */
  96028. _checkInputs(): void;
  96029. /** @hidden */
  96030. _decideIfNeedsToMove(): boolean;
  96031. /** @hidden */
  96032. _updatePosition(): void;
  96033. /**
  96034. * Destroy the camera and release the current resources hold by it.
  96035. */
  96036. dispose(): void;
  96037. /**
  96038. * Gets the current object class name.
  96039. * @return the class name
  96040. */
  96041. getClassName(): string;
  96042. }
  96043. }
  96044. declare module BABYLON {
  96045. /**
  96046. * Represents a gamepad control stick position
  96047. */
  96048. export class StickValues {
  96049. /**
  96050. * The x component of the control stick
  96051. */
  96052. x: number;
  96053. /**
  96054. * The y component of the control stick
  96055. */
  96056. y: number;
  96057. /**
  96058. * Initializes the gamepad x and y control stick values
  96059. * @param x The x component of the gamepad control stick value
  96060. * @param y The y component of the gamepad control stick value
  96061. */
  96062. constructor(
  96063. /**
  96064. * The x component of the control stick
  96065. */
  96066. x: number,
  96067. /**
  96068. * The y component of the control stick
  96069. */
  96070. y: number);
  96071. }
  96072. /**
  96073. * An interface which manages callbacks for gamepad button changes
  96074. */
  96075. export interface GamepadButtonChanges {
  96076. /**
  96077. * Called when a gamepad has been changed
  96078. */
  96079. changed: boolean;
  96080. /**
  96081. * Called when a gamepad press event has been triggered
  96082. */
  96083. pressChanged: boolean;
  96084. /**
  96085. * Called when a touch event has been triggered
  96086. */
  96087. touchChanged: boolean;
  96088. /**
  96089. * Called when a value has changed
  96090. */
  96091. valueChanged: boolean;
  96092. }
  96093. /**
  96094. * Represents a gamepad
  96095. */
  96096. export class Gamepad {
  96097. /**
  96098. * The id of the gamepad
  96099. */
  96100. id: string;
  96101. /**
  96102. * The index of the gamepad
  96103. */
  96104. index: number;
  96105. /**
  96106. * The browser gamepad
  96107. */
  96108. browserGamepad: any;
  96109. /**
  96110. * Specifies what type of gamepad this represents
  96111. */
  96112. type: number;
  96113. private _leftStick;
  96114. private _rightStick;
  96115. /** @hidden */
  96116. _isConnected: boolean;
  96117. private _leftStickAxisX;
  96118. private _leftStickAxisY;
  96119. private _rightStickAxisX;
  96120. private _rightStickAxisY;
  96121. /**
  96122. * Triggered when the left control stick has been changed
  96123. */
  96124. private _onleftstickchanged;
  96125. /**
  96126. * Triggered when the right control stick has been changed
  96127. */
  96128. private _onrightstickchanged;
  96129. /**
  96130. * Represents a gamepad controller
  96131. */
  96132. static GAMEPAD: number;
  96133. /**
  96134. * Represents a generic controller
  96135. */
  96136. static GENERIC: number;
  96137. /**
  96138. * Represents an XBox controller
  96139. */
  96140. static XBOX: number;
  96141. /**
  96142. * Represents a pose-enabled controller
  96143. */
  96144. static POSE_ENABLED: number;
  96145. /**
  96146. * Represents an Dual Shock controller
  96147. */
  96148. static DUALSHOCK: number;
  96149. /**
  96150. * Specifies whether the left control stick should be Y-inverted
  96151. */
  96152. protected _invertLeftStickY: boolean;
  96153. /**
  96154. * Specifies if the gamepad has been connected
  96155. */
  96156. get isConnected(): boolean;
  96157. /**
  96158. * Initializes the gamepad
  96159. * @param id The id of the gamepad
  96160. * @param index The index of the gamepad
  96161. * @param browserGamepad The browser gamepad
  96162. * @param leftStickX The x component of the left joystick
  96163. * @param leftStickY The y component of the left joystick
  96164. * @param rightStickX The x component of the right joystick
  96165. * @param rightStickY The y component of the right joystick
  96166. */
  96167. constructor(
  96168. /**
  96169. * The id of the gamepad
  96170. */
  96171. id: string,
  96172. /**
  96173. * The index of the gamepad
  96174. */
  96175. index: number,
  96176. /**
  96177. * The browser gamepad
  96178. */
  96179. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  96180. /**
  96181. * Callback triggered when the left joystick has changed
  96182. * @param callback
  96183. */
  96184. onleftstickchanged(callback: (values: StickValues) => void): void;
  96185. /**
  96186. * Callback triggered when the right joystick has changed
  96187. * @param callback
  96188. */
  96189. onrightstickchanged(callback: (values: StickValues) => void): void;
  96190. /**
  96191. * Gets the left joystick
  96192. */
  96193. get leftStick(): StickValues;
  96194. /**
  96195. * Sets the left joystick values
  96196. */
  96197. set leftStick(newValues: StickValues);
  96198. /**
  96199. * Gets the right joystick
  96200. */
  96201. get rightStick(): StickValues;
  96202. /**
  96203. * Sets the right joystick value
  96204. */
  96205. set rightStick(newValues: StickValues);
  96206. /**
  96207. * Updates the gamepad joystick positions
  96208. */
  96209. update(): void;
  96210. /**
  96211. * Disposes the gamepad
  96212. */
  96213. dispose(): void;
  96214. }
  96215. /**
  96216. * Represents a generic gamepad
  96217. */
  96218. export class GenericPad extends Gamepad {
  96219. private _buttons;
  96220. private _onbuttondown;
  96221. private _onbuttonup;
  96222. /**
  96223. * Observable triggered when a button has been pressed
  96224. */
  96225. onButtonDownObservable: Observable<number>;
  96226. /**
  96227. * Observable triggered when a button has been released
  96228. */
  96229. onButtonUpObservable: Observable<number>;
  96230. /**
  96231. * Callback triggered when a button has been pressed
  96232. * @param callback Called when a button has been pressed
  96233. */
  96234. onbuttondown(callback: (buttonPressed: number) => void): void;
  96235. /**
  96236. * Callback triggered when a button has been released
  96237. * @param callback Called when a button has been released
  96238. */
  96239. onbuttonup(callback: (buttonReleased: number) => void): void;
  96240. /**
  96241. * Initializes the generic gamepad
  96242. * @param id The id of the generic gamepad
  96243. * @param index The index of the generic gamepad
  96244. * @param browserGamepad The browser gamepad
  96245. */
  96246. constructor(id: string, index: number, browserGamepad: any);
  96247. private _setButtonValue;
  96248. /**
  96249. * Updates the generic gamepad
  96250. */
  96251. update(): void;
  96252. /**
  96253. * Disposes the generic gamepad
  96254. */
  96255. dispose(): void;
  96256. }
  96257. }
  96258. declare module BABYLON {
  96259. /**
  96260. * Defines the types of pose enabled controllers that are supported
  96261. */
  96262. export enum PoseEnabledControllerType {
  96263. /**
  96264. * HTC Vive
  96265. */
  96266. VIVE = 0,
  96267. /**
  96268. * Oculus Rift
  96269. */
  96270. OCULUS = 1,
  96271. /**
  96272. * Windows mixed reality
  96273. */
  96274. WINDOWS = 2,
  96275. /**
  96276. * Samsung gear VR
  96277. */
  96278. GEAR_VR = 3,
  96279. /**
  96280. * Google Daydream
  96281. */
  96282. DAYDREAM = 4,
  96283. /**
  96284. * Generic
  96285. */
  96286. GENERIC = 5
  96287. }
  96288. /**
  96289. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96290. */
  96291. export interface MutableGamepadButton {
  96292. /**
  96293. * Value of the button/trigger
  96294. */
  96295. value: number;
  96296. /**
  96297. * If the button/trigger is currently touched
  96298. */
  96299. touched: boolean;
  96300. /**
  96301. * If the button/trigger is currently pressed
  96302. */
  96303. pressed: boolean;
  96304. }
  96305. /**
  96306. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96307. * @hidden
  96308. */
  96309. export interface ExtendedGamepadButton extends GamepadButton {
  96310. /**
  96311. * If the button/trigger is currently pressed
  96312. */
  96313. readonly pressed: boolean;
  96314. /**
  96315. * If the button/trigger is currently touched
  96316. */
  96317. readonly touched: boolean;
  96318. /**
  96319. * Value of the button/trigger
  96320. */
  96321. readonly value: number;
  96322. }
  96323. /** @hidden */
  96324. export interface _GamePadFactory {
  96325. /**
  96326. * Returns whether or not the current gamepad can be created for this type of controller.
  96327. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96328. * @returns true if it can be created, otherwise false
  96329. */
  96330. canCreate(gamepadInfo: any): boolean;
  96331. /**
  96332. * Creates a new instance of the Gamepad.
  96333. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96334. * @returns the new gamepad instance
  96335. */
  96336. create(gamepadInfo: any): Gamepad;
  96337. }
  96338. /**
  96339. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96340. */
  96341. export class PoseEnabledControllerHelper {
  96342. /** @hidden */
  96343. static _ControllerFactories: _GamePadFactory[];
  96344. /** @hidden */
  96345. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96346. /**
  96347. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96348. * @param vrGamepad the gamepad to initialized
  96349. * @returns a vr controller of the type the gamepad identified as
  96350. */
  96351. static InitiateController(vrGamepad: any): Gamepad;
  96352. }
  96353. /**
  96354. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96355. */
  96356. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96357. /**
  96358. * If the controller is used in a webXR session
  96359. */
  96360. isXR: boolean;
  96361. private _deviceRoomPosition;
  96362. private _deviceRoomRotationQuaternion;
  96363. /**
  96364. * The device position in babylon space
  96365. */
  96366. devicePosition: Vector3;
  96367. /**
  96368. * The device rotation in babylon space
  96369. */
  96370. deviceRotationQuaternion: Quaternion;
  96371. /**
  96372. * The scale factor of the device in babylon space
  96373. */
  96374. deviceScaleFactor: number;
  96375. /**
  96376. * (Likely devicePosition should be used instead) The device position in its room space
  96377. */
  96378. position: Vector3;
  96379. /**
  96380. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96381. */
  96382. rotationQuaternion: Quaternion;
  96383. /**
  96384. * The type of controller (Eg. Windows mixed reality)
  96385. */
  96386. controllerType: PoseEnabledControllerType;
  96387. protected _calculatedPosition: Vector3;
  96388. private _calculatedRotation;
  96389. /**
  96390. * The raw pose from the device
  96391. */
  96392. rawPose: DevicePose;
  96393. private _trackPosition;
  96394. private _maxRotationDistFromHeadset;
  96395. private _draggedRoomRotation;
  96396. /**
  96397. * @hidden
  96398. */
  96399. _disableTrackPosition(fixedPosition: Vector3): void;
  96400. /**
  96401. * Internal, the mesh attached to the controller
  96402. * @hidden
  96403. */
  96404. _mesh: Nullable<AbstractMesh>;
  96405. private _poseControlledCamera;
  96406. private _leftHandSystemQuaternion;
  96407. /**
  96408. * Internal, matrix used to convert room space to babylon space
  96409. * @hidden
  96410. */
  96411. _deviceToWorld: Matrix;
  96412. /**
  96413. * Node to be used when casting a ray from the controller
  96414. * @hidden
  96415. */
  96416. _pointingPoseNode: Nullable<TransformNode>;
  96417. /**
  96418. * Name of the child mesh that can be used to cast a ray from the controller
  96419. */
  96420. static readonly POINTING_POSE: string;
  96421. /**
  96422. * Creates a new PoseEnabledController from a gamepad
  96423. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  96424. */
  96425. constructor(browserGamepad: any);
  96426. private _workingMatrix;
  96427. /**
  96428. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  96429. */
  96430. update(): void;
  96431. /**
  96432. * Updates only the pose device and mesh without doing any button event checking
  96433. */
  96434. protected _updatePoseAndMesh(): void;
  96435. /**
  96436. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  96437. * @param poseData raw pose fromthe device
  96438. */
  96439. updateFromDevice(poseData: DevicePose): void;
  96440. /**
  96441. * @hidden
  96442. */
  96443. _meshAttachedObservable: Observable<AbstractMesh>;
  96444. /**
  96445. * Attaches a mesh to the controller
  96446. * @param mesh the mesh to be attached
  96447. */
  96448. attachToMesh(mesh: AbstractMesh): void;
  96449. /**
  96450. * Attaches the controllers mesh to a camera
  96451. * @param camera the camera the mesh should be attached to
  96452. */
  96453. attachToPoseControlledCamera(camera: TargetCamera): void;
  96454. /**
  96455. * Disposes of the controller
  96456. */
  96457. dispose(): void;
  96458. /**
  96459. * The mesh that is attached to the controller
  96460. */
  96461. get mesh(): Nullable<AbstractMesh>;
  96462. /**
  96463. * Gets the ray of the controller in the direction the controller is pointing
  96464. * @param length the length the resulting ray should be
  96465. * @returns a ray in the direction the controller is pointing
  96466. */
  96467. getForwardRay(length?: number): Ray;
  96468. }
  96469. }
  96470. declare module BABYLON {
  96471. /**
  96472. * Defines the WebVRController object that represents controllers tracked in 3D space
  96473. */
  96474. export abstract class WebVRController extends PoseEnabledController {
  96475. /**
  96476. * Internal, the default controller model for the controller
  96477. */
  96478. protected _defaultModel: Nullable<AbstractMesh>;
  96479. /**
  96480. * Fired when the trigger state has changed
  96481. */
  96482. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  96483. /**
  96484. * Fired when the main button state has changed
  96485. */
  96486. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96487. /**
  96488. * Fired when the secondary button state has changed
  96489. */
  96490. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96491. /**
  96492. * Fired when the pad state has changed
  96493. */
  96494. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  96495. /**
  96496. * Fired when controllers stick values have changed
  96497. */
  96498. onPadValuesChangedObservable: Observable<StickValues>;
  96499. /**
  96500. * Array of button availible on the controller
  96501. */
  96502. protected _buttons: Array<MutableGamepadButton>;
  96503. private _onButtonStateChange;
  96504. /**
  96505. * Fired when a controller button's state has changed
  96506. * @param callback the callback containing the button that was modified
  96507. */
  96508. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  96509. /**
  96510. * X and Y axis corresponding to the controllers joystick
  96511. */
  96512. pad: StickValues;
  96513. /**
  96514. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  96515. */
  96516. hand: string;
  96517. /**
  96518. * The default controller model for the controller
  96519. */
  96520. get defaultModel(): Nullable<AbstractMesh>;
  96521. /**
  96522. * Creates a new WebVRController from a gamepad
  96523. * @param vrGamepad the gamepad that the WebVRController should be created from
  96524. */
  96525. constructor(vrGamepad: any);
  96526. /**
  96527. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  96528. */
  96529. update(): void;
  96530. /**
  96531. * Function to be called when a button is modified
  96532. */
  96533. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  96534. /**
  96535. * Loads a mesh and attaches it to the controller
  96536. * @param scene the scene the mesh should be added to
  96537. * @param meshLoaded callback for when the mesh has been loaded
  96538. */
  96539. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  96540. private _setButtonValue;
  96541. private _changes;
  96542. private _checkChanges;
  96543. /**
  96544. * Disposes of th webVRCOntroller
  96545. */
  96546. dispose(): void;
  96547. }
  96548. }
  96549. declare module BABYLON {
  96550. /**
  96551. * The HemisphericLight simulates the ambient environment light,
  96552. * so the passed direction is the light reflection direction, not the incoming direction.
  96553. */
  96554. export class HemisphericLight extends Light {
  96555. /**
  96556. * The groundColor is the light in the opposite direction to the one specified during creation.
  96557. * 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.
  96558. */
  96559. groundColor: Color3;
  96560. /**
  96561. * The light reflection direction, not the incoming direction.
  96562. */
  96563. direction: Vector3;
  96564. /**
  96565. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  96566. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  96567. * The HemisphericLight can't cast shadows.
  96568. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96569. * @param name The friendly name of the light
  96570. * @param direction The direction of the light reflection
  96571. * @param scene The scene the light belongs to
  96572. */
  96573. constructor(name: string, direction: Vector3, scene: Scene);
  96574. protected _buildUniformLayout(): void;
  96575. /**
  96576. * Returns the string "HemisphericLight".
  96577. * @return The class name
  96578. */
  96579. getClassName(): string;
  96580. /**
  96581. * Sets the HemisphericLight direction towards the passed target (Vector3).
  96582. * Returns the updated direction.
  96583. * @param target The target the direction should point to
  96584. * @return The computed direction
  96585. */
  96586. setDirectionToTarget(target: Vector3): Vector3;
  96587. /**
  96588. * Returns the shadow generator associated to the light.
  96589. * @returns Always null for hemispheric lights because it does not support shadows.
  96590. */
  96591. getShadowGenerator(): Nullable<IShadowGenerator>;
  96592. /**
  96593. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  96594. * @param effect The effect to update
  96595. * @param lightIndex The index of the light in the effect to update
  96596. * @returns The hemispheric light
  96597. */
  96598. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  96599. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  96600. /**
  96601. * Computes the world matrix of the node
  96602. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96603. * @param useWasUpdatedFlag defines a reserved property
  96604. * @returns the world matrix
  96605. */
  96606. computeWorldMatrix(): Matrix;
  96607. /**
  96608. * Returns the integer 3.
  96609. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96610. */
  96611. getTypeID(): number;
  96612. /**
  96613. * Prepares the list of defines specific to the light type.
  96614. * @param defines the list of defines
  96615. * @param lightIndex defines the index of the light for the effect
  96616. */
  96617. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96618. }
  96619. }
  96620. declare module BABYLON {
  96621. /** @hidden */
  96622. export var vrMultiviewToSingleviewPixelShader: {
  96623. name: string;
  96624. shader: string;
  96625. };
  96626. }
  96627. declare module BABYLON {
  96628. /**
  96629. * Renders to multiple views with a single draw call
  96630. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  96631. */
  96632. export class MultiviewRenderTarget extends RenderTargetTexture {
  96633. /**
  96634. * Creates a multiview render target
  96635. * @param scene scene used with the render target
  96636. * @param size the size of the render target (used for each view)
  96637. */
  96638. constructor(scene: Scene, size?: number | {
  96639. width: number;
  96640. height: number;
  96641. } | {
  96642. ratio: number;
  96643. });
  96644. /**
  96645. * @hidden
  96646. * @param faceIndex the face index, if its a cube texture
  96647. */
  96648. _bindFrameBuffer(faceIndex?: number): void;
  96649. /**
  96650. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  96651. * @returns the view count
  96652. */
  96653. getViewCount(): number;
  96654. }
  96655. }
  96656. declare module BABYLON {
  96657. interface Engine {
  96658. /**
  96659. * Creates a new multiview render target
  96660. * @param width defines the width of the texture
  96661. * @param height defines the height of the texture
  96662. * @returns the created multiview texture
  96663. */
  96664. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  96665. /**
  96666. * Binds a multiview framebuffer to be drawn to
  96667. * @param multiviewTexture texture to bind
  96668. */
  96669. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  96670. }
  96671. interface Camera {
  96672. /**
  96673. * @hidden
  96674. * 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)
  96675. */
  96676. _useMultiviewToSingleView: boolean;
  96677. /**
  96678. * @hidden
  96679. * 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)
  96680. */
  96681. _multiviewTexture: Nullable<RenderTargetTexture>;
  96682. /**
  96683. * @hidden
  96684. * ensures the multiview texture of the camera exists and has the specified width/height
  96685. * @param width height to set on the multiview texture
  96686. * @param height width to set on the multiview texture
  96687. */
  96688. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  96689. }
  96690. interface Scene {
  96691. /** @hidden */
  96692. _transformMatrixR: Matrix;
  96693. /** @hidden */
  96694. _multiviewSceneUbo: Nullable<UniformBuffer>;
  96695. /** @hidden */
  96696. _createMultiviewUbo(): void;
  96697. /** @hidden */
  96698. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  96699. /** @hidden */
  96700. _renderMultiviewToSingleView(camera: Camera): void;
  96701. }
  96702. }
  96703. declare module BABYLON {
  96704. /**
  96705. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  96706. * This will not be used for webXR as it supports displaying texture arrays directly
  96707. */
  96708. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  96709. /**
  96710. * Initializes a VRMultiviewToSingleview
  96711. * @param name name of the post process
  96712. * @param camera camera to be applied to
  96713. * @param scaleFactor scaling factor to the size of the output texture
  96714. */
  96715. constructor(name: string, camera: Camera, scaleFactor: number);
  96716. }
  96717. }
  96718. declare module BABYLON {
  96719. /**
  96720. * Interface used to define additional presentation attributes
  96721. */
  96722. export interface IVRPresentationAttributes {
  96723. /**
  96724. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  96725. */
  96726. highRefreshRate: boolean;
  96727. /**
  96728. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  96729. */
  96730. foveationLevel: number;
  96731. }
  96732. interface Engine {
  96733. /** @hidden */
  96734. _vrDisplay: any;
  96735. /** @hidden */
  96736. _vrSupported: boolean;
  96737. /** @hidden */
  96738. _oldSize: Size;
  96739. /** @hidden */
  96740. _oldHardwareScaleFactor: number;
  96741. /** @hidden */
  96742. _vrExclusivePointerMode: boolean;
  96743. /** @hidden */
  96744. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  96745. /** @hidden */
  96746. _onVRDisplayPointerRestricted: () => void;
  96747. /** @hidden */
  96748. _onVRDisplayPointerUnrestricted: () => void;
  96749. /** @hidden */
  96750. _onVrDisplayConnect: Nullable<(display: any) => void>;
  96751. /** @hidden */
  96752. _onVrDisplayDisconnect: Nullable<() => void>;
  96753. /** @hidden */
  96754. _onVrDisplayPresentChange: Nullable<() => void>;
  96755. /**
  96756. * Observable signaled when VR display mode changes
  96757. */
  96758. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  96759. /**
  96760. * Observable signaled when VR request present is complete
  96761. */
  96762. onVRRequestPresentComplete: Observable<boolean>;
  96763. /**
  96764. * Observable signaled when VR request present starts
  96765. */
  96766. onVRRequestPresentStart: Observable<Engine>;
  96767. /**
  96768. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  96769. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  96770. */
  96771. isInVRExclusivePointerMode: boolean;
  96772. /**
  96773. * Gets a boolean indicating if a webVR device was detected
  96774. * @returns true if a webVR device was detected
  96775. */
  96776. isVRDevicePresent(): boolean;
  96777. /**
  96778. * Gets the current webVR device
  96779. * @returns the current webVR device (or null)
  96780. */
  96781. getVRDevice(): any;
  96782. /**
  96783. * Initializes a webVR display and starts listening to display change events
  96784. * The onVRDisplayChangedObservable will be notified upon these changes
  96785. * @returns A promise containing a VRDisplay and if vr is supported
  96786. */
  96787. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  96788. /** @hidden */
  96789. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  96790. /**
  96791. * Gets or sets the presentation attributes used to configure VR rendering
  96792. */
  96793. vrPresentationAttributes?: IVRPresentationAttributes;
  96794. /**
  96795. * Call this function to switch to webVR mode
  96796. * Will do nothing if webVR is not supported or if there is no webVR device
  96797. * @param options the webvr options provided to the camera. mainly used for multiview
  96798. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96799. */
  96800. enableVR(options: WebVROptions): void;
  96801. /** @hidden */
  96802. _onVRFullScreenTriggered(): void;
  96803. }
  96804. }
  96805. declare module BABYLON {
  96806. /**
  96807. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  96808. * IMPORTANT!! The data is right-hand data.
  96809. * @export
  96810. * @interface DevicePose
  96811. */
  96812. export interface DevicePose {
  96813. /**
  96814. * The position of the device, values in array are [x,y,z].
  96815. */
  96816. readonly position: Nullable<Float32Array>;
  96817. /**
  96818. * The linearVelocity of the device, values in array are [x,y,z].
  96819. */
  96820. readonly linearVelocity: Nullable<Float32Array>;
  96821. /**
  96822. * The linearAcceleration of the device, values in array are [x,y,z].
  96823. */
  96824. readonly linearAcceleration: Nullable<Float32Array>;
  96825. /**
  96826. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  96827. */
  96828. readonly orientation: Nullable<Float32Array>;
  96829. /**
  96830. * The angularVelocity of the device, values in array are [x,y,z].
  96831. */
  96832. readonly angularVelocity: Nullable<Float32Array>;
  96833. /**
  96834. * The angularAcceleration of the device, values in array are [x,y,z].
  96835. */
  96836. readonly angularAcceleration: Nullable<Float32Array>;
  96837. }
  96838. /**
  96839. * Interface representing a pose controlled object in Babylon.
  96840. * A pose controlled object has both regular pose values as well as pose values
  96841. * from an external device such as a VR head mounted display
  96842. */
  96843. export interface PoseControlled {
  96844. /**
  96845. * The position of the object in babylon space.
  96846. */
  96847. position: Vector3;
  96848. /**
  96849. * The rotation quaternion of the object in babylon space.
  96850. */
  96851. rotationQuaternion: Quaternion;
  96852. /**
  96853. * The position of the device in babylon space.
  96854. */
  96855. devicePosition?: Vector3;
  96856. /**
  96857. * The rotation quaternion of the device in babylon space.
  96858. */
  96859. deviceRotationQuaternion: Quaternion;
  96860. /**
  96861. * The raw pose coming from the device.
  96862. */
  96863. rawPose: Nullable<DevicePose>;
  96864. /**
  96865. * The scale of the device to be used when translating from device space to babylon space.
  96866. */
  96867. deviceScaleFactor: number;
  96868. /**
  96869. * Updates the poseControlled values based on the input device pose.
  96870. * @param poseData the pose data to update the object with
  96871. */
  96872. updateFromDevice(poseData: DevicePose): void;
  96873. }
  96874. /**
  96875. * Set of options to customize the webVRCamera
  96876. */
  96877. export interface WebVROptions {
  96878. /**
  96879. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  96880. */
  96881. trackPosition?: boolean;
  96882. /**
  96883. * Sets the scale of the vrDevice in babylon space. (default: 1)
  96884. */
  96885. positionScale?: number;
  96886. /**
  96887. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  96888. */
  96889. displayName?: string;
  96890. /**
  96891. * Should the native controller meshes be initialized. (default: true)
  96892. */
  96893. controllerMeshes?: boolean;
  96894. /**
  96895. * Creating a default HemiLight only on controllers. (default: true)
  96896. */
  96897. defaultLightingOnControllers?: boolean;
  96898. /**
  96899. * If you don't want to use the default VR button of the helper. (default: false)
  96900. */
  96901. useCustomVRButton?: boolean;
  96902. /**
  96903. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  96904. */
  96905. customVRButton?: HTMLButtonElement;
  96906. /**
  96907. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  96908. */
  96909. rayLength?: number;
  96910. /**
  96911. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  96912. */
  96913. defaultHeight?: number;
  96914. /**
  96915. * If multiview should be used if availible (default: false)
  96916. */
  96917. useMultiview?: boolean;
  96918. }
  96919. /**
  96920. * This represents a WebVR camera.
  96921. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  96922. * @example http://doc.babylonjs.com/how_to/webvr_camera
  96923. */
  96924. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  96925. private webVROptions;
  96926. /**
  96927. * @hidden
  96928. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  96929. */
  96930. _vrDevice: any;
  96931. /**
  96932. * The rawPose of the vrDevice.
  96933. */
  96934. rawPose: Nullable<DevicePose>;
  96935. private _onVREnabled;
  96936. private _specsVersion;
  96937. private _attached;
  96938. private _frameData;
  96939. protected _descendants: Array<Node>;
  96940. private _deviceRoomPosition;
  96941. /** @hidden */
  96942. _deviceRoomRotationQuaternion: Quaternion;
  96943. private _standingMatrix;
  96944. /**
  96945. * Represents device position in babylon space.
  96946. */
  96947. devicePosition: Vector3;
  96948. /**
  96949. * Represents device rotation in babylon space.
  96950. */
  96951. deviceRotationQuaternion: Quaternion;
  96952. /**
  96953. * The scale of the device to be used when translating from device space to babylon space.
  96954. */
  96955. deviceScaleFactor: number;
  96956. private _deviceToWorld;
  96957. private _worldToDevice;
  96958. /**
  96959. * References to the webVR controllers for the vrDevice.
  96960. */
  96961. controllers: Array<WebVRController>;
  96962. /**
  96963. * Emits an event when a controller is attached.
  96964. */
  96965. onControllersAttachedObservable: Observable<WebVRController[]>;
  96966. /**
  96967. * Emits an event when a controller's mesh has been loaded;
  96968. */
  96969. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96970. /**
  96971. * Emits an event when the HMD's pose has been updated.
  96972. */
  96973. onPoseUpdatedFromDeviceObservable: Observable<any>;
  96974. private _poseSet;
  96975. /**
  96976. * If the rig cameras be used as parent instead of this camera.
  96977. */
  96978. rigParenting: boolean;
  96979. private _lightOnControllers;
  96980. private _defaultHeight?;
  96981. /**
  96982. * Instantiates a WebVRFreeCamera.
  96983. * @param name The name of the WebVRFreeCamera
  96984. * @param position The starting anchor position for the camera
  96985. * @param scene The scene the camera belongs to
  96986. * @param webVROptions a set of customizable options for the webVRCamera
  96987. */
  96988. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  96989. /**
  96990. * Gets the device distance from the ground in meters.
  96991. * @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.
  96992. */
  96993. deviceDistanceToRoomGround(): number;
  96994. /**
  96995. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  96996. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  96997. */
  96998. useStandingMatrix(callback?: (bool: boolean) => void): void;
  96999. /**
  97000. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97001. * @returns A promise with a boolean set to if the standing matrix is supported.
  97002. */
  97003. useStandingMatrixAsync(): Promise<boolean>;
  97004. /**
  97005. * Disposes the camera
  97006. */
  97007. dispose(): void;
  97008. /**
  97009. * Gets a vrController by name.
  97010. * @param name The name of the controller to retreive
  97011. * @returns the controller matching the name specified or null if not found
  97012. */
  97013. getControllerByName(name: string): Nullable<WebVRController>;
  97014. private _leftController;
  97015. /**
  97016. * The controller corresponding to the users left hand.
  97017. */
  97018. get leftController(): Nullable<WebVRController>;
  97019. private _rightController;
  97020. /**
  97021. * The controller corresponding to the users right hand.
  97022. */
  97023. get rightController(): Nullable<WebVRController>;
  97024. /**
  97025. * Casts a ray forward from the vrCamera's gaze.
  97026. * @param length Length of the ray (default: 100)
  97027. * @returns the ray corresponding to the gaze
  97028. */
  97029. getForwardRay(length?: number): Ray;
  97030. /**
  97031. * @hidden
  97032. * Updates the camera based on device's frame data
  97033. */
  97034. _checkInputs(): void;
  97035. /**
  97036. * Updates the poseControlled values based on the input device pose.
  97037. * @param poseData Pose coming from the device
  97038. */
  97039. updateFromDevice(poseData: DevicePose): void;
  97040. private _htmlElementAttached;
  97041. private _detachIfAttached;
  97042. /**
  97043. * WebVR's attach control will start broadcasting frames to the device.
  97044. * Note that in certain browsers (chrome for example) this function must be called
  97045. * within a user-interaction callback. Example:
  97046. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  97047. *
  97048. * @param element html element to attach the vrDevice to
  97049. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  97050. */
  97051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97052. /**
  97053. * Detaches the camera from the html element and disables VR
  97054. *
  97055. * @param element html element to detach from
  97056. */
  97057. detachControl(element: HTMLElement): void;
  97058. /**
  97059. * @returns the name of this class
  97060. */
  97061. getClassName(): string;
  97062. /**
  97063. * Calls resetPose on the vrDisplay
  97064. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  97065. */
  97066. resetToCurrentRotation(): void;
  97067. /**
  97068. * @hidden
  97069. * Updates the rig cameras (left and right eye)
  97070. */
  97071. _updateRigCameras(): void;
  97072. private _workingVector;
  97073. private _oneVector;
  97074. private _workingMatrix;
  97075. private updateCacheCalled;
  97076. private _correctPositionIfNotTrackPosition;
  97077. /**
  97078. * @hidden
  97079. * Updates the cached values of the camera
  97080. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  97081. */
  97082. _updateCache(ignoreParentClass?: boolean): void;
  97083. /**
  97084. * @hidden
  97085. * Get current device position in babylon world
  97086. */
  97087. _computeDevicePosition(): void;
  97088. /**
  97089. * Updates the current device position and rotation in the babylon world
  97090. */
  97091. update(): void;
  97092. /**
  97093. * @hidden
  97094. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  97095. * @returns an identity matrix
  97096. */
  97097. _getViewMatrix(): Matrix;
  97098. private _tmpMatrix;
  97099. /**
  97100. * This function is called by the two RIG cameras.
  97101. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  97102. * @hidden
  97103. */
  97104. _getWebVRViewMatrix(): Matrix;
  97105. /** @hidden */
  97106. _getWebVRProjectionMatrix(): Matrix;
  97107. private _onGamepadConnectedObserver;
  97108. private _onGamepadDisconnectedObserver;
  97109. private _updateCacheWhenTrackingDisabledObserver;
  97110. /**
  97111. * Initializes the controllers and their meshes
  97112. */
  97113. initControllers(): void;
  97114. }
  97115. }
  97116. declare module BABYLON {
  97117. /**
  97118. * "Static Class" containing the most commonly used helper while dealing with material for
  97119. * rendering purpose.
  97120. *
  97121. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  97122. *
  97123. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  97124. */
  97125. export class MaterialHelper {
  97126. /**
  97127. * Bind the current view position to an effect.
  97128. * @param effect The effect to be bound
  97129. * @param scene The scene the eyes position is used from
  97130. * @param variableName name of the shader variable that will hold the eye position
  97131. */
  97132. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  97133. /**
  97134. * Helps preparing the defines values about the UVs in used in the effect.
  97135. * UVs are shared as much as we can accross channels in the shaders.
  97136. * @param texture The texture we are preparing the UVs for
  97137. * @param defines The defines to update
  97138. * @param key The channel key "diffuse", "specular"... used in the shader
  97139. */
  97140. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  97141. /**
  97142. * Binds a texture matrix value to its corrsponding uniform
  97143. * @param texture The texture to bind the matrix for
  97144. * @param uniformBuffer The uniform buffer receivin the data
  97145. * @param key The channel key "diffuse", "specular"... used in the shader
  97146. */
  97147. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  97148. /**
  97149. * Gets the current status of the fog (should it be enabled?)
  97150. * @param mesh defines the mesh to evaluate for fog support
  97151. * @param scene defines the hosting scene
  97152. * @returns true if fog must be enabled
  97153. */
  97154. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  97155. /**
  97156. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  97157. * @param mesh defines the current mesh
  97158. * @param scene defines the current scene
  97159. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  97160. * @param pointsCloud defines if point cloud rendering has to be turned on
  97161. * @param fogEnabled defines if fog has to be turned on
  97162. * @param alphaTest defines if alpha testing has to be turned on
  97163. * @param defines defines the current list of defines
  97164. */
  97165. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  97166. /**
  97167. * Helper used to prepare the list of defines associated with frame values for shader compilation
  97168. * @param scene defines the current scene
  97169. * @param engine defines the current engine
  97170. * @param defines specifies the list of active defines
  97171. * @param useInstances defines if instances have to be turned on
  97172. * @param useClipPlane defines if clip plane have to be turned on
  97173. * @param useInstances defines if instances have to be turned on
  97174. * @param useThinInstances defines if thin instances have to be turned on
  97175. */
  97176. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  97177. /**
  97178. * Prepares the defines for bones
  97179. * @param mesh The mesh containing the geometry data we will draw
  97180. * @param defines The defines to update
  97181. */
  97182. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  97183. /**
  97184. * Prepares the defines for morph targets
  97185. * @param mesh The mesh containing the geometry data we will draw
  97186. * @param defines The defines to update
  97187. */
  97188. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  97189. /**
  97190. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  97191. * @param mesh The mesh containing the geometry data we will draw
  97192. * @param defines The defines to update
  97193. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  97194. * @param useBones Precise whether bones should be used or not (override mesh info)
  97195. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  97196. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  97197. * @returns false if defines are considered not dirty and have not been checked
  97198. */
  97199. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  97200. /**
  97201. * Prepares the defines related to multiview
  97202. * @param scene The scene we are intending to draw
  97203. * @param defines The defines to update
  97204. */
  97205. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  97206. /**
  97207. * Prepares the defines related to the light information passed in parameter
  97208. * @param scene The scene we are intending to draw
  97209. * @param mesh The mesh the effect is compiling for
  97210. * @param light The light the effect is compiling for
  97211. * @param lightIndex The index of the light
  97212. * @param defines The defines to update
  97213. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97214. * @param state Defines the current state regarding what is needed (normals, etc...)
  97215. */
  97216. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  97217. needNormals: boolean;
  97218. needRebuild: boolean;
  97219. shadowEnabled: boolean;
  97220. specularEnabled: boolean;
  97221. lightmapMode: boolean;
  97222. }): void;
  97223. /**
  97224. * Prepares the defines related to the light information passed in parameter
  97225. * @param scene The scene we are intending to draw
  97226. * @param mesh The mesh the effect is compiling for
  97227. * @param defines The defines to update
  97228. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97229. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  97230. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  97231. * @returns true if normals will be required for the rest of the effect
  97232. */
  97233. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  97234. /**
  97235. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  97236. * @param lightIndex defines the light index
  97237. * @param uniformsList The uniform list
  97238. * @param samplersList The sampler list
  97239. * @param projectedLightTexture defines if projected texture must be used
  97240. * @param uniformBuffersList defines an optional list of uniform buffers
  97241. */
  97242. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  97243. /**
  97244. * Prepares the uniforms and samplers list to be used in the effect
  97245. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  97246. * @param samplersList The sampler list
  97247. * @param defines The defines helping in the list generation
  97248. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  97249. */
  97250. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  97251. /**
  97252. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  97253. * @param defines The defines to update while falling back
  97254. * @param fallbacks The authorized effect fallbacks
  97255. * @param maxSimultaneousLights The maximum number of lights allowed
  97256. * @param rank the current rank of the Effect
  97257. * @returns The newly affected rank
  97258. */
  97259. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  97260. private static _TmpMorphInfluencers;
  97261. /**
  97262. * Prepares the list of attributes required for morph targets according to the effect defines.
  97263. * @param attribs The current list of supported attribs
  97264. * @param mesh The mesh to prepare the morph targets attributes for
  97265. * @param influencers The number of influencers
  97266. */
  97267. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  97268. /**
  97269. * Prepares the list of attributes required for morph targets according to the effect defines.
  97270. * @param attribs The current list of supported attribs
  97271. * @param mesh The mesh to prepare the morph targets attributes for
  97272. * @param defines The current Defines of the effect
  97273. */
  97274. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  97275. /**
  97276. * Prepares the list of attributes required for bones according to the effect defines.
  97277. * @param attribs The current list of supported attribs
  97278. * @param mesh The mesh to prepare the bones attributes for
  97279. * @param defines The current Defines of the effect
  97280. * @param fallbacks The current efffect fallback strategy
  97281. */
  97282. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97283. /**
  97284. * Check and prepare the list of attributes required for instances according to the effect defines.
  97285. * @param attribs The current list of supported attribs
  97286. * @param defines The current MaterialDefines of the effect
  97287. */
  97288. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97289. /**
  97290. * Add the list of attributes required for instances to the attribs array.
  97291. * @param attribs The current list of supported attribs
  97292. */
  97293. static PushAttributesForInstances(attribs: string[]): void;
  97294. /**
  97295. * Binds the light information to the effect.
  97296. * @param light The light containing the generator
  97297. * @param effect The effect we are binding the data to
  97298. * @param lightIndex The light index in the effect used to render
  97299. */
  97300. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97301. /**
  97302. * Binds the lights information from the scene to the effect for the given mesh.
  97303. * @param light Light to bind
  97304. * @param lightIndex Light index
  97305. * @param scene The scene where the light belongs to
  97306. * @param effect The effect we are binding the data to
  97307. * @param useSpecular Defines if specular is supported
  97308. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97309. */
  97310. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97311. /**
  97312. * Binds the lights information from the scene to the effect for the given mesh.
  97313. * @param scene The scene the lights belongs to
  97314. * @param mesh The mesh we are binding the information to render
  97315. * @param effect The effect we are binding the data to
  97316. * @param defines The generated defines for the effect
  97317. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97318. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97319. */
  97320. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97321. private static _tempFogColor;
  97322. /**
  97323. * Binds the fog information from the scene to the effect for the given mesh.
  97324. * @param scene The scene the lights belongs to
  97325. * @param mesh The mesh we are binding the information to render
  97326. * @param effect The effect we are binding the data to
  97327. * @param linearSpace Defines if the fog effect is applied in linear space
  97328. */
  97329. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97330. /**
  97331. * Binds the bones information from the mesh to the effect.
  97332. * @param mesh The mesh we are binding the information to render
  97333. * @param effect The effect we are binding the data to
  97334. */
  97335. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97336. /**
  97337. * Binds the morph targets information from the mesh to the effect.
  97338. * @param abstractMesh The mesh we are binding the information to render
  97339. * @param effect The effect we are binding the data to
  97340. */
  97341. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97342. /**
  97343. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97344. * @param defines The generated defines used in the effect
  97345. * @param effect The effect we are binding the data to
  97346. * @param scene The scene we are willing to render with logarithmic scale for
  97347. */
  97348. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97349. /**
  97350. * Binds the clip plane information from the scene to the effect.
  97351. * @param scene The scene the clip plane information are extracted from
  97352. * @param effect The effect we are binding the data to
  97353. */
  97354. static BindClipPlane(effect: Effect, scene: Scene): void;
  97355. }
  97356. }
  97357. declare module BABYLON {
  97358. /**
  97359. * Block used to expose an input value
  97360. */
  97361. export class InputBlock extends NodeMaterialBlock {
  97362. private _mode;
  97363. private _associatedVariableName;
  97364. private _storedValue;
  97365. private _valueCallback;
  97366. private _type;
  97367. private _animationType;
  97368. /** Gets or set a value used to limit the range of float values */
  97369. min: number;
  97370. /** Gets or set a value used to limit the range of float values */
  97371. max: number;
  97372. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97373. isBoolean: boolean;
  97374. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97375. matrixMode: number;
  97376. /** @hidden */
  97377. _systemValue: Nullable<NodeMaterialSystemValues>;
  97378. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97379. visibleInInspector: boolean;
  97380. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97381. isConstant: boolean;
  97382. /** Gets or sets the group to use to display this block in the Inspector */
  97383. groupInInspector: string;
  97384. /** Gets an observable raised when the value is changed */
  97385. onValueChangedObservable: Observable<InputBlock>;
  97386. /**
  97387. * Gets or sets the connection point type (default is float)
  97388. */
  97389. get type(): NodeMaterialBlockConnectionPointTypes;
  97390. /**
  97391. * Creates a new InputBlock
  97392. * @param name defines the block name
  97393. * @param target defines the target of that block (Vertex by default)
  97394. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97395. */
  97396. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97397. /**
  97398. * Gets the output component
  97399. */
  97400. get output(): NodeMaterialConnectionPoint;
  97401. /**
  97402. * Set the source of this connection point to a vertex attribute
  97403. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97404. * @returns the current connection point
  97405. */
  97406. setAsAttribute(attributeName?: string): InputBlock;
  97407. /**
  97408. * Set the source of this connection point to a system value
  97409. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97410. * @returns the current connection point
  97411. */
  97412. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  97413. /**
  97414. * Gets or sets the value of that point.
  97415. * Please note that this value will be ignored if valueCallback is defined
  97416. */
  97417. get value(): any;
  97418. set value(value: any);
  97419. /**
  97420. * Gets or sets a callback used to get the value of that point.
  97421. * Please note that setting this value will force the connection point to ignore the value property
  97422. */
  97423. get valueCallback(): () => any;
  97424. set valueCallback(value: () => any);
  97425. /**
  97426. * Gets or sets the associated variable name in the shader
  97427. */
  97428. get associatedVariableName(): string;
  97429. set associatedVariableName(value: string);
  97430. /** Gets or sets the type of animation applied to the input */
  97431. get animationType(): AnimatedInputBlockTypes;
  97432. set animationType(value: AnimatedInputBlockTypes);
  97433. /**
  97434. * Gets a boolean indicating that this connection point not defined yet
  97435. */
  97436. get isUndefined(): boolean;
  97437. /**
  97438. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  97439. * In this case the connection point name must be the name of the uniform to use.
  97440. * Can only be set on inputs
  97441. */
  97442. get isUniform(): boolean;
  97443. set isUniform(value: boolean);
  97444. /**
  97445. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  97446. * In this case the connection point name must be the name of the attribute to use
  97447. * Can only be set on inputs
  97448. */
  97449. get isAttribute(): boolean;
  97450. set isAttribute(value: boolean);
  97451. /**
  97452. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  97453. * Can only be set on exit points
  97454. */
  97455. get isVarying(): boolean;
  97456. set isVarying(value: boolean);
  97457. /**
  97458. * Gets a boolean indicating that the current connection point is a system value
  97459. */
  97460. get isSystemValue(): boolean;
  97461. /**
  97462. * Gets or sets the current well known value or null if not defined as a system value
  97463. */
  97464. get systemValue(): Nullable<NodeMaterialSystemValues>;
  97465. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  97466. /**
  97467. * Gets the current class name
  97468. * @returns the class name
  97469. */
  97470. getClassName(): string;
  97471. /**
  97472. * Animate the input if animationType !== None
  97473. * @param scene defines the rendering scene
  97474. */
  97475. animate(scene: Scene): void;
  97476. private _emitDefine;
  97477. initialize(state: NodeMaterialBuildState): void;
  97478. /**
  97479. * Set the input block to its default value (based on its type)
  97480. */
  97481. setDefaultValue(): void;
  97482. private _emitConstant;
  97483. /** @hidden */
  97484. get _noContextSwitch(): boolean;
  97485. private _emit;
  97486. /** @hidden */
  97487. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  97488. /** @hidden */
  97489. _transmit(effect: Effect, scene: Scene): void;
  97490. protected _buildBlock(state: NodeMaterialBuildState): void;
  97491. protected _dumpPropertiesCode(): string;
  97492. dispose(): void;
  97493. serialize(): any;
  97494. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97495. }
  97496. }
  97497. declare module BABYLON {
  97498. /**
  97499. * Enum used to define the compatibility state between two connection points
  97500. */
  97501. export enum NodeMaterialConnectionPointCompatibilityStates {
  97502. /** Points are compatibles */
  97503. Compatible = 0,
  97504. /** Points are incompatible because of their types */
  97505. TypeIncompatible = 1,
  97506. /** Points are incompatible because of their targets (vertex vs fragment) */
  97507. TargetIncompatible = 2
  97508. }
  97509. /**
  97510. * Defines the direction of a connection point
  97511. */
  97512. export enum NodeMaterialConnectionPointDirection {
  97513. /** Input */
  97514. Input = 0,
  97515. /** Output */
  97516. Output = 1
  97517. }
  97518. /**
  97519. * Defines a connection point for a block
  97520. */
  97521. export class NodeMaterialConnectionPoint {
  97522. /** @hidden */
  97523. _ownerBlock: NodeMaterialBlock;
  97524. /** @hidden */
  97525. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  97526. private _endpoints;
  97527. private _associatedVariableName;
  97528. private _direction;
  97529. /** @hidden */
  97530. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97531. /** @hidden */
  97532. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97533. private _type;
  97534. /** @hidden */
  97535. _enforceAssociatedVariableName: boolean;
  97536. /** Gets the direction of the point */
  97537. get direction(): NodeMaterialConnectionPointDirection;
  97538. /** Indicates that this connection point needs dual validation before being connected to another point */
  97539. needDualDirectionValidation: boolean;
  97540. /**
  97541. * Gets or sets the additional types supported by this connection point
  97542. */
  97543. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97544. /**
  97545. * Gets or sets the additional types excluded by this connection point
  97546. */
  97547. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97548. /**
  97549. * Observable triggered when this point is connected
  97550. */
  97551. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  97552. /**
  97553. * Gets or sets the associated variable name in the shader
  97554. */
  97555. get associatedVariableName(): string;
  97556. set associatedVariableName(value: string);
  97557. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  97558. get innerType(): NodeMaterialBlockConnectionPointTypes;
  97559. /**
  97560. * Gets or sets the connection point type (default is float)
  97561. */
  97562. get type(): NodeMaterialBlockConnectionPointTypes;
  97563. set type(value: NodeMaterialBlockConnectionPointTypes);
  97564. /**
  97565. * Gets or sets the connection point name
  97566. */
  97567. name: string;
  97568. /**
  97569. * Gets or sets the connection point name
  97570. */
  97571. displayName: string;
  97572. /**
  97573. * Gets or sets a boolean indicating that this connection point can be omitted
  97574. */
  97575. isOptional: boolean;
  97576. /**
  97577. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  97578. */
  97579. define: string;
  97580. /** @hidden */
  97581. _prioritizeVertex: boolean;
  97582. private _target;
  97583. /** Gets or sets the target of that connection point */
  97584. get target(): NodeMaterialBlockTargets;
  97585. set target(value: NodeMaterialBlockTargets);
  97586. /**
  97587. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  97588. */
  97589. get isConnected(): boolean;
  97590. /**
  97591. * Gets a boolean indicating that the current point is connected to an input block
  97592. */
  97593. get isConnectedToInputBlock(): boolean;
  97594. /**
  97595. * Gets a the connected input block (if any)
  97596. */
  97597. get connectInputBlock(): Nullable<InputBlock>;
  97598. /** Get the other side of the connection (if any) */
  97599. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  97600. /** Get the block that owns this connection point */
  97601. get ownerBlock(): NodeMaterialBlock;
  97602. /** Get the block connected on the other side of this connection (if any) */
  97603. get sourceBlock(): Nullable<NodeMaterialBlock>;
  97604. /** Get the block connected on the endpoints of this connection (if any) */
  97605. get connectedBlocks(): Array<NodeMaterialBlock>;
  97606. /** Gets the list of connected endpoints */
  97607. get endpoints(): NodeMaterialConnectionPoint[];
  97608. /** Gets a boolean indicating if that output point is connected to at least one input */
  97609. get hasEndpoints(): boolean;
  97610. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  97611. get isConnectedInVertexShader(): boolean;
  97612. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  97613. get isConnectedInFragmentShader(): boolean;
  97614. /**
  97615. * Creates a block suitable to be used as an input for this input point.
  97616. * If null is returned, a block based on the point type will be created.
  97617. * @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
  97618. */
  97619. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97620. /**
  97621. * Creates a new connection point
  97622. * @param name defines the connection point name
  97623. * @param ownerBlock defines the block hosting this connection point
  97624. * @param direction defines the direction of the connection point
  97625. */
  97626. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  97627. /**
  97628. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  97629. * @returns the class name
  97630. */
  97631. getClassName(): string;
  97632. /**
  97633. * Gets a boolean indicating if the current point can be connected to another point
  97634. * @param connectionPoint defines the other connection point
  97635. * @returns a boolean
  97636. */
  97637. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  97638. /**
  97639. * Gets a number indicating if the current point can be connected to another point
  97640. * @param connectionPoint defines the other connection point
  97641. * @returns a number defining the compatibility state
  97642. */
  97643. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97644. /**
  97645. * Connect this point to another connection point
  97646. * @param connectionPoint defines the other connection point
  97647. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  97648. * @returns the current connection point
  97649. */
  97650. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  97651. /**
  97652. * Disconnect this point from one of his endpoint
  97653. * @param endpoint defines the other connection point
  97654. * @returns the current connection point
  97655. */
  97656. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  97657. /**
  97658. * Serializes this point in a JSON representation
  97659. * @param isInput defines if the connection point is an input (default is true)
  97660. * @returns the serialized point object
  97661. */
  97662. serialize(isInput?: boolean): any;
  97663. /**
  97664. * Release resources
  97665. */
  97666. dispose(): void;
  97667. }
  97668. }
  97669. declare module BABYLON {
  97670. /**
  97671. * Enum used to define the material modes
  97672. */
  97673. export enum NodeMaterialModes {
  97674. /** Regular material */
  97675. Material = 0,
  97676. /** For post process */
  97677. PostProcess = 1,
  97678. /** For particle system */
  97679. Particle = 2
  97680. }
  97681. }
  97682. declare module BABYLON {
  97683. /**
  97684. * Block used to read a texture from a sampler
  97685. */
  97686. export class TextureBlock extends NodeMaterialBlock {
  97687. private _defineName;
  97688. private _linearDefineName;
  97689. private _gammaDefineName;
  97690. private _tempTextureRead;
  97691. private _samplerName;
  97692. private _transformedUVName;
  97693. private _textureTransformName;
  97694. private _textureInfoName;
  97695. private _mainUVName;
  97696. private _mainUVDefineName;
  97697. private _fragmentOnly;
  97698. /**
  97699. * Gets or sets the texture associated with the node
  97700. */
  97701. texture: Nullable<Texture>;
  97702. /**
  97703. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97704. */
  97705. convertToGammaSpace: boolean;
  97706. /**
  97707. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97708. */
  97709. convertToLinearSpace: boolean;
  97710. /**
  97711. * Create a new TextureBlock
  97712. * @param name defines the block name
  97713. */
  97714. constructor(name: string, fragmentOnly?: boolean);
  97715. /**
  97716. * Gets the current class name
  97717. * @returns the class name
  97718. */
  97719. getClassName(): string;
  97720. /**
  97721. * Gets the uv input component
  97722. */
  97723. get uv(): NodeMaterialConnectionPoint;
  97724. /**
  97725. * Gets the rgba output component
  97726. */
  97727. get rgba(): NodeMaterialConnectionPoint;
  97728. /**
  97729. * Gets the rgb output component
  97730. */
  97731. get rgb(): NodeMaterialConnectionPoint;
  97732. /**
  97733. * Gets the r output component
  97734. */
  97735. get r(): NodeMaterialConnectionPoint;
  97736. /**
  97737. * Gets the g output component
  97738. */
  97739. get g(): NodeMaterialConnectionPoint;
  97740. /**
  97741. * Gets the b output component
  97742. */
  97743. get b(): NodeMaterialConnectionPoint;
  97744. /**
  97745. * Gets the a output component
  97746. */
  97747. get a(): NodeMaterialConnectionPoint;
  97748. get target(): NodeMaterialBlockTargets;
  97749. autoConfigure(material: NodeMaterial): void;
  97750. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  97751. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97752. isReady(): boolean;
  97753. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97754. private get _isMixed();
  97755. private _injectVertexCode;
  97756. private _writeTextureRead;
  97757. private _writeOutput;
  97758. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97759. protected _dumpPropertiesCode(): string;
  97760. serialize(): any;
  97761. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97762. }
  97763. }
  97764. declare module BABYLON {
  97765. /** @hidden */
  97766. export var reflectionFunction: {
  97767. name: string;
  97768. shader: string;
  97769. };
  97770. }
  97771. declare module BABYLON {
  97772. /**
  97773. * Base block used to read a reflection texture from a sampler
  97774. */
  97775. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  97776. /** @hidden */
  97777. _define3DName: string;
  97778. /** @hidden */
  97779. _defineCubicName: string;
  97780. /** @hidden */
  97781. _defineExplicitName: string;
  97782. /** @hidden */
  97783. _defineProjectionName: string;
  97784. /** @hidden */
  97785. _defineLocalCubicName: string;
  97786. /** @hidden */
  97787. _defineSphericalName: string;
  97788. /** @hidden */
  97789. _definePlanarName: string;
  97790. /** @hidden */
  97791. _defineEquirectangularName: string;
  97792. /** @hidden */
  97793. _defineMirroredEquirectangularFixedName: string;
  97794. /** @hidden */
  97795. _defineEquirectangularFixedName: string;
  97796. /** @hidden */
  97797. _defineSkyboxName: string;
  97798. /** @hidden */
  97799. _defineOppositeZ: string;
  97800. /** @hidden */
  97801. _cubeSamplerName: string;
  97802. /** @hidden */
  97803. _2DSamplerName: string;
  97804. protected _positionUVWName: string;
  97805. protected _directionWName: string;
  97806. protected _reflectionVectorName: string;
  97807. /** @hidden */
  97808. _reflectionCoordsName: string;
  97809. /** @hidden */
  97810. _reflectionMatrixName: string;
  97811. protected _reflectionColorName: string;
  97812. /**
  97813. * Gets or sets the texture associated with the node
  97814. */
  97815. texture: Nullable<BaseTexture>;
  97816. /**
  97817. * Create a new ReflectionTextureBaseBlock
  97818. * @param name defines the block name
  97819. */
  97820. constructor(name: string);
  97821. /**
  97822. * Gets the current class name
  97823. * @returns the class name
  97824. */
  97825. getClassName(): string;
  97826. /**
  97827. * Gets the world position input component
  97828. */
  97829. abstract get position(): NodeMaterialConnectionPoint;
  97830. /**
  97831. * Gets the world position input component
  97832. */
  97833. abstract get worldPosition(): NodeMaterialConnectionPoint;
  97834. /**
  97835. * Gets the world normal input component
  97836. */
  97837. abstract get worldNormal(): NodeMaterialConnectionPoint;
  97838. /**
  97839. * Gets the world input component
  97840. */
  97841. abstract get world(): NodeMaterialConnectionPoint;
  97842. /**
  97843. * Gets the camera (or eye) position component
  97844. */
  97845. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  97846. /**
  97847. * Gets the view input component
  97848. */
  97849. abstract get view(): NodeMaterialConnectionPoint;
  97850. protected _getTexture(): Nullable<BaseTexture>;
  97851. autoConfigure(material: NodeMaterial): void;
  97852. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97853. isReady(): boolean;
  97854. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97855. /**
  97856. * Gets the code to inject in the vertex shader
  97857. * @param state current state of the node material building
  97858. * @returns the shader code
  97859. */
  97860. handleVertexSide(state: NodeMaterialBuildState): string;
  97861. /**
  97862. * Handles the inits for the fragment code path
  97863. * @param state node material build state
  97864. */
  97865. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  97866. /**
  97867. * Generates the reflection coords code for the fragment code path
  97868. * @param worldNormalVarName name of the world normal variable
  97869. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  97870. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  97871. * @returns the shader code
  97872. */
  97873. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  97874. /**
  97875. * Generates the reflection color code for the fragment code path
  97876. * @param lodVarName name of the lod variable
  97877. * @param swizzleLookupTexture swizzle to use for the final color variable
  97878. * @returns the shader code
  97879. */
  97880. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  97881. /**
  97882. * Generates the code corresponding to the connected output points
  97883. * @param state node material build state
  97884. * @param varName name of the variable to output
  97885. * @returns the shader code
  97886. */
  97887. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  97888. protected _buildBlock(state: NodeMaterialBuildState): this;
  97889. protected _dumpPropertiesCode(): string;
  97890. serialize(): any;
  97891. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97892. }
  97893. }
  97894. declare module BABYLON {
  97895. /**
  97896. * Defines a connection point to be used for points with a custom object type
  97897. */
  97898. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  97899. private _blockType;
  97900. private _blockName;
  97901. private _nameForCheking?;
  97902. /**
  97903. * Creates a new connection point
  97904. * @param name defines the connection point name
  97905. * @param ownerBlock defines the block hosting this connection point
  97906. * @param direction defines the direction of the connection point
  97907. */
  97908. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  97909. /**
  97910. * Gets a number indicating if the current point can be connected to another point
  97911. * @param connectionPoint defines the other connection point
  97912. * @returns a number defining the compatibility state
  97913. */
  97914. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97915. /**
  97916. * Creates a block suitable to be used as an input for this input point.
  97917. * If null is returned, a block based on the point type will be created.
  97918. * @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
  97919. */
  97920. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97921. }
  97922. }
  97923. declare module BABYLON {
  97924. /**
  97925. * Enum defining the type of properties that can be edited in the property pages in the NME
  97926. */
  97927. export enum PropertyTypeForEdition {
  97928. /** property is a boolean */
  97929. Boolean = 0,
  97930. /** property is a float */
  97931. Float = 1,
  97932. /** property is a Vector2 */
  97933. Vector2 = 2,
  97934. /** property is a list of values */
  97935. List = 3
  97936. }
  97937. /**
  97938. * Interface that defines an option in a variable of type list
  97939. */
  97940. export interface IEditablePropertyListOption {
  97941. /** label of the option */
  97942. "label": string;
  97943. /** value of the option */
  97944. "value": number;
  97945. }
  97946. /**
  97947. * Interface that defines the options available for an editable property
  97948. */
  97949. export interface IEditablePropertyOption {
  97950. /** min value */
  97951. "min"?: number;
  97952. /** max value */
  97953. "max"?: number;
  97954. /** notifiers: indicates which actions to take when the property is changed */
  97955. "notifiers"?: {
  97956. /** the material should be rebuilt */
  97957. "rebuild"?: boolean;
  97958. /** the preview should be updated */
  97959. "update"?: boolean;
  97960. };
  97961. /** list of the options for a variable of type list */
  97962. "options"?: IEditablePropertyListOption[];
  97963. }
  97964. /**
  97965. * Interface that describes an editable property
  97966. */
  97967. export interface IPropertyDescriptionForEdition {
  97968. /** name of the property */
  97969. "propertyName": string;
  97970. /** display name of the property */
  97971. "displayName": string;
  97972. /** type of the property */
  97973. "type": PropertyTypeForEdition;
  97974. /** group of the property - all properties with the same group value will be displayed in a specific section */
  97975. "groupName": string;
  97976. /** options for the property */
  97977. "options": IEditablePropertyOption;
  97978. }
  97979. /**
  97980. * Decorator that flags a property in a node material block as being editable
  97981. */
  97982. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  97983. }
  97984. declare module BABYLON {
  97985. /**
  97986. * Block used to implement the refraction part of the sub surface module of the PBR material
  97987. */
  97988. export class RefractionBlock extends NodeMaterialBlock {
  97989. /** @hidden */
  97990. _define3DName: string;
  97991. /** @hidden */
  97992. _refractionMatrixName: string;
  97993. /** @hidden */
  97994. _defineLODRefractionAlpha: string;
  97995. /** @hidden */
  97996. _defineLinearSpecularRefraction: string;
  97997. /** @hidden */
  97998. _defineOppositeZ: string;
  97999. /** @hidden */
  98000. _cubeSamplerName: string;
  98001. /** @hidden */
  98002. _2DSamplerName: string;
  98003. /** @hidden */
  98004. _vRefractionMicrosurfaceInfosName: string;
  98005. /** @hidden */
  98006. _vRefractionInfosName: string;
  98007. private _scene;
  98008. /**
  98009. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98010. * Materials half opaque for instance using refraction could benefit from this control.
  98011. */
  98012. linkRefractionWithTransparency: boolean;
  98013. /**
  98014. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98015. */
  98016. invertRefractionY: boolean;
  98017. /**
  98018. * Gets or sets the texture associated with the node
  98019. */
  98020. texture: Nullable<BaseTexture>;
  98021. /**
  98022. * Create a new RefractionBlock
  98023. * @param name defines the block name
  98024. */
  98025. constructor(name: string);
  98026. /**
  98027. * Gets the current class name
  98028. * @returns the class name
  98029. */
  98030. getClassName(): string;
  98031. /**
  98032. * Gets the intensity input component
  98033. */
  98034. get intensity(): NodeMaterialConnectionPoint;
  98035. /**
  98036. * Gets the index of refraction input component
  98037. */
  98038. get indexOfRefraction(): NodeMaterialConnectionPoint;
  98039. /**
  98040. * Gets the tint at distance input component
  98041. */
  98042. get tintAtDistance(): NodeMaterialConnectionPoint;
  98043. /**
  98044. * Gets the view input component
  98045. */
  98046. get view(): NodeMaterialConnectionPoint;
  98047. /**
  98048. * Gets the refraction object output component
  98049. */
  98050. get refraction(): NodeMaterialConnectionPoint;
  98051. /**
  98052. * Returns true if the block has a texture
  98053. */
  98054. get hasTexture(): boolean;
  98055. protected _getTexture(): Nullable<BaseTexture>;
  98056. autoConfigure(material: NodeMaterial): void;
  98057. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98058. isReady(): boolean;
  98059. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98060. /**
  98061. * Gets the main code of the block (fragment side)
  98062. * @param state current state of the node material building
  98063. * @returns the shader code
  98064. */
  98065. getCode(state: NodeMaterialBuildState): string;
  98066. protected _buildBlock(state: NodeMaterialBuildState): this;
  98067. protected _dumpPropertiesCode(): string;
  98068. serialize(): any;
  98069. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98070. }
  98071. }
  98072. declare module BABYLON {
  98073. /**
  98074. * Base block used as input for post process
  98075. */
  98076. export class CurrentScreenBlock extends NodeMaterialBlock {
  98077. private _samplerName;
  98078. private _linearDefineName;
  98079. private _gammaDefineName;
  98080. private _mainUVName;
  98081. private _tempTextureRead;
  98082. /**
  98083. * Gets or sets the texture associated with the node
  98084. */
  98085. texture: Nullable<BaseTexture>;
  98086. /**
  98087. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98088. */
  98089. convertToGammaSpace: boolean;
  98090. /**
  98091. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98092. */
  98093. convertToLinearSpace: boolean;
  98094. /**
  98095. * Create a new CurrentScreenBlock
  98096. * @param name defines the block name
  98097. */
  98098. constructor(name: string);
  98099. /**
  98100. * Gets the current class name
  98101. * @returns the class name
  98102. */
  98103. getClassName(): string;
  98104. /**
  98105. * Gets the uv input component
  98106. */
  98107. get uv(): NodeMaterialConnectionPoint;
  98108. /**
  98109. * Gets the rgba output component
  98110. */
  98111. get rgba(): NodeMaterialConnectionPoint;
  98112. /**
  98113. * Gets the rgb output component
  98114. */
  98115. get rgb(): NodeMaterialConnectionPoint;
  98116. /**
  98117. * Gets the r output component
  98118. */
  98119. get r(): NodeMaterialConnectionPoint;
  98120. /**
  98121. * Gets the g output component
  98122. */
  98123. get g(): NodeMaterialConnectionPoint;
  98124. /**
  98125. * Gets the b output component
  98126. */
  98127. get b(): NodeMaterialConnectionPoint;
  98128. /**
  98129. * Gets the a output component
  98130. */
  98131. get a(): NodeMaterialConnectionPoint;
  98132. /**
  98133. * Initialize the block and prepare the context for build
  98134. * @param state defines the state that will be used for the build
  98135. */
  98136. initialize(state: NodeMaterialBuildState): void;
  98137. get target(): NodeMaterialBlockTargets;
  98138. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98139. isReady(): boolean;
  98140. private _injectVertexCode;
  98141. private _writeTextureRead;
  98142. private _writeOutput;
  98143. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98144. serialize(): any;
  98145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98146. }
  98147. }
  98148. declare module BABYLON {
  98149. /**
  98150. * Base block used for the particle texture
  98151. */
  98152. export class ParticleTextureBlock extends NodeMaterialBlock {
  98153. private _samplerName;
  98154. private _linearDefineName;
  98155. private _gammaDefineName;
  98156. private _tempTextureRead;
  98157. /**
  98158. * Gets or sets the texture associated with the node
  98159. */
  98160. texture: Nullable<BaseTexture>;
  98161. /**
  98162. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98163. */
  98164. convertToGammaSpace: boolean;
  98165. /**
  98166. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98167. */
  98168. convertToLinearSpace: boolean;
  98169. /**
  98170. * Create a new ParticleTextureBlock
  98171. * @param name defines the block name
  98172. */
  98173. constructor(name: string);
  98174. /**
  98175. * Gets the current class name
  98176. * @returns the class name
  98177. */
  98178. getClassName(): string;
  98179. /**
  98180. * Gets the uv input component
  98181. */
  98182. get uv(): NodeMaterialConnectionPoint;
  98183. /**
  98184. * Gets the rgba output component
  98185. */
  98186. get rgba(): NodeMaterialConnectionPoint;
  98187. /**
  98188. * Gets the rgb output component
  98189. */
  98190. get rgb(): NodeMaterialConnectionPoint;
  98191. /**
  98192. * Gets the r output component
  98193. */
  98194. get r(): NodeMaterialConnectionPoint;
  98195. /**
  98196. * Gets the g output component
  98197. */
  98198. get g(): NodeMaterialConnectionPoint;
  98199. /**
  98200. * Gets the b output component
  98201. */
  98202. get b(): NodeMaterialConnectionPoint;
  98203. /**
  98204. * Gets the a output component
  98205. */
  98206. get a(): NodeMaterialConnectionPoint;
  98207. /**
  98208. * Initialize the block and prepare the context for build
  98209. * @param state defines the state that will be used for the build
  98210. */
  98211. initialize(state: NodeMaterialBuildState): void;
  98212. autoConfigure(material: NodeMaterial): void;
  98213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98214. isReady(): boolean;
  98215. private _writeOutput;
  98216. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98217. serialize(): any;
  98218. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98219. }
  98220. }
  98221. declare module BABYLON {
  98222. /**
  98223. * Class used to store shared data between 2 NodeMaterialBuildState
  98224. */
  98225. export class NodeMaterialBuildStateSharedData {
  98226. /**
  98227. * Gets the list of emitted varyings
  98228. */
  98229. temps: string[];
  98230. /**
  98231. * Gets the list of emitted varyings
  98232. */
  98233. varyings: string[];
  98234. /**
  98235. * Gets the varying declaration string
  98236. */
  98237. varyingDeclaration: string;
  98238. /**
  98239. * Input blocks
  98240. */
  98241. inputBlocks: InputBlock[];
  98242. /**
  98243. * Input blocks
  98244. */
  98245. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98246. /**
  98247. * Bindable blocks (Blocks that need to set data to the effect)
  98248. */
  98249. bindableBlocks: NodeMaterialBlock[];
  98250. /**
  98251. * List of blocks that can provide a compilation fallback
  98252. */
  98253. blocksWithFallbacks: NodeMaterialBlock[];
  98254. /**
  98255. * List of blocks that can provide a define update
  98256. */
  98257. blocksWithDefines: NodeMaterialBlock[];
  98258. /**
  98259. * List of blocks that can provide a repeatable content
  98260. */
  98261. repeatableContentBlocks: NodeMaterialBlock[];
  98262. /**
  98263. * List of blocks that can provide a dynamic list of uniforms
  98264. */
  98265. dynamicUniformBlocks: NodeMaterialBlock[];
  98266. /**
  98267. * List of blocks that can block the isReady function for the material
  98268. */
  98269. blockingBlocks: NodeMaterialBlock[];
  98270. /**
  98271. * Gets the list of animated inputs
  98272. */
  98273. animatedInputs: InputBlock[];
  98274. /**
  98275. * Build Id used to avoid multiple recompilations
  98276. */
  98277. buildId: number;
  98278. /** List of emitted variables */
  98279. variableNames: {
  98280. [key: string]: number;
  98281. };
  98282. /** List of emitted defines */
  98283. defineNames: {
  98284. [key: string]: number;
  98285. };
  98286. /** Should emit comments? */
  98287. emitComments: boolean;
  98288. /** Emit build activity */
  98289. verbose: boolean;
  98290. /** Gets or sets the hosting scene */
  98291. scene: Scene;
  98292. /**
  98293. * Gets the compilation hints emitted at compilation time
  98294. */
  98295. hints: {
  98296. needWorldViewMatrix: boolean;
  98297. needWorldViewProjectionMatrix: boolean;
  98298. needAlphaBlending: boolean;
  98299. needAlphaTesting: boolean;
  98300. };
  98301. /**
  98302. * List of compilation checks
  98303. */
  98304. checks: {
  98305. emitVertex: boolean;
  98306. emitFragment: boolean;
  98307. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98308. };
  98309. /**
  98310. * Is vertex program allowed to be empty?
  98311. */
  98312. allowEmptyVertexProgram: boolean;
  98313. /** Creates a new shared data */
  98314. constructor();
  98315. /**
  98316. * Emits console errors and exceptions if there is a failing check
  98317. */
  98318. emitErrors(): void;
  98319. }
  98320. }
  98321. declare module BABYLON {
  98322. /**
  98323. * Class used to store node based material build state
  98324. */
  98325. export class NodeMaterialBuildState {
  98326. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98327. supportUniformBuffers: boolean;
  98328. /**
  98329. * Gets the list of emitted attributes
  98330. */
  98331. attributes: string[];
  98332. /**
  98333. * Gets the list of emitted uniforms
  98334. */
  98335. uniforms: string[];
  98336. /**
  98337. * Gets the list of emitted constants
  98338. */
  98339. constants: string[];
  98340. /**
  98341. * Gets the list of emitted samplers
  98342. */
  98343. samplers: string[];
  98344. /**
  98345. * Gets the list of emitted functions
  98346. */
  98347. functions: {
  98348. [key: string]: string;
  98349. };
  98350. /**
  98351. * Gets the list of emitted extensions
  98352. */
  98353. extensions: {
  98354. [key: string]: string;
  98355. };
  98356. /**
  98357. * Gets the target of the compilation state
  98358. */
  98359. target: NodeMaterialBlockTargets;
  98360. /**
  98361. * Gets the list of emitted counters
  98362. */
  98363. counters: {
  98364. [key: string]: number;
  98365. };
  98366. /**
  98367. * Shared data between multiple NodeMaterialBuildState instances
  98368. */
  98369. sharedData: NodeMaterialBuildStateSharedData;
  98370. /** @hidden */
  98371. _vertexState: NodeMaterialBuildState;
  98372. /** @hidden */
  98373. _attributeDeclaration: string;
  98374. /** @hidden */
  98375. _uniformDeclaration: string;
  98376. /** @hidden */
  98377. _constantDeclaration: string;
  98378. /** @hidden */
  98379. _samplerDeclaration: string;
  98380. /** @hidden */
  98381. _varyingTransfer: string;
  98382. /** @hidden */
  98383. _injectAtEnd: string;
  98384. private _repeatableContentAnchorIndex;
  98385. /** @hidden */
  98386. _builtCompilationString: string;
  98387. /**
  98388. * Gets the emitted compilation strings
  98389. */
  98390. compilationString: string;
  98391. /**
  98392. * Finalize the compilation strings
  98393. * @param state defines the current compilation state
  98394. */
  98395. finalize(state: NodeMaterialBuildState): void;
  98396. /** @hidden */
  98397. get _repeatableContentAnchor(): string;
  98398. /** @hidden */
  98399. _getFreeVariableName(prefix: string): string;
  98400. /** @hidden */
  98401. _getFreeDefineName(prefix: string): string;
  98402. /** @hidden */
  98403. _excludeVariableName(name: string): void;
  98404. /** @hidden */
  98405. _emit2DSampler(name: string): void;
  98406. /** @hidden */
  98407. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  98408. /** @hidden */
  98409. _emitExtension(name: string, extension: string, define?: string): void;
  98410. /** @hidden */
  98411. _emitFunction(name: string, code: string, comments: string): void;
  98412. /** @hidden */
  98413. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  98414. replaceStrings?: {
  98415. search: RegExp;
  98416. replace: string;
  98417. }[];
  98418. repeatKey?: string;
  98419. }): string;
  98420. /** @hidden */
  98421. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  98422. repeatKey?: string;
  98423. removeAttributes?: boolean;
  98424. removeUniforms?: boolean;
  98425. removeVaryings?: boolean;
  98426. removeIfDef?: boolean;
  98427. replaceStrings?: {
  98428. search: RegExp;
  98429. replace: string;
  98430. }[];
  98431. }, storeKey?: string): void;
  98432. /** @hidden */
  98433. _registerTempVariable(name: string): boolean;
  98434. /** @hidden */
  98435. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  98436. /** @hidden */
  98437. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  98438. /** @hidden */
  98439. _emitFloat(value: number): string;
  98440. }
  98441. }
  98442. declare module BABYLON {
  98443. /**
  98444. * Helper class used to generate session unique ID
  98445. */
  98446. export class UniqueIdGenerator {
  98447. private static _UniqueIdCounter;
  98448. /**
  98449. * Gets an unique (relatively to the current scene) Id
  98450. */
  98451. static get UniqueId(): number;
  98452. }
  98453. }
  98454. declare module BABYLON {
  98455. /**
  98456. * Defines a block that can be used inside a node based material
  98457. */
  98458. export class NodeMaterialBlock {
  98459. private _buildId;
  98460. private _buildTarget;
  98461. private _target;
  98462. private _isFinalMerger;
  98463. private _isInput;
  98464. protected _isUnique: boolean;
  98465. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98466. inputsAreExclusive: boolean;
  98467. /** @hidden */
  98468. _codeVariableName: string;
  98469. /** @hidden */
  98470. _inputs: NodeMaterialConnectionPoint[];
  98471. /** @hidden */
  98472. _outputs: NodeMaterialConnectionPoint[];
  98473. /** @hidden */
  98474. _preparationId: number;
  98475. /**
  98476. * Gets or sets the name of the block
  98477. */
  98478. name: string;
  98479. /**
  98480. * Gets or sets the unique id of the node
  98481. */
  98482. uniqueId: number;
  98483. /**
  98484. * Gets or sets the comments associated with this block
  98485. */
  98486. comments: string;
  98487. /**
  98488. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98489. */
  98490. get isUnique(): boolean;
  98491. /**
  98492. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98493. */
  98494. get isFinalMerger(): boolean;
  98495. /**
  98496. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98497. */
  98498. get isInput(): boolean;
  98499. /**
  98500. * Gets or sets the build Id
  98501. */
  98502. get buildId(): number;
  98503. set buildId(value: number);
  98504. /**
  98505. * Gets or sets the target of the block
  98506. */
  98507. get target(): NodeMaterialBlockTargets;
  98508. set target(value: NodeMaterialBlockTargets);
  98509. /**
  98510. * Gets the list of input points
  98511. */
  98512. get inputs(): NodeMaterialConnectionPoint[];
  98513. /** Gets the list of output points */
  98514. get outputs(): NodeMaterialConnectionPoint[];
  98515. /**
  98516. * Find an input by its name
  98517. * @param name defines the name of the input to look for
  98518. * @returns the input or null if not found
  98519. */
  98520. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98521. /**
  98522. * Find an output by its name
  98523. * @param name defines the name of the outputto look for
  98524. * @returns the output or null if not found
  98525. */
  98526. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98527. /**
  98528. * Creates a new NodeMaterialBlock
  98529. * @param name defines the block name
  98530. * @param target defines the target of that block (Vertex by default)
  98531. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  98532. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  98533. */
  98534. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  98535. /**
  98536. * Initialize the block and prepare the context for build
  98537. * @param state defines the state that will be used for the build
  98538. */
  98539. initialize(state: NodeMaterialBuildState): void;
  98540. /**
  98541. * Bind data to effect. Will only be called for blocks with isBindable === true
  98542. * @param effect defines the effect to bind data to
  98543. * @param nodeMaterial defines the hosting NodeMaterial
  98544. * @param mesh defines the mesh that will be rendered
  98545. * @param subMesh defines the submesh that will be rendered
  98546. */
  98547. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98548. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  98549. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  98550. protected _writeFloat(value: number): string;
  98551. /**
  98552. * Gets the current class name e.g. "NodeMaterialBlock"
  98553. * @returns the class name
  98554. */
  98555. getClassName(): string;
  98556. /**
  98557. * Register a new input. Must be called inside a block constructor
  98558. * @param name defines the connection point name
  98559. * @param type defines the connection point type
  98560. * @param isOptional defines a boolean indicating that this input can be omitted
  98561. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98562. * @param point an already created connection point. If not provided, create a new one
  98563. * @returns the current block
  98564. */
  98565. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98566. /**
  98567. * Register a new output. Must be called inside a block constructor
  98568. * @param name defines the connection point name
  98569. * @param type defines the connection point type
  98570. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98571. * @param point an already created connection point. If not provided, create a new one
  98572. * @returns the current block
  98573. */
  98574. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98575. /**
  98576. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  98577. * @param forOutput defines an optional connection point to check compatibility with
  98578. * @returns the first available input or null
  98579. */
  98580. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  98581. /**
  98582. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  98583. * @param forBlock defines an optional block to check compatibility with
  98584. * @returns the first available input or null
  98585. */
  98586. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  98587. /**
  98588. * Gets the sibling of the given output
  98589. * @param current defines the current output
  98590. * @returns the next output in the list or null
  98591. */
  98592. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  98593. /**
  98594. * Connect current block with another block
  98595. * @param other defines the block to connect with
  98596. * @param options define the various options to help pick the right connections
  98597. * @returns the current block
  98598. */
  98599. connectTo(other: NodeMaterialBlock, options?: {
  98600. input?: string;
  98601. output?: string;
  98602. outputSwizzle?: string;
  98603. }): this | undefined;
  98604. protected _buildBlock(state: NodeMaterialBuildState): void;
  98605. /**
  98606. * Add uniforms, samplers and uniform buffers at compilation time
  98607. * @param state defines the state to update
  98608. * @param nodeMaterial defines the node material requesting the update
  98609. * @param defines defines the material defines to update
  98610. * @param uniformBuffers defines the list of uniform buffer names
  98611. */
  98612. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  98613. /**
  98614. * Add potential fallbacks if shader compilation fails
  98615. * @param mesh defines the mesh to be rendered
  98616. * @param fallbacks defines the current prioritized list of fallbacks
  98617. */
  98618. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  98619. /**
  98620. * Initialize defines for shader compilation
  98621. * @param mesh defines the mesh to be rendered
  98622. * @param nodeMaterial defines the node material requesting the update
  98623. * @param defines defines the material defines to update
  98624. * @param useInstances specifies that instances should be used
  98625. */
  98626. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98627. /**
  98628. * Update defines for shader compilation
  98629. * @param mesh defines the mesh to be rendered
  98630. * @param nodeMaterial defines the node material requesting the update
  98631. * @param defines defines the material defines to update
  98632. * @param useInstances specifies that instances should be used
  98633. * @param subMesh defines which submesh to render
  98634. */
  98635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98636. /**
  98637. * Lets the block try to connect some inputs automatically
  98638. * @param material defines the hosting NodeMaterial
  98639. */
  98640. autoConfigure(material: NodeMaterial): void;
  98641. /**
  98642. * Function called when a block is declared as repeatable content generator
  98643. * @param vertexShaderState defines the current compilation state for the vertex shader
  98644. * @param fragmentShaderState defines the current compilation state for the fragment shader
  98645. * @param mesh defines the mesh to be rendered
  98646. * @param defines defines the material defines to update
  98647. */
  98648. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  98649. /**
  98650. * Checks if the block is ready
  98651. * @param mesh defines the mesh to be rendered
  98652. * @param nodeMaterial defines the node material requesting the update
  98653. * @param defines defines the material defines to update
  98654. * @param useInstances specifies that instances should be used
  98655. * @returns true if the block is ready
  98656. */
  98657. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  98658. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  98659. private _processBuild;
  98660. /**
  98661. * Compile the current node and generate the shader code
  98662. * @param state defines the current compilation state (uniforms, samplers, current string)
  98663. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  98664. * @returns true if already built
  98665. */
  98666. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  98667. protected _inputRename(name: string): string;
  98668. protected _outputRename(name: string): string;
  98669. protected _dumpPropertiesCode(): string;
  98670. /** @hidden */
  98671. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  98672. /** @hidden */
  98673. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  98674. /**
  98675. * Clone the current block to a new identical block
  98676. * @param scene defines the hosting scene
  98677. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98678. * @returns a copy of the current block
  98679. */
  98680. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  98681. /**
  98682. * Serializes this block in a JSON representation
  98683. * @returns the serialized block object
  98684. */
  98685. serialize(): any;
  98686. /** @hidden */
  98687. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98688. private _deserializePortDisplayNames;
  98689. /**
  98690. * Release resources
  98691. */
  98692. dispose(): void;
  98693. }
  98694. }
  98695. declare module BABYLON {
  98696. /**
  98697. * Base class of materials working in push mode in babylon JS
  98698. * @hidden
  98699. */
  98700. export class PushMaterial extends Material {
  98701. protected _activeEffect: Effect;
  98702. protected _normalMatrix: Matrix;
  98703. /**
  98704. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98705. * This means that the material can keep using a previous shader while a new one is being compiled.
  98706. * This is mostly used when shader parallel compilation is supported (true by default)
  98707. */
  98708. allowShaderHotSwapping: boolean;
  98709. constructor(name: string, scene: Scene);
  98710. getEffect(): Effect;
  98711. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98712. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  98713. /**
  98714. * Binds the given world matrix to the active effect
  98715. *
  98716. * @param world the matrix to bind
  98717. */
  98718. bindOnlyWorldMatrix(world: Matrix): void;
  98719. /**
  98720. * Binds the given normal matrix to the active effect
  98721. *
  98722. * @param normalMatrix the matrix to bind
  98723. */
  98724. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98725. bind(world: Matrix, mesh?: Mesh): void;
  98726. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98727. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98728. }
  98729. }
  98730. declare module BABYLON {
  98731. /**
  98732. * Root class for all node material optimizers
  98733. */
  98734. export class NodeMaterialOptimizer {
  98735. /**
  98736. * Function used to optimize a NodeMaterial graph
  98737. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  98738. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  98739. */
  98740. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  98741. }
  98742. }
  98743. declare module BABYLON {
  98744. /**
  98745. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  98746. */
  98747. export class TransformBlock extends NodeMaterialBlock {
  98748. /**
  98749. * Defines the value to use to complement W value to transform it to a Vector4
  98750. */
  98751. complementW: number;
  98752. /**
  98753. * Defines the value to use to complement z value to transform it to a Vector4
  98754. */
  98755. complementZ: number;
  98756. /**
  98757. * Creates a new TransformBlock
  98758. * @param name defines the block name
  98759. */
  98760. constructor(name: string);
  98761. /**
  98762. * Gets the current class name
  98763. * @returns the class name
  98764. */
  98765. getClassName(): string;
  98766. /**
  98767. * Gets the vector input
  98768. */
  98769. get vector(): NodeMaterialConnectionPoint;
  98770. /**
  98771. * Gets the output component
  98772. */
  98773. get output(): NodeMaterialConnectionPoint;
  98774. /**
  98775. * Gets the xyz output component
  98776. */
  98777. get xyz(): NodeMaterialConnectionPoint;
  98778. /**
  98779. * Gets the matrix transform input
  98780. */
  98781. get transform(): NodeMaterialConnectionPoint;
  98782. protected _buildBlock(state: NodeMaterialBuildState): this;
  98783. serialize(): any;
  98784. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98785. protected _dumpPropertiesCode(): string;
  98786. }
  98787. }
  98788. declare module BABYLON {
  98789. /**
  98790. * Block used to output the vertex position
  98791. */
  98792. export class VertexOutputBlock extends NodeMaterialBlock {
  98793. /**
  98794. * Creates a new VertexOutputBlock
  98795. * @param name defines the block name
  98796. */
  98797. constructor(name: string);
  98798. /**
  98799. * Gets the current class name
  98800. * @returns the class name
  98801. */
  98802. getClassName(): string;
  98803. /**
  98804. * Gets the vector input component
  98805. */
  98806. get vector(): NodeMaterialConnectionPoint;
  98807. protected _buildBlock(state: NodeMaterialBuildState): this;
  98808. }
  98809. }
  98810. declare module BABYLON {
  98811. /**
  98812. * Block used to output the final color
  98813. */
  98814. export class FragmentOutputBlock extends NodeMaterialBlock {
  98815. /**
  98816. * Create a new FragmentOutputBlock
  98817. * @param name defines the block name
  98818. */
  98819. constructor(name: string);
  98820. /**
  98821. * Gets the current class name
  98822. * @returns the class name
  98823. */
  98824. getClassName(): string;
  98825. /**
  98826. * Gets the rgba input component
  98827. */
  98828. get rgba(): NodeMaterialConnectionPoint;
  98829. /**
  98830. * Gets the rgb input component
  98831. */
  98832. get rgb(): NodeMaterialConnectionPoint;
  98833. /**
  98834. * Gets the a input component
  98835. */
  98836. get a(): NodeMaterialConnectionPoint;
  98837. protected _buildBlock(state: NodeMaterialBuildState): this;
  98838. }
  98839. }
  98840. declare module BABYLON {
  98841. /**
  98842. * Block used for the particle ramp gradient section
  98843. */
  98844. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  98845. /**
  98846. * Create a new ParticleRampGradientBlock
  98847. * @param name defines the block name
  98848. */
  98849. constructor(name: string);
  98850. /**
  98851. * Gets the current class name
  98852. * @returns the class name
  98853. */
  98854. getClassName(): string;
  98855. /**
  98856. * Gets the color input component
  98857. */
  98858. get color(): NodeMaterialConnectionPoint;
  98859. /**
  98860. * Gets the rampColor output component
  98861. */
  98862. get rampColor(): NodeMaterialConnectionPoint;
  98863. /**
  98864. * Initialize the block and prepare the context for build
  98865. * @param state defines the state that will be used for the build
  98866. */
  98867. initialize(state: NodeMaterialBuildState): void;
  98868. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98869. }
  98870. }
  98871. declare module BABYLON {
  98872. /**
  98873. * Block used for the particle blend multiply section
  98874. */
  98875. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  98876. /**
  98877. * Create a new ParticleBlendMultiplyBlock
  98878. * @param name defines the block name
  98879. */
  98880. constructor(name: string);
  98881. /**
  98882. * Gets the current class name
  98883. * @returns the class name
  98884. */
  98885. getClassName(): string;
  98886. /**
  98887. * Gets the color input component
  98888. */
  98889. get color(): NodeMaterialConnectionPoint;
  98890. /**
  98891. * Gets the alphaTexture input component
  98892. */
  98893. get alphaTexture(): NodeMaterialConnectionPoint;
  98894. /**
  98895. * Gets the alphaColor input component
  98896. */
  98897. get alphaColor(): NodeMaterialConnectionPoint;
  98898. /**
  98899. * Gets the blendColor output component
  98900. */
  98901. get blendColor(): NodeMaterialConnectionPoint;
  98902. /**
  98903. * Initialize the block and prepare the context for build
  98904. * @param state defines the state that will be used for the build
  98905. */
  98906. initialize(state: NodeMaterialBuildState): void;
  98907. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98908. }
  98909. }
  98910. declare module BABYLON {
  98911. /**
  98912. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  98913. */
  98914. export class VectorMergerBlock extends NodeMaterialBlock {
  98915. /**
  98916. * Create a new VectorMergerBlock
  98917. * @param name defines the block name
  98918. */
  98919. constructor(name: string);
  98920. /**
  98921. * Gets the current class name
  98922. * @returns the class name
  98923. */
  98924. getClassName(): string;
  98925. /**
  98926. * Gets the xyz component (input)
  98927. */
  98928. get xyzIn(): NodeMaterialConnectionPoint;
  98929. /**
  98930. * Gets the xy component (input)
  98931. */
  98932. get xyIn(): NodeMaterialConnectionPoint;
  98933. /**
  98934. * Gets the x component (input)
  98935. */
  98936. get x(): NodeMaterialConnectionPoint;
  98937. /**
  98938. * Gets the y component (input)
  98939. */
  98940. get y(): NodeMaterialConnectionPoint;
  98941. /**
  98942. * Gets the z component (input)
  98943. */
  98944. get z(): NodeMaterialConnectionPoint;
  98945. /**
  98946. * Gets the w component (input)
  98947. */
  98948. get w(): NodeMaterialConnectionPoint;
  98949. /**
  98950. * Gets the xyzw component (output)
  98951. */
  98952. get xyzw(): NodeMaterialConnectionPoint;
  98953. /**
  98954. * Gets the xyz component (output)
  98955. */
  98956. get xyzOut(): NodeMaterialConnectionPoint;
  98957. /**
  98958. * Gets the xy component (output)
  98959. */
  98960. get xyOut(): NodeMaterialConnectionPoint;
  98961. /**
  98962. * Gets the xy component (output)
  98963. * @deprecated Please use xyOut instead.
  98964. */
  98965. get xy(): NodeMaterialConnectionPoint;
  98966. /**
  98967. * Gets the xyz component (output)
  98968. * @deprecated Please use xyzOut instead.
  98969. */
  98970. get xyz(): NodeMaterialConnectionPoint;
  98971. protected _buildBlock(state: NodeMaterialBuildState): this;
  98972. }
  98973. }
  98974. declare module BABYLON {
  98975. /**
  98976. * Block used to remap a float from a range to a new one
  98977. */
  98978. export class RemapBlock extends NodeMaterialBlock {
  98979. /**
  98980. * Gets or sets the source range
  98981. */
  98982. sourceRange: Vector2;
  98983. /**
  98984. * Gets or sets the target range
  98985. */
  98986. targetRange: Vector2;
  98987. /**
  98988. * Creates a new RemapBlock
  98989. * @param name defines the block name
  98990. */
  98991. constructor(name: string);
  98992. /**
  98993. * Gets the current class name
  98994. * @returns the class name
  98995. */
  98996. getClassName(): string;
  98997. /**
  98998. * Gets the input component
  98999. */
  99000. get input(): NodeMaterialConnectionPoint;
  99001. /**
  99002. * Gets the source min input component
  99003. */
  99004. get sourceMin(): NodeMaterialConnectionPoint;
  99005. /**
  99006. * Gets the source max input component
  99007. */
  99008. get sourceMax(): NodeMaterialConnectionPoint;
  99009. /**
  99010. * Gets the target min input component
  99011. */
  99012. get targetMin(): NodeMaterialConnectionPoint;
  99013. /**
  99014. * Gets the target max input component
  99015. */
  99016. get targetMax(): NodeMaterialConnectionPoint;
  99017. /**
  99018. * Gets the output component
  99019. */
  99020. get output(): NodeMaterialConnectionPoint;
  99021. protected _buildBlock(state: NodeMaterialBuildState): this;
  99022. protected _dumpPropertiesCode(): string;
  99023. serialize(): any;
  99024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99025. }
  99026. }
  99027. declare module BABYLON {
  99028. /**
  99029. * Block used to multiply 2 values
  99030. */
  99031. export class MultiplyBlock extends NodeMaterialBlock {
  99032. /**
  99033. * Creates a new MultiplyBlock
  99034. * @param name defines the block name
  99035. */
  99036. constructor(name: string);
  99037. /**
  99038. * Gets the current class name
  99039. * @returns the class name
  99040. */
  99041. getClassName(): string;
  99042. /**
  99043. * Gets the left operand input component
  99044. */
  99045. get left(): NodeMaterialConnectionPoint;
  99046. /**
  99047. * Gets the right operand input component
  99048. */
  99049. get right(): NodeMaterialConnectionPoint;
  99050. /**
  99051. * Gets the output component
  99052. */
  99053. get output(): NodeMaterialConnectionPoint;
  99054. protected _buildBlock(state: NodeMaterialBuildState): this;
  99055. }
  99056. }
  99057. declare module BABYLON {
  99058. /**
  99059. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  99060. */
  99061. export class ColorSplitterBlock extends NodeMaterialBlock {
  99062. /**
  99063. * Create a new ColorSplitterBlock
  99064. * @param name defines the block name
  99065. */
  99066. constructor(name: string);
  99067. /**
  99068. * Gets the current class name
  99069. * @returns the class name
  99070. */
  99071. getClassName(): string;
  99072. /**
  99073. * Gets the rgba component (input)
  99074. */
  99075. get rgba(): NodeMaterialConnectionPoint;
  99076. /**
  99077. * Gets the rgb component (input)
  99078. */
  99079. get rgbIn(): NodeMaterialConnectionPoint;
  99080. /**
  99081. * Gets the rgb component (output)
  99082. */
  99083. get rgbOut(): NodeMaterialConnectionPoint;
  99084. /**
  99085. * Gets the r component (output)
  99086. */
  99087. get r(): NodeMaterialConnectionPoint;
  99088. /**
  99089. * Gets the g component (output)
  99090. */
  99091. get g(): NodeMaterialConnectionPoint;
  99092. /**
  99093. * Gets the b component (output)
  99094. */
  99095. get b(): NodeMaterialConnectionPoint;
  99096. /**
  99097. * Gets the a component (output)
  99098. */
  99099. get a(): NodeMaterialConnectionPoint;
  99100. protected _inputRename(name: string): string;
  99101. protected _outputRename(name: string): string;
  99102. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99103. }
  99104. }
  99105. declare module BABYLON {
  99106. /**
  99107. * Interface used to configure the node material editor
  99108. */
  99109. export interface INodeMaterialEditorOptions {
  99110. /** Define the URl to load node editor script */
  99111. editorURL?: string;
  99112. }
  99113. /** @hidden */
  99114. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99115. NORMAL: boolean;
  99116. TANGENT: boolean;
  99117. UV1: boolean;
  99118. /** BONES */
  99119. NUM_BONE_INFLUENCERS: number;
  99120. BonesPerMesh: number;
  99121. BONETEXTURE: boolean;
  99122. /** MORPH TARGETS */
  99123. MORPHTARGETS: boolean;
  99124. MORPHTARGETS_NORMAL: boolean;
  99125. MORPHTARGETS_TANGENT: boolean;
  99126. MORPHTARGETS_UV: boolean;
  99127. NUM_MORPH_INFLUENCERS: number;
  99128. /** IMAGE PROCESSING */
  99129. IMAGEPROCESSING: boolean;
  99130. VIGNETTE: boolean;
  99131. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99132. VIGNETTEBLENDMODEOPAQUE: boolean;
  99133. TONEMAPPING: boolean;
  99134. TONEMAPPING_ACES: boolean;
  99135. CONTRAST: boolean;
  99136. EXPOSURE: boolean;
  99137. COLORCURVES: boolean;
  99138. COLORGRADING: boolean;
  99139. COLORGRADING3D: boolean;
  99140. SAMPLER3DGREENDEPTH: boolean;
  99141. SAMPLER3DBGRMAP: boolean;
  99142. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99143. /** MISC. */
  99144. BUMPDIRECTUV: number;
  99145. constructor();
  99146. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  99147. }
  99148. /**
  99149. * Class used to configure NodeMaterial
  99150. */
  99151. export interface INodeMaterialOptions {
  99152. /**
  99153. * Defines if blocks should emit comments
  99154. */
  99155. emitComments: boolean;
  99156. }
  99157. /**
  99158. * Class used to create a node based material built by assembling shader blocks
  99159. */
  99160. export class NodeMaterial extends PushMaterial {
  99161. private static _BuildIdGenerator;
  99162. private _options;
  99163. private _vertexCompilationState;
  99164. private _fragmentCompilationState;
  99165. private _sharedData;
  99166. private _buildId;
  99167. private _buildWasSuccessful;
  99168. private _cachedWorldViewMatrix;
  99169. private _cachedWorldViewProjectionMatrix;
  99170. private _optimizers;
  99171. private _animationFrame;
  99172. /** Define the Url to load node editor script */
  99173. static EditorURL: string;
  99174. /** Define the Url to load snippets */
  99175. static SnippetUrl: string;
  99176. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  99177. static IgnoreTexturesAtLoadTime: boolean;
  99178. private BJSNODEMATERIALEDITOR;
  99179. /** Get the inspector from bundle or global */
  99180. private _getGlobalNodeMaterialEditor;
  99181. /**
  99182. * Snippet ID if the material was created from the snippet server
  99183. */
  99184. snippetId: string;
  99185. /**
  99186. * Gets or sets data used by visual editor
  99187. * @see https://nme.babylonjs.com
  99188. */
  99189. editorData: any;
  99190. /**
  99191. * 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)
  99192. */
  99193. ignoreAlpha: boolean;
  99194. /**
  99195. * Defines the maximum number of lights that can be used in the material
  99196. */
  99197. maxSimultaneousLights: number;
  99198. /**
  99199. * Observable raised when the material is built
  99200. */
  99201. onBuildObservable: Observable<NodeMaterial>;
  99202. /**
  99203. * Gets or sets the root nodes of the material vertex shader
  99204. */
  99205. _vertexOutputNodes: NodeMaterialBlock[];
  99206. /**
  99207. * Gets or sets the root nodes of the material fragment (pixel) shader
  99208. */
  99209. _fragmentOutputNodes: NodeMaterialBlock[];
  99210. /** Gets or sets options to control the node material overall behavior */
  99211. get options(): INodeMaterialOptions;
  99212. set options(options: INodeMaterialOptions);
  99213. /**
  99214. * Default configuration related to image processing available in the standard Material.
  99215. */
  99216. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99217. /**
  99218. * Gets the image processing configuration used either in this material.
  99219. */
  99220. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99221. /**
  99222. * Sets the Default image processing configuration used either in the this material.
  99223. *
  99224. * If sets to null, the scene one is in use.
  99225. */
  99226. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99227. /**
  99228. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99229. */
  99230. attachedBlocks: NodeMaterialBlock[];
  99231. /**
  99232. * Specifies the mode of the node material
  99233. * @hidden
  99234. */
  99235. _mode: NodeMaterialModes;
  99236. /**
  99237. * Gets the mode property
  99238. */
  99239. get mode(): NodeMaterialModes;
  99240. /**
  99241. * Create a new node based material
  99242. * @param name defines the material name
  99243. * @param scene defines the hosting scene
  99244. * @param options defines creation option
  99245. */
  99246. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99247. /**
  99248. * Gets the current class name of the material e.g. "NodeMaterial"
  99249. * @returns the class name
  99250. */
  99251. getClassName(): string;
  99252. /**
  99253. * Keep track of the image processing observer to allow dispose and replace.
  99254. */
  99255. private _imageProcessingObserver;
  99256. /**
  99257. * Attaches a new image processing configuration to the Standard Material.
  99258. * @param configuration
  99259. */
  99260. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99261. /**
  99262. * Get a block by its name
  99263. * @param name defines the name of the block to retrieve
  99264. * @returns the required block or null if not found
  99265. */
  99266. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99267. /**
  99268. * Get a block by its name
  99269. * @param predicate defines the predicate used to find the good candidate
  99270. * @returns the required block or null if not found
  99271. */
  99272. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99273. /**
  99274. * Get an input block by its name
  99275. * @param predicate defines the predicate used to find the good candidate
  99276. * @returns the required input block or null if not found
  99277. */
  99278. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99279. /**
  99280. * Gets the list of input blocks attached to this material
  99281. * @returns an array of InputBlocks
  99282. */
  99283. getInputBlocks(): InputBlock[];
  99284. /**
  99285. * Adds a new optimizer to the list of optimizers
  99286. * @param optimizer defines the optimizers to add
  99287. * @returns the current material
  99288. */
  99289. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99290. /**
  99291. * Remove an optimizer from the list of optimizers
  99292. * @param optimizer defines the optimizers to remove
  99293. * @returns the current material
  99294. */
  99295. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99296. /**
  99297. * Add a new block to the list of output nodes
  99298. * @param node defines the node to add
  99299. * @returns the current material
  99300. */
  99301. addOutputNode(node: NodeMaterialBlock): this;
  99302. /**
  99303. * Remove a block from the list of root nodes
  99304. * @param node defines the node to remove
  99305. * @returns the current material
  99306. */
  99307. removeOutputNode(node: NodeMaterialBlock): this;
  99308. private _addVertexOutputNode;
  99309. private _removeVertexOutputNode;
  99310. private _addFragmentOutputNode;
  99311. private _removeFragmentOutputNode;
  99312. /**
  99313. * Specifies if the material will require alpha blending
  99314. * @returns a boolean specifying if alpha blending is needed
  99315. */
  99316. needAlphaBlending(): boolean;
  99317. /**
  99318. * Specifies if this material should be rendered in alpha test mode
  99319. * @returns a boolean specifying if an alpha test is needed.
  99320. */
  99321. needAlphaTesting(): boolean;
  99322. private _initializeBlock;
  99323. private _resetDualBlocks;
  99324. /**
  99325. * Remove a block from the current node material
  99326. * @param block defines the block to remove
  99327. */
  99328. removeBlock(block: NodeMaterialBlock): void;
  99329. /**
  99330. * Build the material and generates the inner effect
  99331. * @param verbose defines if the build should log activity
  99332. */
  99333. build(verbose?: boolean): void;
  99334. /**
  99335. * Runs an otpimization phase to try to improve the shader code
  99336. */
  99337. optimize(): void;
  99338. private _prepareDefinesForAttributes;
  99339. /**
  99340. * Create a post process from the material
  99341. * @param camera The camera to apply the render pass to.
  99342. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99344. * @param engine The engine which the post process will be applied. (default: current engine)
  99345. * @param reusable If the post process can be reused on the same frame. (default: false)
  99346. * @param textureType Type of textures used when performing the post process. (default: 0)
  99347. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99348. * @returns the post process created
  99349. */
  99350. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99351. /**
  99352. * Create the post process effect from the material
  99353. * @param postProcess The post process to create the effect for
  99354. */
  99355. createEffectForPostProcess(postProcess: PostProcess): void;
  99356. private _createEffectOrPostProcess;
  99357. private _createEffectForParticles;
  99358. /**
  99359. * Create the effect to be used as the custom effect for a particle system
  99360. * @param particleSystem Particle system to create the effect for
  99361. * @param onCompiled defines a function to call when the effect creation is successful
  99362. * @param onError defines a function to call when the effect creation has failed
  99363. */
  99364. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99365. private _processDefines;
  99366. /**
  99367. * Get if the submesh is ready to be used and all its information available.
  99368. * Child classes can use it to update shaders
  99369. * @param mesh defines the mesh to check
  99370. * @param subMesh defines which submesh to check
  99371. * @param useInstances specifies that instances should be used
  99372. * @returns a boolean indicating that the submesh is ready or not
  99373. */
  99374. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99375. /**
  99376. * Get a string representing the shaders built by the current node graph
  99377. */
  99378. get compiledShaders(): string;
  99379. /**
  99380. * Binds the world matrix to the material
  99381. * @param world defines the world transformation matrix
  99382. */
  99383. bindOnlyWorldMatrix(world: Matrix): void;
  99384. /**
  99385. * Binds the submesh to this material by preparing the effect and shader to draw
  99386. * @param world defines the world transformation matrix
  99387. * @param mesh defines the mesh containing the submesh
  99388. * @param subMesh defines the submesh to bind the material to
  99389. */
  99390. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99391. /**
  99392. * Gets the active textures from the material
  99393. * @returns an array of textures
  99394. */
  99395. getActiveTextures(): BaseTexture[];
  99396. /**
  99397. * Gets the list of texture blocks
  99398. * @returns an array of texture blocks
  99399. */
  99400. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99401. /**
  99402. * Specifies if the material uses a texture
  99403. * @param texture defines the texture to check against the material
  99404. * @returns a boolean specifying if the material uses the texture
  99405. */
  99406. hasTexture(texture: BaseTexture): boolean;
  99407. /**
  99408. * Disposes the material
  99409. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99410. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99411. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99412. */
  99413. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99414. /** Creates the node editor window. */
  99415. private _createNodeEditor;
  99416. /**
  99417. * Launch the node material editor
  99418. * @param config Define the configuration of the editor
  99419. * @return a promise fulfilled when the node editor is visible
  99420. */
  99421. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99422. /**
  99423. * Clear the current material
  99424. */
  99425. clear(): void;
  99426. /**
  99427. * Clear the current material and set it to a default state
  99428. */
  99429. setToDefault(): void;
  99430. /**
  99431. * Clear the current material and set it to a default state for post process
  99432. */
  99433. setToDefaultPostProcess(): void;
  99434. /**
  99435. * Clear the current material and set it to a default state for particle
  99436. */
  99437. setToDefaultParticle(): void;
  99438. /**
  99439. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99440. * @param url defines the url to load from
  99441. * @returns a promise that will fullfil when the material is fully loaded
  99442. */
  99443. loadAsync(url: string): Promise<void>;
  99444. private _gatherBlocks;
  99445. /**
  99446. * Generate a string containing the code declaration required to create an equivalent of this material
  99447. * @returns a string
  99448. */
  99449. generateCode(): string;
  99450. /**
  99451. * Serializes this material in a JSON representation
  99452. * @returns the serialized material object
  99453. */
  99454. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99455. private _restoreConnections;
  99456. /**
  99457. * Clear the current graph and load a new one from a serialization object
  99458. * @param source defines the JSON representation of the material
  99459. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99460. */
  99461. loadFromSerialization(source: any, rootUrl?: string): void;
  99462. /**
  99463. * Makes a duplicate of the current material.
  99464. * @param name - name to use for the new material.
  99465. */
  99466. clone(name: string): NodeMaterial;
  99467. /**
  99468. * Creates a node material from parsed material data
  99469. * @param source defines the JSON representation of the material
  99470. * @param scene defines the hosting scene
  99471. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99472. * @returns a new node material
  99473. */
  99474. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99475. /**
  99476. * Creates a node material from a snippet saved in a remote file
  99477. * @param name defines the name of the material to create
  99478. * @param url defines the url to load from
  99479. * @param scene defines the hosting scene
  99480. * @returns a promise that will resolve to the new node material
  99481. */
  99482. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99483. /**
  99484. * Creates a node material from a snippet saved by the node material editor
  99485. * @param snippetId defines the snippet to load
  99486. * @param scene defines the hosting scene
  99487. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99488. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99489. * @returns a promise that will resolve to the new node material
  99490. */
  99491. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99492. /**
  99493. * Creates a new node material set to default basic configuration
  99494. * @param name defines the name of the material
  99495. * @param scene defines the hosting scene
  99496. * @returns a new NodeMaterial
  99497. */
  99498. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99499. }
  99500. }
  99501. declare module BABYLON {
  99502. /**
  99503. * Size options for a post process
  99504. */
  99505. export type PostProcessOptions = {
  99506. width: number;
  99507. height: number;
  99508. };
  99509. /**
  99510. * PostProcess can be used to apply a shader to a texture after it has been rendered
  99511. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  99512. */
  99513. export class PostProcess {
  99514. /** Name of the PostProcess. */
  99515. name: string;
  99516. /**
  99517. * Gets or sets the unique id of the post process
  99518. */
  99519. uniqueId: number;
  99520. /**
  99521. * Width of the texture to apply the post process on
  99522. */
  99523. width: number;
  99524. /**
  99525. * Height of the texture to apply the post process on
  99526. */
  99527. height: number;
  99528. /**
  99529. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  99530. */
  99531. nodeMaterialSource: Nullable<NodeMaterial>;
  99532. /**
  99533. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  99534. * @hidden
  99535. */
  99536. _outputTexture: Nullable<InternalTexture>;
  99537. /**
  99538. * Sampling mode used by the shader
  99539. * See https://doc.babylonjs.com/classes/3.1/texture
  99540. */
  99541. renderTargetSamplingMode: number;
  99542. /**
  99543. * Clear color to use when screen clearing
  99544. */
  99545. clearColor: Color4;
  99546. /**
  99547. * If the buffer needs to be cleared before applying the post process. (default: true)
  99548. * Should be set to false if shader will overwrite all previous pixels.
  99549. */
  99550. autoClear: boolean;
  99551. /**
  99552. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  99553. */
  99554. alphaMode: number;
  99555. /**
  99556. * Sets the setAlphaBlendConstants of the babylon engine
  99557. */
  99558. alphaConstants: Color4;
  99559. /**
  99560. * Animations to be used for the post processing
  99561. */
  99562. animations: Animation[];
  99563. /**
  99564. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  99565. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  99566. */
  99567. enablePixelPerfectMode: boolean;
  99568. /**
  99569. * Force the postprocess to be applied without taking in account viewport
  99570. */
  99571. forceFullscreenViewport: boolean;
  99572. /**
  99573. * List of inspectable custom properties (used by the Inspector)
  99574. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99575. */
  99576. inspectableCustomProperties: IInspectable[];
  99577. /**
  99578. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  99579. *
  99580. * | Value | Type | Description |
  99581. * | ----- | ----------------------------------- | ----------- |
  99582. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  99583. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  99584. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  99585. *
  99586. */
  99587. scaleMode: number;
  99588. /**
  99589. * Force textures to be a power of two (default: false)
  99590. */
  99591. alwaysForcePOT: boolean;
  99592. private _samples;
  99593. /**
  99594. * Number of sample textures (default: 1)
  99595. */
  99596. get samples(): number;
  99597. set samples(n: number);
  99598. /**
  99599. * Modify the scale of the post process to be the same as the viewport (default: false)
  99600. */
  99601. adaptScaleToCurrentViewport: boolean;
  99602. private _camera;
  99603. private _scene;
  99604. private _engine;
  99605. private _options;
  99606. private _reusable;
  99607. private _textureType;
  99608. private _textureFormat;
  99609. /**
  99610. * Smart array of input and output textures for the post process.
  99611. * @hidden
  99612. */
  99613. _textures: SmartArray<InternalTexture>;
  99614. /**
  99615. * The index in _textures that corresponds to the output texture.
  99616. * @hidden
  99617. */
  99618. _currentRenderTextureInd: number;
  99619. private _effect;
  99620. private _samplers;
  99621. private _fragmentUrl;
  99622. private _vertexUrl;
  99623. private _parameters;
  99624. private _scaleRatio;
  99625. protected _indexParameters: any;
  99626. private _shareOutputWithPostProcess;
  99627. private _texelSize;
  99628. private _forcedOutputTexture;
  99629. /**
  99630. * Returns the fragment url or shader name used in the post process.
  99631. * @returns the fragment url or name in the shader store.
  99632. */
  99633. getEffectName(): string;
  99634. /**
  99635. * An event triggered when the postprocess is activated.
  99636. */
  99637. onActivateObservable: Observable<Camera>;
  99638. private _onActivateObserver;
  99639. /**
  99640. * A function that is added to the onActivateObservable
  99641. */
  99642. set onActivate(callback: Nullable<(camera: Camera) => void>);
  99643. /**
  99644. * An event triggered when the postprocess changes its size.
  99645. */
  99646. onSizeChangedObservable: Observable<PostProcess>;
  99647. private _onSizeChangedObserver;
  99648. /**
  99649. * A function that is added to the onSizeChangedObservable
  99650. */
  99651. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  99652. /**
  99653. * An event triggered when the postprocess applies its effect.
  99654. */
  99655. onApplyObservable: Observable<Effect>;
  99656. private _onApplyObserver;
  99657. /**
  99658. * A function that is added to the onApplyObservable
  99659. */
  99660. set onApply(callback: (effect: Effect) => void);
  99661. /**
  99662. * An event triggered before rendering the postprocess
  99663. */
  99664. onBeforeRenderObservable: Observable<Effect>;
  99665. private _onBeforeRenderObserver;
  99666. /**
  99667. * A function that is added to the onBeforeRenderObservable
  99668. */
  99669. set onBeforeRender(callback: (effect: Effect) => void);
  99670. /**
  99671. * An event triggered after rendering the postprocess
  99672. */
  99673. onAfterRenderObservable: Observable<Effect>;
  99674. private _onAfterRenderObserver;
  99675. /**
  99676. * A function that is added to the onAfterRenderObservable
  99677. */
  99678. set onAfterRender(callback: (efect: Effect) => void);
  99679. /**
  99680. * 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
  99681. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  99682. */
  99683. get inputTexture(): InternalTexture;
  99684. set inputTexture(value: InternalTexture);
  99685. /**
  99686. * Gets the camera which post process is applied to.
  99687. * @returns The camera the post process is applied to.
  99688. */
  99689. getCamera(): Camera;
  99690. /**
  99691. * Gets the texel size of the postprocess.
  99692. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  99693. */
  99694. get texelSize(): Vector2;
  99695. /**
  99696. * Creates a new instance PostProcess
  99697. * @param name The name of the PostProcess.
  99698. * @param fragmentUrl The url of the fragment shader to be used.
  99699. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  99700. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  99701. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99702. * @param camera The camera to apply the render pass to.
  99703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99704. * @param engine The engine which the post process will be applied. (default: current engine)
  99705. * @param reusable If the post process can be reused on the same frame. (default: false)
  99706. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  99707. * @param textureType Type of textures used when performing the post process. (default: 0)
  99708. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  99709. * @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
  99710. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  99711. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99712. */
  99713. constructor(
  99714. /** Name of the PostProcess. */
  99715. 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);
  99716. /**
  99717. * Gets a string idenfifying the name of the class
  99718. * @returns "PostProcess" string
  99719. */
  99720. getClassName(): string;
  99721. /**
  99722. * Gets the engine which this post process belongs to.
  99723. * @returns The engine the post process was enabled with.
  99724. */
  99725. getEngine(): Engine;
  99726. /**
  99727. * The effect that is created when initializing the post process.
  99728. * @returns The created effect corresponding the the postprocess.
  99729. */
  99730. getEffect(): Effect;
  99731. /**
  99732. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  99733. * @param postProcess The post process to share the output with.
  99734. * @returns This post process.
  99735. */
  99736. shareOutputWith(postProcess: PostProcess): PostProcess;
  99737. /**
  99738. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  99739. * This should be called if the post process that shares output with this post process is disabled/disposed.
  99740. */
  99741. useOwnOutput(): void;
  99742. /**
  99743. * Updates the effect with the current post process compile time values and recompiles the shader.
  99744. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  99745. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  99746. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  99747. * @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
  99748. * @param onCompiled Called when the shader has been compiled.
  99749. * @param onError Called if there is an error when compiling a shader.
  99750. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  99751. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  99752. */
  99753. 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;
  99754. /**
  99755. * The post process is reusable if it can be used multiple times within one frame.
  99756. * @returns If the post process is reusable
  99757. */
  99758. isReusable(): boolean;
  99759. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  99760. markTextureDirty(): void;
  99761. /**
  99762. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  99763. * 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.
  99764. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  99765. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  99766. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  99767. * @returns The target texture that was bound to be written to.
  99768. */
  99769. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  99770. /**
  99771. * If the post process is supported.
  99772. */
  99773. get isSupported(): boolean;
  99774. /**
  99775. * The aspect ratio of the output texture.
  99776. */
  99777. get aspectRatio(): number;
  99778. /**
  99779. * Get a value indicating if the post-process is ready to be used
  99780. * @returns true if the post-process is ready (shader is compiled)
  99781. */
  99782. isReady(): boolean;
  99783. /**
  99784. * Binds all textures and uniforms to the shader, this will be run on every pass.
  99785. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  99786. */
  99787. apply(): Nullable<Effect>;
  99788. private _disposeTextures;
  99789. /**
  99790. * Disposes the post process.
  99791. * @param camera The camera to dispose the post process on.
  99792. */
  99793. dispose(camera?: Camera): void;
  99794. }
  99795. }
  99796. declare module BABYLON {
  99797. /** @hidden */
  99798. export var kernelBlurVaryingDeclaration: {
  99799. name: string;
  99800. shader: string;
  99801. };
  99802. }
  99803. declare module BABYLON {
  99804. /** @hidden */
  99805. export var kernelBlurFragment: {
  99806. name: string;
  99807. shader: string;
  99808. };
  99809. }
  99810. declare module BABYLON {
  99811. /** @hidden */
  99812. export var kernelBlurFragment2: {
  99813. name: string;
  99814. shader: string;
  99815. };
  99816. }
  99817. declare module BABYLON {
  99818. /** @hidden */
  99819. export var kernelBlurPixelShader: {
  99820. name: string;
  99821. shader: string;
  99822. };
  99823. }
  99824. declare module BABYLON {
  99825. /** @hidden */
  99826. export var kernelBlurVertex: {
  99827. name: string;
  99828. shader: string;
  99829. };
  99830. }
  99831. declare module BABYLON {
  99832. /** @hidden */
  99833. export var kernelBlurVertexShader: {
  99834. name: string;
  99835. shader: string;
  99836. };
  99837. }
  99838. declare module BABYLON {
  99839. /**
  99840. * The Blur Post Process which blurs an image based on a kernel and direction.
  99841. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  99842. */
  99843. export class BlurPostProcess extends PostProcess {
  99844. /** The direction in which to blur the image. */
  99845. direction: Vector2;
  99846. private blockCompilation;
  99847. protected _kernel: number;
  99848. protected _idealKernel: number;
  99849. protected _packedFloat: boolean;
  99850. private _staticDefines;
  99851. /**
  99852. * Sets the length in pixels of the blur sample region
  99853. */
  99854. set kernel(v: number);
  99855. /**
  99856. * Gets the length in pixels of the blur sample region
  99857. */
  99858. get kernel(): number;
  99859. /**
  99860. * Sets wether or not the blur needs to unpack/repack floats
  99861. */
  99862. set packedFloat(v: boolean);
  99863. /**
  99864. * Gets wether or not the blur is unpacking/repacking floats
  99865. */
  99866. get packedFloat(): boolean;
  99867. /**
  99868. * Creates a new instance BlurPostProcess
  99869. * @param name The name of the effect.
  99870. * @param direction The direction in which to blur the image.
  99871. * @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.
  99872. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99873. * @param camera The camera to apply the render pass to.
  99874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99875. * @param engine The engine which the post process will be applied. (default: current engine)
  99876. * @param reusable If the post process can be reused on the same frame. (default: false)
  99877. * @param textureType Type of textures used when performing the post process. (default: 0)
  99878. * @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)
  99879. */
  99880. constructor(name: string,
  99881. /** The direction in which to blur the image. */
  99882. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  99883. /**
  99884. * Updates the effect with the current post process compile time values and recompiles the shader.
  99885. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  99886. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  99887. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  99888. * @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
  99889. * @param onCompiled Called when the shader has been compiled.
  99890. * @param onError Called if there is an error when compiling a shader.
  99891. */
  99892. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99893. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99894. /**
  99895. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  99896. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  99897. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  99898. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  99899. * The gaps between physical kernels are compensated for in the weighting of the samples
  99900. * @param idealKernel Ideal blur kernel.
  99901. * @return Nearest best kernel.
  99902. */
  99903. protected _nearestBestKernel(idealKernel: number): number;
  99904. /**
  99905. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  99906. * @param x The point on the Gaussian distribution to sample.
  99907. * @return the value of the Gaussian function at x.
  99908. */
  99909. protected _gaussianWeight(x: number): number;
  99910. /**
  99911. * Generates a string that can be used as a floating point number in GLSL.
  99912. * @param x Value to print.
  99913. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  99914. * @return GLSL float string.
  99915. */
  99916. protected _glslFloat(x: number, decimalFigures?: number): string;
  99917. }
  99918. }
  99919. declare module BABYLON {
  99920. /**
  99921. * Mirror texture can be used to simulate the view from a mirror in a scene.
  99922. * It will dynamically be rendered every frame to adapt to the camera point of view.
  99923. * You can then easily use it as a reflectionTexture on a flat surface.
  99924. * In case the surface is not a plane, please consider relying on reflection probes.
  99925. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99926. */
  99927. export class MirrorTexture extends RenderTargetTexture {
  99928. private scene;
  99929. /**
  99930. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  99931. * 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.
  99932. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99933. */
  99934. mirrorPlane: Plane;
  99935. /**
  99936. * Define the blur ratio used to blur the reflection if needed.
  99937. */
  99938. set blurRatio(value: number);
  99939. get blurRatio(): number;
  99940. /**
  99941. * Define the adaptive blur kernel used to blur the reflection if needed.
  99942. * This will autocompute the closest best match for the `blurKernel`
  99943. */
  99944. set adaptiveBlurKernel(value: number);
  99945. /**
  99946. * Define the blur kernel used to blur the reflection if needed.
  99947. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99948. */
  99949. set blurKernel(value: number);
  99950. /**
  99951. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  99952. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99953. */
  99954. set blurKernelX(value: number);
  99955. get blurKernelX(): number;
  99956. /**
  99957. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  99958. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99959. */
  99960. set blurKernelY(value: number);
  99961. get blurKernelY(): number;
  99962. private _autoComputeBlurKernel;
  99963. protected _onRatioRescale(): void;
  99964. private _updateGammaSpace;
  99965. private _imageProcessingConfigChangeObserver;
  99966. private _transformMatrix;
  99967. private _mirrorMatrix;
  99968. private _savedViewMatrix;
  99969. private _blurX;
  99970. private _blurY;
  99971. private _adaptiveBlurKernel;
  99972. private _blurKernelX;
  99973. private _blurKernelY;
  99974. private _blurRatio;
  99975. /**
  99976. * Instantiates a Mirror Texture.
  99977. * Mirror texture can be used to simulate the view from a mirror in a scene.
  99978. * It will dynamically be rendered every frame to adapt to the camera point of view.
  99979. * You can then easily use it as a reflectionTexture on a flat surface.
  99980. * In case the surface is not a plane, please consider relying on reflection probes.
  99981. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99982. * @param name
  99983. * @param size
  99984. * @param scene
  99985. * @param generateMipMaps
  99986. * @param type
  99987. * @param samplingMode
  99988. * @param generateDepthBuffer
  99989. */
  99990. constructor(name: string, size: number | {
  99991. width: number;
  99992. height: number;
  99993. } | {
  99994. ratio: number;
  99995. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  99996. private _preparePostProcesses;
  99997. /**
  99998. * Clone the mirror texture.
  99999. * @returns the cloned texture
  100000. */
  100001. clone(): MirrorTexture;
  100002. /**
  100003. * Serialize the texture to a JSON representation you could use in Parse later on
  100004. * @returns the serialized JSON representation
  100005. */
  100006. serialize(): any;
  100007. /**
  100008. * Dispose the texture and release its associated resources.
  100009. */
  100010. dispose(): void;
  100011. }
  100012. }
  100013. declare module BABYLON {
  100014. /**
  100015. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100016. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100017. */
  100018. export class Texture extends BaseTexture {
  100019. /**
  100020. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  100021. */
  100022. static SerializeBuffers: boolean;
  100023. /** @hidden */
  100024. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  100025. /** @hidden */
  100026. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  100027. /** @hidden */
  100028. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  100029. /** nearest is mag = nearest and min = nearest and mip = linear */
  100030. static readonly NEAREST_SAMPLINGMODE: number;
  100031. /** nearest is mag = nearest and min = nearest and mip = linear */
  100032. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  100033. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100034. static readonly BILINEAR_SAMPLINGMODE: number;
  100035. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100036. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  100037. /** Trilinear is mag = linear and min = linear and mip = linear */
  100038. static readonly TRILINEAR_SAMPLINGMODE: number;
  100039. /** Trilinear is mag = linear and min = linear and mip = linear */
  100040. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  100041. /** mag = nearest and min = nearest and mip = nearest */
  100042. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  100043. /** mag = nearest and min = linear and mip = nearest */
  100044. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  100045. /** mag = nearest and min = linear and mip = linear */
  100046. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  100047. /** mag = nearest and min = linear and mip = none */
  100048. static readonly NEAREST_LINEAR: number;
  100049. /** mag = nearest and min = nearest and mip = none */
  100050. static readonly NEAREST_NEAREST: number;
  100051. /** mag = linear and min = nearest and mip = nearest */
  100052. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  100053. /** mag = linear and min = nearest and mip = linear */
  100054. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  100055. /** mag = linear and min = linear and mip = none */
  100056. static readonly LINEAR_LINEAR: number;
  100057. /** mag = linear and min = nearest and mip = none */
  100058. static readonly LINEAR_NEAREST: number;
  100059. /** Explicit coordinates mode */
  100060. static readonly EXPLICIT_MODE: number;
  100061. /** Spherical coordinates mode */
  100062. static readonly SPHERICAL_MODE: number;
  100063. /** Planar coordinates mode */
  100064. static readonly PLANAR_MODE: number;
  100065. /** Cubic coordinates mode */
  100066. static readonly CUBIC_MODE: number;
  100067. /** Projection coordinates mode */
  100068. static readonly PROJECTION_MODE: number;
  100069. /** Inverse Cubic coordinates mode */
  100070. static readonly SKYBOX_MODE: number;
  100071. /** Inverse Cubic coordinates mode */
  100072. static readonly INVCUBIC_MODE: number;
  100073. /** Equirectangular coordinates mode */
  100074. static readonly EQUIRECTANGULAR_MODE: number;
  100075. /** Equirectangular Fixed coordinates mode */
  100076. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  100077. /** Equirectangular Fixed Mirrored coordinates mode */
  100078. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100079. /** Texture is not repeating outside of 0..1 UVs */
  100080. static readonly CLAMP_ADDRESSMODE: number;
  100081. /** Texture is repeating outside of 0..1 UVs */
  100082. static readonly WRAP_ADDRESSMODE: number;
  100083. /** Texture is repeating and mirrored */
  100084. static readonly MIRROR_ADDRESSMODE: number;
  100085. /**
  100086. * 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
  100087. */
  100088. static UseSerializedUrlIfAny: boolean;
  100089. /**
  100090. * Define the url of the texture.
  100091. */
  100092. url: Nullable<string>;
  100093. /**
  100094. * Define an offset on the texture to offset the u coordinates of the UVs
  100095. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100096. */
  100097. uOffset: number;
  100098. /**
  100099. * Define an offset on the texture to offset the v coordinates of the UVs
  100100. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100101. */
  100102. vOffset: number;
  100103. /**
  100104. * Define an offset on the texture to scale the u coordinates of the UVs
  100105. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100106. */
  100107. uScale: number;
  100108. /**
  100109. * Define an offset on the texture to scale the v coordinates of the UVs
  100110. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100111. */
  100112. vScale: number;
  100113. /**
  100114. * Define an offset on the texture to rotate around the u coordinates of the UVs
  100115. * @see http://doc.babylonjs.com/how_to/more_materials
  100116. */
  100117. uAng: number;
  100118. /**
  100119. * Define an offset on the texture to rotate around the v coordinates of the UVs
  100120. * @see http://doc.babylonjs.com/how_to/more_materials
  100121. */
  100122. vAng: number;
  100123. /**
  100124. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  100125. * @see http://doc.babylonjs.com/how_to/more_materials
  100126. */
  100127. wAng: number;
  100128. /**
  100129. * Defines the center of rotation (U)
  100130. */
  100131. uRotationCenter: number;
  100132. /**
  100133. * Defines the center of rotation (V)
  100134. */
  100135. vRotationCenter: number;
  100136. /**
  100137. * Defines the center of rotation (W)
  100138. */
  100139. wRotationCenter: number;
  100140. /**
  100141. * Are mip maps generated for this texture or not.
  100142. */
  100143. get noMipmap(): boolean;
  100144. /**
  100145. * List of inspectable custom properties (used by the Inspector)
  100146. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100147. */
  100148. inspectableCustomProperties: Nullable<IInspectable[]>;
  100149. private _noMipmap;
  100150. /** @hidden */
  100151. _invertY: boolean;
  100152. private _rowGenerationMatrix;
  100153. private _cachedTextureMatrix;
  100154. private _projectionModeMatrix;
  100155. private _t0;
  100156. private _t1;
  100157. private _t2;
  100158. private _cachedUOffset;
  100159. private _cachedVOffset;
  100160. private _cachedUScale;
  100161. private _cachedVScale;
  100162. private _cachedUAng;
  100163. private _cachedVAng;
  100164. private _cachedWAng;
  100165. private _cachedProjectionMatrixId;
  100166. private _cachedCoordinatesMode;
  100167. /** @hidden */
  100168. protected _initialSamplingMode: number;
  100169. /** @hidden */
  100170. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100171. private _deleteBuffer;
  100172. protected _format: Nullable<number>;
  100173. private _delayedOnLoad;
  100174. private _delayedOnError;
  100175. private _mimeType?;
  100176. /**
  100177. * Observable triggered once the texture has been loaded.
  100178. */
  100179. onLoadObservable: Observable<Texture>;
  100180. protected _isBlocking: boolean;
  100181. /**
  100182. * Is the texture preventing material to render while loading.
  100183. * If false, a default texture will be used instead of the loading one during the preparation step.
  100184. */
  100185. set isBlocking(value: boolean);
  100186. get isBlocking(): boolean;
  100187. /**
  100188. * Get the current sampling mode associated with the texture.
  100189. */
  100190. get samplingMode(): number;
  100191. /**
  100192. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  100193. */
  100194. get invertY(): boolean;
  100195. /**
  100196. * Instantiates a new texture.
  100197. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100198. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100199. * @param url defines the url of the picture to load as a texture
  100200. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100201. * @param noMipmap defines if the texture will require mip maps or not
  100202. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  100203. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100204. * @param onLoad defines a callback triggered when the texture has been loaded
  100205. * @param onError defines a callback triggered when an error occurred during the loading session
  100206. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  100207. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  100208. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100209. * @param mimeType defines an optional mime type information
  100210. */
  100211. 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);
  100212. /**
  100213. * Update the url (and optional buffer) of this texture if url was null during construction.
  100214. * @param url the url of the texture
  100215. * @param buffer the buffer of the texture (defaults to null)
  100216. * @param onLoad callback called when the texture is loaded (defaults to null)
  100217. */
  100218. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  100219. /**
  100220. * Finish the loading sequence of a texture flagged as delayed load.
  100221. * @hidden
  100222. */
  100223. delayLoad(): void;
  100224. private _prepareRowForTextureGeneration;
  100225. /**
  100226. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  100227. * @returns the transform matrix of the texture.
  100228. */
  100229. getTextureMatrix(uBase?: number): Matrix;
  100230. /**
  100231. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  100232. * @returns The reflection texture transform
  100233. */
  100234. getReflectionTextureMatrix(): Matrix;
  100235. /**
  100236. * Clones the texture.
  100237. * @returns the cloned texture
  100238. */
  100239. clone(): Texture;
  100240. /**
  100241. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100242. * @returns The JSON representation of the texture
  100243. */
  100244. serialize(): any;
  100245. /**
  100246. * Get the current class name of the texture useful for serialization or dynamic coding.
  100247. * @returns "Texture"
  100248. */
  100249. getClassName(): string;
  100250. /**
  100251. * Dispose the texture and release its associated resources.
  100252. */
  100253. dispose(): void;
  100254. /**
  100255. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  100256. * @param parsedTexture Define the JSON representation of the texture
  100257. * @param scene Define the scene the parsed texture should be instantiated in
  100258. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  100259. * @returns The parsed texture if successful
  100260. */
  100261. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  100262. /**
  100263. * Creates a texture from its base 64 representation.
  100264. * @param data Define the base64 payload without the data: prefix
  100265. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100266. * @param scene Define the scene the texture should belong to
  100267. * @param noMipmap Forces the texture to not create mip map information if true
  100268. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100269. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100270. * @param onLoad define a callback triggered when the texture has been loaded
  100271. * @param onError define a callback triggered when an error occurred during the loading session
  100272. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100273. * @returns the created texture
  100274. */
  100275. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  100276. /**
  100277. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  100278. * @param data Define the base64 payload without the data: prefix
  100279. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100280. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  100281. * @param scene Define the scene the texture should belong to
  100282. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  100283. * @param noMipmap Forces the texture to not create mip map information if true
  100284. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100285. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100286. * @param onLoad define a callback triggered when the texture has been loaded
  100287. * @param onError define a callback triggered when an error occurred during the loading session
  100288. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100289. * @returns the created texture
  100290. */
  100291. 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;
  100292. }
  100293. }
  100294. declare module BABYLON {
  100295. /**
  100296. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100297. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100298. */
  100299. export class PostProcessManager {
  100300. private _scene;
  100301. private _indexBuffer;
  100302. private _vertexBuffers;
  100303. /**
  100304. * Creates a new instance PostProcess
  100305. * @param scene The scene that the post process is associated with.
  100306. */
  100307. constructor(scene: Scene);
  100308. private _prepareBuffers;
  100309. private _buildIndexBuffer;
  100310. /**
  100311. * Rebuilds the vertex buffers of the manager.
  100312. * @hidden
  100313. */
  100314. _rebuild(): void;
  100315. /**
  100316. * Prepares a frame to be run through a post process.
  100317. * @param sourceTexture The input texture to the post procesess. (default: null)
  100318. * @param postProcesses An array of post processes to be run. (default: null)
  100319. * @returns True if the post processes were able to be run.
  100320. * @hidden
  100321. */
  100322. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100323. /**
  100324. * Manually render a set of post processes to a texture.
  100325. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100326. * @param postProcesses An array of post processes to be run.
  100327. * @param targetTexture The target texture to render to.
  100328. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100329. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100330. * @param lodLevel defines which lod of the texture to render to
  100331. */
  100332. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100333. /**
  100334. * Finalize the result of the output of the postprocesses.
  100335. * @param doNotPresent If true the result will not be displayed to the screen.
  100336. * @param targetTexture The target texture to render to.
  100337. * @param faceIndex The index of the face to bind the target texture to.
  100338. * @param postProcesses The array of post processes to render.
  100339. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100340. * @hidden
  100341. */
  100342. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100343. /**
  100344. * Disposes of the post process manager.
  100345. */
  100346. dispose(): void;
  100347. }
  100348. }
  100349. declare module BABYLON {
  100350. /**
  100351. * This Helps creating a texture that will be created from a camera in your scene.
  100352. * It is basically a dynamic texture that could be used to create special effects for instance.
  100353. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100354. */
  100355. export class RenderTargetTexture extends Texture {
  100356. isCube: boolean;
  100357. /**
  100358. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100359. */
  100360. static readonly REFRESHRATE_RENDER_ONCE: number;
  100361. /**
  100362. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100363. */
  100364. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100365. /**
  100366. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100367. * the central point of your effect and can save a lot of performances.
  100368. */
  100369. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100370. /**
  100371. * Use this predicate to dynamically define the list of mesh you want to render.
  100372. * If set, the renderList property will be overwritten.
  100373. */
  100374. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100375. private _renderList;
  100376. /**
  100377. * Use this list to define the list of mesh you want to render.
  100378. */
  100379. get renderList(): Nullable<Array<AbstractMesh>>;
  100380. set renderList(value: Nullable<Array<AbstractMesh>>);
  100381. /**
  100382. * Use this function to overload the renderList array at rendering time.
  100383. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  100384. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  100385. * the cube (if the RTT is a cube, else layerOrFace=0).
  100386. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  100387. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  100388. * hold dummy elements!
  100389. */
  100390. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  100391. private _hookArray;
  100392. /**
  100393. * Define if particles should be rendered in your texture.
  100394. */
  100395. renderParticles: boolean;
  100396. /**
  100397. * Define if sprites should be rendered in your texture.
  100398. */
  100399. renderSprites: boolean;
  100400. /**
  100401. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  100402. */
  100403. coordinatesMode: number;
  100404. /**
  100405. * Define the camera used to render the texture.
  100406. */
  100407. activeCamera: Nullable<Camera>;
  100408. /**
  100409. * Override the mesh isReady function with your own one.
  100410. */
  100411. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  100412. /**
  100413. * Override the render function of the texture with your own one.
  100414. */
  100415. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  100416. /**
  100417. * Define if camera post processes should be use while rendering the texture.
  100418. */
  100419. useCameraPostProcesses: boolean;
  100420. /**
  100421. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  100422. */
  100423. ignoreCameraViewport: boolean;
  100424. private _postProcessManager;
  100425. private _postProcesses;
  100426. private _resizeObserver;
  100427. /**
  100428. * An event triggered when the texture is unbind.
  100429. */
  100430. onBeforeBindObservable: Observable<RenderTargetTexture>;
  100431. /**
  100432. * An event triggered when the texture is unbind.
  100433. */
  100434. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  100435. private _onAfterUnbindObserver;
  100436. /**
  100437. * Set a after unbind callback in the texture.
  100438. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  100439. */
  100440. set onAfterUnbind(callback: () => void);
  100441. /**
  100442. * An event triggered before rendering the texture
  100443. */
  100444. onBeforeRenderObservable: Observable<number>;
  100445. private _onBeforeRenderObserver;
  100446. /**
  100447. * Set a before render callback in the texture.
  100448. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  100449. */
  100450. set onBeforeRender(callback: (faceIndex: number) => void);
  100451. /**
  100452. * An event triggered after rendering the texture
  100453. */
  100454. onAfterRenderObservable: Observable<number>;
  100455. private _onAfterRenderObserver;
  100456. /**
  100457. * Set a after render callback in the texture.
  100458. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  100459. */
  100460. set onAfterRender(callback: (faceIndex: number) => void);
  100461. /**
  100462. * An event triggered after the texture clear
  100463. */
  100464. onClearObservable: Observable<Engine>;
  100465. private _onClearObserver;
  100466. /**
  100467. * Set a clear callback in the texture.
  100468. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  100469. */
  100470. set onClear(callback: (Engine: Engine) => void);
  100471. /**
  100472. * An event triggered when the texture is resized.
  100473. */
  100474. onResizeObservable: Observable<RenderTargetTexture>;
  100475. /**
  100476. * Define the clear color of the Render Target if it should be different from the scene.
  100477. */
  100478. clearColor: Color4;
  100479. protected _size: number | {
  100480. width: number;
  100481. height: number;
  100482. layers?: number;
  100483. };
  100484. protected _initialSizeParameter: number | {
  100485. width: number;
  100486. height: number;
  100487. } | {
  100488. ratio: number;
  100489. };
  100490. protected _sizeRatio: Nullable<number>;
  100491. /** @hidden */
  100492. _generateMipMaps: boolean;
  100493. protected _renderingManager: RenderingManager;
  100494. /** @hidden */
  100495. _waitingRenderList: string[];
  100496. protected _doNotChangeAspectRatio: boolean;
  100497. protected _currentRefreshId: number;
  100498. protected _refreshRate: number;
  100499. protected _textureMatrix: Matrix;
  100500. protected _samples: number;
  100501. protected _renderTargetOptions: RenderTargetCreationOptions;
  100502. /**
  100503. * Gets render target creation options that were used.
  100504. */
  100505. get renderTargetOptions(): RenderTargetCreationOptions;
  100506. protected _onRatioRescale(): void;
  100507. /**
  100508. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  100509. * It must define where the camera used to render the texture is set
  100510. */
  100511. boundingBoxPosition: Vector3;
  100512. private _boundingBoxSize;
  100513. /**
  100514. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  100515. * When defined, the cubemap will switch to local mode
  100516. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  100517. * @example https://www.babylonjs-playground.com/#RNASML
  100518. */
  100519. set boundingBoxSize(value: Vector3);
  100520. get boundingBoxSize(): Vector3;
  100521. /**
  100522. * In case the RTT has been created with a depth texture, get the associated
  100523. * depth texture.
  100524. * Otherwise, return null.
  100525. */
  100526. get depthStencilTexture(): Nullable<InternalTexture>;
  100527. /**
  100528. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  100529. * or used a shadow, depth texture...
  100530. * @param name The friendly name of the texture
  100531. * @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)
  100532. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  100533. * @param generateMipMaps True if mip maps need to be generated after render.
  100534. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  100535. * @param type The type of the buffer in the RTT (int, half float, float...)
  100536. * @param isCube True if a cube texture needs to be created
  100537. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  100538. * @param generateDepthBuffer True to generate a depth buffer
  100539. * @param generateStencilBuffer True to generate a stencil buffer
  100540. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  100541. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  100542. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100543. */
  100544. constructor(name: string, size: number | {
  100545. width: number;
  100546. height: number;
  100547. layers?: number;
  100548. } | {
  100549. ratio: number;
  100550. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  100551. /**
  100552. * Creates a depth stencil texture.
  100553. * This is only available in WebGL 2 or with the depth texture extension available.
  100554. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  100555. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  100556. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  100557. */
  100558. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  100559. private _processSizeParameter;
  100560. /**
  100561. * Define the number of samples to use in case of MSAA.
  100562. * It defaults to one meaning no MSAA has been enabled.
  100563. */
  100564. get samples(): number;
  100565. set samples(value: number);
  100566. /**
  100567. * Resets the refresh counter of the texture and start bak from scratch.
  100568. * Could be useful to regenerate the texture if it is setup to render only once.
  100569. */
  100570. resetRefreshCounter(): void;
  100571. /**
  100572. * Define the refresh rate of the texture or the rendering frequency.
  100573. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  100574. */
  100575. get refreshRate(): number;
  100576. set refreshRate(value: number);
  100577. /**
  100578. * Adds a post process to the render target rendering passes.
  100579. * @param postProcess define the post process to add
  100580. */
  100581. addPostProcess(postProcess: PostProcess): void;
  100582. /**
  100583. * Clear all the post processes attached to the render target
  100584. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  100585. */
  100586. clearPostProcesses(dispose?: boolean): void;
  100587. /**
  100588. * Remove one of the post process from the list of attached post processes to the texture
  100589. * @param postProcess define the post process to remove from the list
  100590. */
  100591. removePostProcess(postProcess: PostProcess): void;
  100592. /** @hidden */
  100593. _shouldRender(): boolean;
  100594. /**
  100595. * Gets the actual render size of the texture.
  100596. * @returns the width of the render size
  100597. */
  100598. getRenderSize(): number;
  100599. /**
  100600. * Gets the actual render width of the texture.
  100601. * @returns the width of the render size
  100602. */
  100603. getRenderWidth(): number;
  100604. /**
  100605. * Gets the actual render height of the texture.
  100606. * @returns the height of the render size
  100607. */
  100608. getRenderHeight(): number;
  100609. /**
  100610. * Gets the actual number of layers of the texture.
  100611. * @returns the number of layers
  100612. */
  100613. getRenderLayers(): number;
  100614. /**
  100615. * Get if the texture can be rescaled or not.
  100616. */
  100617. get canRescale(): boolean;
  100618. /**
  100619. * Resize the texture using a ratio.
  100620. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  100621. */
  100622. scale(ratio: number): void;
  100623. /**
  100624. * Get the texture reflection matrix used to rotate/transform the reflection.
  100625. * @returns the reflection matrix
  100626. */
  100627. getReflectionTextureMatrix(): Matrix;
  100628. /**
  100629. * Resize the texture to a new desired size.
  100630. * Be carrefull as it will recreate all the data in the new texture.
  100631. * @param size Define the new size. It can be:
  100632. * - a number for squared texture,
  100633. * - an object containing { width: number, height: number }
  100634. * - or an object containing a ratio { ratio: number }
  100635. */
  100636. resize(size: number | {
  100637. width: number;
  100638. height: number;
  100639. } | {
  100640. ratio: number;
  100641. }): void;
  100642. private _defaultRenderListPrepared;
  100643. /**
  100644. * Renders all the objects from the render list into the texture.
  100645. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  100646. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  100647. */
  100648. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  100649. private _bestReflectionRenderTargetDimension;
  100650. private _prepareRenderingManager;
  100651. /**
  100652. * @hidden
  100653. * @param faceIndex face index to bind to if this is a cubetexture
  100654. * @param layer defines the index of the texture to bind in the array
  100655. */
  100656. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  100657. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  100658. private renderToTarget;
  100659. /**
  100660. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100661. * This allowed control for front to back rendering or reversly depending of the special needs.
  100662. *
  100663. * @param renderingGroupId The rendering group id corresponding to its index
  100664. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100665. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100666. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100667. */
  100668. 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;
  100669. /**
  100670. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100671. *
  100672. * @param renderingGroupId The rendering group id corresponding to its index
  100673. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100674. */
  100675. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  100676. /**
  100677. * Clones the texture.
  100678. * @returns the cloned texture
  100679. */
  100680. clone(): RenderTargetTexture;
  100681. /**
  100682. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100683. * @returns The JSON representation of the texture
  100684. */
  100685. serialize(): any;
  100686. /**
  100687. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  100688. */
  100689. disposeFramebufferObjects(): void;
  100690. /**
  100691. * Dispose the texture and release its associated resources.
  100692. */
  100693. dispose(): void;
  100694. /** @hidden */
  100695. _rebuild(): void;
  100696. /**
  100697. * Clear the info related to rendering groups preventing retention point in material dispose.
  100698. */
  100699. freeRenderingGroups(): void;
  100700. /**
  100701. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100702. * @returns the view count
  100703. */
  100704. getViewCount(): number;
  100705. }
  100706. }
  100707. declare module BABYLON {
  100708. /**
  100709. * Class used to manipulate GUIDs
  100710. */
  100711. export class GUID {
  100712. /**
  100713. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100714. * Be aware Math.random() could cause collisions, but:
  100715. * "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"
  100716. * @returns a pseudo random id
  100717. */
  100718. static RandomId(): string;
  100719. }
  100720. }
  100721. declare module BABYLON {
  100722. /**
  100723. * Options to be used when creating a shadow depth material
  100724. */
  100725. export interface IIOptionShadowDepthMaterial {
  100726. /** Variables in the vertex shader code that need to have their names remapped.
  100727. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  100728. * "var_name" should be either: worldPos or vNormalW
  100729. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  100730. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  100731. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  100732. */
  100733. remappedVariables?: string[];
  100734. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  100735. standalone?: boolean;
  100736. }
  100737. /**
  100738. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  100739. */
  100740. export class ShadowDepthWrapper {
  100741. private _scene;
  100742. private _options?;
  100743. private _baseMaterial;
  100744. private _onEffectCreatedObserver;
  100745. private _subMeshToEffect;
  100746. private _subMeshToDepthEffect;
  100747. private _meshes;
  100748. /** @hidden */
  100749. _matriceNames: any;
  100750. /** Gets the standalone status of the wrapper */
  100751. get standalone(): boolean;
  100752. /** Gets the base material the wrapper is built upon */
  100753. get baseMaterial(): Material;
  100754. /**
  100755. * Instantiate a new shadow depth wrapper.
  100756. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  100757. * generate the shadow depth map. For more information, please refer to the documentation:
  100758. * https://doc.babylonjs.com/babylon101/shadows
  100759. * @param baseMaterial Material to wrap
  100760. * @param scene Define the scene the material belongs to
  100761. * @param options Options used to create the wrapper
  100762. */
  100763. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  100764. /**
  100765. * Gets the effect to use to generate the depth map
  100766. * @param subMesh subMesh to get the effect for
  100767. * @param shadowGenerator shadow generator to get the effect for
  100768. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  100769. */
  100770. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  100771. /**
  100772. * Specifies that the submesh is ready to be used for depth rendering
  100773. * @param subMesh submesh to check
  100774. * @param defines the list of defines to take into account when checking the effect
  100775. * @param shadowGenerator combined with subMesh, it defines the effect to check
  100776. * @param useInstances specifies that instances should be used
  100777. * @returns a boolean indicating that the submesh is ready or not
  100778. */
  100779. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  100780. /**
  100781. * Disposes the resources
  100782. */
  100783. dispose(): void;
  100784. private _makeEffect;
  100785. }
  100786. }
  100787. declare module BABYLON {
  100788. /**
  100789. * Options for compiling materials.
  100790. */
  100791. export interface IMaterialCompilationOptions {
  100792. /**
  100793. * Defines whether clip planes are enabled.
  100794. */
  100795. clipPlane: boolean;
  100796. /**
  100797. * Defines whether instances are enabled.
  100798. */
  100799. useInstances: boolean;
  100800. }
  100801. /**
  100802. * Options passed when calling customShaderNameResolve
  100803. */
  100804. export interface ICustomShaderNameResolveOptions {
  100805. /**
  100806. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  100807. */
  100808. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  100809. }
  100810. /**
  100811. * Base class for the main features of a material in Babylon.js
  100812. */
  100813. export class Material implements IAnimatable {
  100814. /**
  100815. * Returns the triangle fill mode
  100816. */
  100817. static readonly TriangleFillMode: number;
  100818. /**
  100819. * Returns the wireframe mode
  100820. */
  100821. static readonly WireFrameFillMode: number;
  100822. /**
  100823. * Returns the point fill mode
  100824. */
  100825. static readonly PointFillMode: number;
  100826. /**
  100827. * Returns the point list draw mode
  100828. */
  100829. static readonly PointListDrawMode: number;
  100830. /**
  100831. * Returns the line list draw mode
  100832. */
  100833. static readonly LineListDrawMode: number;
  100834. /**
  100835. * Returns the line loop draw mode
  100836. */
  100837. static readonly LineLoopDrawMode: number;
  100838. /**
  100839. * Returns the line strip draw mode
  100840. */
  100841. static readonly LineStripDrawMode: number;
  100842. /**
  100843. * Returns the triangle strip draw mode
  100844. */
  100845. static readonly TriangleStripDrawMode: number;
  100846. /**
  100847. * Returns the triangle fan draw mode
  100848. */
  100849. static readonly TriangleFanDrawMode: number;
  100850. /**
  100851. * Stores the clock-wise side orientation
  100852. */
  100853. static readonly ClockWiseSideOrientation: number;
  100854. /**
  100855. * Stores the counter clock-wise side orientation
  100856. */
  100857. static readonly CounterClockWiseSideOrientation: number;
  100858. /**
  100859. * The dirty texture flag value
  100860. */
  100861. static readonly TextureDirtyFlag: number;
  100862. /**
  100863. * The dirty light flag value
  100864. */
  100865. static readonly LightDirtyFlag: number;
  100866. /**
  100867. * The dirty fresnel flag value
  100868. */
  100869. static readonly FresnelDirtyFlag: number;
  100870. /**
  100871. * The dirty attribute flag value
  100872. */
  100873. static readonly AttributesDirtyFlag: number;
  100874. /**
  100875. * The dirty misc flag value
  100876. */
  100877. static readonly MiscDirtyFlag: number;
  100878. /**
  100879. * The all dirty flag value
  100880. */
  100881. static readonly AllDirtyFlag: number;
  100882. /**
  100883. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100884. */
  100885. static readonly MATERIAL_OPAQUE: number;
  100886. /**
  100887. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100888. */
  100889. static readonly MATERIAL_ALPHATEST: number;
  100890. /**
  100891. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100892. */
  100893. static readonly MATERIAL_ALPHABLEND: number;
  100894. /**
  100895. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100896. * They are also discarded below the alpha cutoff threshold to improve performances.
  100897. */
  100898. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  100899. /**
  100900. * Custom callback helping to override the default shader used in the material.
  100901. */
  100902. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  100903. /**
  100904. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  100905. */
  100906. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  100907. /**
  100908. * The ID of the material
  100909. */
  100910. id: string;
  100911. /**
  100912. * Gets or sets the unique id of the material
  100913. */
  100914. uniqueId: number;
  100915. /**
  100916. * The name of the material
  100917. */
  100918. name: string;
  100919. /**
  100920. * Gets or sets user defined metadata
  100921. */
  100922. metadata: any;
  100923. /**
  100924. * For internal use only. Please do not use.
  100925. */
  100926. reservedDataStore: any;
  100927. /**
  100928. * Specifies if the ready state should be checked on each call
  100929. */
  100930. checkReadyOnEveryCall: boolean;
  100931. /**
  100932. * Specifies if the ready state should be checked once
  100933. */
  100934. checkReadyOnlyOnce: boolean;
  100935. /**
  100936. * The state of the material
  100937. */
  100938. state: string;
  100939. /**
  100940. * The alpha value of the material
  100941. */
  100942. protected _alpha: number;
  100943. /**
  100944. * List of inspectable custom properties (used by the Inspector)
  100945. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100946. */
  100947. inspectableCustomProperties: IInspectable[];
  100948. /**
  100949. * Sets the alpha value of the material
  100950. */
  100951. set alpha(value: number);
  100952. /**
  100953. * Gets the alpha value of the material
  100954. */
  100955. get alpha(): number;
  100956. /**
  100957. * Specifies if back face culling is enabled
  100958. */
  100959. protected _backFaceCulling: boolean;
  100960. /**
  100961. * Sets the back-face culling state
  100962. */
  100963. set backFaceCulling(value: boolean);
  100964. /**
  100965. * Gets the back-face culling state
  100966. */
  100967. get backFaceCulling(): boolean;
  100968. /**
  100969. * Stores the value for side orientation
  100970. */
  100971. sideOrientation: number;
  100972. /**
  100973. * Callback triggered when the material is compiled
  100974. */
  100975. onCompiled: Nullable<(effect: Effect) => void>;
  100976. /**
  100977. * Callback triggered when an error occurs
  100978. */
  100979. onError: Nullable<(effect: Effect, errors: string) => void>;
  100980. /**
  100981. * Callback triggered to get the render target textures
  100982. */
  100983. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  100984. /**
  100985. * Gets a boolean indicating that current material needs to register RTT
  100986. */
  100987. get hasRenderTargetTextures(): boolean;
  100988. /**
  100989. * Specifies if the material should be serialized
  100990. */
  100991. doNotSerialize: boolean;
  100992. /**
  100993. * @hidden
  100994. */
  100995. _storeEffectOnSubMeshes: boolean;
  100996. /**
  100997. * Stores the animations for the material
  100998. */
  100999. animations: Nullable<Array<Animation>>;
  101000. /**
  101001. * An event triggered when the material is disposed
  101002. */
  101003. onDisposeObservable: Observable<Material>;
  101004. /**
  101005. * An observer which watches for dispose events
  101006. */
  101007. private _onDisposeObserver;
  101008. private _onUnBindObservable;
  101009. /**
  101010. * Called during a dispose event
  101011. */
  101012. set onDispose(callback: () => void);
  101013. private _onBindObservable;
  101014. /**
  101015. * An event triggered when the material is bound
  101016. */
  101017. get onBindObservable(): Observable<AbstractMesh>;
  101018. /**
  101019. * An observer which watches for bind events
  101020. */
  101021. private _onBindObserver;
  101022. /**
  101023. * Called during a bind event
  101024. */
  101025. set onBind(callback: (Mesh: AbstractMesh) => void);
  101026. /**
  101027. * An event triggered when the material is unbound
  101028. */
  101029. get onUnBindObservable(): Observable<Material>;
  101030. protected _onEffectCreatedObservable: Nullable<Observable<{
  101031. effect: Effect;
  101032. subMesh: Nullable<SubMesh>;
  101033. }>>;
  101034. /**
  101035. * An event triggered when the effect is (re)created
  101036. */
  101037. get onEffectCreatedObservable(): Observable<{
  101038. effect: Effect;
  101039. subMesh: Nullable<SubMesh>;
  101040. }>;
  101041. /**
  101042. * Stores the value of the alpha mode
  101043. */
  101044. private _alphaMode;
  101045. /**
  101046. * Sets the value of the alpha mode.
  101047. *
  101048. * | Value | Type | Description |
  101049. * | --- | --- | --- |
  101050. * | 0 | ALPHA_DISABLE | |
  101051. * | 1 | ALPHA_ADD | |
  101052. * | 2 | ALPHA_COMBINE | |
  101053. * | 3 | ALPHA_SUBTRACT | |
  101054. * | 4 | ALPHA_MULTIPLY | |
  101055. * | 5 | ALPHA_MAXIMIZED | |
  101056. * | 6 | ALPHA_ONEONE | |
  101057. * | 7 | ALPHA_PREMULTIPLIED | |
  101058. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  101059. * | 9 | ALPHA_INTERPOLATE | |
  101060. * | 10 | ALPHA_SCREENMODE | |
  101061. *
  101062. */
  101063. set alphaMode(value: number);
  101064. /**
  101065. * Gets the value of the alpha mode
  101066. */
  101067. get alphaMode(): number;
  101068. /**
  101069. * Stores the state of the need depth pre-pass value
  101070. */
  101071. private _needDepthPrePass;
  101072. /**
  101073. * Sets the need depth pre-pass value
  101074. */
  101075. set needDepthPrePass(value: boolean);
  101076. /**
  101077. * Gets the depth pre-pass value
  101078. */
  101079. get needDepthPrePass(): boolean;
  101080. /**
  101081. * Specifies if depth writing should be disabled
  101082. */
  101083. disableDepthWrite: boolean;
  101084. /**
  101085. * Specifies if color writing should be disabled
  101086. */
  101087. disableColorWrite: boolean;
  101088. /**
  101089. * Specifies if depth writing should be forced
  101090. */
  101091. forceDepthWrite: boolean;
  101092. /**
  101093. * Specifies the depth function that should be used. 0 means the default engine function
  101094. */
  101095. depthFunction: number;
  101096. /**
  101097. * Specifies if there should be a separate pass for culling
  101098. */
  101099. separateCullingPass: boolean;
  101100. /**
  101101. * Stores the state specifing if fog should be enabled
  101102. */
  101103. private _fogEnabled;
  101104. /**
  101105. * Sets the state for enabling fog
  101106. */
  101107. set fogEnabled(value: boolean);
  101108. /**
  101109. * Gets the value of the fog enabled state
  101110. */
  101111. get fogEnabled(): boolean;
  101112. /**
  101113. * Stores the size of points
  101114. */
  101115. pointSize: number;
  101116. /**
  101117. * Stores the z offset value
  101118. */
  101119. zOffset: number;
  101120. get wireframe(): boolean;
  101121. /**
  101122. * Sets the state of wireframe mode
  101123. */
  101124. set wireframe(value: boolean);
  101125. /**
  101126. * Gets the value specifying if point clouds are enabled
  101127. */
  101128. get pointsCloud(): boolean;
  101129. /**
  101130. * Sets the state of point cloud mode
  101131. */
  101132. set pointsCloud(value: boolean);
  101133. /**
  101134. * Gets the material fill mode
  101135. */
  101136. get fillMode(): number;
  101137. /**
  101138. * Sets the material fill mode
  101139. */
  101140. set fillMode(value: number);
  101141. /**
  101142. * @hidden
  101143. * Stores the effects for the material
  101144. */
  101145. _effect: Nullable<Effect>;
  101146. /**
  101147. * Specifies if uniform buffers should be used
  101148. */
  101149. private _useUBO;
  101150. /**
  101151. * Stores a reference to the scene
  101152. */
  101153. private _scene;
  101154. /**
  101155. * Stores the fill mode state
  101156. */
  101157. private _fillMode;
  101158. /**
  101159. * Specifies if the depth write state should be cached
  101160. */
  101161. private _cachedDepthWriteState;
  101162. /**
  101163. * Specifies if the color write state should be cached
  101164. */
  101165. private _cachedColorWriteState;
  101166. /**
  101167. * Specifies if the depth function state should be cached
  101168. */
  101169. private _cachedDepthFunctionState;
  101170. /**
  101171. * Stores the uniform buffer
  101172. */
  101173. protected _uniformBuffer: UniformBuffer;
  101174. /** @hidden */
  101175. _indexInSceneMaterialArray: number;
  101176. /** @hidden */
  101177. meshMap: Nullable<{
  101178. [id: string]: AbstractMesh | undefined;
  101179. }>;
  101180. /**
  101181. * Creates a material instance
  101182. * @param name defines the name of the material
  101183. * @param scene defines the scene to reference
  101184. * @param doNotAdd specifies if the material should be added to the scene
  101185. */
  101186. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  101187. /**
  101188. * Returns a string representation of the current material
  101189. * @param fullDetails defines a boolean indicating which levels of logging is desired
  101190. * @returns a string with material information
  101191. */
  101192. toString(fullDetails?: boolean): string;
  101193. /**
  101194. * Gets the class name of the material
  101195. * @returns a string with the class name of the material
  101196. */
  101197. getClassName(): string;
  101198. /**
  101199. * Specifies if updates for the material been locked
  101200. */
  101201. get isFrozen(): boolean;
  101202. /**
  101203. * Locks updates for the material
  101204. */
  101205. freeze(): void;
  101206. /**
  101207. * Unlocks updates for the material
  101208. */
  101209. unfreeze(): void;
  101210. /**
  101211. * Specifies if the material is ready to be used
  101212. * @param mesh defines the mesh to check
  101213. * @param useInstances specifies if instances should be used
  101214. * @returns a boolean indicating if the material is ready to be used
  101215. */
  101216. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101217. /**
  101218. * Specifies that the submesh is ready to be used
  101219. * @param mesh defines the mesh to check
  101220. * @param subMesh defines which submesh to check
  101221. * @param useInstances specifies that instances should be used
  101222. * @returns a boolean indicating that the submesh is ready or not
  101223. */
  101224. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  101225. /**
  101226. * Returns the material effect
  101227. * @returns the effect associated with the material
  101228. */
  101229. getEffect(): Nullable<Effect>;
  101230. /**
  101231. * Returns the current scene
  101232. * @returns a Scene
  101233. */
  101234. getScene(): Scene;
  101235. /**
  101236. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101237. */
  101238. protected _forceAlphaTest: boolean;
  101239. /**
  101240. * The transparency mode of the material.
  101241. */
  101242. protected _transparencyMode: Nullable<number>;
  101243. /**
  101244. * Gets the current transparency mode.
  101245. */
  101246. get transparencyMode(): Nullable<number>;
  101247. /**
  101248. * Sets the transparency mode of the material.
  101249. *
  101250. * | Value | Type | Description |
  101251. * | ----- | ----------------------------------- | ----------- |
  101252. * | 0 | OPAQUE | |
  101253. * | 1 | ALPHATEST | |
  101254. * | 2 | ALPHABLEND | |
  101255. * | 3 | ALPHATESTANDBLEND | |
  101256. *
  101257. */
  101258. set transparencyMode(value: Nullable<number>);
  101259. /**
  101260. * Returns true if alpha blending should be disabled.
  101261. */
  101262. protected get _disableAlphaBlending(): boolean;
  101263. /**
  101264. * Specifies whether or not this material should be rendered in alpha blend mode.
  101265. * @returns a boolean specifying if alpha blending is needed
  101266. */
  101267. needAlphaBlending(): boolean;
  101268. /**
  101269. * Specifies if the mesh will require alpha blending
  101270. * @param mesh defines the mesh to check
  101271. * @returns a boolean specifying if alpha blending is needed for the mesh
  101272. */
  101273. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101274. /**
  101275. * Specifies whether or not this material should be rendered in alpha test mode.
  101276. * @returns a boolean specifying if an alpha test is needed.
  101277. */
  101278. needAlphaTesting(): boolean;
  101279. /**
  101280. * Specifies if material alpha testing should be turned on for the mesh
  101281. * @param mesh defines the mesh to check
  101282. */
  101283. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  101284. /**
  101285. * Gets the texture used for the alpha test
  101286. * @returns the texture to use for alpha testing
  101287. */
  101288. getAlphaTestTexture(): Nullable<BaseTexture>;
  101289. /**
  101290. * Marks the material to indicate that it needs to be re-calculated
  101291. */
  101292. markDirty(): void;
  101293. /** @hidden */
  101294. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  101295. /**
  101296. * Binds the material to the mesh
  101297. * @param world defines the world transformation matrix
  101298. * @param mesh defines the mesh to bind the material to
  101299. */
  101300. bind(world: Matrix, mesh?: Mesh): void;
  101301. /**
  101302. * Binds the submesh to the material
  101303. * @param world defines the world transformation matrix
  101304. * @param mesh defines the mesh containing the submesh
  101305. * @param subMesh defines the submesh to bind the material to
  101306. */
  101307. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101308. /**
  101309. * Binds the world matrix to the material
  101310. * @param world defines the world transformation matrix
  101311. */
  101312. bindOnlyWorldMatrix(world: Matrix): void;
  101313. /**
  101314. * Binds the scene's uniform buffer to the effect.
  101315. * @param effect defines the effect to bind to the scene uniform buffer
  101316. * @param sceneUbo defines the uniform buffer storing scene data
  101317. */
  101318. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101319. /**
  101320. * Binds the view matrix to the effect
  101321. * @param effect defines the effect to bind the view matrix to
  101322. */
  101323. bindView(effect: Effect): void;
  101324. /**
  101325. * Binds the view projection matrix to the effect
  101326. * @param effect defines the effect to bind the view projection matrix to
  101327. */
  101328. bindViewProjection(effect: Effect): void;
  101329. /**
  101330. * Processes to execute after binding the material to a mesh
  101331. * @param mesh defines the rendered mesh
  101332. */
  101333. protected _afterBind(mesh?: Mesh): void;
  101334. /**
  101335. * Unbinds the material from the mesh
  101336. */
  101337. unbind(): void;
  101338. /**
  101339. * Gets the active textures from the material
  101340. * @returns an array of textures
  101341. */
  101342. getActiveTextures(): BaseTexture[];
  101343. /**
  101344. * Specifies if the material uses a texture
  101345. * @param texture defines the texture to check against the material
  101346. * @returns a boolean specifying if the material uses the texture
  101347. */
  101348. hasTexture(texture: BaseTexture): boolean;
  101349. /**
  101350. * Makes a duplicate of the material, and gives it a new name
  101351. * @param name defines the new name for the duplicated material
  101352. * @returns the cloned material
  101353. */
  101354. clone(name: string): Nullable<Material>;
  101355. /**
  101356. * Gets the meshes bound to the material
  101357. * @returns an array of meshes bound to the material
  101358. */
  101359. getBindedMeshes(): AbstractMesh[];
  101360. /**
  101361. * Force shader compilation
  101362. * @param mesh defines the mesh associated with this material
  101363. * @param onCompiled defines a function to execute once the material is compiled
  101364. * @param options defines the options to configure the compilation
  101365. * @param onError defines a function to execute if the material fails compiling
  101366. */
  101367. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  101368. /**
  101369. * Force shader compilation
  101370. * @param mesh defines the mesh that will use this material
  101371. * @param options defines additional options for compiling the shaders
  101372. * @returns a promise that resolves when the compilation completes
  101373. */
  101374. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  101375. private static readonly _AllDirtyCallBack;
  101376. private static readonly _ImageProcessingDirtyCallBack;
  101377. private static readonly _TextureDirtyCallBack;
  101378. private static readonly _FresnelDirtyCallBack;
  101379. private static readonly _MiscDirtyCallBack;
  101380. private static readonly _LightsDirtyCallBack;
  101381. private static readonly _AttributeDirtyCallBack;
  101382. private static _FresnelAndMiscDirtyCallBack;
  101383. private static _TextureAndMiscDirtyCallBack;
  101384. private static readonly _DirtyCallbackArray;
  101385. private static readonly _RunDirtyCallBacks;
  101386. /**
  101387. * Marks a define in the material to indicate that it needs to be re-computed
  101388. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  101389. */
  101390. markAsDirty(flag: number): void;
  101391. /**
  101392. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  101393. * @param func defines a function which checks material defines against the submeshes
  101394. */
  101395. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  101396. /**
  101397. * Indicates that we need to re-calculated for all submeshes
  101398. */
  101399. protected _markAllSubMeshesAsAllDirty(): void;
  101400. /**
  101401. * Indicates that image processing needs to be re-calculated for all submeshes
  101402. */
  101403. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  101404. /**
  101405. * Indicates that textures need to be re-calculated for all submeshes
  101406. */
  101407. protected _markAllSubMeshesAsTexturesDirty(): void;
  101408. /**
  101409. * Indicates that fresnel needs to be re-calculated for all submeshes
  101410. */
  101411. protected _markAllSubMeshesAsFresnelDirty(): void;
  101412. /**
  101413. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  101414. */
  101415. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  101416. /**
  101417. * Indicates that lights need to be re-calculated for all submeshes
  101418. */
  101419. protected _markAllSubMeshesAsLightsDirty(): void;
  101420. /**
  101421. * Indicates that attributes need to be re-calculated for all submeshes
  101422. */
  101423. protected _markAllSubMeshesAsAttributesDirty(): void;
  101424. /**
  101425. * Indicates that misc needs to be re-calculated for all submeshes
  101426. */
  101427. protected _markAllSubMeshesAsMiscDirty(): void;
  101428. /**
  101429. * Indicates that textures and misc need to be re-calculated for all submeshes
  101430. */
  101431. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  101432. /**
  101433. * Disposes the material
  101434. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101435. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101436. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101437. */
  101438. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101439. /** @hidden */
  101440. private releaseVertexArrayObject;
  101441. /**
  101442. * Serializes this material
  101443. * @returns the serialized material object
  101444. */
  101445. serialize(): any;
  101446. /**
  101447. * Creates a material from parsed material data
  101448. * @param parsedMaterial defines parsed material data
  101449. * @param scene defines the hosting scene
  101450. * @param rootUrl defines the root URL to use to load textures
  101451. * @returns a new material
  101452. */
  101453. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  101454. }
  101455. }
  101456. declare module BABYLON {
  101457. /**
  101458. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101459. * separate meshes. This can be use to improve performances.
  101460. * @see http://doc.babylonjs.com/how_to/multi_materials
  101461. */
  101462. export class MultiMaterial extends Material {
  101463. private _subMaterials;
  101464. /**
  101465. * Gets or Sets the list of Materials used within the multi material.
  101466. * They need to be ordered according to the submeshes order in the associated mesh
  101467. */
  101468. get subMaterials(): Nullable<Material>[];
  101469. set subMaterials(value: Nullable<Material>[]);
  101470. /**
  101471. * Function used to align with Node.getChildren()
  101472. * @returns the list of Materials used within the multi material
  101473. */
  101474. getChildren(): Nullable<Material>[];
  101475. /**
  101476. * Instantiates a new Multi Material
  101477. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101478. * separate meshes. This can be use to improve performances.
  101479. * @see http://doc.babylonjs.com/how_to/multi_materials
  101480. * @param name Define the name in the scene
  101481. * @param scene Define the scene the material belongs to
  101482. */
  101483. constructor(name: string, scene: Scene);
  101484. private _hookArray;
  101485. /**
  101486. * Get one of the submaterial by its index in the submaterials array
  101487. * @param index The index to look the sub material at
  101488. * @returns The Material if the index has been defined
  101489. */
  101490. getSubMaterial(index: number): Nullable<Material>;
  101491. /**
  101492. * Get the list of active textures for the whole sub materials list.
  101493. * @returns All the textures that will be used during the rendering
  101494. */
  101495. getActiveTextures(): BaseTexture[];
  101496. /**
  101497. * Gets the current class name of the material e.g. "MultiMaterial"
  101498. * Mainly use in serialization.
  101499. * @returns the class name
  101500. */
  101501. getClassName(): string;
  101502. /**
  101503. * Checks if the material is ready to render the requested sub mesh
  101504. * @param mesh Define the mesh the submesh belongs to
  101505. * @param subMesh Define the sub mesh to look readyness for
  101506. * @param useInstances Define whether or not the material is used with instances
  101507. * @returns true if ready, otherwise false
  101508. */
  101509. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  101510. /**
  101511. * Clones the current material and its related sub materials
  101512. * @param name Define the name of the newly cloned material
  101513. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  101514. * @returns the cloned material
  101515. */
  101516. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  101517. /**
  101518. * Serializes the materials into a JSON representation.
  101519. * @returns the JSON representation
  101520. */
  101521. serialize(): any;
  101522. /**
  101523. * Dispose the material and release its associated resources
  101524. * @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)
  101525. * @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)
  101526. * @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)
  101527. */
  101528. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  101529. /**
  101530. * Creates a MultiMaterial from parsed MultiMaterial data.
  101531. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  101532. * @param scene defines the hosting scene
  101533. * @returns a new MultiMaterial
  101534. */
  101535. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  101536. }
  101537. }
  101538. declare module BABYLON {
  101539. /**
  101540. * Base class for submeshes
  101541. */
  101542. export class BaseSubMesh {
  101543. /** @hidden */
  101544. _materialDefines: Nullable<MaterialDefines>;
  101545. /** @hidden */
  101546. _materialEffect: Nullable<Effect>;
  101547. /** @hidden */
  101548. _effectOverride: Nullable<Effect>;
  101549. /**
  101550. * Gets material defines used by the effect associated to the sub mesh
  101551. */
  101552. get materialDefines(): Nullable<MaterialDefines>;
  101553. /**
  101554. * Sets material defines used by the effect associated to the sub mesh
  101555. */
  101556. set materialDefines(defines: Nullable<MaterialDefines>);
  101557. /**
  101558. * Gets associated effect
  101559. */
  101560. get effect(): Nullable<Effect>;
  101561. /**
  101562. * Sets associated effect (effect used to render this submesh)
  101563. * @param effect defines the effect to associate with
  101564. * @param defines defines the set of defines used to compile this effect
  101565. */
  101566. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  101567. }
  101568. /**
  101569. * Defines a subdivision inside a mesh
  101570. */
  101571. export class SubMesh extends BaseSubMesh implements ICullable {
  101572. /** the material index to use */
  101573. materialIndex: number;
  101574. /** vertex index start */
  101575. verticesStart: number;
  101576. /** vertices count */
  101577. verticesCount: number;
  101578. /** index start */
  101579. indexStart: number;
  101580. /** indices count */
  101581. indexCount: number;
  101582. /** @hidden */
  101583. _linesIndexCount: number;
  101584. private _mesh;
  101585. private _renderingMesh;
  101586. private _boundingInfo;
  101587. private _linesIndexBuffer;
  101588. /** @hidden */
  101589. _lastColliderWorldVertices: Nullable<Vector3[]>;
  101590. /** @hidden */
  101591. _trianglePlanes: Plane[];
  101592. /** @hidden */
  101593. _lastColliderTransformMatrix: Nullable<Matrix>;
  101594. /** @hidden */
  101595. _renderId: number;
  101596. /** @hidden */
  101597. _alphaIndex: number;
  101598. /** @hidden */
  101599. _distanceToCamera: number;
  101600. /** @hidden */
  101601. _id: number;
  101602. private _currentMaterial;
  101603. /**
  101604. * Add a new submesh to a mesh
  101605. * @param materialIndex defines the material index to use
  101606. * @param verticesStart defines vertex index start
  101607. * @param verticesCount defines vertices count
  101608. * @param indexStart defines index start
  101609. * @param indexCount defines indices count
  101610. * @param mesh defines the parent mesh
  101611. * @param renderingMesh defines an optional rendering mesh
  101612. * @param createBoundingBox defines if bounding box should be created for this submesh
  101613. * @returns the new submesh
  101614. */
  101615. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  101616. /**
  101617. * Creates a new submesh
  101618. * @param materialIndex defines the material index to use
  101619. * @param verticesStart defines vertex index start
  101620. * @param verticesCount defines vertices count
  101621. * @param indexStart defines index start
  101622. * @param indexCount defines indices count
  101623. * @param mesh defines the parent mesh
  101624. * @param renderingMesh defines an optional rendering mesh
  101625. * @param createBoundingBox defines if bounding box should be created for this submesh
  101626. */
  101627. constructor(
  101628. /** the material index to use */
  101629. materialIndex: number,
  101630. /** vertex index start */
  101631. verticesStart: number,
  101632. /** vertices count */
  101633. verticesCount: number,
  101634. /** index start */
  101635. indexStart: number,
  101636. /** indices count */
  101637. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  101638. /**
  101639. * Returns true if this submesh covers the entire parent mesh
  101640. * @ignorenaming
  101641. */
  101642. get IsGlobal(): boolean;
  101643. /**
  101644. * Returns the submesh BoudingInfo object
  101645. * @returns current bounding info (or mesh's one if the submesh is global)
  101646. */
  101647. getBoundingInfo(): BoundingInfo;
  101648. /**
  101649. * Sets the submesh BoundingInfo
  101650. * @param boundingInfo defines the new bounding info to use
  101651. * @returns the SubMesh
  101652. */
  101653. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  101654. /**
  101655. * Returns the mesh of the current submesh
  101656. * @return the parent mesh
  101657. */
  101658. getMesh(): AbstractMesh;
  101659. /**
  101660. * Returns the rendering mesh of the submesh
  101661. * @returns the rendering mesh (could be different from parent mesh)
  101662. */
  101663. getRenderingMesh(): Mesh;
  101664. /**
  101665. * Returns the replacement mesh of the submesh
  101666. * @returns the replacement mesh (could be different from parent mesh)
  101667. */
  101668. getReplacementMesh(): Nullable<AbstractMesh>;
  101669. /**
  101670. * Returns the effective mesh of the submesh
  101671. * @returns the effective mesh (could be different from parent mesh)
  101672. */
  101673. getEffectiveMesh(): AbstractMesh;
  101674. /**
  101675. * Returns the submesh material
  101676. * @returns null or the current material
  101677. */
  101678. getMaterial(): Nullable<Material>;
  101679. /**
  101680. * Sets a new updated BoundingInfo object to the submesh
  101681. * @param data defines an optional position array to use to determine the bounding info
  101682. * @returns the SubMesh
  101683. */
  101684. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  101685. /** @hidden */
  101686. _checkCollision(collider: Collider): boolean;
  101687. /**
  101688. * Updates the submesh BoundingInfo
  101689. * @param world defines the world matrix to use to update the bounding info
  101690. * @returns the submesh
  101691. */
  101692. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  101693. /**
  101694. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  101695. * @param frustumPlanes defines the frustum planes
  101696. * @returns true if the submesh is intersecting with the frustum
  101697. */
  101698. isInFrustum(frustumPlanes: Plane[]): boolean;
  101699. /**
  101700. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  101701. * @param frustumPlanes defines the frustum planes
  101702. * @returns true if the submesh is inside the frustum
  101703. */
  101704. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101705. /**
  101706. * Renders the submesh
  101707. * @param enableAlphaMode defines if alpha needs to be used
  101708. * @returns the submesh
  101709. */
  101710. render(enableAlphaMode: boolean): SubMesh;
  101711. /**
  101712. * @hidden
  101713. */
  101714. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  101715. /**
  101716. * Checks if the submesh intersects with a ray
  101717. * @param ray defines the ray to test
  101718. * @returns true is the passed ray intersects the submesh bounding box
  101719. */
  101720. canIntersects(ray: Ray): boolean;
  101721. /**
  101722. * Intersects current submesh with a ray
  101723. * @param ray defines the ray to test
  101724. * @param positions defines mesh's positions array
  101725. * @param indices defines mesh's indices array
  101726. * @param fastCheck defines if the first intersection will be used (and not the closest)
  101727. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101728. * @returns intersection info or null if no intersection
  101729. */
  101730. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  101731. /** @hidden */
  101732. private _intersectLines;
  101733. /** @hidden */
  101734. private _intersectUnIndexedLines;
  101735. /** @hidden */
  101736. private _intersectTriangles;
  101737. /** @hidden */
  101738. private _intersectUnIndexedTriangles;
  101739. /** @hidden */
  101740. _rebuild(): void;
  101741. /**
  101742. * Creates a new submesh from the passed mesh
  101743. * @param newMesh defines the new hosting mesh
  101744. * @param newRenderingMesh defines an optional rendering mesh
  101745. * @returns the new submesh
  101746. */
  101747. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  101748. /**
  101749. * Release associated resources
  101750. */
  101751. dispose(): void;
  101752. /**
  101753. * Gets the class name
  101754. * @returns the string "SubMesh".
  101755. */
  101756. getClassName(): string;
  101757. /**
  101758. * Creates a new submesh from indices data
  101759. * @param materialIndex the index of the main mesh material
  101760. * @param startIndex the index where to start the copy in the mesh indices array
  101761. * @param indexCount the number of indices to copy then from the startIndex
  101762. * @param mesh the main mesh to create the submesh from
  101763. * @param renderingMesh the optional rendering mesh
  101764. * @returns a new submesh
  101765. */
  101766. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  101767. }
  101768. }
  101769. declare module BABYLON {
  101770. /**
  101771. * Class used to represent data loading progression
  101772. */
  101773. export class SceneLoaderFlags {
  101774. private static _ForceFullSceneLoadingForIncremental;
  101775. private static _ShowLoadingScreen;
  101776. private static _CleanBoneMatrixWeights;
  101777. private static _loggingLevel;
  101778. /**
  101779. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101780. */
  101781. static get ForceFullSceneLoadingForIncremental(): boolean;
  101782. static set ForceFullSceneLoadingForIncremental(value: boolean);
  101783. /**
  101784. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101785. */
  101786. static get ShowLoadingScreen(): boolean;
  101787. static set ShowLoadingScreen(value: boolean);
  101788. /**
  101789. * Defines the current logging level (while loading the scene)
  101790. * @ignorenaming
  101791. */
  101792. static get loggingLevel(): number;
  101793. static set loggingLevel(value: number);
  101794. /**
  101795. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101796. */
  101797. static get CleanBoneMatrixWeights(): boolean;
  101798. static set CleanBoneMatrixWeights(value: boolean);
  101799. }
  101800. }
  101801. declare module BABYLON {
  101802. /**
  101803. * Class used to store geometry data (vertex buffers + index buffer)
  101804. */
  101805. export class Geometry implements IGetSetVerticesData {
  101806. /**
  101807. * Gets or sets the ID of the geometry
  101808. */
  101809. id: string;
  101810. /**
  101811. * Gets or sets the unique ID of the geometry
  101812. */
  101813. uniqueId: number;
  101814. /**
  101815. * Gets the delay loading state of the geometry (none by default which means not delayed)
  101816. */
  101817. delayLoadState: number;
  101818. /**
  101819. * Gets the file containing the data to load when running in delay load state
  101820. */
  101821. delayLoadingFile: Nullable<string>;
  101822. /**
  101823. * Callback called when the geometry is updated
  101824. */
  101825. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  101826. private _scene;
  101827. private _engine;
  101828. private _meshes;
  101829. private _totalVertices;
  101830. /** @hidden */
  101831. _indices: IndicesArray;
  101832. /** @hidden */
  101833. _vertexBuffers: {
  101834. [key: string]: VertexBuffer;
  101835. };
  101836. private _isDisposed;
  101837. private _extend;
  101838. private _boundingBias;
  101839. /** @hidden */
  101840. _delayInfo: Array<string>;
  101841. private _indexBuffer;
  101842. private _indexBufferIsUpdatable;
  101843. /** @hidden */
  101844. _boundingInfo: Nullable<BoundingInfo>;
  101845. /** @hidden */
  101846. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  101847. /** @hidden */
  101848. _softwareSkinningFrameId: number;
  101849. private _vertexArrayObjects;
  101850. private _updatable;
  101851. /** @hidden */
  101852. _positions: Nullable<Vector3[]>;
  101853. /**
  101854. * 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
  101855. */
  101856. get boundingBias(): Vector2;
  101857. /**
  101858. * 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
  101859. */
  101860. set boundingBias(value: Vector2);
  101861. /**
  101862. * Static function used to attach a new empty geometry to a mesh
  101863. * @param mesh defines the mesh to attach the geometry to
  101864. * @returns the new Geometry
  101865. */
  101866. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  101867. /** Get the list of meshes using this geometry */
  101868. get meshes(): Mesh[];
  101869. /**
  101870. * Creates a new geometry
  101871. * @param id defines the unique ID
  101872. * @param scene defines the hosting scene
  101873. * @param vertexData defines the VertexData used to get geometry data
  101874. * @param updatable defines if geometry must be updatable (false by default)
  101875. * @param mesh defines the mesh that will be associated with the geometry
  101876. */
  101877. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  101878. /**
  101879. * Gets the current extend of the geometry
  101880. */
  101881. get extend(): {
  101882. minimum: Vector3;
  101883. maximum: Vector3;
  101884. };
  101885. /**
  101886. * Gets the hosting scene
  101887. * @returns the hosting Scene
  101888. */
  101889. getScene(): Scene;
  101890. /**
  101891. * Gets the hosting engine
  101892. * @returns the hosting Engine
  101893. */
  101894. getEngine(): Engine;
  101895. /**
  101896. * Defines if the geometry is ready to use
  101897. * @returns true if the geometry is ready to be used
  101898. */
  101899. isReady(): boolean;
  101900. /**
  101901. * Gets a value indicating that the geometry should not be serialized
  101902. */
  101903. get doNotSerialize(): boolean;
  101904. /** @hidden */
  101905. _rebuild(): void;
  101906. /**
  101907. * Affects all geometry data in one call
  101908. * @param vertexData defines the geometry data
  101909. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  101910. */
  101911. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  101912. /**
  101913. * Set specific vertex data
  101914. * @param kind defines the data kind (Position, normal, etc...)
  101915. * @param data defines the vertex data to use
  101916. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  101917. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  101918. */
  101919. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  101920. /**
  101921. * Removes a specific vertex data
  101922. * @param kind defines the data kind (Position, normal, etc...)
  101923. */
  101924. removeVerticesData(kind: string): void;
  101925. /**
  101926. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  101927. * @param buffer defines the vertex buffer to use
  101928. * @param totalVertices defines the total number of vertices for position kind (could be null)
  101929. */
  101930. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  101931. /**
  101932. * Update a specific vertex buffer
  101933. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  101934. * It will do nothing if the buffer is not updatable
  101935. * @param kind defines the data kind (Position, normal, etc...)
  101936. * @param data defines the data to use
  101937. * @param offset defines the offset in the target buffer where to store the data
  101938. * @param useBytes set to true if the offset is in bytes
  101939. */
  101940. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  101941. /**
  101942. * Update a specific vertex buffer
  101943. * This function will create a new buffer if the current one is not updatable
  101944. * @param kind defines the data kind (Position, normal, etc...)
  101945. * @param data defines the data to use
  101946. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  101947. */
  101948. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  101949. private _updateBoundingInfo;
  101950. /** @hidden */
  101951. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  101952. /**
  101953. * Gets total number of vertices
  101954. * @returns the total number of vertices
  101955. */
  101956. getTotalVertices(): number;
  101957. /**
  101958. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  101959. * @param kind defines the data kind (Position, normal, etc...)
  101960. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  101961. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101962. * @returns a float array containing vertex data
  101963. */
  101964. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  101965. /**
  101966. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  101967. * @param kind defines the data kind (Position, normal, etc...)
  101968. * @returns true if the vertex buffer with the specified kind is updatable
  101969. */
  101970. isVertexBufferUpdatable(kind: string): boolean;
  101971. /**
  101972. * Gets a specific vertex buffer
  101973. * @param kind defines the data kind (Position, normal, etc...)
  101974. * @returns a VertexBuffer
  101975. */
  101976. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  101977. /**
  101978. * Returns all vertex buffers
  101979. * @return an object holding all vertex buffers indexed by kind
  101980. */
  101981. getVertexBuffers(): Nullable<{
  101982. [key: string]: VertexBuffer;
  101983. }>;
  101984. /**
  101985. * Gets a boolean indicating if specific vertex buffer is present
  101986. * @param kind defines the data kind (Position, normal, etc...)
  101987. * @returns true if data is present
  101988. */
  101989. isVerticesDataPresent(kind: string): boolean;
  101990. /**
  101991. * Gets a list of all attached data kinds (Position, normal, etc...)
  101992. * @returns a list of string containing all kinds
  101993. */
  101994. getVerticesDataKinds(): string[];
  101995. /**
  101996. * Update index buffer
  101997. * @param indices defines the indices to store in the index buffer
  101998. * @param offset defines the offset in the target buffer where to store the data
  101999. * @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)
  102000. */
  102001. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  102002. /**
  102003. * Creates a new index buffer
  102004. * @param indices defines the indices to store in the index buffer
  102005. * @param totalVertices defines the total number of vertices (could be null)
  102006. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102007. */
  102008. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  102009. /**
  102010. * Return the total number of indices
  102011. * @returns the total number of indices
  102012. */
  102013. getTotalIndices(): number;
  102014. /**
  102015. * Gets the index buffer array
  102016. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102017. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102018. * @returns the index buffer array
  102019. */
  102020. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102021. /**
  102022. * Gets the index buffer
  102023. * @return the index buffer
  102024. */
  102025. getIndexBuffer(): Nullable<DataBuffer>;
  102026. /** @hidden */
  102027. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  102028. /**
  102029. * Release the associated resources for a specific mesh
  102030. * @param mesh defines the source mesh
  102031. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  102032. */
  102033. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  102034. /**
  102035. * Apply current geometry to a given mesh
  102036. * @param mesh defines the mesh to apply geometry to
  102037. */
  102038. applyToMesh(mesh: Mesh): void;
  102039. private _updateExtend;
  102040. private _applyToMesh;
  102041. private notifyUpdate;
  102042. /**
  102043. * Load the geometry if it was flagged as delay loaded
  102044. * @param scene defines the hosting scene
  102045. * @param onLoaded defines a callback called when the geometry is loaded
  102046. */
  102047. load(scene: Scene, onLoaded?: () => void): void;
  102048. private _queueLoad;
  102049. /**
  102050. * Invert the geometry to move from a right handed system to a left handed one.
  102051. */
  102052. toLeftHanded(): void;
  102053. /** @hidden */
  102054. _resetPointsArrayCache(): void;
  102055. /** @hidden */
  102056. _generatePointsArray(): boolean;
  102057. /**
  102058. * Gets a value indicating if the geometry is disposed
  102059. * @returns true if the geometry was disposed
  102060. */
  102061. isDisposed(): boolean;
  102062. private _disposeVertexArrayObjects;
  102063. /**
  102064. * Free all associated resources
  102065. */
  102066. dispose(): void;
  102067. /**
  102068. * Clone the current geometry into a new geometry
  102069. * @param id defines the unique ID of the new geometry
  102070. * @returns a new geometry object
  102071. */
  102072. copy(id: string): Geometry;
  102073. /**
  102074. * Serialize the current geometry info (and not the vertices data) into a JSON object
  102075. * @return a JSON representation of the current geometry data (without the vertices data)
  102076. */
  102077. serialize(): any;
  102078. private toNumberArray;
  102079. /**
  102080. * Serialize all vertices data into a JSON oject
  102081. * @returns a JSON representation of the current geometry data
  102082. */
  102083. serializeVerticeData(): any;
  102084. /**
  102085. * Extracts a clone of a mesh geometry
  102086. * @param mesh defines the source mesh
  102087. * @param id defines the unique ID of the new geometry object
  102088. * @returns the new geometry object
  102089. */
  102090. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  102091. /**
  102092. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  102093. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102094. * Be aware Math.random() could cause collisions, but:
  102095. * "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"
  102096. * @returns a string containing a new GUID
  102097. */
  102098. static RandomId(): string;
  102099. /** @hidden */
  102100. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  102101. private static _CleanMatricesWeights;
  102102. /**
  102103. * Create a new geometry from persisted data (Using .babylon file format)
  102104. * @param parsedVertexData defines the persisted data
  102105. * @param scene defines the hosting scene
  102106. * @param rootUrl defines the root url to use to load assets (like delayed data)
  102107. * @returns the new geometry object
  102108. */
  102109. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  102110. }
  102111. }
  102112. declare module BABYLON {
  102113. /**
  102114. * Define an interface for all classes that will get and set the data on vertices
  102115. */
  102116. export interface IGetSetVerticesData {
  102117. /**
  102118. * Gets a boolean indicating if specific vertex data is present
  102119. * @param kind defines the vertex data kind to use
  102120. * @returns true is data kind is present
  102121. */
  102122. isVerticesDataPresent(kind: string): boolean;
  102123. /**
  102124. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102125. * @param kind defines the data kind (Position, normal, etc...)
  102126. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102127. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102128. * @returns a float array containing vertex data
  102129. */
  102130. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102131. /**
  102132. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  102133. * @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.
  102134. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102135. * @returns the indices array or an empty array if the mesh has no geometry
  102136. */
  102137. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102138. /**
  102139. * Set specific vertex data
  102140. * @param kind defines the data kind (Position, normal, etc...)
  102141. * @param data defines the vertex data to use
  102142. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102143. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102144. */
  102145. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  102146. /**
  102147. * Update a specific associated vertex buffer
  102148. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  102149. * - VertexBuffer.PositionKind
  102150. * - VertexBuffer.UVKind
  102151. * - VertexBuffer.UV2Kind
  102152. * - VertexBuffer.UV3Kind
  102153. * - VertexBuffer.UV4Kind
  102154. * - VertexBuffer.UV5Kind
  102155. * - VertexBuffer.UV6Kind
  102156. * - VertexBuffer.ColorKind
  102157. * - VertexBuffer.MatricesIndicesKind
  102158. * - VertexBuffer.MatricesIndicesExtraKind
  102159. * - VertexBuffer.MatricesWeightsKind
  102160. * - VertexBuffer.MatricesWeightsExtraKind
  102161. * @param data defines the data source
  102162. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  102163. * @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)
  102164. */
  102165. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  102166. /**
  102167. * Creates a new index buffer
  102168. * @param indices defines the indices to store in the index buffer
  102169. * @param totalVertices defines the total number of vertices (could be null)
  102170. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102171. */
  102172. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  102173. }
  102174. /**
  102175. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  102176. */
  102177. export class VertexData {
  102178. /**
  102179. * Mesh side orientation : usually the external or front surface
  102180. */
  102181. static readonly FRONTSIDE: number;
  102182. /**
  102183. * Mesh side orientation : usually the internal or back surface
  102184. */
  102185. static readonly BACKSIDE: number;
  102186. /**
  102187. * Mesh side orientation : both internal and external or front and back surfaces
  102188. */
  102189. static readonly DOUBLESIDE: number;
  102190. /**
  102191. * Mesh side orientation : by default, `FRONTSIDE`
  102192. */
  102193. static readonly DEFAULTSIDE: number;
  102194. /**
  102195. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  102196. */
  102197. positions: Nullable<FloatArray>;
  102198. /**
  102199. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  102200. */
  102201. normals: Nullable<FloatArray>;
  102202. /**
  102203. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  102204. */
  102205. tangents: Nullable<FloatArray>;
  102206. /**
  102207. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102208. */
  102209. uvs: Nullable<FloatArray>;
  102210. /**
  102211. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102212. */
  102213. uvs2: Nullable<FloatArray>;
  102214. /**
  102215. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102216. */
  102217. uvs3: Nullable<FloatArray>;
  102218. /**
  102219. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102220. */
  102221. uvs4: Nullable<FloatArray>;
  102222. /**
  102223. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102224. */
  102225. uvs5: Nullable<FloatArray>;
  102226. /**
  102227. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102228. */
  102229. uvs6: Nullable<FloatArray>;
  102230. /**
  102231. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  102232. */
  102233. colors: Nullable<FloatArray>;
  102234. /**
  102235. * 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).
  102236. */
  102237. matricesIndices: Nullable<FloatArray>;
  102238. /**
  102239. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  102240. */
  102241. matricesWeights: Nullable<FloatArray>;
  102242. /**
  102243. * An array extending the number of possible indices
  102244. */
  102245. matricesIndicesExtra: Nullable<FloatArray>;
  102246. /**
  102247. * An array extending the number of possible weights when the number of indices is extended
  102248. */
  102249. matricesWeightsExtra: Nullable<FloatArray>;
  102250. /**
  102251. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  102252. */
  102253. indices: Nullable<IndicesArray>;
  102254. /**
  102255. * Uses the passed data array to set the set the values for the specified kind of data
  102256. * @param data a linear array of floating numbers
  102257. * @param kind the type of data that is being set, eg positions, colors etc
  102258. */
  102259. set(data: FloatArray, kind: string): void;
  102260. /**
  102261. * Associates the vertexData to the passed Mesh.
  102262. * Sets it as updatable or not (default `false`)
  102263. * @param mesh the mesh the vertexData is applied to
  102264. * @param updatable when used and having the value true allows new data to update the vertexData
  102265. * @returns the VertexData
  102266. */
  102267. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  102268. /**
  102269. * Associates the vertexData to the passed Geometry.
  102270. * Sets it as updatable or not (default `false`)
  102271. * @param geometry the geometry the vertexData is applied to
  102272. * @param updatable when used and having the value true allows new data to update the vertexData
  102273. * @returns VertexData
  102274. */
  102275. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  102276. /**
  102277. * Updates the associated mesh
  102278. * @param mesh the mesh to be updated
  102279. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102280. * @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
  102281. * @returns VertexData
  102282. */
  102283. updateMesh(mesh: Mesh): VertexData;
  102284. /**
  102285. * Updates the associated geometry
  102286. * @param geometry the geometry to be updated
  102287. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102288. * @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
  102289. * @returns VertexData.
  102290. */
  102291. updateGeometry(geometry: Geometry): VertexData;
  102292. private _applyTo;
  102293. private _update;
  102294. /**
  102295. * Transforms each position and each normal of the vertexData according to the passed Matrix
  102296. * @param matrix the transforming matrix
  102297. * @returns the VertexData
  102298. */
  102299. transform(matrix: Matrix): VertexData;
  102300. /**
  102301. * Merges the passed VertexData into the current one
  102302. * @param other the VertexData to be merged into the current one
  102303. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102304. * @returns the modified VertexData
  102305. */
  102306. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102307. private _mergeElement;
  102308. private _validate;
  102309. /**
  102310. * Serializes the VertexData
  102311. * @returns a serialized object
  102312. */
  102313. serialize(): any;
  102314. /**
  102315. * Extracts the vertexData from a mesh
  102316. * @param mesh the mesh from which to extract the VertexData
  102317. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102318. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102319. * @returns the object VertexData associated to the passed mesh
  102320. */
  102321. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102322. /**
  102323. * Extracts the vertexData from the geometry
  102324. * @param geometry the geometry from which to extract the VertexData
  102325. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102326. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102327. * @returns the object VertexData associated to the passed mesh
  102328. */
  102329. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102330. private static _ExtractFrom;
  102331. /**
  102332. * Creates the VertexData for a Ribbon
  102333. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102334. * * pathArray array of paths, each of which an array of successive Vector3
  102335. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102336. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102337. * * 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
  102338. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102339. * * 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)
  102340. * * 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)
  102341. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102342. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102343. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102344. * @returns the VertexData of the ribbon
  102345. */
  102346. static CreateRibbon(options: {
  102347. pathArray: Vector3[][];
  102348. closeArray?: boolean;
  102349. closePath?: boolean;
  102350. offset?: number;
  102351. sideOrientation?: number;
  102352. frontUVs?: Vector4;
  102353. backUVs?: Vector4;
  102354. invertUV?: boolean;
  102355. uvs?: Vector2[];
  102356. colors?: Color4[];
  102357. }): VertexData;
  102358. /**
  102359. * Creates the VertexData for a box
  102360. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102361. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102362. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102363. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102364. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102365. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102366. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102367. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102368. * * 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)
  102369. * * 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)
  102370. * @returns the VertexData of the box
  102371. */
  102372. static CreateBox(options: {
  102373. size?: number;
  102374. width?: number;
  102375. height?: number;
  102376. depth?: number;
  102377. faceUV?: Vector4[];
  102378. faceColors?: Color4[];
  102379. sideOrientation?: number;
  102380. frontUVs?: Vector4;
  102381. backUVs?: Vector4;
  102382. }): VertexData;
  102383. /**
  102384. * Creates the VertexData for a tiled box
  102385. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102386. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102387. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102388. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102390. * @returns the VertexData of the box
  102391. */
  102392. static CreateTiledBox(options: {
  102393. pattern?: number;
  102394. width?: number;
  102395. height?: number;
  102396. depth?: number;
  102397. tileSize?: number;
  102398. tileWidth?: number;
  102399. tileHeight?: number;
  102400. alignHorizontal?: number;
  102401. alignVertical?: number;
  102402. faceUV?: Vector4[];
  102403. faceColors?: Color4[];
  102404. sideOrientation?: number;
  102405. }): VertexData;
  102406. /**
  102407. * Creates the VertexData for a tiled plane
  102408. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102409. * * pattern a limited pattern arrangement depending on the number
  102410. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  102411. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  102412. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  102413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102414. * * 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)
  102415. * * 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)
  102416. * @returns the VertexData of the tiled plane
  102417. */
  102418. static CreateTiledPlane(options: {
  102419. pattern?: number;
  102420. tileSize?: number;
  102421. tileWidth?: number;
  102422. tileHeight?: number;
  102423. size?: number;
  102424. width?: number;
  102425. height?: number;
  102426. alignHorizontal?: number;
  102427. alignVertical?: number;
  102428. sideOrientation?: number;
  102429. frontUVs?: Vector4;
  102430. backUVs?: Vector4;
  102431. }): VertexData;
  102432. /**
  102433. * Creates the VertexData for an ellipsoid, defaults to a sphere
  102434. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102435. * * segments sets the number of horizontal strips optional, default 32
  102436. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  102437. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  102438. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  102439. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  102440. * * 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
  102441. * * 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
  102442. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102443. * * 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)
  102444. * * 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)
  102445. * @returns the VertexData of the ellipsoid
  102446. */
  102447. static CreateSphere(options: {
  102448. segments?: number;
  102449. diameter?: number;
  102450. diameterX?: number;
  102451. diameterY?: number;
  102452. diameterZ?: number;
  102453. arc?: number;
  102454. slice?: number;
  102455. sideOrientation?: number;
  102456. frontUVs?: Vector4;
  102457. backUVs?: Vector4;
  102458. }): VertexData;
  102459. /**
  102460. * Creates the VertexData for a cylinder, cone or prism
  102461. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102462. * * height sets the height (y direction) of the cylinder, optional, default 2
  102463. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  102464. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  102465. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  102466. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102467. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  102468. * * 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
  102469. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102470. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102471. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  102472. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  102473. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102474. * * 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)
  102475. * * 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)
  102476. * @returns the VertexData of the cylinder, cone or prism
  102477. */
  102478. static CreateCylinder(options: {
  102479. height?: number;
  102480. diameterTop?: number;
  102481. diameterBottom?: number;
  102482. diameter?: number;
  102483. tessellation?: number;
  102484. subdivisions?: number;
  102485. arc?: number;
  102486. faceColors?: Color4[];
  102487. faceUV?: Vector4[];
  102488. hasRings?: boolean;
  102489. enclose?: boolean;
  102490. sideOrientation?: number;
  102491. frontUVs?: Vector4;
  102492. backUVs?: Vector4;
  102493. }): VertexData;
  102494. /**
  102495. * Creates the VertexData for a torus
  102496. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102497. * * diameter the diameter of the torus, optional default 1
  102498. * * thickness the diameter of the tube forming the torus, optional default 0.5
  102499. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102501. * * 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)
  102502. * * 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)
  102503. * @returns the VertexData of the torus
  102504. */
  102505. static CreateTorus(options: {
  102506. diameter?: number;
  102507. thickness?: number;
  102508. tessellation?: number;
  102509. sideOrientation?: number;
  102510. frontUVs?: Vector4;
  102511. backUVs?: Vector4;
  102512. }): VertexData;
  102513. /**
  102514. * Creates the VertexData of the LineSystem
  102515. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  102516. * - lines an array of lines, each line being an array of successive Vector3
  102517. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  102518. * @returns the VertexData of the LineSystem
  102519. */
  102520. static CreateLineSystem(options: {
  102521. lines: Vector3[][];
  102522. colors?: Nullable<Color4[][]>;
  102523. }): VertexData;
  102524. /**
  102525. * Create the VertexData for a DashedLines
  102526. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  102527. * - points an array successive Vector3
  102528. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  102529. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  102530. * - dashNb the intended total number of dashes, optional, default 200
  102531. * @returns the VertexData for the DashedLines
  102532. */
  102533. static CreateDashedLines(options: {
  102534. points: Vector3[];
  102535. dashSize?: number;
  102536. gapSize?: number;
  102537. dashNb?: number;
  102538. }): VertexData;
  102539. /**
  102540. * Creates the VertexData for a Ground
  102541. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102542. * - width the width (x direction) of the ground, optional, default 1
  102543. * - height the height (z direction) of the ground, optional, default 1
  102544. * - subdivisions the number of subdivisions per side, optional, default 1
  102545. * @returns the VertexData of the Ground
  102546. */
  102547. static CreateGround(options: {
  102548. width?: number;
  102549. height?: number;
  102550. subdivisions?: number;
  102551. subdivisionsX?: number;
  102552. subdivisionsY?: number;
  102553. }): VertexData;
  102554. /**
  102555. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  102556. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102557. * * xmin the ground minimum X coordinate, optional, default -1
  102558. * * zmin the ground minimum Z coordinate, optional, default -1
  102559. * * xmax the ground maximum X coordinate, optional, default 1
  102560. * * zmax the ground maximum Z coordinate, optional, default 1
  102561. * * 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}
  102562. * * 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}
  102563. * @returns the VertexData of the TiledGround
  102564. */
  102565. static CreateTiledGround(options: {
  102566. xmin: number;
  102567. zmin: number;
  102568. xmax: number;
  102569. zmax: number;
  102570. subdivisions?: {
  102571. w: number;
  102572. h: number;
  102573. };
  102574. precision?: {
  102575. w: number;
  102576. h: number;
  102577. };
  102578. }): VertexData;
  102579. /**
  102580. * Creates the VertexData of the Ground designed from a heightmap
  102581. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  102582. * * width the width (x direction) of the ground
  102583. * * height the height (z direction) of the ground
  102584. * * subdivisions the number of subdivisions per side
  102585. * * minHeight the minimum altitude on the ground, optional, default 0
  102586. * * maxHeight the maximum altitude on the ground, optional default 1
  102587. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  102588. * * buffer the array holding the image color data
  102589. * * bufferWidth the width of image
  102590. * * bufferHeight the height of image
  102591. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  102592. * @returns the VertexData of the Ground designed from a heightmap
  102593. */
  102594. static CreateGroundFromHeightMap(options: {
  102595. width: number;
  102596. height: number;
  102597. subdivisions: number;
  102598. minHeight: number;
  102599. maxHeight: number;
  102600. colorFilter: Color3;
  102601. buffer: Uint8Array;
  102602. bufferWidth: number;
  102603. bufferHeight: number;
  102604. alphaFilter: number;
  102605. }): VertexData;
  102606. /**
  102607. * Creates the VertexData for a Plane
  102608. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  102609. * * size sets the width and height of the plane to the value of size, optional default 1
  102610. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  102611. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  102612. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102613. * * 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)
  102614. * * 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)
  102615. * @returns the VertexData of the box
  102616. */
  102617. static CreatePlane(options: {
  102618. size?: number;
  102619. width?: number;
  102620. height?: number;
  102621. sideOrientation?: number;
  102622. frontUVs?: Vector4;
  102623. backUVs?: Vector4;
  102624. }): VertexData;
  102625. /**
  102626. * Creates the VertexData of the Disc or regular Polygon
  102627. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  102628. * * radius the radius of the disc, optional default 0.5
  102629. * * tessellation the number of polygon sides, optional, default 64
  102630. * * 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
  102631. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102632. * * 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)
  102633. * * 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)
  102634. * @returns the VertexData of the box
  102635. */
  102636. static CreateDisc(options: {
  102637. radius?: number;
  102638. tessellation?: number;
  102639. arc?: number;
  102640. sideOrientation?: number;
  102641. frontUVs?: Vector4;
  102642. backUVs?: Vector4;
  102643. }): VertexData;
  102644. /**
  102645. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  102646. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  102647. * @param polygon a mesh built from polygonTriangulation.build()
  102648. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102649. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102650. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102651. * @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)
  102652. * @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)
  102653. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  102654. * @returns the VertexData of the Polygon
  102655. */
  102656. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  102657. /**
  102658. * Creates the VertexData of the IcoSphere
  102659. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  102660. * * radius the radius of the IcoSphere, optional default 1
  102661. * * radiusX allows stretching in the x direction, optional, default radius
  102662. * * radiusY allows stretching in the y direction, optional, default radius
  102663. * * radiusZ allows stretching in the z direction, optional, default radius
  102664. * * flat when true creates a flat shaded mesh, optional, default true
  102665. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102666. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102667. * * 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)
  102668. * * 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)
  102669. * @returns the VertexData of the IcoSphere
  102670. */
  102671. static CreateIcoSphere(options: {
  102672. radius?: number;
  102673. radiusX?: number;
  102674. radiusY?: number;
  102675. radiusZ?: number;
  102676. flat?: boolean;
  102677. subdivisions?: number;
  102678. sideOrientation?: number;
  102679. frontUVs?: Vector4;
  102680. backUVs?: Vector4;
  102681. }): VertexData;
  102682. /**
  102683. * Creates the VertexData for a Polyhedron
  102684. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  102685. * * type provided types are:
  102686. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  102687. * * 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)
  102688. * * size the size of the IcoSphere, optional default 1
  102689. * * sizeX allows stretching in the x direction, optional, default size
  102690. * * sizeY allows stretching in the y direction, optional, default size
  102691. * * sizeZ allows stretching in the z direction, optional, default size
  102692. * * 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
  102693. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102694. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102695. * * flat when true creates a flat shaded mesh, optional, default true
  102696. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102697. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102698. * * 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)
  102699. * * 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)
  102700. * @returns the VertexData of the Polyhedron
  102701. */
  102702. static CreatePolyhedron(options: {
  102703. type?: number;
  102704. size?: number;
  102705. sizeX?: number;
  102706. sizeY?: number;
  102707. sizeZ?: number;
  102708. custom?: any;
  102709. faceUV?: Vector4[];
  102710. faceColors?: Color4[];
  102711. flat?: boolean;
  102712. sideOrientation?: number;
  102713. frontUVs?: Vector4;
  102714. backUVs?: Vector4;
  102715. }): VertexData;
  102716. /**
  102717. * Creates the VertexData for a TorusKnot
  102718. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  102719. * * radius the radius of the torus knot, optional, default 2
  102720. * * tube the thickness of the tube, optional, default 0.5
  102721. * * radialSegments the number of sides on each tube segments, optional, default 32
  102722. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  102723. * * p the number of windings around the z axis, optional, default 2
  102724. * * q the number of windings around the x axis, optional, default 3
  102725. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102726. * * 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)
  102727. * * 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)
  102728. * @returns the VertexData of the Torus Knot
  102729. */
  102730. static CreateTorusKnot(options: {
  102731. radius?: number;
  102732. tube?: number;
  102733. radialSegments?: number;
  102734. tubularSegments?: number;
  102735. p?: number;
  102736. q?: number;
  102737. sideOrientation?: number;
  102738. frontUVs?: Vector4;
  102739. backUVs?: Vector4;
  102740. }): VertexData;
  102741. /**
  102742. * Compute normals for given positions and indices
  102743. * @param positions an array of vertex positions, [...., x, y, z, ......]
  102744. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  102745. * @param normals an array of vertex normals, [...., x, y, z, ......]
  102746. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  102747. * * facetNormals : optional array of facet normals (vector3)
  102748. * * facetPositions : optional array of facet positions (vector3)
  102749. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  102750. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  102751. * * bInfo : optional bounding info, required for facetPartitioning computation
  102752. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  102753. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  102754. * * useRightHandedSystem: optional boolean to for right handed system computation
  102755. * * depthSort : optional boolean to enable the facet depth sort computation
  102756. * * distanceTo : optional Vector3 to compute the facet depth from this location
  102757. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  102758. */
  102759. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  102760. facetNormals?: any;
  102761. facetPositions?: any;
  102762. facetPartitioning?: any;
  102763. ratio?: number;
  102764. bInfo?: any;
  102765. bbSize?: Vector3;
  102766. subDiv?: any;
  102767. useRightHandedSystem?: boolean;
  102768. depthSort?: boolean;
  102769. distanceTo?: Vector3;
  102770. depthSortedFacets?: any;
  102771. }): void;
  102772. /** @hidden */
  102773. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  102774. /**
  102775. * Applies VertexData created from the imported parameters to the geometry
  102776. * @param parsedVertexData the parsed data from an imported file
  102777. * @param geometry the geometry to apply the VertexData to
  102778. */
  102779. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  102780. }
  102781. }
  102782. declare module BABYLON {
  102783. /**
  102784. * Defines a target to use with MorphTargetManager
  102785. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102786. */
  102787. export class MorphTarget implements IAnimatable {
  102788. /** defines the name of the target */
  102789. name: string;
  102790. /**
  102791. * Gets or sets the list of animations
  102792. */
  102793. animations: Animation[];
  102794. private _scene;
  102795. private _positions;
  102796. private _normals;
  102797. private _tangents;
  102798. private _uvs;
  102799. private _influence;
  102800. private _uniqueId;
  102801. /**
  102802. * Observable raised when the influence changes
  102803. */
  102804. onInfluenceChanged: Observable<boolean>;
  102805. /** @hidden */
  102806. _onDataLayoutChanged: Observable<void>;
  102807. /**
  102808. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  102809. */
  102810. get influence(): number;
  102811. set influence(influence: number);
  102812. /**
  102813. * Gets or sets the id of the morph Target
  102814. */
  102815. id: string;
  102816. private _animationPropertiesOverride;
  102817. /**
  102818. * Gets or sets the animation properties override
  102819. */
  102820. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102821. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102822. /**
  102823. * Creates a new MorphTarget
  102824. * @param name defines the name of the target
  102825. * @param influence defines the influence to use
  102826. * @param scene defines the scene the morphtarget belongs to
  102827. */
  102828. constructor(
  102829. /** defines the name of the target */
  102830. name: string, influence?: number, scene?: Nullable<Scene>);
  102831. /**
  102832. * Gets the unique ID of this manager
  102833. */
  102834. get uniqueId(): number;
  102835. /**
  102836. * Gets a boolean defining if the target contains position data
  102837. */
  102838. get hasPositions(): boolean;
  102839. /**
  102840. * Gets a boolean defining if the target contains normal data
  102841. */
  102842. get hasNormals(): boolean;
  102843. /**
  102844. * Gets a boolean defining if the target contains tangent data
  102845. */
  102846. get hasTangents(): boolean;
  102847. /**
  102848. * Gets a boolean defining if the target contains texture coordinates data
  102849. */
  102850. get hasUVs(): boolean;
  102851. /**
  102852. * Affects position data to this target
  102853. * @param data defines the position data to use
  102854. */
  102855. setPositions(data: Nullable<FloatArray>): void;
  102856. /**
  102857. * Gets the position data stored in this target
  102858. * @returns a FloatArray containing the position data (or null if not present)
  102859. */
  102860. getPositions(): Nullable<FloatArray>;
  102861. /**
  102862. * Affects normal data to this target
  102863. * @param data defines the normal data to use
  102864. */
  102865. setNormals(data: Nullable<FloatArray>): void;
  102866. /**
  102867. * Gets the normal data stored in this target
  102868. * @returns a FloatArray containing the normal data (or null if not present)
  102869. */
  102870. getNormals(): Nullable<FloatArray>;
  102871. /**
  102872. * Affects tangent data to this target
  102873. * @param data defines the tangent data to use
  102874. */
  102875. setTangents(data: Nullable<FloatArray>): void;
  102876. /**
  102877. * Gets the tangent data stored in this target
  102878. * @returns a FloatArray containing the tangent data (or null if not present)
  102879. */
  102880. getTangents(): Nullable<FloatArray>;
  102881. /**
  102882. * Affects texture coordinates data to this target
  102883. * @param data defines the texture coordinates data to use
  102884. */
  102885. setUVs(data: Nullable<FloatArray>): void;
  102886. /**
  102887. * Gets the texture coordinates data stored in this target
  102888. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  102889. */
  102890. getUVs(): Nullable<FloatArray>;
  102891. /**
  102892. * Clone the current target
  102893. * @returns a new MorphTarget
  102894. */
  102895. clone(): MorphTarget;
  102896. /**
  102897. * Serializes the current target into a Serialization object
  102898. * @returns the serialized object
  102899. */
  102900. serialize(): any;
  102901. /**
  102902. * Returns the string "MorphTarget"
  102903. * @returns "MorphTarget"
  102904. */
  102905. getClassName(): string;
  102906. /**
  102907. * Creates a new target from serialized data
  102908. * @param serializationObject defines the serialized data to use
  102909. * @returns a new MorphTarget
  102910. */
  102911. static Parse(serializationObject: any): MorphTarget;
  102912. /**
  102913. * Creates a MorphTarget from mesh data
  102914. * @param mesh defines the source mesh
  102915. * @param name defines the name to use for the new target
  102916. * @param influence defines the influence to attach to the target
  102917. * @returns a new MorphTarget
  102918. */
  102919. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  102920. }
  102921. }
  102922. declare module BABYLON {
  102923. /**
  102924. * This class is used to deform meshes using morphing between different targets
  102925. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102926. */
  102927. export class MorphTargetManager {
  102928. private _targets;
  102929. private _targetInfluenceChangedObservers;
  102930. private _targetDataLayoutChangedObservers;
  102931. private _activeTargets;
  102932. private _scene;
  102933. private _influences;
  102934. private _supportsNormals;
  102935. private _supportsTangents;
  102936. private _supportsUVs;
  102937. private _vertexCount;
  102938. private _uniqueId;
  102939. private _tempInfluences;
  102940. /**
  102941. * Gets or sets a boolean indicating if normals must be morphed
  102942. */
  102943. enableNormalMorphing: boolean;
  102944. /**
  102945. * Gets or sets a boolean indicating if tangents must be morphed
  102946. */
  102947. enableTangentMorphing: boolean;
  102948. /**
  102949. * Gets or sets a boolean indicating if UV must be morphed
  102950. */
  102951. enableUVMorphing: boolean;
  102952. /**
  102953. * Creates a new MorphTargetManager
  102954. * @param scene defines the current scene
  102955. */
  102956. constructor(scene?: Nullable<Scene>);
  102957. /**
  102958. * Gets the unique ID of this manager
  102959. */
  102960. get uniqueId(): number;
  102961. /**
  102962. * Gets the number of vertices handled by this manager
  102963. */
  102964. get vertexCount(): number;
  102965. /**
  102966. * Gets a boolean indicating if this manager supports morphing of normals
  102967. */
  102968. get supportsNormals(): boolean;
  102969. /**
  102970. * Gets a boolean indicating if this manager supports morphing of tangents
  102971. */
  102972. get supportsTangents(): boolean;
  102973. /**
  102974. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  102975. */
  102976. get supportsUVs(): boolean;
  102977. /**
  102978. * Gets the number of targets stored in this manager
  102979. */
  102980. get numTargets(): number;
  102981. /**
  102982. * Gets the number of influencers (ie. the number of targets with influences > 0)
  102983. */
  102984. get numInfluencers(): number;
  102985. /**
  102986. * Gets the list of influences (one per target)
  102987. */
  102988. get influences(): Float32Array;
  102989. /**
  102990. * Gets the active target at specified index. An active target is a target with an influence > 0
  102991. * @param index defines the index to check
  102992. * @returns the requested target
  102993. */
  102994. getActiveTarget(index: number): MorphTarget;
  102995. /**
  102996. * Gets the target at specified index
  102997. * @param index defines the index to check
  102998. * @returns the requested target
  102999. */
  103000. getTarget(index: number): MorphTarget;
  103001. /**
  103002. * Add a new target to this manager
  103003. * @param target defines the target to add
  103004. */
  103005. addTarget(target: MorphTarget): void;
  103006. /**
  103007. * Removes a target from the manager
  103008. * @param target defines the target to remove
  103009. */
  103010. removeTarget(target: MorphTarget): void;
  103011. /**
  103012. * Clone the current manager
  103013. * @returns a new MorphTargetManager
  103014. */
  103015. clone(): MorphTargetManager;
  103016. /**
  103017. * Serializes the current manager into a Serialization object
  103018. * @returns the serialized object
  103019. */
  103020. serialize(): any;
  103021. private _syncActiveTargets;
  103022. /**
  103023. * Syncrhonize the targets with all the meshes using this morph target manager
  103024. */
  103025. synchronize(): void;
  103026. /**
  103027. * Creates a new MorphTargetManager from serialized data
  103028. * @param serializationObject defines the serialized data
  103029. * @param scene defines the hosting scene
  103030. * @returns the new MorphTargetManager
  103031. */
  103032. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  103033. }
  103034. }
  103035. declare module BABYLON {
  103036. /**
  103037. * Class used to represent a specific level of detail of a mesh
  103038. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  103039. */
  103040. export class MeshLODLevel {
  103041. /** Defines the distance where this level should start being displayed */
  103042. distance: number;
  103043. /** Defines the mesh to use to render this level */
  103044. mesh: Nullable<Mesh>;
  103045. /**
  103046. * Creates a new LOD level
  103047. * @param distance defines the distance where this level should star being displayed
  103048. * @param mesh defines the mesh to use to render this level
  103049. */
  103050. constructor(
  103051. /** Defines the distance where this level should start being displayed */
  103052. distance: number,
  103053. /** Defines the mesh to use to render this level */
  103054. mesh: Nullable<Mesh>);
  103055. }
  103056. }
  103057. declare module BABYLON {
  103058. /**
  103059. * Mesh representing the gorund
  103060. */
  103061. export class GroundMesh extends Mesh {
  103062. /** If octree should be generated */
  103063. generateOctree: boolean;
  103064. private _heightQuads;
  103065. /** @hidden */
  103066. _subdivisionsX: number;
  103067. /** @hidden */
  103068. _subdivisionsY: number;
  103069. /** @hidden */
  103070. _width: number;
  103071. /** @hidden */
  103072. _height: number;
  103073. /** @hidden */
  103074. _minX: number;
  103075. /** @hidden */
  103076. _maxX: number;
  103077. /** @hidden */
  103078. _minZ: number;
  103079. /** @hidden */
  103080. _maxZ: number;
  103081. constructor(name: string, scene: Scene);
  103082. /**
  103083. * "GroundMesh"
  103084. * @returns "GroundMesh"
  103085. */
  103086. getClassName(): string;
  103087. /**
  103088. * The minimum of x and y subdivisions
  103089. */
  103090. get subdivisions(): number;
  103091. /**
  103092. * X subdivisions
  103093. */
  103094. get subdivisionsX(): number;
  103095. /**
  103096. * Y subdivisions
  103097. */
  103098. get subdivisionsY(): number;
  103099. /**
  103100. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  103101. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103102. * @param chunksCount the number of subdivisions for x and y
  103103. * @param octreeBlocksSize (Default: 32)
  103104. */
  103105. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  103106. /**
  103107. * Returns a height (y) value in the Worl system :
  103108. * the ground altitude at the coordinates (x, z) expressed in the World system.
  103109. * @param x x coordinate
  103110. * @param z z coordinate
  103111. * @returns the ground y position if (x, z) are outside the ground surface.
  103112. */
  103113. getHeightAtCoordinates(x: number, z: number): number;
  103114. /**
  103115. * Returns a normalized vector (Vector3) orthogonal to the ground
  103116. * at the ground coordinates (x, z) expressed in the World system.
  103117. * @param x x coordinate
  103118. * @param z z coordinate
  103119. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  103120. */
  103121. getNormalAtCoordinates(x: number, z: number): Vector3;
  103122. /**
  103123. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  103124. * at the ground coordinates (x, z) expressed in the World system.
  103125. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  103126. * @param x x coordinate
  103127. * @param z z coordinate
  103128. * @param ref vector to store the result
  103129. * @returns the GroundMesh.
  103130. */
  103131. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  103132. /**
  103133. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  103134. * if the ground has been updated.
  103135. * This can be used in the render loop.
  103136. * @returns the GroundMesh.
  103137. */
  103138. updateCoordinateHeights(): GroundMesh;
  103139. private _getFacetAt;
  103140. private _initHeightQuads;
  103141. private _computeHeightQuads;
  103142. /**
  103143. * Serializes this ground mesh
  103144. * @param serializationObject object to write serialization to
  103145. */
  103146. serialize(serializationObject: any): void;
  103147. /**
  103148. * Parses a serialized ground mesh
  103149. * @param parsedMesh the serialized mesh
  103150. * @param scene the scene to create the ground mesh in
  103151. * @returns the created ground mesh
  103152. */
  103153. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  103154. }
  103155. }
  103156. declare module BABYLON {
  103157. /**
  103158. * Interface for Physics-Joint data
  103159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103160. */
  103161. export interface PhysicsJointData {
  103162. /**
  103163. * The main pivot of the joint
  103164. */
  103165. mainPivot?: Vector3;
  103166. /**
  103167. * The connected pivot of the joint
  103168. */
  103169. connectedPivot?: Vector3;
  103170. /**
  103171. * The main axis of the joint
  103172. */
  103173. mainAxis?: Vector3;
  103174. /**
  103175. * The connected axis of the joint
  103176. */
  103177. connectedAxis?: Vector3;
  103178. /**
  103179. * The collision of the joint
  103180. */
  103181. collision?: boolean;
  103182. /**
  103183. * Native Oimo/Cannon/Energy data
  103184. */
  103185. nativeParams?: any;
  103186. }
  103187. /**
  103188. * This is a holder class for the physics joint created by the physics plugin
  103189. * It holds a set of functions to control the underlying joint
  103190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103191. */
  103192. export class PhysicsJoint {
  103193. /**
  103194. * The type of the physics joint
  103195. */
  103196. type: number;
  103197. /**
  103198. * The data for the physics joint
  103199. */
  103200. jointData: PhysicsJointData;
  103201. private _physicsJoint;
  103202. protected _physicsPlugin: IPhysicsEnginePlugin;
  103203. /**
  103204. * Initializes the physics joint
  103205. * @param type The type of the physics joint
  103206. * @param jointData The data for the physics joint
  103207. */
  103208. constructor(
  103209. /**
  103210. * The type of the physics joint
  103211. */
  103212. type: number,
  103213. /**
  103214. * The data for the physics joint
  103215. */
  103216. jointData: PhysicsJointData);
  103217. /**
  103218. * Gets the physics joint
  103219. */
  103220. get physicsJoint(): any;
  103221. /**
  103222. * Sets the physics joint
  103223. */
  103224. set physicsJoint(newJoint: any);
  103225. /**
  103226. * Sets the physics plugin
  103227. */
  103228. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  103229. /**
  103230. * Execute a function that is physics-plugin specific.
  103231. * @param {Function} func the function that will be executed.
  103232. * It accepts two parameters: the physics world and the physics joint
  103233. */
  103234. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  103235. /**
  103236. * Distance-Joint type
  103237. */
  103238. static DistanceJoint: number;
  103239. /**
  103240. * Hinge-Joint type
  103241. */
  103242. static HingeJoint: number;
  103243. /**
  103244. * Ball-and-Socket joint type
  103245. */
  103246. static BallAndSocketJoint: number;
  103247. /**
  103248. * Wheel-Joint type
  103249. */
  103250. static WheelJoint: number;
  103251. /**
  103252. * Slider-Joint type
  103253. */
  103254. static SliderJoint: number;
  103255. /**
  103256. * Prismatic-Joint type
  103257. */
  103258. static PrismaticJoint: number;
  103259. /**
  103260. * Universal-Joint type
  103261. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  103262. */
  103263. static UniversalJoint: number;
  103264. /**
  103265. * Hinge-Joint 2 type
  103266. */
  103267. static Hinge2Joint: number;
  103268. /**
  103269. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  103270. */
  103271. static PointToPointJoint: number;
  103272. /**
  103273. * Spring-Joint type
  103274. */
  103275. static SpringJoint: number;
  103276. /**
  103277. * Lock-Joint type
  103278. */
  103279. static LockJoint: number;
  103280. }
  103281. /**
  103282. * A class representing a physics distance joint
  103283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103284. */
  103285. export class DistanceJoint extends PhysicsJoint {
  103286. /**
  103287. *
  103288. * @param jointData The data for the Distance-Joint
  103289. */
  103290. constructor(jointData: DistanceJointData);
  103291. /**
  103292. * Update the predefined distance.
  103293. * @param maxDistance The maximum preferred distance
  103294. * @param minDistance The minimum preferred distance
  103295. */
  103296. updateDistance(maxDistance: number, minDistance?: number): void;
  103297. }
  103298. /**
  103299. * Represents a Motor-Enabled Joint
  103300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103301. */
  103302. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  103303. /**
  103304. * Initializes the Motor-Enabled Joint
  103305. * @param type The type of the joint
  103306. * @param jointData The physica joint data for the joint
  103307. */
  103308. constructor(type: number, jointData: PhysicsJointData);
  103309. /**
  103310. * Set the motor values.
  103311. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103312. * @param force the force to apply
  103313. * @param maxForce max force for this motor.
  103314. */
  103315. setMotor(force?: number, maxForce?: number): void;
  103316. /**
  103317. * Set the motor's limits.
  103318. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103319. * @param upperLimit The upper limit of the motor
  103320. * @param lowerLimit The lower limit of the motor
  103321. */
  103322. setLimit(upperLimit: number, lowerLimit?: number): void;
  103323. }
  103324. /**
  103325. * This class represents a single physics Hinge-Joint
  103326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103327. */
  103328. export class HingeJoint extends MotorEnabledJoint {
  103329. /**
  103330. * Initializes the Hinge-Joint
  103331. * @param jointData The joint data for the Hinge-Joint
  103332. */
  103333. constructor(jointData: PhysicsJointData);
  103334. /**
  103335. * Set the motor values.
  103336. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103337. * @param {number} force the force to apply
  103338. * @param {number} maxForce max force for this motor.
  103339. */
  103340. setMotor(force?: number, maxForce?: number): void;
  103341. /**
  103342. * Set the motor's limits.
  103343. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103344. * @param upperLimit The upper limit of the motor
  103345. * @param lowerLimit The lower limit of the motor
  103346. */
  103347. setLimit(upperLimit: number, lowerLimit?: number): void;
  103348. }
  103349. /**
  103350. * This class represents a dual hinge physics joint (same as wheel joint)
  103351. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103352. */
  103353. export class Hinge2Joint extends MotorEnabledJoint {
  103354. /**
  103355. * Initializes the Hinge2-Joint
  103356. * @param jointData The joint data for the Hinge2-Joint
  103357. */
  103358. constructor(jointData: PhysicsJointData);
  103359. /**
  103360. * Set the motor values.
  103361. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103362. * @param {number} targetSpeed the speed the motor is to reach
  103363. * @param {number} maxForce max force for this motor.
  103364. * @param {motorIndex} the motor's index, 0 or 1.
  103365. */
  103366. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  103367. /**
  103368. * Set the motor limits.
  103369. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103370. * @param {number} upperLimit the upper limit
  103371. * @param {number} lowerLimit lower limit
  103372. * @param {motorIndex} the motor's index, 0 or 1.
  103373. */
  103374. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103375. }
  103376. /**
  103377. * Interface for a motor enabled joint
  103378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103379. */
  103380. export interface IMotorEnabledJoint {
  103381. /**
  103382. * Physics joint
  103383. */
  103384. physicsJoint: any;
  103385. /**
  103386. * Sets the motor of the motor-enabled joint
  103387. * @param force The force of the motor
  103388. * @param maxForce The maximum force of the motor
  103389. * @param motorIndex The index of the motor
  103390. */
  103391. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  103392. /**
  103393. * Sets the limit of the motor
  103394. * @param upperLimit The upper limit of the motor
  103395. * @param lowerLimit The lower limit of the motor
  103396. * @param motorIndex The index of the motor
  103397. */
  103398. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103399. }
  103400. /**
  103401. * Joint data for a Distance-Joint
  103402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103403. */
  103404. export interface DistanceJointData extends PhysicsJointData {
  103405. /**
  103406. * Max distance the 2 joint objects can be apart
  103407. */
  103408. maxDistance: number;
  103409. }
  103410. /**
  103411. * Joint data from a spring joint
  103412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103413. */
  103414. export interface SpringJointData extends PhysicsJointData {
  103415. /**
  103416. * Length of the spring
  103417. */
  103418. length: number;
  103419. /**
  103420. * Stiffness of the spring
  103421. */
  103422. stiffness: number;
  103423. /**
  103424. * Damping of the spring
  103425. */
  103426. damping: number;
  103427. /** this callback will be called when applying the force to the impostors. */
  103428. forceApplicationCallback: () => void;
  103429. }
  103430. }
  103431. declare module BABYLON {
  103432. /**
  103433. * Holds the data for the raycast result
  103434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103435. */
  103436. export class PhysicsRaycastResult {
  103437. private _hasHit;
  103438. private _hitDistance;
  103439. private _hitNormalWorld;
  103440. private _hitPointWorld;
  103441. private _rayFromWorld;
  103442. private _rayToWorld;
  103443. /**
  103444. * Gets if there was a hit
  103445. */
  103446. get hasHit(): boolean;
  103447. /**
  103448. * Gets the distance from the hit
  103449. */
  103450. get hitDistance(): number;
  103451. /**
  103452. * Gets the hit normal/direction in the world
  103453. */
  103454. get hitNormalWorld(): Vector3;
  103455. /**
  103456. * Gets the hit point in the world
  103457. */
  103458. get hitPointWorld(): Vector3;
  103459. /**
  103460. * Gets the ray "start point" of the ray in the world
  103461. */
  103462. get rayFromWorld(): Vector3;
  103463. /**
  103464. * Gets the ray "end point" of the ray in the world
  103465. */
  103466. get rayToWorld(): Vector3;
  103467. /**
  103468. * Sets the hit data (normal & point in world space)
  103469. * @param hitNormalWorld defines the normal in world space
  103470. * @param hitPointWorld defines the point in world space
  103471. */
  103472. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  103473. /**
  103474. * Sets the distance from the start point to the hit point
  103475. * @param distance
  103476. */
  103477. setHitDistance(distance: number): void;
  103478. /**
  103479. * Calculates the distance manually
  103480. */
  103481. calculateHitDistance(): void;
  103482. /**
  103483. * Resets all the values to default
  103484. * @param from The from point on world space
  103485. * @param to The to point on world space
  103486. */
  103487. reset(from?: Vector3, to?: Vector3): void;
  103488. }
  103489. /**
  103490. * Interface for the size containing width and height
  103491. */
  103492. interface IXYZ {
  103493. /**
  103494. * X
  103495. */
  103496. x: number;
  103497. /**
  103498. * Y
  103499. */
  103500. y: number;
  103501. /**
  103502. * Z
  103503. */
  103504. z: number;
  103505. }
  103506. }
  103507. declare module BABYLON {
  103508. /**
  103509. * Interface used to describe a physics joint
  103510. */
  103511. export interface PhysicsImpostorJoint {
  103512. /** Defines the main impostor to which the joint is linked */
  103513. mainImpostor: PhysicsImpostor;
  103514. /** Defines the impostor that is connected to the main impostor using this joint */
  103515. connectedImpostor: PhysicsImpostor;
  103516. /** Defines the joint itself */
  103517. joint: PhysicsJoint;
  103518. }
  103519. /** @hidden */
  103520. export interface IPhysicsEnginePlugin {
  103521. world: any;
  103522. name: string;
  103523. setGravity(gravity: Vector3): void;
  103524. setTimeStep(timeStep: number): void;
  103525. getTimeStep(): number;
  103526. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103527. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103528. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103529. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103530. removePhysicsBody(impostor: PhysicsImpostor): void;
  103531. generateJoint(joint: PhysicsImpostorJoint): void;
  103532. removeJoint(joint: PhysicsImpostorJoint): void;
  103533. isSupported(): boolean;
  103534. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103535. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103536. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103537. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103538. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103539. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103540. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103541. getBodyMass(impostor: PhysicsImpostor): number;
  103542. getBodyFriction(impostor: PhysicsImpostor): number;
  103543. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103544. getBodyRestitution(impostor: PhysicsImpostor): number;
  103545. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103546. getBodyPressure?(impostor: PhysicsImpostor): number;
  103547. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  103548. getBodyStiffness?(impostor: PhysicsImpostor): number;
  103549. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  103550. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  103551. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  103552. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  103553. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  103554. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103555. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103556. sleepBody(impostor: PhysicsImpostor): void;
  103557. wakeUpBody(impostor: PhysicsImpostor): void;
  103558. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103559. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103560. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  103561. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103562. getRadius(impostor: PhysicsImpostor): number;
  103563. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103564. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103565. dispose(): void;
  103566. }
  103567. /**
  103568. * Interface used to define a physics engine
  103569. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103570. */
  103571. export interface IPhysicsEngine {
  103572. /**
  103573. * Gets the gravity vector used by the simulation
  103574. */
  103575. gravity: Vector3;
  103576. /**
  103577. * Sets the gravity vector used by the simulation
  103578. * @param gravity defines the gravity vector to use
  103579. */
  103580. setGravity(gravity: Vector3): void;
  103581. /**
  103582. * Set the time step of the physics engine.
  103583. * Default is 1/60.
  103584. * To slow it down, enter 1/600 for example.
  103585. * To speed it up, 1/30
  103586. * @param newTimeStep the new timestep to apply to this world.
  103587. */
  103588. setTimeStep(newTimeStep: number): void;
  103589. /**
  103590. * Get the time step of the physics engine.
  103591. * @returns the current time step
  103592. */
  103593. getTimeStep(): number;
  103594. /**
  103595. * Set the sub time step of the physics engine.
  103596. * Default is 0 meaning there is no sub steps
  103597. * To increase physics resolution precision, set a small value (like 1 ms)
  103598. * @param subTimeStep defines the new sub timestep used for physics resolution.
  103599. */
  103600. setSubTimeStep(subTimeStep: number): void;
  103601. /**
  103602. * Get the sub time step of the physics engine.
  103603. * @returns the current sub time step
  103604. */
  103605. getSubTimeStep(): number;
  103606. /**
  103607. * Release all resources
  103608. */
  103609. dispose(): void;
  103610. /**
  103611. * Gets the name of the current physics plugin
  103612. * @returns the name of the plugin
  103613. */
  103614. getPhysicsPluginName(): string;
  103615. /**
  103616. * Adding a new impostor for the impostor tracking.
  103617. * This will be done by the impostor itself.
  103618. * @param impostor the impostor to add
  103619. */
  103620. addImpostor(impostor: PhysicsImpostor): void;
  103621. /**
  103622. * Remove an impostor from the engine.
  103623. * This impostor and its mesh will not longer be updated by the physics engine.
  103624. * @param impostor the impostor to remove
  103625. */
  103626. removeImpostor(impostor: PhysicsImpostor): void;
  103627. /**
  103628. * Add a joint to the physics engine
  103629. * @param mainImpostor defines the main impostor to which the joint is added.
  103630. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103631. * @param joint defines the joint that will connect both impostors.
  103632. */
  103633. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103634. /**
  103635. * Removes a joint from the simulation
  103636. * @param mainImpostor defines the impostor used with the joint
  103637. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103638. * @param joint defines the joint to remove
  103639. */
  103640. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103641. /**
  103642. * Gets the current plugin used to run the simulation
  103643. * @returns current plugin
  103644. */
  103645. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103646. /**
  103647. * Gets the list of physic impostors
  103648. * @returns an array of PhysicsImpostor
  103649. */
  103650. getImpostors(): Array<PhysicsImpostor>;
  103651. /**
  103652. * Gets the impostor for a physics enabled object
  103653. * @param object defines the object impersonated by the impostor
  103654. * @returns the PhysicsImpostor or null if not found
  103655. */
  103656. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103657. /**
  103658. * Gets the impostor for a physics body object
  103659. * @param body defines physics body used by the impostor
  103660. * @returns the PhysicsImpostor or null if not found
  103661. */
  103662. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103663. /**
  103664. * Does a raycast in the physics world
  103665. * @param from when should the ray start?
  103666. * @param to when should the ray end?
  103667. * @returns PhysicsRaycastResult
  103668. */
  103669. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103670. /**
  103671. * Called by the scene. No need to call it.
  103672. * @param delta defines the timespam between frames
  103673. */
  103674. _step(delta: number): void;
  103675. }
  103676. }
  103677. declare module BABYLON {
  103678. /**
  103679. * The interface for the physics imposter parameters
  103680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103681. */
  103682. export interface PhysicsImpostorParameters {
  103683. /**
  103684. * The mass of the physics imposter
  103685. */
  103686. mass: number;
  103687. /**
  103688. * The friction of the physics imposter
  103689. */
  103690. friction?: number;
  103691. /**
  103692. * The coefficient of restitution of the physics imposter
  103693. */
  103694. restitution?: number;
  103695. /**
  103696. * The native options of the physics imposter
  103697. */
  103698. nativeOptions?: any;
  103699. /**
  103700. * Specifies if the parent should be ignored
  103701. */
  103702. ignoreParent?: boolean;
  103703. /**
  103704. * Specifies if bi-directional transformations should be disabled
  103705. */
  103706. disableBidirectionalTransformation?: boolean;
  103707. /**
  103708. * The pressure inside the physics imposter, soft object only
  103709. */
  103710. pressure?: number;
  103711. /**
  103712. * The stiffness the physics imposter, soft object only
  103713. */
  103714. stiffness?: number;
  103715. /**
  103716. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  103717. */
  103718. velocityIterations?: number;
  103719. /**
  103720. * The number of iterations used in maintaining consistent vertex positions, soft object only
  103721. */
  103722. positionIterations?: number;
  103723. /**
  103724. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  103725. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  103726. * Add to fix multiple points
  103727. */
  103728. fixedPoints?: number;
  103729. /**
  103730. * The collision margin around a soft object
  103731. */
  103732. margin?: number;
  103733. /**
  103734. * The collision margin around a soft object
  103735. */
  103736. damping?: number;
  103737. /**
  103738. * The path for a rope based on an extrusion
  103739. */
  103740. path?: any;
  103741. /**
  103742. * The shape of an extrusion used for a rope based on an extrusion
  103743. */
  103744. shape?: any;
  103745. }
  103746. /**
  103747. * Interface for a physics-enabled object
  103748. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103749. */
  103750. export interface IPhysicsEnabledObject {
  103751. /**
  103752. * The position of the physics-enabled object
  103753. */
  103754. position: Vector3;
  103755. /**
  103756. * The rotation of the physics-enabled object
  103757. */
  103758. rotationQuaternion: Nullable<Quaternion>;
  103759. /**
  103760. * The scale of the physics-enabled object
  103761. */
  103762. scaling: Vector3;
  103763. /**
  103764. * The rotation of the physics-enabled object
  103765. */
  103766. rotation?: Vector3;
  103767. /**
  103768. * The parent of the physics-enabled object
  103769. */
  103770. parent?: any;
  103771. /**
  103772. * The bounding info of the physics-enabled object
  103773. * @returns The bounding info of the physics-enabled object
  103774. */
  103775. getBoundingInfo(): BoundingInfo;
  103776. /**
  103777. * Computes the world matrix
  103778. * @param force Specifies if the world matrix should be computed by force
  103779. * @returns A world matrix
  103780. */
  103781. computeWorldMatrix(force: boolean): Matrix;
  103782. /**
  103783. * Gets the world matrix
  103784. * @returns A world matrix
  103785. */
  103786. getWorldMatrix?(): Matrix;
  103787. /**
  103788. * Gets the child meshes
  103789. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  103790. * @returns An array of abstract meshes
  103791. */
  103792. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  103793. /**
  103794. * Gets the vertex data
  103795. * @param kind The type of vertex data
  103796. * @returns A nullable array of numbers, or a float32 array
  103797. */
  103798. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  103799. /**
  103800. * Gets the indices from the mesh
  103801. * @returns A nullable array of index arrays
  103802. */
  103803. getIndices?(): Nullable<IndicesArray>;
  103804. /**
  103805. * Gets the scene from the mesh
  103806. * @returns the indices array or null
  103807. */
  103808. getScene?(): Scene;
  103809. /**
  103810. * Gets the absolute position from the mesh
  103811. * @returns the absolute position
  103812. */
  103813. getAbsolutePosition(): Vector3;
  103814. /**
  103815. * Gets the absolute pivot point from the mesh
  103816. * @returns the absolute pivot point
  103817. */
  103818. getAbsolutePivotPoint(): Vector3;
  103819. /**
  103820. * Rotates the mesh
  103821. * @param axis The axis of rotation
  103822. * @param amount The amount of rotation
  103823. * @param space The space of the rotation
  103824. * @returns The rotation transform node
  103825. */
  103826. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  103827. /**
  103828. * Translates the mesh
  103829. * @param axis The axis of translation
  103830. * @param distance The distance of translation
  103831. * @param space The space of the translation
  103832. * @returns The transform node
  103833. */
  103834. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  103835. /**
  103836. * Sets the absolute position of the mesh
  103837. * @param absolutePosition The absolute position of the mesh
  103838. * @returns The transform node
  103839. */
  103840. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  103841. /**
  103842. * Gets the class name of the mesh
  103843. * @returns The class name
  103844. */
  103845. getClassName(): string;
  103846. }
  103847. /**
  103848. * Represents a physics imposter
  103849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103850. */
  103851. export class PhysicsImpostor {
  103852. /**
  103853. * The physics-enabled object used as the physics imposter
  103854. */
  103855. object: IPhysicsEnabledObject;
  103856. /**
  103857. * The type of the physics imposter
  103858. */
  103859. type: number;
  103860. private _options;
  103861. private _scene?;
  103862. /**
  103863. * The default object size of the imposter
  103864. */
  103865. static DEFAULT_OBJECT_SIZE: Vector3;
  103866. /**
  103867. * The identity quaternion of the imposter
  103868. */
  103869. static IDENTITY_QUATERNION: Quaternion;
  103870. /** @hidden */
  103871. _pluginData: any;
  103872. private _physicsEngine;
  103873. private _physicsBody;
  103874. private _bodyUpdateRequired;
  103875. private _onBeforePhysicsStepCallbacks;
  103876. private _onAfterPhysicsStepCallbacks;
  103877. /** @hidden */
  103878. _onPhysicsCollideCallbacks: Array<{
  103879. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  103880. otherImpostors: Array<PhysicsImpostor>;
  103881. }>;
  103882. private _deltaPosition;
  103883. private _deltaRotation;
  103884. private _deltaRotationConjugated;
  103885. /** @hidden */
  103886. _isFromLine: boolean;
  103887. private _parent;
  103888. private _isDisposed;
  103889. private static _tmpVecs;
  103890. private static _tmpQuat;
  103891. /**
  103892. * Specifies if the physics imposter is disposed
  103893. */
  103894. get isDisposed(): boolean;
  103895. /**
  103896. * Gets the mass of the physics imposter
  103897. */
  103898. get mass(): number;
  103899. set mass(value: number);
  103900. /**
  103901. * Gets the coefficient of friction
  103902. */
  103903. get friction(): number;
  103904. /**
  103905. * Sets the coefficient of friction
  103906. */
  103907. set friction(value: number);
  103908. /**
  103909. * Gets the coefficient of restitution
  103910. */
  103911. get restitution(): number;
  103912. /**
  103913. * Sets the coefficient of restitution
  103914. */
  103915. set restitution(value: number);
  103916. /**
  103917. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  103918. */
  103919. get pressure(): number;
  103920. /**
  103921. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  103922. */
  103923. set pressure(value: number);
  103924. /**
  103925. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  103926. */
  103927. get stiffness(): number;
  103928. /**
  103929. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  103930. */
  103931. set stiffness(value: number);
  103932. /**
  103933. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  103934. */
  103935. get velocityIterations(): number;
  103936. /**
  103937. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  103938. */
  103939. set velocityIterations(value: number);
  103940. /**
  103941. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  103942. */
  103943. get positionIterations(): number;
  103944. /**
  103945. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  103946. */
  103947. set positionIterations(value: number);
  103948. /**
  103949. * The unique id of the physics imposter
  103950. * set by the physics engine when adding this impostor to the array
  103951. */
  103952. uniqueId: number;
  103953. /**
  103954. * @hidden
  103955. */
  103956. soft: boolean;
  103957. /**
  103958. * @hidden
  103959. */
  103960. segments: number;
  103961. private _joints;
  103962. /**
  103963. * Initializes the physics imposter
  103964. * @param object The physics-enabled object used as the physics imposter
  103965. * @param type The type of the physics imposter
  103966. * @param _options The options for the physics imposter
  103967. * @param _scene The Babylon scene
  103968. */
  103969. constructor(
  103970. /**
  103971. * The physics-enabled object used as the physics imposter
  103972. */
  103973. object: IPhysicsEnabledObject,
  103974. /**
  103975. * The type of the physics imposter
  103976. */
  103977. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  103978. /**
  103979. * This function will completly initialize this impostor.
  103980. * It will create a new body - but only if this mesh has no parent.
  103981. * If it has, this impostor will not be used other than to define the impostor
  103982. * of the child mesh.
  103983. * @hidden
  103984. */
  103985. _init(): void;
  103986. private _getPhysicsParent;
  103987. /**
  103988. * Should a new body be generated.
  103989. * @returns boolean specifying if body initialization is required
  103990. */
  103991. isBodyInitRequired(): boolean;
  103992. /**
  103993. * Sets the updated scaling
  103994. * @param updated Specifies if the scaling is updated
  103995. */
  103996. setScalingUpdated(): void;
  103997. /**
  103998. * Force a regeneration of this or the parent's impostor's body.
  103999. * Use under cautious - This will remove all joints already implemented.
  104000. */
  104001. forceUpdate(): void;
  104002. /**
  104003. * Gets the body that holds this impostor. Either its own, or its parent.
  104004. */
  104005. get physicsBody(): any;
  104006. /**
  104007. * Get the parent of the physics imposter
  104008. * @returns Physics imposter or null
  104009. */
  104010. get parent(): Nullable<PhysicsImpostor>;
  104011. /**
  104012. * Sets the parent of the physics imposter
  104013. */
  104014. set parent(value: Nullable<PhysicsImpostor>);
  104015. /**
  104016. * Set the physics body. Used mainly by the physics engine/plugin
  104017. */
  104018. set physicsBody(physicsBody: any);
  104019. /**
  104020. * Resets the update flags
  104021. */
  104022. resetUpdateFlags(): void;
  104023. /**
  104024. * Gets the object extend size
  104025. * @returns the object extend size
  104026. */
  104027. getObjectExtendSize(): Vector3;
  104028. /**
  104029. * Gets the object center
  104030. * @returns The object center
  104031. */
  104032. getObjectCenter(): Vector3;
  104033. /**
  104034. * Get a specific parameter from the options parameters
  104035. * @param paramName The object parameter name
  104036. * @returns The object parameter
  104037. */
  104038. getParam(paramName: string): any;
  104039. /**
  104040. * Sets a specific parameter in the options given to the physics plugin
  104041. * @param paramName The parameter name
  104042. * @param value The value of the parameter
  104043. */
  104044. setParam(paramName: string, value: number): void;
  104045. /**
  104046. * Specifically change the body's mass option. Won't recreate the physics body object
  104047. * @param mass The mass of the physics imposter
  104048. */
  104049. setMass(mass: number): void;
  104050. /**
  104051. * Gets the linear velocity
  104052. * @returns linear velocity or null
  104053. */
  104054. getLinearVelocity(): Nullable<Vector3>;
  104055. /**
  104056. * Sets the linear velocity
  104057. * @param velocity linear velocity or null
  104058. */
  104059. setLinearVelocity(velocity: Nullable<Vector3>): void;
  104060. /**
  104061. * Gets the angular velocity
  104062. * @returns angular velocity or null
  104063. */
  104064. getAngularVelocity(): Nullable<Vector3>;
  104065. /**
  104066. * Sets the angular velocity
  104067. * @param velocity The velocity or null
  104068. */
  104069. setAngularVelocity(velocity: Nullable<Vector3>): void;
  104070. /**
  104071. * Execute a function with the physics plugin native code
  104072. * Provide a function the will have two variables - the world object and the physics body object
  104073. * @param func The function to execute with the physics plugin native code
  104074. */
  104075. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  104076. /**
  104077. * Register a function that will be executed before the physics world is stepping forward
  104078. * @param func The function to execute before the physics world is stepped forward
  104079. */
  104080. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104081. /**
  104082. * Unregister a function that will be executed before the physics world is stepping forward
  104083. * @param func The function to execute before the physics world is stepped forward
  104084. */
  104085. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104086. /**
  104087. * Register a function that will be executed after the physics step
  104088. * @param func The function to execute after physics step
  104089. */
  104090. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104091. /**
  104092. * Unregisters a function that will be executed after the physics step
  104093. * @param func The function to execute after physics step
  104094. */
  104095. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104096. /**
  104097. * register a function that will be executed when this impostor collides against a different body
  104098. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  104099. * @param func Callback that is executed on collision
  104100. */
  104101. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  104102. /**
  104103. * Unregisters the physics imposter on contact
  104104. * @param collideAgainst The physics object to collide against
  104105. * @param func Callback to execute on collision
  104106. */
  104107. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  104108. private _tmpQuat;
  104109. private _tmpQuat2;
  104110. /**
  104111. * Get the parent rotation
  104112. * @returns The parent rotation
  104113. */
  104114. getParentsRotation(): Quaternion;
  104115. /**
  104116. * this function is executed by the physics engine.
  104117. */
  104118. beforeStep: () => void;
  104119. /**
  104120. * this function is executed by the physics engine
  104121. */
  104122. afterStep: () => void;
  104123. /**
  104124. * Legacy collision detection event support
  104125. */
  104126. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  104127. /**
  104128. * event and body object due to cannon's event-based architecture.
  104129. */
  104130. onCollide: (e: {
  104131. body: any;
  104132. }) => void;
  104133. /**
  104134. * Apply a force
  104135. * @param force The force to apply
  104136. * @param contactPoint The contact point for the force
  104137. * @returns The physics imposter
  104138. */
  104139. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104140. /**
  104141. * Apply an impulse
  104142. * @param force The impulse force
  104143. * @param contactPoint The contact point for the impulse force
  104144. * @returns The physics imposter
  104145. */
  104146. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104147. /**
  104148. * A help function to create a joint
  104149. * @param otherImpostor A physics imposter used to create a joint
  104150. * @param jointType The type of joint
  104151. * @param jointData The data for the joint
  104152. * @returns The physics imposter
  104153. */
  104154. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  104155. /**
  104156. * Add a joint to this impostor with a different impostor
  104157. * @param otherImpostor A physics imposter used to add a joint
  104158. * @param joint The joint to add
  104159. * @returns The physics imposter
  104160. */
  104161. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  104162. /**
  104163. * Add an anchor to a cloth impostor
  104164. * @param otherImpostor rigid impostor to anchor to
  104165. * @param width ratio across width from 0 to 1
  104166. * @param height ratio up height from 0 to 1
  104167. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  104168. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  104169. * @returns impostor the soft imposter
  104170. */
  104171. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104172. /**
  104173. * Add a hook to a rope impostor
  104174. * @param otherImpostor rigid impostor to anchor to
  104175. * @param length ratio across rope from 0 to 1
  104176. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  104177. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  104178. * @returns impostor the rope imposter
  104179. */
  104180. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104181. /**
  104182. * Will keep this body still, in a sleep mode.
  104183. * @returns the physics imposter
  104184. */
  104185. sleep(): PhysicsImpostor;
  104186. /**
  104187. * Wake the body up.
  104188. * @returns The physics imposter
  104189. */
  104190. wakeUp(): PhysicsImpostor;
  104191. /**
  104192. * Clones the physics imposter
  104193. * @param newObject The physics imposter clones to this physics-enabled object
  104194. * @returns A nullable physics imposter
  104195. */
  104196. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104197. /**
  104198. * Disposes the physics imposter
  104199. */
  104200. dispose(): void;
  104201. /**
  104202. * Sets the delta position
  104203. * @param position The delta position amount
  104204. */
  104205. setDeltaPosition(position: Vector3): void;
  104206. /**
  104207. * Sets the delta rotation
  104208. * @param rotation The delta rotation amount
  104209. */
  104210. setDeltaRotation(rotation: Quaternion): void;
  104211. /**
  104212. * Gets the box size of the physics imposter and stores the result in the input parameter
  104213. * @param result Stores the box size
  104214. * @returns The physics imposter
  104215. */
  104216. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  104217. /**
  104218. * Gets the radius of the physics imposter
  104219. * @returns Radius of the physics imposter
  104220. */
  104221. getRadius(): number;
  104222. /**
  104223. * Sync a bone with this impostor
  104224. * @param bone The bone to sync to the impostor.
  104225. * @param boneMesh The mesh that the bone is influencing.
  104226. * @param jointPivot The pivot of the joint / bone in local space.
  104227. * @param distToJoint Optional distance from the impostor to the joint.
  104228. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104229. */
  104230. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  104231. /**
  104232. * Sync impostor to a bone
  104233. * @param bone The bone that the impostor will be synced to.
  104234. * @param boneMesh The mesh that the bone is influencing.
  104235. * @param jointPivot The pivot of the joint / bone in local space.
  104236. * @param distToJoint Optional distance from the impostor to the joint.
  104237. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104238. * @param boneAxis Optional vector3 axis the bone is aligned with
  104239. */
  104240. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  104241. /**
  104242. * No-Imposter type
  104243. */
  104244. static NoImpostor: number;
  104245. /**
  104246. * Sphere-Imposter type
  104247. */
  104248. static SphereImpostor: number;
  104249. /**
  104250. * Box-Imposter type
  104251. */
  104252. static BoxImpostor: number;
  104253. /**
  104254. * Plane-Imposter type
  104255. */
  104256. static PlaneImpostor: number;
  104257. /**
  104258. * Mesh-imposter type
  104259. */
  104260. static MeshImpostor: number;
  104261. /**
  104262. * Capsule-Impostor type (Ammo.js plugin only)
  104263. */
  104264. static CapsuleImpostor: number;
  104265. /**
  104266. * Cylinder-Imposter type
  104267. */
  104268. static CylinderImpostor: number;
  104269. /**
  104270. * Particle-Imposter type
  104271. */
  104272. static ParticleImpostor: number;
  104273. /**
  104274. * Heightmap-Imposter type
  104275. */
  104276. static HeightmapImpostor: number;
  104277. /**
  104278. * ConvexHull-Impostor type (Ammo.js plugin only)
  104279. */
  104280. static ConvexHullImpostor: number;
  104281. /**
  104282. * Custom-Imposter type (Ammo.js plugin only)
  104283. */
  104284. static CustomImpostor: number;
  104285. /**
  104286. * Rope-Imposter type
  104287. */
  104288. static RopeImpostor: number;
  104289. /**
  104290. * Cloth-Imposter type
  104291. */
  104292. static ClothImpostor: number;
  104293. /**
  104294. * Softbody-Imposter type
  104295. */
  104296. static SoftbodyImpostor: number;
  104297. }
  104298. }
  104299. declare module BABYLON {
  104300. /**
  104301. * @hidden
  104302. **/
  104303. export class _CreationDataStorage {
  104304. closePath?: boolean;
  104305. closeArray?: boolean;
  104306. idx: number[];
  104307. dashSize: number;
  104308. gapSize: number;
  104309. path3D: Path3D;
  104310. pathArray: Vector3[][];
  104311. arc: number;
  104312. radius: number;
  104313. cap: number;
  104314. tessellation: number;
  104315. }
  104316. /**
  104317. * @hidden
  104318. **/
  104319. class _InstanceDataStorage {
  104320. visibleInstances: any;
  104321. batchCache: _InstancesBatch;
  104322. instancesBufferSize: number;
  104323. instancesBuffer: Nullable<Buffer>;
  104324. instancesData: Float32Array;
  104325. overridenInstanceCount: number;
  104326. isFrozen: boolean;
  104327. previousBatch: Nullable<_InstancesBatch>;
  104328. hardwareInstancedRendering: boolean;
  104329. sideOrientation: number;
  104330. manualUpdate: boolean;
  104331. }
  104332. /**
  104333. * @hidden
  104334. **/
  104335. export class _InstancesBatch {
  104336. mustReturn: boolean;
  104337. visibleInstances: Nullable<InstancedMesh[]>[];
  104338. renderSelf: boolean[];
  104339. hardwareInstancedRendering: boolean[];
  104340. }
  104341. /**
  104342. * @hidden
  104343. **/
  104344. class _ThinInstanceDataStorage {
  104345. instancesCount: number;
  104346. matrixBuffer: Nullable<Buffer>;
  104347. matrixBufferSize: number;
  104348. matrixData: Nullable<Float32Array>;
  104349. boundingVectors: Array<Vector3>;
  104350. }
  104351. /**
  104352. * Class used to represent renderable models
  104353. */
  104354. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  104355. /**
  104356. * Mesh side orientation : usually the external or front surface
  104357. */
  104358. static readonly FRONTSIDE: number;
  104359. /**
  104360. * Mesh side orientation : usually the internal or back surface
  104361. */
  104362. static readonly BACKSIDE: number;
  104363. /**
  104364. * Mesh side orientation : both internal and external or front and back surfaces
  104365. */
  104366. static readonly DOUBLESIDE: number;
  104367. /**
  104368. * Mesh side orientation : by default, `FRONTSIDE`
  104369. */
  104370. static readonly DEFAULTSIDE: number;
  104371. /**
  104372. * Mesh cap setting : no cap
  104373. */
  104374. static readonly NO_CAP: number;
  104375. /**
  104376. * Mesh cap setting : one cap at the beginning of the mesh
  104377. */
  104378. static readonly CAP_START: number;
  104379. /**
  104380. * Mesh cap setting : one cap at the end of the mesh
  104381. */
  104382. static readonly CAP_END: number;
  104383. /**
  104384. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  104385. */
  104386. static readonly CAP_ALL: number;
  104387. /**
  104388. * Mesh pattern setting : no flip or rotate
  104389. */
  104390. static readonly NO_FLIP: number;
  104391. /**
  104392. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  104393. */
  104394. static readonly FLIP_TILE: number;
  104395. /**
  104396. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  104397. */
  104398. static readonly ROTATE_TILE: number;
  104399. /**
  104400. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  104401. */
  104402. static readonly FLIP_ROW: number;
  104403. /**
  104404. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  104405. */
  104406. static readonly ROTATE_ROW: number;
  104407. /**
  104408. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  104409. */
  104410. static readonly FLIP_N_ROTATE_TILE: number;
  104411. /**
  104412. * Mesh pattern setting : rotate pattern and rotate
  104413. */
  104414. static readonly FLIP_N_ROTATE_ROW: number;
  104415. /**
  104416. * Mesh tile positioning : part tiles same on left/right or top/bottom
  104417. */
  104418. static readonly CENTER: number;
  104419. /**
  104420. * Mesh tile positioning : part tiles on left
  104421. */
  104422. static readonly LEFT: number;
  104423. /**
  104424. * Mesh tile positioning : part tiles on right
  104425. */
  104426. static readonly RIGHT: number;
  104427. /**
  104428. * Mesh tile positioning : part tiles on top
  104429. */
  104430. static readonly TOP: number;
  104431. /**
  104432. * Mesh tile positioning : part tiles on bottom
  104433. */
  104434. static readonly BOTTOM: number;
  104435. /**
  104436. * Gets the default side orientation.
  104437. * @param orientation the orientation to value to attempt to get
  104438. * @returns the default orientation
  104439. * @hidden
  104440. */
  104441. static _GetDefaultSideOrientation(orientation?: number): number;
  104442. private _internalMeshDataInfo;
  104443. /**
  104444. * An event triggered before rendering the mesh
  104445. */
  104446. get onBeforeRenderObservable(): Observable<Mesh>;
  104447. /**
  104448. * An event triggered before binding the mesh
  104449. */
  104450. get onBeforeBindObservable(): Observable<Mesh>;
  104451. /**
  104452. * An event triggered after rendering the mesh
  104453. */
  104454. get onAfterRenderObservable(): Observable<Mesh>;
  104455. /**
  104456. * An event triggered before drawing the mesh
  104457. */
  104458. get onBeforeDrawObservable(): Observable<Mesh>;
  104459. private _onBeforeDrawObserver;
  104460. /**
  104461. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  104462. */
  104463. set onBeforeDraw(callback: () => void);
  104464. get hasInstances(): boolean;
  104465. get hasThinInstances(): boolean;
  104466. /**
  104467. * Gets the delay loading state of the mesh (when delay loading is turned on)
  104468. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  104469. */
  104470. delayLoadState: number;
  104471. /**
  104472. * Gets the list of instances created from this mesh
  104473. * it is not supposed to be modified manually.
  104474. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  104475. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  104476. */
  104477. instances: InstancedMesh[];
  104478. /**
  104479. * Gets the file containing delay loading data for this mesh
  104480. */
  104481. delayLoadingFile: string;
  104482. /** @hidden */
  104483. _binaryInfo: any;
  104484. /**
  104485. * User defined function used to change how LOD level selection is done
  104486. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  104487. */
  104488. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  104489. /**
  104490. * Gets or sets the morph target manager
  104491. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104492. */
  104493. get morphTargetManager(): Nullable<MorphTargetManager>;
  104494. set morphTargetManager(value: Nullable<MorphTargetManager>);
  104495. /** @hidden */
  104496. _creationDataStorage: Nullable<_CreationDataStorage>;
  104497. /** @hidden */
  104498. _geometry: Nullable<Geometry>;
  104499. /** @hidden */
  104500. _delayInfo: Array<string>;
  104501. /** @hidden */
  104502. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  104503. /** @hidden */
  104504. _instanceDataStorage: _InstanceDataStorage;
  104505. /** @hidden */
  104506. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  104507. private _effectiveMaterial;
  104508. /** @hidden */
  104509. _shouldGenerateFlatShading: boolean;
  104510. /** @hidden */
  104511. _originalBuilderSideOrientation: number;
  104512. /**
  104513. * Use this property to change the original side orientation defined at construction time
  104514. */
  104515. overrideMaterialSideOrientation: Nullable<number>;
  104516. /**
  104517. * Gets the source mesh (the one used to clone this one from)
  104518. */
  104519. get source(): Nullable<Mesh>;
  104520. /**
  104521. * Gets or sets a boolean indicating that this mesh does not use index buffer
  104522. */
  104523. get isUnIndexed(): boolean;
  104524. set isUnIndexed(value: boolean);
  104525. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  104526. get worldMatrixInstancedBuffer(): Float32Array;
  104527. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  104528. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  104529. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  104530. /**
  104531. * @constructor
  104532. * @param name The value used by scene.getMeshByName() to do a lookup.
  104533. * @param scene The scene to add this mesh to.
  104534. * @param parent The parent of this mesh, if it has one
  104535. * @param source An optional Mesh from which geometry is shared, cloned.
  104536. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  104537. * When false, achieved by calling a clone(), also passing False.
  104538. * This will make creation of children, recursive.
  104539. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  104540. */
  104541. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  104542. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  104543. doNotInstantiate: boolean;
  104544. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  104545. /**
  104546. * Gets the class name
  104547. * @returns the string "Mesh".
  104548. */
  104549. getClassName(): string;
  104550. /** @hidden */
  104551. get _isMesh(): boolean;
  104552. /**
  104553. * Returns a description of this mesh
  104554. * @param fullDetails define if full details about this mesh must be used
  104555. * @returns a descriptive string representing this mesh
  104556. */
  104557. toString(fullDetails?: boolean): string;
  104558. /** @hidden */
  104559. _unBindEffect(): void;
  104560. /**
  104561. * Gets a boolean indicating if this mesh has LOD
  104562. */
  104563. get hasLODLevels(): boolean;
  104564. /**
  104565. * Gets the list of MeshLODLevel associated with the current mesh
  104566. * @returns an array of MeshLODLevel
  104567. */
  104568. getLODLevels(): MeshLODLevel[];
  104569. private _sortLODLevels;
  104570. /**
  104571. * Add a mesh as LOD level triggered at the given distance.
  104572. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104573. * @param distance The distance from the center of the object to show this level
  104574. * @param mesh The mesh to be added as LOD level (can be null)
  104575. * @return This mesh (for chaining)
  104576. */
  104577. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  104578. /**
  104579. * Returns the LOD level mesh at the passed distance or null if not found.
  104580. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104581. * @param distance The distance from the center of the object to show this level
  104582. * @returns a Mesh or `null`
  104583. */
  104584. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  104585. /**
  104586. * Remove a mesh from the LOD array
  104587. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104588. * @param mesh defines the mesh to be removed
  104589. * @return This mesh (for chaining)
  104590. */
  104591. removeLODLevel(mesh: Mesh): Mesh;
  104592. /**
  104593. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  104594. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104595. * @param camera defines the camera to use to compute distance
  104596. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  104597. * @return This mesh (for chaining)
  104598. */
  104599. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  104600. /**
  104601. * Gets the mesh internal Geometry object
  104602. */
  104603. get geometry(): Nullable<Geometry>;
  104604. /**
  104605. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  104606. * @returns the total number of vertices
  104607. */
  104608. getTotalVertices(): number;
  104609. /**
  104610. * Returns the content of an associated vertex buffer
  104611. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104612. * - VertexBuffer.PositionKind
  104613. * - VertexBuffer.UVKind
  104614. * - VertexBuffer.UV2Kind
  104615. * - VertexBuffer.UV3Kind
  104616. * - VertexBuffer.UV4Kind
  104617. * - VertexBuffer.UV5Kind
  104618. * - VertexBuffer.UV6Kind
  104619. * - VertexBuffer.ColorKind
  104620. * - VertexBuffer.MatricesIndicesKind
  104621. * - VertexBuffer.MatricesIndicesExtraKind
  104622. * - VertexBuffer.MatricesWeightsKind
  104623. * - VertexBuffer.MatricesWeightsExtraKind
  104624. * @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
  104625. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  104626. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  104627. */
  104628. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104629. /**
  104630. * Returns the mesh VertexBuffer object from the requested `kind`
  104631. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104632. * - VertexBuffer.PositionKind
  104633. * - VertexBuffer.NormalKind
  104634. * - VertexBuffer.UVKind
  104635. * - VertexBuffer.UV2Kind
  104636. * - VertexBuffer.UV3Kind
  104637. * - VertexBuffer.UV4Kind
  104638. * - VertexBuffer.UV5Kind
  104639. * - VertexBuffer.UV6Kind
  104640. * - VertexBuffer.ColorKind
  104641. * - VertexBuffer.MatricesIndicesKind
  104642. * - VertexBuffer.MatricesIndicesExtraKind
  104643. * - VertexBuffer.MatricesWeightsKind
  104644. * - VertexBuffer.MatricesWeightsExtraKind
  104645. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  104646. */
  104647. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104648. /**
  104649. * Tests if a specific vertex buffer is associated with this mesh
  104650. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104651. * - VertexBuffer.PositionKind
  104652. * - VertexBuffer.NormalKind
  104653. * - VertexBuffer.UVKind
  104654. * - VertexBuffer.UV2Kind
  104655. * - VertexBuffer.UV3Kind
  104656. * - VertexBuffer.UV4Kind
  104657. * - VertexBuffer.UV5Kind
  104658. * - VertexBuffer.UV6Kind
  104659. * - VertexBuffer.ColorKind
  104660. * - VertexBuffer.MatricesIndicesKind
  104661. * - VertexBuffer.MatricesIndicesExtraKind
  104662. * - VertexBuffer.MatricesWeightsKind
  104663. * - VertexBuffer.MatricesWeightsExtraKind
  104664. * @returns a boolean
  104665. */
  104666. isVerticesDataPresent(kind: string): boolean;
  104667. /**
  104668. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  104669. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104670. * - VertexBuffer.PositionKind
  104671. * - VertexBuffer.UVKind
  104672. * - VertexBuffer.UV2Kind
  104673. * - VertexBuffer.UV3Kind
  104674. * - VertexBuffer.UV4Kind
  104675. * - VertexBuffer.UV5Kind
  104676. * - VertexBuffer.UV6Kind
  104677. * - VertexBuffer.ColorKind
  104678. * - VertexBuffer.MatricesIndicesKind
  104679. * - VertexBuffer.MatricesIndicesExtraKind
  104680. * - VertexBuffer.MatricesWeightsKind
  104681. * - VertexBuffer.MatricesWeightsExtraKind
  104682. * @returns a boolean
  104683. */
  104684. isVertexBufferUpdatable(kind: string): boolean;
  104685. /**
  104686. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  104687. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104688. * - VertexBuffer.PositionKind
  104689. * - VertexBuffer.NormalKind
  104690. * - VertexBuffer.UVKind
  104691. * - VertexBuffer.UV2Kind
  104692. * - VertexBuffer.UV3Kind
  104693. * - VertexBuffer.UV4Kind
  104694. * - VertexBuffer.UV5Kind
  104695. * - VertexBuffer.UV6Kind
  104696. * - VertexBuffer.ColorKind
  104697. * - VertexBuffer.MatricesIndicesKind
  104698. * - VertexBuffer.MatricesIndicesExtraKind
  104699. * - VertexBuffer.MatricesWeightsKind
  104700. * - VertexBuffer.MatricesWeightsExtraKind
  104701. * @returns an array of strings
  104702. */
  104703. getVerticesDataKinds(): string[];
  104704. /**
  104705. * Returns a positive integer : the total number of indices in this mesh geometry.
  104706. * @returns the numner of indices or zero if the mesh has no geometry.
  104707. */
  104708. getTotalIndices(): number;
  104709. /**
  104710. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104711. * @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.
  104712. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104713. * @returns the indices array or an empty array if the mesh has no geometry
  104714. */
  104715. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104716. get isBlocked(): boolean;
  104717. /**
  104718. * Determine if the current mesh is ready to be rendered
  104719. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  104720. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  104721. * @returns true if all associated assets are ready (material, textures, shaders)
  104722. */
  104723. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  104724. /**
  104725. * 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.
  104726. */
  104727. get areNormalsFrozen(): boolean;
  104728. /**
  104729. * 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.
  104730. * @returns the current mesh
  104731. */
  104732. freezeNormals(): Mesh;
  104733. /**
  104734. * 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
  104735. * @returns the current mesh
  104736. */
  104737. unfreezeNormals(): Mesh;
  104738. /**
  104739. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  104740. */
  104741. set overridenInstanceCount(count: number);
  104742. /** @hidden */
  104743. _preActivate(): Mesh;
  104744. /** @hidden */
  104745. _preActivateForIntermediateRendering(renderId: number): Mesh;
  104746. /** @hidden */
  104747. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  104748. protected _afterComputeWorldMatrix(): void;
  104749. /**
  104750. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104751. * This means the mesh underlying bounding box and sphere are recomputed.
  104752. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104753. * @returns the current mesh
  104754. */
  104755. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  104756. /** @hidden */
  104757. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  104758. /**
  104759. * This function will subdivide the mesh into multiple submeshes
  104760. * @param count defines the expected number of submeshes
  104761. */
  104762. subdivide(count: number): void;
  104763. /**
  104764. * Copy a FloatArray into a specific associated vertex buffer
  104765. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104766. * - VertexBuffer.PositionKind
  104767. * - VertexBuffer.UVKind
  104768. * - VertexBuffer.UV2Kind
  104769. * - VertexBuffer.UV3Kind
  104770. * - VertexBuffer.UV4Kind
  104771. * - VertexBuffer.UV5Kind
  104772. * - VertexBuffer.UV6Kind
  104773. * - VertexBuffer.ColorKind
  104774. * - VertexBuffer.MatricesIndicesKind
  104775. * - VertexBuffer.MatricesIndicesExtraKind
  104776. * - VertexBuffer.MatricesWeightsKind
  104777. * - VertexBuffer.MatricesWeightsExtraKind
  104778. * @param data defines the data source
  104779. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104780. * @param stride defines the data stride size (can be null)
  104781. * @returns the current mesh
  104782. */
  104783. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104784. /**
  104785. * Delete a vertex buffer associated with this mesh
  104786. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  104787. * - VertexBuffer.PositionKind
  104788. * - VertexBuffer.UVKind
  104789. * - VertexBuffer.UV2Kind
  104790. * - VertexBuffer.UV3Kind
  104791. * - VertexBuffer.UV4Kind
  104792. * - VertexBuffer.UV5Kind
  104793. * - VertexBuffer.UV6Kind
  104794. * - VertexBuffer.ColorKind
  104795. * - VertexBuffer.MatricesIndicesKind
  104796. * - VertexBuffer.MatricesIndicesExtraKind
  104797. * - VertexBuffer.MatricesWeightsKind
  104798. * - VertexBuffer.MatricesWeightsExtraKind
  104799. */
  104800. removeVerticesData(kind: string): void;
  104801. /**
  104802. * Flags an associated vertex buffer as updatable
  104803. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  104804. * - VertexBuffer.PositionKind
  104805. * - VertexBuffer.UVKind
  104806. * - VertexBuffer.UV2Kind
  104807. * - VertexBuffer.UV3Kind
  104808. * - VertexBuffer.UV4Kind
  104809. * - VertexBuffer.UV5Kind
  104810. * - VertexBuffer.UV6Kind
  104811. * - VertexBuffer.ColorKind
  104812. * - VertexBuffer.MatricesIndicesKind
  104813. * - VertexBuffer.MatricesIndicesExtraKind
  104814. * - VertexBuffer.MatricesWeightsKind
  104815. * - VertexBuffer.MatricesWeightsExtraKind
  104816. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104817. */
  104818. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  104819. /**
  104820. * Sets the mesh global Vertex Buffer
  104821. * @param buffer defines the buffer to use
  104822. * @returns the current mesh
  104823. */
  104824. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  104825. /**
  104826. * Update a specific associated vertex buffer
  104827. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104828. * - VertexBuffer.PositionKind
  104829. * - VertexBuffer.UVKind
  104830. * - VertexBuffer.UV2Kind
  104831. * - VertexBuffer.UV3Kind
  104832. * - VertexBuffer.UV4Kind
  104833. * - VertexBuffer.UV5Kind
  104834. * - VertexBuffer.UV6Kind
  104835. * - VertexBuffer.ColorKind
  104836. * - VertexBuffer.MatricesIndicesKind
  104837. * - VertexBuffer.MatricesIndicesExtraKind
  104838. * - VertexBuffer.MatricesWeightsKind
  104839. * - VertexBuffer.MatricesWeightsExtraKind
  104840. * @param data defines the data source
  104841. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104842. * @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)
  104843. * @returns the current mesh
  104844. */
  104845. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104846. /**
  104847. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  104848. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  104849. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  104850. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  104851. * @returns the current mesh
  104852. */
  104853. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  104854. /**
  104855. * Creates a un-shared specific occurence of the geometry for the mesh.
  104856. * @returns the current mesh
  104857. */
  104858. makeGeometryUnique(): Mesh;
  104859. /**
  104860. * Set the index buffer of this mesh
  104861. * @param indices defines the source data
  104862. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  104863. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  104864. * @returns the current mesh
  104865. */
  104866. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  104867. /**
  104868. * Update the current index buffer
  104869. * @param indices defines the source data
  104870. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  104871. * @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)
  104872. * @returns the current mesh
  104873. */
  104874. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  104875. /**
  104876. * Invert the geometry to move from a right handed system to a left handed one.
  104877. * @returns the current mesh
  104878. */
  104879. toLeftHanded(): Mesh;
  104880. /** @hidden */
  104881. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  104882. /** @hidden */
  104883. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  104884. /**
  104885. * Registers for this mesh a javascript function called just before the rendering process
  104886. * @param func defines the function to call before rendering this mesh
  104887. * @returns the current mesh
  104888. */
  104889. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  104890. /**
  104891. * Disposes a previously registered javascript function called before the rendering
  104892. * @param func defines the function to remove
  104893. * @returns the current mesh
  104894. */
  104895. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  104896. /**
  104897. * Registers for this mesh a javascript function called just after the rendering is complete
  104898. * @param func defines the function to call after rendering this mesh
  104899. * @returns the current mesh
  104900. */
  104901. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  104902. /**
  104903. * Disposes a previously registered javascript function called after the rendering.
  104904. * @param func defines the function to remove
  104905. * @returns the current mesh
  104906. */
  104907. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  104908. /** @hidden */
  104909. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  104910. /** @hidden */
  104911. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  104912. /** @hidden */
  104913. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  104914. /** @hidden */
  104915. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  104916. /** @hidden */
  104917. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  104918. /** @hidden */
  104919. _rebuild(): void;
  104920. /** @hidden */
  104921. _freeze(): void;
  104922. /** @hidden */
  104923. _unFreeze(): void;
  104924. /**
  104925. * 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
  104926. * @param subMesh defines the subMesh to render
  104927. * @param enableAlphaMode defines if alpha mode can be changed
  104928. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  104929. * @returns the current mesh
  104930. */
  104931. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  104932. private _onBeforeDraw;
  104933. /**
  104934. * Renormalize the mesh and patch it up if there are no weights
  104935. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  104936. * However in the case of zero weights then we set just a single influence to 1.
  104937. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  104938. */
  104939. cleanMatrixWeights(): void;
  104940. private normalizeSkinFourWeights;
  104941. private normalizeSkinWeightsAndExtra;
  104942. /**
  104943. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  104944. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  104945. * the user know there was an issue with importing the mesh
  104946. * @returns a validation object with skinned, valid and report string
  104947. */
  104948. validateSkinning(): {
  104949. skinned: boolean;
  104950. valid: boolean;
  104951. report: string;
  104952. };
  104953. /** @hidden */
  104954. _checkDelayState(): Mesh;
  104955. private _queueLoad;
  104956. /**
  104957. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  104958. * A mesh is in the frustum if its bounding box intersects the frustum
  104959. * @param frustumPlanes defines the frustum to test
  104960. * @returns true if the mesh is in the frustum planes
  104961. */
  104962. isInFrustum(frustumPlanes: Plane[]): boolean;
  104963. /**
  104964. * Sets the mesh material by the material or multiMaterial `id` property
  104965. * @param id is a string identifying the material or the multiMaterial
  104966. * @returns the current mesh
  104967. */
  104968. setMaterialByID(id: string): Mesh;
  104969. /**
  104970. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  104971. * @returns an array of IAnimatable
  104972. */
  104973. getAnimatables(): IAnimatable[];
  104974. /**
  104975. * Modifies the mesh geometry according to the passed transformation matrix.
  104976. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  104977. * The mesh normals are modified using the same transformation.
  104978. * Note that, under the hood, this method sets a new VertexBuffer each call.
  104979. * @param transform defines the transform matrix to use
  104980. * @see http://doc.babylonjs.com/resources/baking_transformations
  104981. * @returns the current mesh
  104982. */
  104983. bakeTransformIntoVertices(transform: Matrix): Mesh;
  104984. /**
  104985. * Modifies the mesh geometry according to its own current World Matrix.
  104986. * The mesh World Matrix is then reset.
  104987. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  104988. * Note that, under the hood, this method sets a new VertexBuffer each call.
  104989. * @see http://doc.babylonjs.com/resources/baking_transformations
  104990. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  104991. * @returns the current mesh
  104992. */
  104993. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  104994. /** @hidden */
  104995. get _positions(): Nullable<Vector3[]>;
  104996. /** @hidden */
  104997. _resetPointsArrayCache(): Mesh;
  104998. /** @hidden */
  104999. _generatePointsArray(): boolean;
  105000. /**
  105001. * Returns a new Mesh object generated from the current mesh properties.
  105002. * This method must not get confused with createInstance()
  105003. * @param name is a string, the name given to the new mesh
  105004. * @param newParent can be any Node object (default `null`)
  105005. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  105006. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  105007. * @returns a new mesh
  105008. */
  105009. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  105010. /**
  105011. * Releases resources associated with this mesh.
  105012. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105013. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105014. */
  105015. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105016. /** @hidden */
  105017. _disposeInstanceSpecificData(): void;
  105018. /** @hidden */
  105019. _disposeThinInstanceSpecificData(): void;
  105020. /**
  105021. * Modifies the mesh geometry according to a displacement map.
  105022. * 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.
  105023. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105024. * @param url is a string, the URL from the image file is to be downloaded.
  105025. * @param minHeight is the lower limit of the displacement.
  105026. * @param maxHeight is the upper limit of the displacement.
  105027. * @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.
  105028. * @param uvOffset is an optional vector2 used to offset UV.
  105029. * @param uvScale is an optional vector2 used to scale UV.
  105030. * @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.
  105031. * @returns the Mesh.
  105032. */
  105033. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105034. /**
  105035. * Modifies the mesh geometry according to a displacementMap buffer.
  105036. * 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.
  105037. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105038. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  105039. * @param heightMapWidth is the width of the buffer image.
  105040. * @param heightMapHeight is the height of the buffer image.
  105041. * @param minHeight is the lower limit of the displacement.
  105042. * @param maxHeight is the upper limit of the displacement.
  105043. * @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.
  105044. * @param uvOffset is an optional vector2 used to offset UV.
  105045. * @param uvScale is an optional vector2 used to scale UV.
  105046. * @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.
  105047. * @returns the Mesh.
  105048. */
  105049. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105050. /**
  105051. * Modify the mesh to get a flat shading rendering.
  105052. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  105053. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  105054. * @returns current mesh
  105055. */
  105056. convertToFlatShadedMesh(): Mesh;
  105057. /**
  105058. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  105059. * In other words, more vertices, no more indices and a single bigger VBO.
  105060. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  105061. * @returns current mesh
  105062. */
  105063. convertToUnIndexedMesh(): Mesh;
  105064. /**
  105065. * Inverses facet orientations.
  105066. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105067. * @param flipNormals will also inverts the normals
  105068. * @returns current mesh
  105069. */
  105070. flipFaces(flipNormals?: boolean): Mesh;
  105071. /**
  105072. * Increase the number of facets and hence vertices in a mesh
  105073. * Vertex normals are interpolated from existing vertex normals
  105074. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105075. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  105076. */
  105077. increaseVertices(numberPerEdge: number): void;
  105078. /**
  105079. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  105080. * This will undo any application of covertToFlatShadedMesh
  105081. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105082. */
  105083. forceSharedVertices(): void;
  105084. /** @hidden */
  105085. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  105086. /** @hidden */
  105087. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  105088. /**
  105089. * Creates a new InstancedMesh object from the mesh model.
  105090. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105091. * @param name defines the name of the new instance
  105092. * @returns a new InstancedMesh
  105093. */
  105094. createInstance(name: string): InstancedMesh;
  105095. /**
  105096. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  105097. * After this call, all the mesh instances have the same submeshes than the current mesh.
  105098. * @returns the current mesh
  105099. */
  105100. synchronizeInstances(): Mesh;
  105101. /**
  105102. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  105103. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  105104. * This should be used together with the simplification to avoid disappearing triangles.
  105105. * @param successCallback an optional success callback to be called after the optimization finished.
  105106. * @returns the current mesh
  105107. */
  105108. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  105109. /**
  105110. * Serialize current mesh
  105111. * @param serializationObject defines the object which will receive the serialization data
  105112. */
  105113. serialize(serializationObject: any): void;
  105114. /** @hidden */
  105115. _syncGeometryWithMorphTargetManager(): void;
  105116. /** @hidden */
  105117. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  105118. /**
  105119. * Returns a new Mesh object parsed from the source provided.
  105120. * @param parsedMesh is the source
  105121. * @param scene defines the hosting scene
  105122. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  105123. * @returns a new Mesh
  105124. */
  105125. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  105126. /**
  105127. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  105128. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105129. * @param name defines the name of the mesh to create
  105130. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  105131. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  105132. * @param closePath creates a seam between the first and the last points of each path of the path array
  105133. * @param offset is taken in account only if the `pathArray` is containing a single path
  105134. * @param scene defines the hosting scene
  105135. * @param updatable defines if the mesh must be flagged as updatable
  105136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105137. * @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)
  105138. * @returns a new Mesh
  105139. */
  105140. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105141. /**
  105142. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  105143. * @param name defines the name of the mesh to create
  105144. * @param radius sets the radius size (float) of the polygon (default 0.5)
  105145. * @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
  105146. * @param scene defines the hosting scene
  105147. * @param updatable defines if the mesh must be flagged as updatable
  105148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105149. * @returns a new Mesh
  105150. */
  105151. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105152. /**
  105153. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  105154. * @param name defines the name of the mesh to create
  105155. * @param size sets the size (float) of each box side (default 1)
  105156. * @param scene defines the hosting scene
  105157. * @param updatable defines if the mesh must be flagged as updatable
  105158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105159. * @returns a new Mesh
  105160. */
  105161. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105162. /**
  105163. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  105164. * @param name defines the name of the mesh to create
  105165. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105166. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105167. * @param scene defines the hosting scene
  105168. * @param updatable defines if the mesh must be flagged as updatable
  105169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105170. * @returns a new Mesh
  105171. */
  105172. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105173. /**
  105174. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  105175. * @param name defines the name of the mesh to create
  105176. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105177. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105178. * @param scene defines the hosting scene
  105179. * @returns a new Mesh
  105180. */
  105181. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  105182. /**
  105183. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  105184. * @param name defines the name of the mesh to create
  105185. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  105186. * @param diameterTop set the top cap diameter (floats, default 1)
  105187. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  105188. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  105189. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  105190. * @param scene defines the hosting scene
  105191. * @param updatable defines if the mesh must be flagged as updatable
  105192. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105193. * @returns a new Mesh
  105194. */
  105195. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  105196. /**
  105197. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  105198. * @param name defines the name of the mesh to create
  105199. * @param diameter sets the diameter size (float) of the torus (default 1)
  105200. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  105201. * @param tessellation sets the number of torus sides (postive integer, default 16)
  105202. * @param scene defines the hosting scene
  105203. * @param updatable defines if the mesh must be flagged as updatable
  105204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105205. * @returns a new Mesh
  105206. */
  105207. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105208. /**
  105209. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  105210. * @param name defines the name of the mesh to create
  105211. * @param radius sets the global radius size (float) of the torus knot (default 2)
  105212. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  105213. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  105214. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  105215. * @param p the number of windings on X axis (positive integers, default 2)
  105216. * @param q the number of windings on Y axis (positive integers, default 3)
  105217. * @param scene defines the hosting scene
  105218. * @param updatable defines if the mesh must be flagged as updatable
  105219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105220. * @returns a new Mesh
  105221. */
  105222. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105223. /**
  105224. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  105225. * @param name defines the name of the mesh to create
  105226. * @param points is an array successive Vector3
  105227. * @param scene defines the hosting scene
  105228. * @param updatable defines if the mesh must be flagged as updatable
  105229. * @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).
  105230. * @returns a new Mesh
  105231. */
  105232. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  105233. /**
  105234. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  105235. * @param name defines the name of the mesh to create
  105236. * @param points is an array successive Vector3
  105237. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  105238. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105239. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  105240. * @param scene defines the hosting scene
  105241. * @param updatable defines if the mesh must be flagged as updatable
  105242. * @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)
  105243. * @returns a new Mesh
  105244. */
  105245. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  105246. /**
  105247. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  105248. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  105249. * 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.
  105250. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105251. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105252. * Remember you can only change the shape positions, not their number when updating a polygon.
  105253. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105254. * @param name defines the name of the mesh to create
  105255. * @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
  105256. * @param scene defines the hosting scene
  105257. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105258. * @param updatable defines if the mesh must be flagged as updatable
  105259. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105260. * @param earcutInjection can be used to inject your own earcut reference
  105261. * @returns a new Mesh
  105262. */
  105263. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105264. /**
  105265. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  105266. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  105267. * @param name defines the name of the mesh to create
  105268. * @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
  105269. * @param depth defines the height of extrusion
  105270. * @param scene defines the hosting scene
  105271. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105272. * @param updatable defines if the mesh must be flagged as updatable
  105273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105274. * @param earcutInjection can be used to inject your own earcut reference
  105275. * @returns a new Mesh
  105276. */
  105277. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105278. /**
  105279. * Creates an extruded shape mesh.
  105280. * 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
  105281. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105282. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105283. * @param name defines the name of the mesh to create
  105284. * @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
  105285. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105286. * @param scale is the value to scale the shape
  105287. * @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
  105288. * @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
  105289. * @param scene defines the hosting scene
  105290. * @param updatable defines if the mesh must be flagged as updatable
  105291. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105292. * @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)
  105293. * @returns a new Mesh
  105294. */
  105295. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105296. /**
  105297. * Creates an custom extruded shape mesh.
  105298. * The custom extrusion is a parametric shape.
  105299. * It has no predefined shape. Its final shape will depend on the input parameters.
  105300. * Please consider using the same method from the MeshBuilder class instead
  105301. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105302. * @param name defines the name of the mesh to create
  105303. * @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
  105304. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105305. * @param scaleFunction is a custom Javascript function called on each path point
  105306. * @param rotationFunction is a custom Javascript function called on each path point
  105307. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105308. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  105309. * @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
  105310. * @param scene defines the hosting scene
  105311. * @param updatable defines if the mesh must be flagged as updatable
  105312. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105313. * @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)
  105314. * @returns a new Mesh
  105315. */
  105316. 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;
  105317. /**
  105318. * Creates lathe mesh.
  105319. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  105320. * Please consider using the same method from the MeshBuilder class instead
  105321. * @param name defines the name of the mesh to create
  105322. * @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
  105323. * @param radius is the radius value of the lathe
  105324. * @param tessellation is the side number of the lathe.
  105325. * @param scene defines the hosting scene
  105326. * @param updatable defines if the mesh must be flagged as updatable
  105327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105328. * @returns a new Mesh
  105329. */
  105330. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105331. /**
  105332. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105333. * @param name defines the name of the mesh to create
  105334. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105335. * @param scene defines the hosting scene
  105336. * @param updatable defines if the mesh must be flagged as updatable
  105337. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105338. * @returns a new Mesh
  105339. */
  105340. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105341. /**
  105342. * Creates a ground mesh.
  105343. * Please consider using the same method from the MeshBuilder class instead
  105344. * @param name defines the name of the mesh to create
  105345. * @param width set the width of the ground
  105346. * @param height set the height of the ground
  105347. * @param subdivisions sets the number of subdivisions per side
  105348. * @param scene defines the hosting scene
  105349. * @param updatable defines if the mesh must be flagged as updatable
  105350. * @returns a new Mesh
  105351. */
  105352. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  105353. /**
  105354. * Creates a tiled ground mesh.
  105355. * Please consider using the same method from the MeshBuilder class instead
  105356. * @param name defines the name of the mesh to create
  105357. * @param xmin set the ground minimum X coordinate
  105358. * @param zmin set the ground minimum Y coordinate
  105359. * @param xmax set the ground maximum X coordinate
  105360. * @param zmax set the ground maximum Z coordinate
  105361. * @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
  105362. * @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
  105363. * @param scene defines the hosting scene
  105364. * @param updatable defines if the mesh must be flagged as updatable
  105365. * @returns a new Mesh
  105366. */
  105367. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  105368. w: number;
  105369. h: number;
  105370. }, precision: {
  105371. w: number;
  105372. h: number;
  105373. }, scene: Scene, updatable?: boolean): Mesh;
  105374. /**
  105375. * Creates a ground mesh from a height map.
  105376. * Please consider using the same method from the MeshBuilder class instead
  105377. * @see http://doc.babylonjs.com/babylon101/height_map
  105378. * @param name defines the name of the mesh to create
  105379. * @param url sets the URL of the height map image resource
  105380. * @param width set the ground width size
  105381. * @param height set the ground height size
  105382. * @param subdivisions sets the number of subdivision per side
  105383. * @param minHeight is the minimum altitude on the ground
  105384. * @param maxHeight is the maximum altitude on the ground
  105385. * @param scene defines the hosting scene
  105386. * @param updatable defines if the mesh must be flagged as updatable
  105387. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  105388. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105389. * @returns a new Mesh
  105390. */
  105391. 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;
  105392. /**
  105393. * Creates a tube mesh.
  105394. * The tube is a parametric shape.
  105395. * It has no predefined shape. Its final shape will depend on the input parameters.
  105396. * Please consider using the same method from the MeshBuilder class instead
  105397. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105398. * @param name defines the name of the mesh to create
  105399. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  105400. * @param radius sets the tube radius size
  105401. * @param tessellation is the number of sides on the tubular surface
  105402. * @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
  105403. * @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
  105404. * @param scene defines the hosting scene
  105405. * @param updatable defines if the mesh must be flagged as updatable
  105406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105407. * @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)
  105408. * @returns a new Mesh
  105409. */
  105410. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  105411. (i: number, distance: number): number;
  105412. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105413. /**
  105414. * Creates a polyhedron mesh.
  105415. * Please consider using the same method from the MeshBuilder class instead.
  105416. * * 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
  105417. * * The parameter `size` (positive float, default 1) sets the polygon size
  105418. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105419. * * 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`
  105420. * * 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
  105421. * * 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)`)
  105422. * * 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
  105423. * * 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
  105424. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105425. * * If you create a double-sided mesh, you can choose what parts of 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
  105426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105427. * @param name defines the name of the mesh to create
  105428. * @param options defines the options used to create the mesh
  105429. * @param scene defines the hosting scene
  105430. * @returns a new Mesh
  105431. */
  105432. static CreatePolyhedron(name: string, options: {
  105433. type?: number;
  105434. size?: number;
  105435. sizeX?: number;
  105436. sizeY?: number;
  105437. sizeZ?: number;
  105438. custom?: any;
  105439. faceUV?: Vector4[];
  105440. faceColors?: Color4[];
  105441. updatable?: boolean;
  105442. sideOrientation?: number;
  105443. }, scene: Scene): Mesh;
  105444. /**
  105445. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105446. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105447. * * 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`)
  105448. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105449. * * 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
  105450. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105451. * * If you create a double-sided mesh, you can choose what parts of 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
  105452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105453. * @param name defines the name of the mesh
  105454. * @param options defines the options used to create the mesh
  105455. * @param scene defines the hosting scene
  105456. * @returns a new Mesh
  105457. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105458. */
  105459. static CreateIcoSphere(name: string, options: {
  105460. radius?: number;
  105461. flat?: boolean;
  105462. subdivisions?: number;
  105463. sideOrientation?: number;
  105464. updatable?: boolean;
  105465. }, scene: Scene): Mesh;
  105466. /**
  105467. * Creates a decal mesh.
  105468. * Please consider using the same method from the MeshBuilder class instead.
  105469. * A decal is a mesh usually applied as a model onto the surface of another mesh
  105470. * @param name defines the name of the mesh
  105471. * @param sourceMesh defines the mesh receiving the decal
  105472. * @param position sets the position of the decal in world coordinates
  105473. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  105474. * @param size sets the decal scaling
  105475. * @param angle sets the angle to rotate the decal
  105476. * @returns a new Mesh
  105477. */
  105478. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  105479. /**
  105480. * Prepare internal position array for software CPU skinning
  105481. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  105482. */
  105483. setPositionsForCPUSkinning(): Float32Array;
  105484. /**
  105485. * Prepare internal normal array for software CPU skinning
  105486. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  105487. */
  105488. setNormalsForCPUSkinning(): Float32Array;
  105489. /**
  105490. * Updates the vertex buffer by applying transformation from the bones
  105491. * @param skeleton defines the skeleton to apply to current mesh
  105492. * @returns the current mesh
  105493. */
  105494. applySkeleton(skeleton: Skeleton): Mesh;
  105495. /**
  105496. * 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
  105497. * @param meshes defines the list of meshes to scan
  105498. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  105499. */
  105500. static MinMax(meshes: AbstractMesh[]): {
  105501. min: Vector3;
  105502. max: Vector3;
  105503. };
  105504. /**
  105505. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  105506. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  105507. * @returns a vector3
  105508. */
  105509. static Center(meshesOrMinMaxVector: {
  105510. min: Vector3;
  105511. max: Vector3;
  105512. } | AbstractMesh[]): Vector3;
  105513. /**
  105514. * Merge the array of meshes into a single mesh for performance reasons.
  105515. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  105516. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  105517. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  105518. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  105519. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  105520. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  105521. * @returns a new mesh
  105522. */
  105523. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  105524. /** @hidden */
  105525. addInstance(instance: InstancedMesh): void;
  105526. /** @hidden */
  105527. removeInstance(instance: InstancedMesh): void;
  105528. }
  105529. }
  105530. declare module BABYLON {
  105531. /**
  105532. * This is the base class of all the camera used in the application.
  105533. * @see http://doc.babylonjs.com/features/cameras
  105534. */
  105535. export class Camera extends Node {
  105536. /** @hidden */
  105537. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  105538. /**
  105539. * This is the default projection mode used by the cameras.
  105540. * It helps recreating a feeling of perspective and better appreciate depth.
  105541. * This is the best way to simulate real life cameras.
  105542. */
  105543. static readonly PERSPECTIVE_CAMERA: number;
  105544. /**
  105545. * This helps creating camera with an orthographic mode.
  105546. * 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.
  105547. */
  105548. static readonly ORTHOGRAPHIC_CAMERA: number;
  105549. /**
  105550. * This is the default FOV mode for perspective cameras.
  105551. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  105552. */
  105553. static readonly FOVMODE_VERTICAL_FIXED: number;
  105554. /**
  105555. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  105556. */
  105557. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  105558. /**
  105559. * This specifies ther is no need for a camera rig.
  105560. * Basically only one eye is rendered corresponding to the camera.
  105561. */
  105562. static readonly RIG_MODE_NONE: number;
  105563. /**
  105564. * Simulates a camera Rig with one blue eye and one red eye.
  105565. * This can be use with 3d blue and red glasses.
  105566. */
  105567. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  105568. /**
  105569. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  105570. */
  105571. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  105572. /**
  105573. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  105574. */
  105575. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  105576. /**
  105577. * Defines that both eyes of the camera will be rendered over under each other.
  105578. */
  105579. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  105580. /**
  105581. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  105582. */
  105583. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  105584. /**
  105585. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  105586. */
  105587. static readonly RIG_MODE_VR: number;
  105588. /**
  105589. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  105590. */
  105591. static readonly RIG_MODE_WEBVR: number;
  105592. /**
  105593. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  105594. */
  105595. static readonly RIG_MODE_CUSTOM: number;
  105596. /**
  105597. * Defines if by default attaching controls should prevent the default javascript event to continue.
  105598. */
  105599. static ForceAttachControlToAlwaysPreventDefault: boolean;
  105600. /**
  105601. * Define the input manager associated with the camera.
  105602. */
  105603. inputs: CameraInputsManager<Camera>;
  105604. /** @hidden */
  105605. _position: Vector3;
  105606. /**
  105607. * Define the current local position of the camera in the scene
  105608. */
  105609. get position(): Vector3;
  105610. set position(newPosition: Vector3);
  105611. /**
  105612. * The vector the camera should consider as up.
  105613. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  105614. */
  105615. upVector: Vector3;
  105616. /**
  105617. * Define the current limit on the left side for an orthographic camera
  105618. * In scene unit
  105619. */
  105620. orthoLeft: Nullable<number>;
  105621. /**
  105622. * Define the current limit on the right side for an orthographic camera
  105623. * In scene unit
  105624. */
  105625. orthoRight: Nullable<number>;
  105626. /**
  105627. * Define the current limit on the bottom side for an orthographic camera
  105628. * In scene unit
  105629. */
  105630. orthoBottom: Nullable<number>;
  105631. /**
  105632. * Define the current limit on the top side for an orthographic camera
  105633. * In scene unit
  105634. */
  105635. orthoTop: Nullable<number>;
  105636. /**
  105637. * Field Of View is set in Radians. (default is 0.8)
  105638. */
  105639. fov: number;
  105640. /**
  105641. * Define the minimum distance the camera can see from.
  105642. * This is important to note that the depth buffer are not infinite and the closer it starts
  105643. * the more your scene might encounter depth fighting issue.
  105644. */
  105645. minZ: number;
  105646. /**
  105647. * Define the maximum distance the camera can see to.
  105648. * This is important to note that the depth buffer are not infinite and the further it end
  105649. * the more your scene might encounter depth fighting issue.
  105650. */
  105651. maxZ: number;
  105652. /**
  105653. * Define the default inertia of the camera.
  105654. * This helps giving a smooth feeling to the camera movement.
  105655. */
  105656. inertia: number;
  105657. /**
  105658. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  105659. */
  105660. mode: number;
  105661. /**
  105662. * Define whether the camera is intermediate.
  105663. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  105664. */
  105665. isIntermediate: boolean;
  105666. /**
  105667. * Define the viewport of the camera.
  105668. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  105669. */
  105670. viewport: Viewport;
  105671. /**
  105672. * Restricts the camera to viewing objects with the same layerMask.
  105673. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  105674. */
  105675. layerMask: number;
  105676. /**
  105677. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  105678. */
  105679. fovMode: number;
  105680. /**
  105681. * Rig mode of the camera.
  105682. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  105683. * This is normally controlled byt the camera themselves as internal use.
  105684. */
  105685. cameraRigMode: number;
  105686. /**
  105687. * Defines the distance between both "eyes" in case of a RIG
  105688. */
  105689. interaxialDistance: number;
  105690. /**
  105691. * Defines if stereoscopic rendering is done side by side or over under.
  105692. */
  105693. isStereoscopicSideBySide: boolean;
  105694. /**
  105695. * 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
  105696. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  105697. * else in the scene. (Eg. security camera)
  105698. *
  105699. * 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)
  105700. */
  105701. customRenderTargets: RenderTargetTexture[];
  105702. /**
  105703. * When set, the camera will render to this render target instead of the default canvas
  105704. *
  105705. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  105706. */
  105707. outputRenderTarget: Nullable<RenderTargetTexture>;
  105708. /**
  105709. * Observable triggered when the camera view matrix has changed.
  105710. */
  105711. onViewMatrixChangedObservable: Observable<Camera>;
  105712. /**
  105713. * Observable triggered when the camera Projection matrix has changed.
  105714. */
  105715. onProjectionMatrixChangedObservable: Observable<Camera>;
  105716. /**
  105717. * Observable triggered when the inputs have been processed.
  105718. */
  105719. onAfterCheckInputsObservable: Observable<Camera>;
  105720. /**
  105721. * Observable triggered when reset has been called and applied to the camera.
  105722. */
  105723. onRestoreStateObservable: Observable<Camera>;
  105724. /**
  105725. * Is this camera a part of a rig system?
  105726. */
  105727. isRigCamera: boolean;
  105728. /**
  105729. * If isRigCamera set to true this will be set with the parent camera.
  105730. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  105731. */
  105732. rigParent?: Camera;
  105733. /** @hidden */
  105734. _cameraRigParams: any;
  105735. /** @hidden */
  105736. _rigCameras: Camera[];
  105737. /** @hidden */
  105738. _rigPostProcess: Nullable<PostProcess>;
  105739. protected _webvrViewMatrix: Matrix;
  105740. /** @hidden */
  105741. _skipRendering: boolean;
  105742. /** @hidden */
  105743. _projectionMatrix: Matrix;
  105744. /** @hidden */
  105745. _postProcesses: Nullable<PostProcess>[];
  105746. /** @hidden */
  105747. _activeMeshes: SmartArray<AbstractMesh>;
  105748. protected _globalPosition: Vector3;
  105749. /** @hidden */
  105750. _computedViewMatrix: Matrix;
  105751. private _doNotComputeProjectionMatrix;
  105752. private _transformMatrix;
  105753. private _frustumPlanes;
  105754. private _refreshFrustumPlanes;
  105755. private _storedFov;
  105756. private _stateStored;
  105757. /**
  105758. * Instantiates a new camera object.
  105759. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  105760. * @see http://doc.babylonjs.com/features/cameras
  105761. * @param name Defines the name of the camera in the scene
  105762. * @param position Defines the position of the camera
  105763. * @param scene Defines the scene the camera belongs too
  105764. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  105765. */
  105766. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105767. /**
  105768. * Store current camera state (fov, position, etc..)
  105769. * @returns the camera
  105770. */
  105771. storeState(): Camera;
  105772. /**
  105773. * Restores the camera state values if it has been stored. You must call storeState() first
  105774. */
  105775. protected _restoreStateValues(): boolean;
  105776. /**
  105777. * Restored camera state. You must call storeState() first.
  105778. * @returns true if restored and false otherwise
  105779. */
  105780. restoreState(): boolean;
  105781. /**
  105782. * Gets the class name of the camera.
  105783. * @returns the class name
  105784. */
  105785. getClassName(): string;
  105786. /** @hidden */
  105787. readonly _isCamera: boolean;
  105788. /**
  105789. * Gets a string representation of the camera useful for debug purpose.
  105790. * @param fullDetails Defines that a more verboe level of logging is required
  105791. * @returns the string representation
  105792. */
  105793. toString(fullDetails?: boolean): string;
  105794. /**
  105795. * Gets the current world space position of the camera.
  105796. */
  105797. get globalPosition(): Vector3;
  105798. /**
  105799. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  105800. * @returns the active meshe list
  105801. */
  105802. getActiveMeshes(): SmartArray<AbstractMesh>;
  105803. /**
  105804. * Check whether a mesh is part of the current active mesh list of the camera
  105805. * @param mesh Defines the mesh to check
  105806. * @returns true if active, false otherwise
  105807. */
  105808. isActiveMesh(mesh: Mesh): boolean;
  105809. /**
  105810. * Is this camera ready to be used/rendered
  105811. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  105812. * @return true if the camera is ready
  105813. */
  105814. isReady(completeCheck?: boolean): boolean;
  105815. /** @hidden */
  105816. _initCache(): void;
  105817. /** @hidden */
  105818. _updateCache(ignoreParentClass?: boolean): void;
  105819. /** @hidden */
  105820. _isSynchronized(): boolean;
  105821. /** @hidden */
  105822. _isSynchronizedViewMatrix(): boolean;
  105823. /** @hidden */
  105824. _isSynchronizedProjectionMatrix(): boolean;
  105825. /**
  105826. * Attach the input controls to a specific dom element to get the input from.
  105827. * @param element Defines the element the controls should be listened from
  105828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105829. */
  105830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105831. /**
  105832. * Detach the current controls from the specified dom element.
  105833. * @param element Defines the element to stop listening the inputs from
  105834. */
  105835. detachControl(element: HTMLElement): void;
  105836. /**
  105837. * Update the camera state according to the different inputs gathered during the frame.
  105838. */
  105839. update(): void;
  105840. /** @hidden */
  105841. _checkInputs(): void;
  105842. /** @hidden */
  105843. get rigCameras(): Camera[];
  105844. /**
  105845. * Gets the post process used by the rig cameras
  105846. */
  105847. get rigPostProcess(): Nullable<PostProcess>;
  105848. /**
  105849. * Internal, gets the first post proces.
  105850. * @returns the first post process to be run on this camera.
  105851. */
  105852. _getFirstPostProcess(): Nullable<PostProcess>;
  105853. private _cascadePostProcessesToRigCams;
  105854. /**
  105855. * Attach a post process to the camera.
  105856. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105857. * @param postProcess The post process to attach to the camera
  105858. * @param insertAt The position of the post process in case several of them are in use in the scene
  105859. * @returns the position the post process has been inserted at
  105860. */
  105861. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  105862. /**
  105863. * Detach a post process to the camera.
  105864. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105865. * @param postProcess The post process to detach from the camera
  105866. */
  105867. detachPostProcess(postProcess: PostProcess): void;
  105868. /**
  105869. * Gets the current world matrix of the camera
  105870. */
  105871. getWorldMatrix(): Matrix;
  105872. /** @hidden */
  105873. _getViewMatrix(): Matrix;
  105874. /**
  105875. * Gets the current view matrix of the camera.
  105876. * @param force forces the camera to recompute the matrix without looking at the cached state
  105877. * @returns the view matrix
  105878. */
  105879. getViewMatrix(force?: boolean): Matrix;
  105880. /**
  105881. * Freeze the projection matrix.
  105882. * It will prevent the cache check of the camera projection compute and can speed up perf
  105883. * if no parameter of the camera are meant to change
  105884. * @param projection Defines manually a projection if necessary
  105885. */
  105886. freezeProjectionMatrix(projection?: Matrix): void;
  105887. /**
  105888. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  105889. */
  105890. unfreezeProjectionMatrix(): void;
  105891. /**
  105892. * Gets the current projection matrix of the camera.
  105893. * @param force forces the camera to recompute the matrix without looking at the cached state
  105894. * @returns the projection matrix
  105895. */
  105896. getProjectionMatrix(force?: boolean): Matrix;
  105897. /**
  105898. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  105899. * @returns a Matrix
  105900. */
  105901. getTransformationMatrix(): Matrix;
  105902. private _updateFrustumPlanes;
  105903. /**
  105904. * Checks if a cullable object (mesh...) is in the camera frustum
  105905. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  105906. * @param target The object to check
  105907. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  105908. * @returns true if the object is in frustum otherwise false
  105909. */
  105910. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  105911. /**
  105912. * Checks if a cullable object (mesh...) is in the camera frustum
  105913. * Unlike isInFrustum this cheks the full bounding box
  105914. * @param target The object to check
  105915. * @returns true if the object is in frustum otherwise false
  105916. */
  105917. isCompletelyInFrustum(target: ICullable): boolean;
  105918. /**
  105919. * Gets a ray in the forward direction from the camera.
  105920. * @param length Defines the length of the ray to create
  105921. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  105922. * @param origin Defines the start point of the ray which defaults to the camera position
  105923. * @returns the forward ray
  105924. */
  105925. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  105926. /**
  105927. * Releases resources associated with this node.
  105928. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105929. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105930. */
  105931. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105932. /** @hidden */
  105933. _isLeftCamera: boolean;
  105934. /**
  105935. * Gets the left camera of a rig setup in case of Rigged Camera
  105936. */
  105937. get isLeftCamera(): boolean;
  105938. /** @hidden */
  105939. _isRightCamera: boolean;
  105940. /**
  105941. * Gets the right camera of a rig setup in case of Rigged Camera
  105942. */
  105943. get isRightCamera(): boolean;
  105944. /**
  105945. * Gets the left camera of a rig setup in case of Rigged Camera
  105946. */
  105947. get leftCamera(): Nullable<FreeCamera>;
  105948. /**
  105949. * Gets the right camera of a rig setup in case of Rigged Camera
  105950. */
  105951. get rightCamera(): Nullable<FreeCamera>;
  105952. /**
  105953. * Gets the left camera target of a rig setup in case of Rigged Camera
  105954. * @returns the target position
  105955. */
  105956. getLeftTarget(): Nullable<Vector3>;
  105957. /**
  105958. * Gets the right camera target of a rig setup in case of Rigged Camera
  105959. * @returns the target position
  105960. */
  105961. getRightTarget(): Nullable<Vector3>;
  105962. /**
  105963. * @hidden
  105964. */
  105965. setCameraRigMode(mode: number, rigParams: any): void;
  105966. /** @hidden */
  105967. static _setStereoscopicRigMode(camera: Camera): void;
  105968. /** @hidden */
  105969. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  105970. /** @hidden */
  105971. static _setVRRigMode(camera: Camera, rigParams: any): void;
  105972. /** @hidden */
  105973. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  105974. /** @hidden */
  105975. _getVRProjectionMatrix(): Matrix;
  105976. protected _updateCameraRotationMatrix(): void;
  105977. protected _updateWebVRCameraRotationMatrix(): void;
  105978. /**
  105979. * This function MUST be overwritten by the different WebVR cameras available.
  105980. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  105981. * @hidden
  105982. */
  105983. _getWebVRProjectionMatrix(): Matrix;
  105984. /**
  105985. * This function MUST be overwritten by the different WebVR cameras available.
  105986. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  105987. * @hidden
  105988. */
  105989. _getWebVRViewMatrix(): Matrix;
  105990. /** @hidden */
  105991. setCameraRigParameter(name: string, value: any): void;
  105992. /**
  105993. * needs to be overridden by children so sub has required properties to be copied
  105994. * @hidden
  105995. */
  105996. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  105997. /**
  105998. * May need to be overridden by children
  105999. * @hidden
  106000. */
  106001. _updateRigCameras(): void;
  106002. /** @hidden */
  106003. _setupInputs(): void;
  106004. /**
  106005. * Serialiaze the camera setup to a json represention
  106006. * @returns the JSON representation
  106007. */
  106008. serialize(): any;
  106009. /**
  106010. * Clones the current camera.
  106011. * @param name The cloned camera name
  106012. * @returns the cloned camera
  106013. */
  106014. clone(name: string): Camera;
  106015. /**
  106016. * Gets the direction of the camera relative to a given local axis.
  106017. * @param localAxis Defines the reference axis to provide a relative direction.
  106018. * @return the direction
  106019. */
  106020. getDirection(localAxis: Vector3): Vector3;
  106021. /**
  106022. * Returns the current camera absolute rotation
  106023. */
  106024. get absoluteRotation(): Quaternion;
  106025. /**
  106026. * Gets the direction of the camera relative to a given local axis into a passed vector.
  106027. * @param localAxis Defines the reference axis to provide a relative direction.
  106028. * @param result Defines the vector to store the result in
  106029. */
  106030. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  106031. /**
  106032. * Gets a camera constructor for a given camera type
  106033. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  106034. * @param name The name of the camera the result will be able to instantiate
  106035. * @param scene The scene the result will construct the camera in
  106036. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  106037. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  106038. * @returns a factory method to construc the camera
  106039. */
  106040. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  106041. /**
  106042. * Compute the world matrix of the camera.
  106043. * @returns the camera world matrix
  106044. */
  106045. computeWorldMatrix(): Matrix;
  106046. /**
  106047. * Parse a JSON and creates the camera from the parsed information
  106048. * @param parsedCamera The JSON to parse
  106049. * @param scene The scene to instantiate the camera in
  106050. * @returns the newly constructed camera
  106051. */
  106052. static Parse(parsedCamera: any, scene: Scene): Camera;
  106053. }
  106054. }
  106055. declare module BABYLON {
  106056. /**
  106057. * Class containing static functions to help procedurally build meshes
  106058. */
  106059. export class DiscBuilder {
  106060. /**
  106061. * Creates a plane polygonal mesh. By default, this is a disc
  106062. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106063. * * 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
  106064. * * 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
  106065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106068. * @param name defines the name of the mesh
  106069. * @param options defines the options used to create the mesh
  106070. * @param scene defines the hosting scene
  106071. * @returns the plane polygonal mesh
  106072. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106073. */
  106074. static CreateDisc(name: string, options: {
  106075. radius?: number;
  106076. tessellation?: number;
  106077. arc?: number;
  106078. updatable?: boolean;
  106079. sideOrientation?: number;
  106080. frontUVs?: Vector4;
  106081. backUVs?: Vector4;
  106082. }, scene?: Nullable<Scene>): Mesh;
  106083. }
  106084. }
  106085. declare module BABYLON {
  106086. /**
  106087. * Options to be used when creating a FresnelParameters.
  106088. */
  106089. export type IFresnelParametersCreationOptions = {
  106090. /**
  106091. * Define the color used on edges (grazing angle)
  106092. */
  106093. leftColor?: Color3;
  106094. /**
  106095. * Define the color used on center
  106096. */
  106097. rightColor?: Color3;
  106098. /**
  106099. * Define bias applied to computed fresnel term
  106100. */
  106101. bias?: number;
  106102. /**
  106103. * Defined the power exponent applied to fresnel term
  106104. */
  106105. power?: number;
  106106. /**
  106107. * Define if the fresnel effect is enable or not.
  106108. */
  106109. isEnabled?: boolean;
  106110. };
  106111. /**
  106112. * Serialized format for FresnelParameters.
  106113. */
  106114. export type IFresnelParametersSerialized = {
  106115. /**
  106116. * Define the color used on edges (grazing angle) [as an array]
  106117. */
  106118. leftColor: number[];
  106119. /**
  106120. * Define the color used on center [as an array]
  106121. */
  106122. rightColor: number[];
  106123. /**
  106124. * Define bias applied to computed fresnel term
  106125. */
  106126. bias: number;
  106127. /**
  106128. * Defined the power exponent applied to fresnel term
  106129. */
  106130. power?: number;
  106131. /**
  106132. * Define if the fresnel effect is enable or not.
  106133. */
  106134. isEnabled: boolean;
  106135. };
  106136. /**
  106137. * This represents all the required information to add a fresnel effect on a material:
  106138. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106139. */
  106140. export class FresnelParameters {
  106141. private _isEnabled;
  106142. /**
  106143. * Define if the fresnel effect is enable or not.
  106144. */
  106145. get isEnabled(): boolean;
  106146. set isEnabled(value: boolean);
  106147. /**
  106148. * Define the color used on edges (grazing angle)
  106149. */
  106150. leftColor: Color3;
  106151. /**
  106152. * Define the color used on center
  106153. */
  106154. rightColor: Color3;
  106155. /**
  106156. * Define bias applied to computed fresnel term
  106157. */
  106158. bias: number;
  106159. /**
  106160. * Defined the power exponent applied to fresnel term
  106161. */
  106162. power: number;
  106163. /**
  106164. * Creates a new FresnelParameters object.
  106165. *
  106166. * @param options provide your own settings to optionally to override defaults
  106167. */
  106168. constructor(options?: IFresnelParametersCreationOptions);
  106169. /**
  106170. * Clones the current fresnel and its valuues
  106171. * @returns a clone fresnel configuration
  106172. */
  106173. clone(): FresnelParameters;
  106174. /**
  106175. * Determines equality between FresnelParameters objects
  106176. * @param otherFresnelParameters defines the second operand
  106177. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  106178. */
  106179. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  106180. /**
  106181. * Serializes the current fresnel parameters to a JSON representation.
  106182. * @return the JSON serialization
  106183. */
  106184. serialize(): IFresnelParametersSerialized;
  106185. /**
  106186. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  106187. * @param parsedFresnelParameters Define the JSON representation
  106188. * @returns the parsed parameters
  106189. */
  106190. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  106191. }
  106192. }
  106193. declare module BABYLON {
  106194. /**
  106195. * This groups all the flags used to control the materials channel.
  106196. */
  106197. export class MaterialFlags {
  106198. private static _DiffuseTextureEnabled;
  106199. /**
  106200. * Are diffuse textures enabled in the application.
  106201. */
  106202. static get DiffuseTextureEnabled(): boolean;
  106203. static set DiffuseTextureEnabled(value: boolean);
  106204. private static _AmbientTextureEnabled;
  106205. /**
  106206. * Are ambient textures enabled in the application.
  106207. */
  106208. static get AmbientTextureEnabled(): boolean;
  106209. static set AmbientTextureEnabled(value: boolean);
  106210. private static _OpacityTextureEnabled;
  106211. /**
  106212. * Are opacity textures enabled in the application.
  106213. */
  106214. static get OpacityTextureEnabled(): boolean;
  106215. static set OpacityTextureEnabled(value: boolean);
  106216. private static _ReflectionTextureEnabled;
  106217. /**
  106218. * Are reflection textures enabled in the application.
  106219. */
  106220. static get ReflectionTextureEnabled(): boolean;
  106221. static set ReflectionTextureEnabled(value: boolean);
  106222. private static _EmissiveTextureEnabled;
  106223. /**
  106224. * Are emissive textures enabled in the application.
  106225. */
  106226. static get EmissiveTextureEnabled(): boolean;
  106227. static set EmissiveTextureEnabled(value: boolean);
  106228. private static _SpecularTextureEnabled;
  106229. /**
  106230. * Are specular textures enabled in the application.
  106231. */
  106232. static get SpecularTextureEnabled(): boolean;
  106233. static set SpecularTextureEnabled(value: boolean);
  106234. private static _BumpTextureEnabled;
  106235. /**
  106236. * Are bump textures enabled in the application.
  106237. */
  106238. static get BumpTextureEnabled(): boolean;
  106239. static set BumpTextureEnabled(value: boolean);
  106240. private static _LightmapTextureEnabled;
  106241. /**
  106242. * Are lightmap textures enabled in the application.
  106243. */
  106244. static get LightmapTextureEnabled(): boolean;
  106245. static set LightmapTextureEnabled(value: boolean);
  106246. private static _RefractionTextureEnabled;
  106247. /**
  106248. * Are refraction textures enabled in the application.
  106249. */
  106250. static get RefractionTextureEnabled(): boolean;
  106251. static set RefractionTextureEnabled(value: boolean);
  106252. private static _ColorGradingTextureEnabled;
  106253. /**
  106254. * Are color grading textures enabled in the application.
  106255. */
  106256. static get ColorGradingTextureEnabled(): boolean;
  106257. static set ColorGradingTextureEnabled(value: boolean);
  106258. private static _FresnelEnabled;
  106259. /**
  106260. * Are fresnels enabled in the application.
  106261. */
  106262. static get FresnelEnabled(): boolean;
  106263. static set FresnelEnabled(value: boolean);
  106264. private static _ClearCoatTextureEnabled;
  106265. /**
  106266. * Are clear coat textures enabled in the application.
  106267. */
  106268. static get ClearCoatTextureEnabled(): boolean;
  106269. static set ClearCoatTextureEnabled(value: boolean);
  106270. private static _ClearCoatBumpTextureEnabled;
  106271. /**
  106272. * Are clear coat bump textures enabled in the application.
  106273. */
  106274. static get ClearCoatBumpTextureEnabled(): boolean;
  106275. static set ClearCoatBumpTextureEnabled(value: boolean);
  106276. private static _ClearCoatTintTextureEnabled;
  106277. /**
  106278. * Are clear coat tint textures enabled in the application.
  106279. */
  106280. static get ClearCoatTintTextureEnabled(): boolean;
  106281. static set ClearCoatTintTextureEnabled(value: boolean);
  106282. private static _SheenTextureEnabled;
  106283. /**
  106284. * Are sheen textures enabled in the application.
  106285. */
  106286. static get SheenTextureEnabled(): boolean;
  106287. static set SheenTextureEnabled(value: boolean);
  106288. private static _AnisotropicTextureEnabled;
  106289. /**
  106290. * Are anisotropic textures enabled in the application.
  106291. */
  106292. static get AnisotropicTextureEnabled(): boolean;
  106293. static set AnisotropicTextureEnabled(value: boolean);
  106294. private static _ThicknessTextureEnabled;
  106295. /**
  106296. * Are thickness textures enabled in the application.
  106297. */
  106298. static get ThicknessTextureEnabled(): boolean;
  106299. static set ThicknessTextureEnabled(value: boolean);
  106300. }
  106301. }
  106302. declare module BABYLON {
  106303. /** @hidden */
  106304. export var defaultFragmentDeclaration: {
  106305. name: string;
  106306. shader: string;
  106307. };
  106308. }
  106309. declare module BABYLON {
  106310. /** @hidden */
  106311. export var defaultUboDeclaration: {
  106312. name: string;
  106313. shader: string;
  106314. };
  106315. }
  106316. declare module BABYLON {
  106317. /** @hidden */
  106318. export var lightFragmentDeclaration: {
  106319. name: string;
  106320. shader: string;
  106321. };
  106322. }
  106323. declare module BABYLON {
  106324. /** @hidden */
  106325. export var lightUboDeclaration: {
  106326. name: string;
  106327. shader: string;
  106328. };
  106329. }
  106330. declare module BABYLON {
  106331. /** @hidden */
  106332. export var lightsFragmentFunctions: {
  106333. name: string;
  106334. shader: string;
  106335. };
  106336. }
  106337. declare module BABYLON {
  106338. /** @hidden */
  106339. export var shadowsFragmentFunctions: {
  106340. name: string;
  106341. shader: string;
  106342. };
  106343. }
  106344. declare module BABYLON {
  106345. /** @hidden */
  106346. export var fresnelFunction: {
  106347. name: string;
  106348. shader: string;
  106349. };
  106350. }
  106351. declare module BABYLON {
  106352. /** @hidden */
  106353. export var bumpFragmentMainFunctions: {
  106354. name: string;
  106355. shader: string;
  106356. };
  106357. }
  106358. declare module BABYLON {
  106359. /** @hidden */
  106360. export var bumpFragmentFunctions: {
  106361. name: string;
  106362. shader: string;
  106363. };
  106364. }
  106365. declare module BABYLON {
  106366. /** @hidden */
  106367. export var logDepthDeclaration: {
  106368. name: string;
  106369. shader: string;
  106370. };
  106371. }
  106372. declare module BABYLON {
  106373. /** @hidden */
  106374. export var bumpFragment: {
  106375. name: string;
  106376. shader: string;
  106377. };
  106378. }
  106379. declare module BABYLON {
  106380. /** @hidden */
  106381. export var depthPrePass: {
  106382. name: string;
  106383. shader: string;
  106384. };
  106385. }
  106386. declare module BABYLON {
  106387. /** @hidden */
  106388. export var lightFragment: {
  106389. name: string;
  106390. shader: string;
  106391. };
  106392. }
  106393. declare module BABYLON {
  106394. /** @hidden */
  106395. export var logDepthFragment: {
  106396. name: string;
  106397. shader: string;
  106398. };
  106399. }
  106400. declare module BABYLON {
  106401. /** @hidden */
  106402. export var defaultPixelShader: {
  106403. name: string;
  106404. shader: string;
  106405. };
  106406. }
  106407. declare module BABYLON {
  106408. /** @hidden */
  106409. export var defaultVertexDeclaration: {
  106410. name: string;
  106411. shader: string;
  106412. };
  106413. }
  106414. declare module BABYLON {
  106415. /** @hidden */
  106416. export var bumpVertexDeclaration: {
  106417. name: string;
  106418. shader: string;
  106419. };
  106420. }
  106421. declare module BABYLON {
  106422. /** @hidden */
  106423. export var bumpVertex: {
  106424. name: string;
  106425. shader: string;
  106426. };
  106427. }
  106428. declare module BABYLON {
  106429. /** @hidden */
  106430. export var fogVertex: {
  106431. name: string;
  106432. shader: string;
  106433. };
  106434. }
  106435. declare module BABYLON {
  106436. /** @hidden */
  106437. export var shadowsVertex: {
  106438. name: string;
  106439. shader: string;
  106440. };
  106441. }
  106442. declare module BABYLON {
  106443. /** @hidden */
  106444. export var pointCloudVertex: {
  106445. name: string;
  106446. shader: string;
  106447. };
  106448. }
  106449. declare module BABYLON {
  106450. /** @hidden */
  106451. export var logDepthVertex: {
  106452. name: string;
  106453. shader: string;
  106454. };
  106455. }
  106456. declare module BABYLON {
  106457. /** @hidden */
  106458. export var defaultVertexShader: {
  106459. name: string;
  106460. shader: string;
  106461. };
  106462. }
  106463. declare module BABYLON {
  106464. /** @hidden */
  106465. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106466. MAINUV1: boolean;
  106467. MAINUV2: boolean;
  106468. DIFFUSE: boolean;
  106469. DIFFUSEDIRECTUV: number;
  106470. AMBIENT: boolean;
  106471. AMBIENTDIRECTUV: number;
  106472. OPACITY: boolean;
  106473. OPACITYDIRECTUV: number;
  106474. OPACITYRGB: boolean;
  106475. REFLECTION: boolean;
  106476. EMISSIVE: boolean;
  106477. EMISSIVEDIRECTUV: number;
  106478. SPECULAR: boolean;
  106479. SPECULARDIRECTUV: number;
  106480. BUMP: boolean;
  106481. BUMPDIRECTUV: number;
  106482. PARALLAX: boolean;
  106483. PARALLAXOCCLUSION: boolean;
  106484. SPECULAROVERALPHA: boolean;
  106485. CLIPPLANE: boolean;
  106486. CLIPPLANE2: boolean;
  106487. CLIPPLANE3: boolean;
  106488. CLIPPLANE4: boolean;
  106489. CLIPPLANE5: boolean;
  106490. CLIPPLANE6: boolean;
  106491. ALPHATEST: boolean;
  106492. DEPTHPREPASS: boolean;
  106493. ALPHAFROMDIFFUSE: boolean;
  106494. POINTSIZE: boolean;
  106495. FOG: boolean;
  106496. SPECULARTERM: boolean;
  106497. DIFFUSEFRESNEL: boolean;
  106498. OPACITYFRESNEL: boolean;
  106499. REFLECTIONFRESNEL: boolean;
  106500. REFRACTIONFRESNEL: boolean;
  106501. EMISSIVEFRESNEL: boolean;
  106502. FRESNEL: boolean;
  106503. NORMAL: boolean;
  106504. UV1: boolean;
  106505. UV2: boolean;
  106506. VERTEXCOLOR: boolean;
  106507. VERTEXALPHA: boolean;
  106508. NUM_BONE_INFLUENCERS: number;
  106509. BonesPerMesh: number;
  106510. BONETEXTURE: boolean;
  106511. INSTANCES: boolean;
  106512. THIN_INSTANCES: boolean;
  106513. GLOSSINESS: boolean;
  106514. ROUGHNESS: boolean;
  106515. EMISSIVEASILLUMINATION: boolean;
  106516. LINKEMISSIVEWITHDIFFUSE: boolean;
  106517. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106518. LIGHTMAP: boolean;
  106519. LIGHTMAPDIRECTUV: number;
  106520. OBJECTSPACE_NORMALMAP: boolean;
  106521. USELIGHTMAPASSHADOWMAP: boolean;
  106522. REFLECTIONMAP_3D: boolean;
  106523. REFLECTIONMAP_SPHERICAL: boolean;
  106524. REFLECTIONMAP_PLANAR: boolean;
  106525. REFLECTIONMAP_CUBIC: boolean;
  106526. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106527. REFLECTIONMAP_PROJECTION: boolean;
  106528. REFLECTIONMAP_SKYBOX: boolean;
  106529. REFLECTIONMAP_EXPLICIT: boolean;
  106530. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106531. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106532. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106533. INVERTCUBICMAP: boolean;
  106534. LOGARITHMICDEPTH: boolean;
  106535. REFRACTION: boolean;
  106536. REFRACTIONMAP_3D: boolean;
  106537. REFLECTIONOVERALPHA: boolean;
  106538. TWOSIDEDLIGHTING: boolean;
  106539. SHADOWFLOAT: boolean;
  106540. MORPHTARGETS: boolean;
  106541. MORPHTARGETS_NORMAL: boolean;
  106542. MORPHTARGETS_TANGENT: boolean;
  106543. MORPHTARGETS_UV: boolean;
  106544. NUM_MORPH_INFLUENCERS: number;
  106545. NONUNIFORMSCALING: boolean;
  106546. PREMULTIPLYALPHA: boolean;
  106547. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  106548. ALPHABLEND: boolean;
  106549. RGBDLIGHTMAP: boolean;
  106550. RGBDREFLECTION: boolean;
  106551. RGBDREFRACTION: boolean;
  106552. IMAGEPROCESSING: boolean;
  106553. VIGNETTE: boolean;
  106554. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106555. VIGNETTEBLENDMODEOPAQUE: boolean;
  106556. TONEMAPPING: boolean;
  106557. TONEMAPPING_ACES: boolean;
  106558. CONTRAST: boolean;
  106559. COLORCURVES: boolean;
  106560. COLORGRADING: boolean;
  106561. COLORGRADING3D: boolean;
  106562. SAMPLER3DGREENDEPTH: boolean;
  106563. SAMPLER3DBGRMAP: boolean;
  106564. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106565. MULTIVIEW: boolean;
  106566. /**
  106567. * If the reflection texture on this material is in linear color space
  106568. * @hidden
  106569. */
  106570. IS_REFLECTION_LINEAR: boolean;
  106571. /**
  106572. * If the refraction texture on this material is in linear color space
  106573. * @hidden
  106574. */
  106575. IS_REFRACTION_LINEAR: boolean;
  106576. EXPOSURE: boolean;
  106577. constructor();
  106578. setReflectionMode(modeToEnable: string): void;
  106579. }
  106580. /**
  106581. * This is the default material used in Babylon. It is the best trade off between quality
  106582. * and performances.
  106583. * @see http://doc.babylonjs.com/babylon101/materials
  106584. */
  106585. export class StandardMaterial extends PushMaterial {
  106586. private _diffuseTexture;
  106587. /**
  106588. * The basic texture of the material as viewed under a light.
  106589. */
  106590. diffuseTexture: Nullable<BaseTexture>;
  106591. private _ambientTexture;
  106592. /**
  106593. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106594. */
  106595. ambientTexture: Nullable<BaseTexture>;
  106596. private _opacityTexture;
  106597. /**
  106598. * Define the transparency of the material from a texture.
  106599. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106600. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106601. */
  106602. opacityTexture: Nullable<BaseTexture>;
  106603. private _reflectionTexture;
  106604. /**
  106605. * Define the texture used to display the reflection.
  106606. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106607. */
  106608. reflectionTexture: Nullable<BaseTexture>;
  106609. private _emissiveTexture;
  106610. /**
  106611. * Define texture of the material as if self lit.
  106612. * This will be mixed in the final result even in the absence of light.
  106613. */
  106614. emissiveTexture: Nullable<BaseTexture>;
  106615. private _specularTexture;
  106616. /**
  106617. * Define how the color and intensity of the highlight given by the light in the material.
  106618. */
  106619. specularTexture: Nullable<BaseTexture>;
  106620. private _bumpTexture;
  106621. /**
  106622. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106623. * 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.
  106624. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106625. */
  106626. bumpTexture: Nullable<BaseTexture>;
  106627. private _lightmapTexture;
  106628. /**
  106629. * Complex lighting can be computationally expensive to compute at runtime.
  106630. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106631. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106632. */
  106633. lightmapTexture: Nullable<BaseTexture>;
  106634. private _refractionTexture;
  106635. /**
  106636. * Define the texture used to display the refraction.
  106637. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106638. */
  106639. refractionTexture: Nullable<BaseTexture>;
  106640. /**
  106641. * The color of the material lit by the environmental background lighting.
  106642. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106643. */
  106644. ambientColor: Color3;
  106645. /**
  106646. * The basic color of the material as viewed under a light.
  106647. */
  106648. diffuseColor: Color3;
  106649. /**
  106650. * Define how the color and intensity of the highlight given by the light in the material.
  106651. */
  106652. specularColor: Color3;
  106653. /**
  106654. * Define the color of the material as if self lit.
  106655. * This will be mixed in the final result even in the absence of light.
  106656. */
  106657. emissiveColor: Color3;
  106658. /**
  106659. * Defines how sharp are the highlights in the material.
  106660. * The bigger the value the sharper giving a more glossy feeling to the result.
  106661. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106662. */
  106663. specularPower: number;
  106664. private _useAlphaFromDiffuseTexture;
  106665. /**
  106666. * Does the transparency come from the diffuse texture alpha channel.
  106667. */
  106668. useAlphaFromDiffuseTexture: boolean;
  106669. private _useEmissiveAsIllumination;
  106670. /**
  106671. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106672. */
  106673. useEmissiveAsIllumination: boolean;
  106674. private _linkEmissiveWithDiffuse;
  106675. /**
  106676. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106677. * the emissive level when the final color is close to one.
  106678. */
  106679. linkEmissiveWithDiffuse: boolean;
  106680. private _useSpecularOverAlpha;
  106681. /**
  106682. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106683. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106684. */
  106685. useSpecularOverAlpha: boolean;
  106686. private _useReflectionOverAlpha;
  106687. /**
  106688. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106689. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106690. */
  106691. useReflectionOverAlpha: boolean;
  106692. private _disableLighting;
  106693. /**
  106694. * Does lights from the scene impacts this material.
  106695. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106696. */
  106697. disableLighting: boolean;
  106698. private _useObjectSpaceNormalMap;
  106699. /**
  106700. * Allows using an object space normal map (instead of tangent space).
  106701. */
  106702. useObjectSpaceNormalMap: boolean;
  106703. private _useParallax;
  106704. /**
  106705. * Is parallax enabled or not.
  106706. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106707. */
  106708. useParallax: boolean;
  106709. private _useParallaxOcclusion;
  106710. /**
  106711. * Is parallax occlusion enabled or not.
  106712. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106713. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106714. */
  106715. useParallaxOcclusion: boolean;
  106716. /**
  106717. * 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.
  106718. */
  106719. parallaxScaleBias: number;
  106720. private _roughness;
  106721. /**
  106722. * Helps to define how blurry the reflections should appears in the material.
  106723. */
  106724. roughness: number;
  106725. /**
  106726. * In case of refraction, define the value of the index of refraction.
  106727. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106728. */
  106729. indexOfRefraction: number;
  106730. /**
  106731. * Invert the refraction texture alongside the y axis.
  106732. * It can be useful with procedural textures or probe for instance.
  106733. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106734. */
  106735. invertRefractionY: boolean;
  106736. /**
  106737. * Defines the alpha limits in alpha test mode.
  106738. */
  106739. alphaCutOff: number;
  106740. private _useLightmapAsShadowmap;
  106741. /**
  106742. * In case of light mapping, define whether the map contains light or shadow informations.
  106743. */
  106744. useLightmapAsShadowmap: boolean;
  106745. private _diffuseFresnelParameters;
  106746. /**
  106747. * Define the diffuse fresnel parameters of the material.
  106748. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106749. */
  106750. diffuseFresnelParameters: FresnelParameters;
  106751. private _opacityFresnelParameters;
  106752. /**
  106753. * Define the opacity fresnel parameters of the material.
  106754. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106755. */
  106756. opacityFresnelParameters: FresnelParameters;
  106757. private _reflectionFresnelParameters;
  106758. /**
  106759. * Define the reflection fresnel parameters of the material.
  106760. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106761. */
  106762. reflectionFresnelParameters: FresnelParameters;
  106763. private _refractionFresnelParameters;
  106764. /**
  106765. * Define the refraction fresnel parameters of the material.
  106766. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106767. */
  106768. refractionFresnelParameters: FresnelParameters;
  106769. private _emissiveFresnelParameters;
  106770. /**
  106771. * Define the emissive fresnel parameters of the material.
  106772. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106773. */
  106774. emissiveFresnelParameters: FresnelParameters;
  106775. private _useReflectionFresnelFromSpecular;
  106776. /**
  106777. * If true automatically deducts the fresnels values from the material specularity.
  106778. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106779. */
  106780. useReflectionFresnelFromSpecular: boolean;
  106781. private _useGlossinessFromSpecularMapAlpha;
  106782. /**
  106783. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106784. */
  106785. useGlossinessFromSpecularMapAlpha: boolean;
  106786. private _maxSimultaneousLights;
  106787. /**
  106788. * Defines the maximum number of lights that can be used in the material
  106789. */
  106790. maxSimultaneousLights: number;
  106791. private _invertNormalMapX;
  106792. /**
  106793. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106794. */
  106795. invertNormalMapX: boolean;
  106796. private _invertNormalMapY;
  106797. /**
  106798. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106799. */
  106800. invertNormalMapY: boolean;
  106801. private _twoSidedLighting;
  106802. /**
  106803. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106804. */
  106805. twoSidedLighting: boolean;
  106806. /**
  106807. * Default configuration related to image processing available in the standard Material.
  106808. */
  106809. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106810. /**
  106811. * Gets the image processing configuration used either in this material.
  106812. */
  106813. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  106814. /**
  106815. * Sets the Default image processing configuration used either in the this material.
  106816. *
  106817. * If sets to null, the scene one is in use.
  106818. */
  106819. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  106820. /**
  106821. * Keep track of the image processing observer to allow dispose and replace.
  106822. */
  106823. private _imageProcessingObserver;
  106824. /**
  106825. * Attaches a new image processing configuration to the Standard Material.
  106826. * @param configuration
  106827. */
  106828. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106829. /**
  106830. * Gets wether the color curves effect is enabled.
  106831. */
  106832. get cameraColorCurvesEnabled(): boolean;
  106833. /**
  106834. * Sets wether the color curves effect is enabled.
  106835. */
  106836. set cameraColorCurvesEnabled(value: boolean);
  106837. /**
  106838. * Gets wether the color grading effect is enabled.
  106839. */
  106840. get cameraColorGradingEnabled(): boolean;
  106841. /**
  106842. * Gets wether the color grading effect is enabled.
  106843. */
  106844. set cameraColorGradingEnabled(value: boolean);
  106845. /**
  106846. * Gets wether tonemapping is enabled or not.
  106847. */
  106848. get cameraToneMappingEnabled(): boolean;
  106849. /**
  106850. * Sets wether tonemapping is enabled or not
  106851. */
  106852. set cameraToneMappingEnabled(value: boolean);
  106853. /**
  106854. * The camera exposure used on this material.
  106855. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106856. * This corresponds to a photographic exposure.
  106857. */
  106858. get cameraExposure(): number;
  106859. /**
  106860. * The camera exposure used on this material.
  106861. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106862. * This corresponds to a photographic exposure.
  106863. */
  106864. set cameraExposure(value: number);
  106865. /**
  106866. * Gets The camera contrast used on this material.
  106867. */
  106868. get cameraContrast(): number;
  106869. /**
  106870. * Sets The camera contrast used on this material.
  106871. */
  106872. set cameraContrast(value: number);
  106873. /**
  106874. * Gets the Color Grading 2D Lookup Texture.
  106875. */
  106876. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  106877. /**
  106878. * Sets the Color Grading 2D Lookup Texture.
  106879. */
  106880. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  106881. /**
  106882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106884. * 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;
  106885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106886. */
  106887. get cameraColorCurves(): Nullable<ColorCurves>;
  106888. /**
  106889. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106890. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106891. * 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;
  106892. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106893. */
  106894. set cameraColorCurves(value: Nullable<ColorCurves>);
  106895. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106896. protected _worldViewProjectionMatrix: Matrix;
  106897. protected _globalAmbientColor: Color3;
  106898. protected _useLogarithmicDepth: boolean;
  106899. protected _rebuildInParallel: boolean;
  106900. /**
  106901. * Instantiates a new standard material.
  106902. * This is the default material used in Babylon. It is the best trade off between quality
  106903. * and performances.
  106904. * @see http://doc.babylonjs.com/babylon101/materials
  106905. * @param name Define the name of the material in the scene
  106906. * @param scene Define the scene the material belong to
  106907. */
  106908. constructor(name: string, scene: Scene);
  106909. /**
  106910. * Gets a boolean indicating that current material needs to register RTT
  106911. */
  106912. get hasRenderTargetTextures(): boolean;
  106913. /**
  106914. * Gets the current class name of the material e.g. "StandardMaterial"
  106915. * Mainly use in serialization.
  106916. * @returns the class name
  106917. */
  106918. getClassName(): string;
  106919. /**
  106920. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106921. * You can try switching to logarithmic depth.
  106922. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106923. */
  106924. get useLogarithmicDepth(): boolean;
  106925. set useLogarithmicDepth(value: boolean);
  106926. /**
  106927. * Specifies if the material will require alpha blending
  106928. * @returns a boolean specifying if alpha blending is needed
  106929. */
  106930. needAlphaBlending(): boolean;
  106931. /**
  106932. * Specifies if this material should be rendered in alpha test mode
  106933. * @returns a boolean specifying if an alpha test is needed.
  106934. */
  106935. needAlphaTesting(): boolean;
  106936. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106937. /**
  106938. * Get the texture used for alpha test purpose.
  106939. * @returns the diffuse texture in case of the standard material.
  106940. */
  106941. getAlphaTestTexture(): Nullable<BaseTexture>;
  106942. /**
  106943. * Get if the submesh is ready to be used and all its information available.
  106944. * Child classes can use it to update shaders
  106945. * @param mesh defines the mesh to check
  106946. * @param subMesh defines which submesh to check
  106947. * @param useInstances specifies that instances should be used
  106948. * @returns a boolean indicating that the submesh is ready or not
  106949. */
  106950. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106951. /**
  106952. * Builds the material UBO layouts.
  106953. * Used internally during the effect preparation.
  106954. */
  106955. buildUniformLayout(): void;
  106956. /**
  106957. * Unbinds the material from the mesh
  106958. */
  106959. unbind(): void;
  106960. /**
  106961. * Binds the submesh to this material by preparing the effect and shader to draw
  106962. * @param world defines the world transformation matrix
  106963. * @param mesh defines the mesh containing the submesh
  106964. * @param subMesh defines the submesh to bind the material to
  106965. */
  106966. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106967. /**
  106968. * Get the list of animatables in the material.
  106969. * @returns the list of animatables object used in the material
  106970. */
  106971. getAnimatables(): IAnimatable[];
  106972. /**
  106973. * Gets the active textures from the material
  106974. * @returns an array of textures
  106975. */
  106976. getActiveTextures(): BaseTexture[];
  106977. /**
  106978. * Specifies if the material uses a texture
  106979. * @param texture defines the texture to check against the material
  106980. * @returns a boolean specifying if the material uses the texture
  106981. */
  106982. hasTexture(texture: BaseTexture): boolean;
  106983. /**
  106984. * Disposes the material
  106985. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106986. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106987. */
  106988. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106989. /**
  106990. * Makes a duplicate of the material, and gives it a new name
  106991. * @param name defines the new name for the duplicated material
  106992. * @returns the cloned material
  106993. */
  106994. clone(name: string): StandardMaterial;
  106995. /**
  106996. * Serializes this material in a JSON representation
  106997. * @returns the serialized material object
  106998. */
  106999. serialize(): any;
  107000. /**
  107001. * Creates a standard material from parsed material data
  107002. * @param source defines the JSON representation of the material
  107003. * @param scene defines the hosting scene
  107004. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107005. * @returns a new standard material
  107006. */
  107007. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107008. /**
  107009. * Are diffuse textures enabled in the application.
  107010. */
  107011. static get DiffuseTextureEnabled(): boolean;
  107012. static set DiffuseTextureEnabled(value: boolean);
  107013. /**
  107014. * Are ambient textures enabled in the application.
  107015. */
  107016. static get AmbientTextureEnabled(): boolean;
  107017. static set AmbientTextureEnabled(value: boolean);
  107018. /**
  107019. * Are opacity textures enabled in the application.
  107020. */
  107021. static get OpacityTextureEnabled(): boolean;
  107022. static set OpacityTextureEnabled(value: boolean);
  107023. /**
  107024. * Are reflection textures enabled in the application.
  107025. */
  107026. static get ReflectionTextureEnabled(): boolean;
  107027. static set ReflectionTextureEnabled(value: boolean);
  107028. /**
  107029. * Are emissive textures enabled in the application.
  107030. */
  107031. static get EmissiveTextureEnabled(): boolean;
  107032. static set EmissiveTextureEnabled(value: boolean);
  107033. /**
  107034. * Are specular textures enabled in the application.
  107035. */
  107036. static get SpecularTextureEnabled(): boolean;
  107037. static set SpecularTextureEnabled(value: boolean);
  107038. /**
  107039. * Are bump textures enabled in the application.
  107040. */
  107041. static get BumpTextureEnabled(): boolean;
  107042. static set BumpTextureEnabled(value: boolean);
  107043. /**
  107044. * Are lightmap textures enabled in the application.
  107045. */
  107046. static get LightmapTextureEnabled(): boolean;
  107047. static set LightmapTextureEnabled(value: boolean);
  107048. /**
  107049. * Are refraction textures enabled in the application.
  107050. */
  107051. static get RefractionTextureEnabled(): boolean;
  107052. static set RefractionTextureEnabled(value: boolean);
  107053. /**
  107054. * Are color grading textures enabled in the application.
  107055. */
  107056. static get ColorGradingTextureEnabled(): boolean;
  107057. static set ColorGradingTextureEnabled(value: boolean);
  107058. /**
  107059. * Are fresnels enabled in the application.
  107060. */
  107061. static get FresnelEnabled(): boolean;
  107062. static set FresnelEnabled(value: boolean);
  107063. }
  107064. }
  107065. declare module BABYLON {
  107066. /**
  107067. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107068. *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.
  107069. * The SPS is also a particle system. It provides some methods to manage the particles.
  107070. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107071. *
  107072. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  107073. */
  107074. export class SolidParticleSystem implements IDisposable {
  107075. /**
  107076. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107077. * Example : var p = SPS.particles[i];
  107078. */
  107079. particles: SolidParticle[];
  107080. /**
  107081. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107082. */
  107083. nbParticles: number;
  107084. /**
  107085. * If the particles must ever face the camera (default false). Useful for planar particles.
  107086. */
  107087. billboard: boolean;
  107088. /**
  107089. * Recompute normals when adding a shape
  107090. */
  107091. recomputeNormals: boolean;
  107092. /**
  107093. * This a counter ofr your own usage. It's not set by any SPS functions.
  107094. */
  107095. counter: number;
  107096. /**
  107097. * The SPS name. This name is also given to the underlying mesh.
  107098. */
  107099. name: string;
  107100. /**
  107101. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  107102. */
  107103. mesh: Mesh;
  107104. /**
  107105. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107106. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  107107. */
  107108. vars: any;
  107109. /**
  107110. * This array is populated when the SPS is set as 'pickable'.
  107111. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  107112. * Each element of this array is an object `{idx: int, faceId: int}`.
  107113. * `idx` is the picked particle index in the `SPS.particles` array
  107114. * `faceId` is the picked face index counted within this particle.
  107115. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  107116. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  107117. * Use the method SPS.pickedParticle(pickingInfo) instead.
  107118. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107119. */
  107120. pickedParticles: {
  107121. idx: number;
  107122. faceId: number;
  107123. }[];
  107124. /**
  107125. * This array is populated when the SPS is set as 'pickable'
  107126. * Each key of this array is a submesh index.
  107127. * Each element of this array is a second array defined like this :
  107128. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  107129. * Each element of this second array is an object `{idx: int, faceId: int}`.
  107130. * `idx` is the picked particle index in the `SPS.particles` array
  107131. * `faceId` is the picked face index counted within this particle.
  107132. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  107133. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107134. */
  107135. pickedBySubMesh: {
  107136. idx: number;
  107137. faceId: number;
  107138. }[][];
  107139. /**
  107140. * This array is populated when `enableDepthSort` is set to true.
  107141. * Each element of this array is an instance of the class DepthSortedParticle.
  107142. */
  107143. depthSortedParticles: DepthSortedParticle[];
  107144. /**
  107145. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107146. * @hidden
  107147. */
  107148. _bSphereOnly: boolean;
  107149. /**
  107150. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107151. * @hidden
  107152. */
  107153. _bSphereRadiusFactor: number;
  107154. private _scene;
  107155. private _positions;
  107156. private _indices;
  107157. private _normals;
  107158. private _colors;
  107159. private _uvs;
  107160. private _indices32;
  107161. private _positions32;
  107162. private _normals32;
  107163. private _fixedNormal32;
  107164. private _colors32;
  107165. private _uvs32;
  107166. private _index;
  107167. private _updatable;
  107168. private _pickable;
  107169. private _isVisibilityBoxLocked;
  107170. private _alwaysVisible;
  107171. private _depthSort;
  107172. private _expandable;
  107173. private _shapeCounter;
  107174. private _copy;
  107175. private _color;
  107176. private _computeParticleColor;
  107177. private _computeParticleTexture;
  107178. private _computeParticleRotation;
  107179. private _computeParticleVertex;
  107180. private _computeBoundingBox;
  107181. private _depthSortParticles;
  107182. private _camera;
  107183. private _mustUnrotateFixedNormals;
  107184. private _particlesIntersect;
  107185. private _needs32Bits;
  107186. private _isNotBuilt;
  107187. private _lastParticleId;
  107188. private _idxOfId;
  107189. private _multimaterialEnabled;
  107190. private _useModelMaterial;
  107191. private _indicesByMaterial;
  107192. private _materialIndexes;
  107193. private _depthSortFunction;
  107194. private _materialSortFunction;
  107195. private _materials;
  107196. private _multimaterial;
  107197. private _materialIndexesById;
  107198. private _defaultMaterial;
  107199. private _autoUpdateSubMeshes;
  107200. private _tmpVertex;
  107201. /**
  107202. * Creates a SPS (Solid Particle System) object.
  107203. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107204. * @param scene (Scene) is the scene in which the SPS is added.
  107205. * @param options defines the options of the sps e.g.
  107206. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107207. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107208. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107209. * * 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.
  107210. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  107211. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  107212. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107213. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107214. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107215. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107216. */
  107217. constructor(name: string, scene: Scene, options?: {
  107218. updatable?: boolean;
  107219. isPickable?: boolean;
  107220. enableDepthSort?: boolean;
  107221. particleIntersection?: boolean;
  107222. boundingSphereOnly?: boolean;
  107223. bSphereRadiusFactor?: number;
  107224. expandable?: boolean;
  107225. useModelMaterial?: boolean;
  107226. enableMultiMaterial?: boolean;
  107227. });
  107228. /**
  107229. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107230. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107231. * @returns the created mesh
  107232. */
  107233. buildMesh(): Mesh;
  107234. /**
  107235. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  107236. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  107237. * Thus the particles generated from `digest()` have their property `position` set yet.
  107238. * @param mesh ( Mesh ) is the mesh to be digested
  107239. * @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
  107240. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  107241. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  107242. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107243. * @returns the current SPS
  107244. */
  107245. digest(mesh: Mesh, options?: {
  107246. facetNb?: number;
  107247. number?: number;
  107248. delta?: number;
  107249. storage?: [];
  107250. }): SolidParticleSystem;
  107251. /**
  107252. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  107253. * @hidden
  107254. */
  107255. private _unrotateFixedNormals;
  107256. /**
  107257. * Resets the temporary working copy particle
  107258. * @hidden
  107259. */
  107260. private _resetCopy;
  107261. /**
  107262. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  107263. * @param p the current index in the positions array to be updated
  107264. * @param ind the current index in the indices array
  107265. * @param shape a Vector3 array, the shape geometry
  107266. * @param positions the positions array to be updated
  107267. * @param meshInd the shape indices array
  107268. * @param indices the indices array to be updated
  107269. * @param meshUV the shape uv array
  107270. * @param uvs the uv array to be updated
  107271. * @param meshCol the shape color array
  107272. * @param colors the color array to be updated
  107273. * @param meshNor the shape normals array
  107274. * @param normals the normals array to be updated
  107275. * @param idx the particle index
  107276. * @param idxInShape the particle index in its shape
  107277. * @param options the addShape() method passed options
  107278. * @model the particle model
  107279. * @hidden
  107280. */
  107281. private _meshBuilder;
  107282. /**
  107283. * Returns a shape Vector3 array from positions float array
  107284. * @param positions float array
  107285. * @returns a vector3 array
  107286. * @hidden
  107287. */
  107288. private _posToShape;
  107289. /**
  107290. * Returns a shapeUV array from a float uvs (array deep copy)
  107291. * @param uvs as a float array
  107292. * @returns a shapeUV array
  107293. * @hidden
  107294. */
  107295. private _uvsToShapeUV;
  107296. /**
  107297. * Adds a new particle object in the particles array
  107298. * @param idx particle index in particles array
  107299. * @param id particle id
  107300. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  107301. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  107302. * @param model particle ModelShape object
  107303. * @param shapeId model shape identifier
  107304. * @param idxInShape index of the particle in the current model
  107305. * @param bInfo model bounding info object
  107306. * @param storage target storage array, if any
  107307. * @hidden
  107308. */
  107309. private _addParticle;
  107310. /**
  107311. * Adds some particles to the SPS from the model shape. Returns the shape id.
  107312. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  107313. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  107314. * @param nb (positive integer) the number of particles to be created from this model
  107315. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  107316. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  107317. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107318. * @returns the number of shapes in the system
  107319. */
  107320. addShape(mesh: Mesh, nb: number, options?: {
  107321. positionFunction?: any;
  107322. vertexFunction?: any;
  107323. storage?: [];
  107324. }): number;
  107325. /**
  107326. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107327. * @hidden
  107328. */
  107329. private _rebuildParticle;
  107330. /**
  107331. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  107332. * @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.
  107333. * @returns the SPS.
  107334. */
  107335. rebuildMesh(reset?: boolean): SolidParticleSystem;
  107336. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  107337. * Returns an array with the removed particles.
  107338. * 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.
  107339. * The SPS can't be empty so at least one particle needs to remain in place.
  107340. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  107341. * @param start index of the first particle to remove
  107342. * @param end index of the last particle to remove (included)
  107343. * @returns an array populated with the removed particles
  107344. */
  107345. removeParticles(start: number, end: number): SolidParticle[];
  107346. /**
  107347. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  107348. * @param solidParticleArray an array populated with Solid Particles objects
  107349. * @returns the SPS
  107350. */
  107351. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  107352. /**
  107353. * Creates a new particle and modifies the SPS mesh geometry :
  107354. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  107355. * - calls _addParticle() to populate the particle array
  107356. * factorized code from addShape() and insertParticlesFromArray()
  107357. * @param idx particle index in the particles array
  107358. * @param i particle index in its shape
  107359. * @param modelShape particle ModelShape object
  107360. * @param shape shape vertex array
  107361. * @param meshInd shape indices array
  107362. * @param meshUV shape uv array
  107363. * @param meshCol shape color array
  107364. * @param meshNor shape normals array
  107365. * @param bbInfo shape bounding info
  107366. * @param storage target particle storage
  107367. * @options addShape() passed options
  107368. * @hidden
  107369. */
  107370. private _insertNewParticle;
  107371. /**
  107372. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  107373. * This method calls `updateParticle()` for each particle of the SPS.
  107374. * For an animated SPS, it is usually called within the render loop.
  107375. * 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.
  107376. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  107377. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  107378. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  107379. * @returns the SPS.
  107380. */
  107381. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  107382. /**
  107383. * Disposes the SPS.
  107384. */
  107385. dispose(): void;
  107386. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  107387. * idx is the particle index in the SPS
  107388. * faceId is the picked face index counted within this particle.
  107389. * Returns null if the pickInfo can't identify a picked particle.
  107390. * @param pickingInfo (PickingInfo object)
  107391. * @returns {idx: number, faceId: number} or null
  107392. */
  107393. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  107394. idx: number;
  107395. faceId: number;
  107396. }>;
  107397. /**
  107398. * Returns a SolidParticle object from its identifier : particle.id
  107399. * @param id (integer) the particle Id
  107400. * @returns the searched particle or null if not found in the SPS.
  107401. */
  107402. getParticleById(id: number): Nullable<SolidParticle>;
  107403. /**
  107404. * Returns a new array populated with the particles having the passed shapeId.
  107405. * @param shapeId (integer) the shape identifier
  107406. * @returns a new solid particle array
  107407. */
  107408. getParticlesByShapeId(shapeId: number): SolidParticle[];
  107409. /**
  107410. * Populates the passed array "ref" with the particles having the passed shapeId.
  107411. * @param shapeId the shape identifier
  107412. * @returns the SPS
  107413. * @param ref
  107414. */
  107415. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  107416. /**
  107417. * Computes the required SubMeshes according the materials assigned to the particles.
  107418. * @returns the solid particle system.
  107419. * Does nothing if called before the SPS mesh is built.
  107420. */
  107421. computeSubMeshes(): SolidParticleSystem;
  107422. /**
  107423. * Sorts the solid particles by material when MultiMaterial is enabled.
  107424. * Updates the indices32 array.
  107425. * Updates the indicesByMaterial array.
  107426. * Updates the mesh indices array.
  107427. * @returns the SPS
  107428. * @hidden
  107429. */
  107430. private _sortParticlesByMaterial;
  107431. /**
  107432. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  107433. * @hidden
  107434. */
  107435. private _setMaterialIndexesById;
  107436. /**
  107437. * Returns an array with unique values of Materials from the passed array
  107438. * @param array the material array to be checked and filtered
  107439. * @hidden
  107440. */
  107441. private _filterUniqueMaterialId;
  107442. /**
  107443. * Sets a new Standard Material as _defaultMaterial if not already set.
  107444. * @hidden
  107445. */
  107446. private _setDefaultMaterial;
  107447. /**
  107448. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  107449. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107450. * @returns the SPS.
  107451. */
  107452. refreshVisibleSize(): SolidParticleSystem;
  107453. /**
  107454. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  107455. * @param size the size (float) of the visibility box
  107456. * note : this doesn't lock the SPS mesh bounding box.
  107457. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107458. */
  107459. setVisibilityBox(size: number): void;
  107460. /**
  107461. * Gets whether the SPS as always visible or not
  107462. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107463. */
  107464. get isAlwaysVisible(): boolean;
  107465. /**
  107466. * Sets the SPS as always visible or not
  107467. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107468. */
  107469. set isAlwaysVisible(val: boolean);
  107470. /**
  107471. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107472. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107473. */
  107474. set isVisibilityBoxLocked(val: boolean);
  107475. /**
  107476. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107477. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107478. */
  107479. get isVisibilityBoxLocked(): boolean;
  107480. /**
  107481. * Tells to `setParticles()` to compute the particle rotations or not.
  107482. * Default value : true. The SPS is faster when it's set to false.
  107483. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107484. */
  107485. set computeParticleRotation(val: boolean);
  107486. /**
  107487. * Tells to `setParticles()` to compute the particle colors or not.
  107488. * Default value : true. The SPS is faster when it's set to false.
  107489. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107490. */
  107491. set computeParticleColor(val: boolean);
  107492. set computeParticleTexture(val: boolean);
  107493. /**
  107494. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  107495. * Default value : false. The SPS is faster when it's set to false.
  107496. * Note : the particle custom vertex positions aren't stored values.
  107497. */
  107498. set computeParticleVertex(val: boolean);
  107499. /**
  107500. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  107501. */
  107502. set computeBoundingBox(val: boolean);
  107503. /**
  107504. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  107505. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107506. * Default : `true`
  107507. */
  107508. set depthSortParticles(val: boolean);
  107509. /**
  107510. * Gets if `setParticles()` computes the particle rotations or not.
  107511. * Default value : true. The SPS is faster when it's set to false.
  107512. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107513. */
  107514. get computeParticleRotation(): boolean;
  107515. /**
  107516. * Gets if `setParticles()` computes the particle colors or not.
  107517. * Default value : true. The SPS is faster when it's set to false.
  107518. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107519. */
  107520. get computeParticleColor(): boolean;
  107521. /**
  107522. * Gets if `setParticles()` computes the particle textures or not.
  107523. * Default value : true. The SPS is faster when it's set to false.
  107524. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  107525. */
  107526. get computeParticleTexture(): boolean;
  107527. /**
  107528. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  107529. * Default value : false. The SPS is faster when it's set to false.
  107530. * Note : the particle custom vertex positions aren't stored values.
  107531. */
  107532. get computeParticleVertex(): boolean;
  107533. /**
  107534. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  107535. */
  107536. get computeBoundingBox(): boolean;
  107537. /**
  107538. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  107539. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107540. * Default : `true`
  107541. */
  107542. get depthSortParticles(): boolean;
  107543. /**
  107544. * Gets if the SPS is created as expandable at construction time.
  107545. * Default : `false`
  107546. */
  107547. get expandable(): boolean;
  107548. /**
  107549. * Gets if the SPS supports the Multi Materials
  107550. */
  107551. get multimaterialEnabled(): boolean;
  107552. /**
  107553. * Gets if the SPS uses the model materials for its own multimaterial.
  107554. */
  107555. get useModelMaterial(): boolean;
  107556. /**
  107557. * The SPS used material array.
  107558. */
  107559. get materials(): Material[];
  107560. /**
  107561. * Sets the SPS MultiMaterial from the passed materials.
  107562. * Note : the passed array is internally copied and not used then by reference.
  107563. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  107564. */
  107565. setMultiMaterial(materials: Material[]): void;
  107566. /**
  107567. * The SPS computed multimaterial object
  107568. */
  107569. get multimaterial(): MultiMaterial;
  107570. set multimaterial(mm: MultiMaterial);
  107571. /**
  107572. * If the subMeshes must be updated on the next call to setParticles()
  107573. */
  107574. get autoUpdateSubMeshes(): boolean;
  107575. set autoUpdateSubMeshes(val: boolean);
  107576. /**
  107577. * This function does nothing. It may be overwritten to set all the particle first values.
  107578. * The SPS doesn't call this function, you may have to call it by your own.
  107579. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107580. */
  107581. initParticles(): void;
  107582. /**
  107583. * This function does nothing. It may be overwritten to recycle a particle.
  107584. * The SPS doesn't call this function, you may have to call it by your own.
  107585. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107586. * @param particle The particle to recycle
  107587. * @returns the recycled particle
  107588. */
  107589. recycleParticle(particle: SolidParticle): SolidParticle;
  107590. /**
  107591. * Updates a particle : this function should be overwritten by the user.
  107592. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  107593. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107594. * @example : just set a particle position or velocity and recycle conditions
  107595. * @param particle The particle to update
  107596. * @returns the updated particle
  107597. */
  107598. updateParticle(particle: SolidParticle): SolidParticle;
  107599. /**
  107600. * Updates a vertex of a particle : it can be overwritten by the user.
  107601. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  107602. * @param particle the current particle
  107603. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  107604. * @param pt the index of the current vertex in the particle shape
  107605. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  107606. * @example : just set a vertex particle position or color
  107607. * @returns the sps
  107608. */
  107609. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  107610. /**
  107611. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  107612. * This does nothing and may be overwritten by the user.
  107613. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107614. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107615. * @param update the boolean update value actually passed to setParticles()
  107616. */
  107617. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107618. /**
  107619. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  107620. * This will be passed three parameters.
  107621. * This does nothing and may be overwritten by the user.
  107622. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107623. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107624. * @param update the boolean update value actually passed to setParticles()
  107625. */
  107626. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107627. }
  107628. }
  107629. declare module BABYLON {
  107630. /**
  107631. * Represents one particle of a solid particle system.
  107632. */
  107633. export class SolidParticle {
  107634. /**
  107635. * particle global index
  107636. */
  107637. idx: number;
  107638. /**
  107639. * particle identifier
  107640. */
  107641. id: number;
  107642. /**
  107643. * The color of the particle
  107644. */
  107645. color: Nullable<Color4>;
  107646. /**
  107647. * The world space position of the particle.
  107648. */
  107649. position: Vector3;
  107650. /**
  107651. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  107652. */
  107653. rotation: Vector3;
  107654. /**
  107655. * The world space rotation quaternion of the particle.
  107656. */
  107657. rotationQuaternion: Nullable<Quaternion>;
  107658. /**
  107659. * The scaling of the particle.
  107660. */
  107661. scaling: Vector3;
  107662. /**
  107663. * The uvs of the particle.
  107664. */
  107665. uvs: Vector4;
  107666. /**
  107667. * The current speed of the particle.
  107668. */
  107669. velocity: Vector3;
  107670. /**
  107671. * The pivot point in the particle local space.
  107672. */
  107673. pivot: Vector3;
  107674. /**
  107675. * Must the particle be translated from its pivot point in its local space ?
  107676. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  107677. * Default : false
  107678. */
  107679. translateFromPivot: boolean;
  107680. /**
  107681. * Is the particle active or not ?
  107682. */
  107683. alive: boolean;
  107684. /**
  107685. * Is the particle visible or not ?
  107686. */
  107687. isVisible: boolean;
  107688. /**
  107689. * Index of this particle in the global "positions" array (Internal use)
  107690. * @hidden
  107691. */
  107692. _pos: number;
  107693. /**
  107694. * @hidden Index of this particle in the global "indices" array (Internal use)
  107695. */
  107696. _ind: number;
  107697. /**
  107698. * @hidden ModelShape of this particle (Internal use)
  107699. */
  107700. _model: ModelShape;
  107701. /**
  107702. * ModelShape id of this particle
  107703. */
  107704. shapeId: number;
  107705. /**
  107706. * Index of the particle in its shape id
  107707. */
  107708. idxInShape: number;
  107709. /**
  107710. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  107711. */
  107712. _modelBoundingInfo: BoundingInfo;
  107713. /**
  107714. * @hidden Particle BoundingInfo object (Internal use)
  107715. */
  107716. _boundingInfo: BoundingInfo;
  107717. /**
  107718. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  107719. */
  107720. _sps: SolidParticleSystem;
  107721. /**
  107722. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  107723. */
  107724. _stillInvisible: boolean;
  107725. /**
  107726. * @hidden Last computed particle rotation matrix
  107727. */
  107728. _rotationMatrix: number[];
  107729. /**
  107730. * Parent particle Id, if any.
  107731. * Default null.
  107732. */
  107733. parentId: Nullable<number>;
  107734. /**
  107735. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  107736. */
  107737. materialIndex: Nullable<number>;
  107738. /**
  107739. * Custom object or properties.
  107740. */
  107741. props: Nullable<any>;
  107742. /**
  107743. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  107744. * The possible values are :
  107745. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107746. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107747. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107748. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107749. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107750. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  107751. * */
  107752. cullingStrategy: number;
  107753. /**
  107754. * @hidden Internal global position in the SPS.
  107755. */
  107756. _globalPosition: Vector3;
  107757. /**
  107758. * Creates a Solid Particle object.
  107759. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  107760. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  107761. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  107762. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  107763. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  107764. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  107765. * @param shapeId (integer) is the model shape identifier in the SPS.
  107766. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  107767. * @param sps defines the sps it is associated to
  107768. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  107769. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  107770. */
  107771. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  107772. /**
  107773. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  107774. * @param target the particle target
  107775. * @returns the current particle
  107776. */
  107777. copyToRef(target: SolidParticle): SolidParticle;
  107778. /**
  107779. * Legacy support, changed scale to scaling
  107780. */
  107781. get scale(): Vector3;
  107782. /**
  107783. * Legacy support, changed scale to scaling
  107784. */
  107785. set scale(scale: Vector3);
  107786. /**
  107787. * Legacy support, changed quaternion to rotationQuaternion
  107788. */
  107789. get quaternion(): Nullable<Quaternion>;
  107790. /**
  107791. * Legacy support, changed quaternion to rotationQuaternion
  107792. */
  107793. set quaternion(q: Nullable<Quaternion>);
  107794. /**
  107795. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  107796. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  107797. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  107798. * @returns true if it intersects
  107799. */
  107800. intersectsMesh(target: Mesh | SolidParticle): boolean;
  107801. /**
  107802. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  107803. * A particle is in the frustum if its bounding box intersects the frustum
  107804. * @param frustumPlanes defines the frustum to test
  107805. * @returns true if the particle is in the frustum planes
  107806. */
  107807. isInFrustum(frustumPlanes: Plane[]): boolean;
  107808. /**
  107809. * get the rotation matrix of the particle
  107810. * @hidden
  107811. */
  107812. getRotationMatrix(m: Matrix): void;
  107813. }
  107814. /**
  107815. * Represents the shape of the model used by one particle of a solid particle system.
  107816. * SPS internal tool, don't use it manually.
  107817. */
  107818. export class ModelShape {
  107819. /**
  107820. * The shape id
  107821. * @hidden
  107822. */
  107823. shapeID: number;
  107824. /**
  107825. * flat array of model positions (internal use)
  107826. * @hidden
  107827. */
  107828. _shape: Vector3[];
  107829. /**
  107830. * flat array of model UVs (internal use)
  107831. * @hidden
  107832. */
  107833. _shapeUV: number[];
  107834. /**
  107835. * color array of the model
  107836. * @hidden
  107837. */
  107838. _shapeColors: number[];
  107839. /**
  107840. * indices array of the model
  107841. * @hidden
  107842. */
  107843. _indices: number[];
  107844. /**
  107845. * normals array of the model
  107846. * @hidden
  107847. */
  107848. _normals: number[];
  107849. /**
  107850. * length of the shape in the model indices array (internal use)
  107851. * @hidden
  107852. */
  107853. _indicesLength: number;
  107854. /**
  107855. * Custom position function (internal use)
  107856. * @hidden
  107857. */
  107858. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  107859. /**
  107860. * Custom vertex function (internal use)
  107861. * @hidden
  107862. */
  107863. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  107864. /**
  107865. * Model material (internal use)
  107866. * @hidden
  107867. */
  107868. _material: Nullable<Material>;
  107869. /**
  107870. * 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.
  107871. * SPS internal tool, don't use it manually.
  107872. * @hidden
  107873. */
  107874. 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>);
  107875. }
  107876. /**
  107877. * Represents a Depth Sorted Particle in the solid particle system.
  107878. * @hidden
  107879. */
  107880. export class DepthSortedParticle {
  107881. /**
  107882. * Particle index
  107883. */
  107884. idx: number;
  107885. /**
  107886. * Index of the particle in the "indices" array
  107887. */
  107888. ind: number;
  107889. /**
  107890. * Length of the particle shape in the "indices" array
  107891. */
  107892. indicesLength: number;
  107893. /**
  107894. * Squared distance from the particle to the camera
  107895. */
  107896. sqDistance: number;
  107897. /**
  107898. * Material index when used with MultiMaterials
  107899. */
  107900. materialIndex: number;
  107901. /**
  107902. * Creates a new sorted particle
  107903. * @param materialIndex
  107904. */
  107905. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  107906. }
  107907. /**
  107908. * Represents a solid particle vertex
  107909. */
  107910. export class SolidParticleVertex {
  107911. /**
  107912. * Vertex position
  107913. */
  107914. position: Vector3;
  107915. /**
  107916. * Vertex color
  107917. */
  107918. color: Color4;
  107919. /**
  107920. * Vertex UV
  107921. */
  107922. uv: Vector2;
  107923. /**
  107924. * Creates a new solid particle vertex
  107925. */
  107926. constructor();
  107927. /** Vertex x coordinate */
  107928. get x(): number;
  107929. set x(val: number);
  107930. /** Vertex y coordinate */
  107931. get y(): number;
  107932. set y(val: number);
  107933. /** Vertex z coordinate */
  107934. get z(): number;
  107935. set z(val: number);
  107936. }
  107937. }
  107938. declare module BABYLON {
  107939. /**
  107940. * @hidden
  107941. */
  107942. export class _MeshCollisionData {
  107943. _checkCollisions: boolean;
  107944. _collisionMask: number;
  107945. _collisionGroup: number;
  107946. _surroundingMeshes: Nullable<AbstractMesh[]>;
  107947. _collider: Nullable<Collider>;
  107948. _oldPositionForCollisions: Vector3;
  107949. _diffPositionForCollisions: Vector3;
  107950. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  107951. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  107952. }
  107953. }
  107954. declare module BABYLON {
  107955. /** @hidden */
  107956. class _FacetDataStorage {
  107957. facetPositions: Vector3[];
  107958. facetNormals: Vector3[];
  107959. facetPartitioning: number[][];
  107960. facetNb: number;
  107961. partitioningSubdivisions: number;
  107962. partitioningBBoxRatio: number;
  107963. facetDataEnabled: boolean;
  107964. facetParameters: any;
  107965. bbSize: Vector3;
  107966. subDiv: {
  107967. max: number;
  107968. X: number;
  107969. Y: number;
  107970. Z: number;
  107971. };
  107972. facetDepthSort: boolean;
  107973. facetDepthSortEnabled: boolean;
  107974. depthSortedIndices: IndicesArray;
  107975. depthSortedFacets: {
  107976. ind: number;
  107977. sqDistance: number;
  107978. }[];
  107979. facetDepthSortFunction: (f1: {
  107980. ind: number;
  107981. sqDistance: number;
  107982. }, f2: {
  107983. ind: number;
  107984. sqDistance: number;
  107985. }) => number;
  107986. facetDepthSortFrom: Vector3;
  107987. facetDepthSortOrigin: Vector3;
  107988. invertedMatrix: Matrix;
  107989. }
  107990. /**
  107991. * @hidden
  107992. **/
  107993. class _InternalAbstractMeshDataInfo {
  107994. _hasVertexAlpha: boolean;
  107995. _useVertexColors: boolean;
  107996. _numBoneInfluencers: number;
  107997. _applyFog: boolean;
  107998. _receiveShadows: boolean;
  107999. _facetData: _FacetDataStorage;
  108000. _visibility: number;
  108001. _skeleton: Nullable<Skeleton>;
  108002. _layerMask: number;
  108003. _computeBonesUsingShaders: boolean;
  108004. _isActive: boolean;
  108005. _onlyForInstances: boolean;
  108006. _isActiveIntermediate: boolean;
  108007. _onlyForInstancesIntermediate: boolean;
  108008. _actAsRegularMesh: boolean;
  108009. }
  108010. /**
  108011. * Class used to store all common mesh properties
  108012. */
  108013. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  108014. /** No occlusion */
  108015. static OCCLUSION_TYPE_NONE: number;
  108016. /** Occlusion set to optimisitic */
  108017. static OCCLUSION_TYPE_OPTIMISTIC: number;
  108018. /** Occlusion set to strict */
  108019. static OCCLUSION_TYPE_STRICT: number;
  108020. /** Use an accurante occlusion algorithm */
  108021. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  108022. /** Use a conservative occlusion algorithm */
  108023. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  108024. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  108025. * Test order :
  108026. * Is the bounding sphere outside the frustum ?
  108027. * If not, are the bounding box vertices outside the frustum ?
  108028. * It not, then the cullable object is in the frustum.
  108029. */
  108030. static readonly CULLINGSTRATEGY_STANDARD: number;
  108031. /** Culling strategy : Bounding Sphere Only.
  108032. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  108033. * It's also less accurate than the standard because some not visible objects can still be selected.
  108034. * Test : is the bounding sphere outside the frustum ?
  108035. * If not, then the cullable object is in the frustum.
  108036. */
  108037. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  108038. /** Culling strategy : Optimistic Inclusion.
  108039. * This in an inclusion test first, then the standard exclusion test.
  108040. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  108041. * 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.
  108042. * Anyway, it's as accurate as the standard strategy.
  108043. * Test :
  108044. * Is the cullable object bounding sphere center in the frustum ?
  108045. * If not, apply the default culling strategy.
  108046. */
  108047. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  108048. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  108049. * This in an inclusion test first, then the bounding sphere only exclusion test.
  108050. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  108051. * 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.
  108052. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  108053. * Test :
  108054. * Is the cullable object bounding sphere center in the frustum ?
  108055. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  108056. */
  108057. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  108058. /**
  108059. * No billboard
  108060. */
  108061. static get BILLBOARDMODE_NONE(): number;
  108062. /** Billboard on X axis */
  108063. static get BILLBOARDMODE_X(): number;
  108064. /** Billboard on Y axis */
  108065. static get BILLBOARDMODE_Y(): number;
  108066. /** Billboard on Z axis */
  108067. static get BILLBOARDMODE_Z(): number;
  108068. /** Billboard on all axes */
  108069. static get BILLBOARDMODE_ALL(): number;
  108070. /** Billboard on using position instead of orientation */
  108071. static get BILLBOARDMODE_USE_POSITION(): number;
  108072. /** @hidden */
  108073. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  108074. /**
  108075. * The culling strategy to use to check whether the mesh must be rendered or not.
  108076. * This value can be changed at any time and will be used on the next render mesh selection.
  108077. * The possible values are :
  108078. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108079. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108080. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108081. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108082. * Please read each static variable documentation to get details about the culling process.
  108083. * */
  108084. cullingStrategy: number;
  108085. /**
  108086. * Gets the number of facets in the mesh
  108087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108088. */
  108089. get facetNb(): number;
  108090. /**
  108091. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  108092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108093. */
  108094. get partitioningSubdivisions(): number;
  108095. set partitioningSubdivisions(nb: number);
  108096. /**
  108097. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  108098. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  108099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108100. */
  108101. get partitioningBBoxRatio(): number;
  108102. set partitioningBBoxRatio(ratio: number);
  108103. /**
  108104. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  108105. * Works only for updatable meshes.
  108106. * Doesn't work with multi-materials
  108107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108108. */
  108109. get mustDepthSortFacets(): boolean;
  108110. set mustDepthSortFacets(sort: boolean);
  108111. /**
  108112. * The location (Vector3) where the facet depth sort must be computed from.
  108113. * By default, the active camera position.
  108114. * Used only when facet depth sort is enabled
  108115. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108116. */
  108117. get facetDepthSortFrom(): Vector3;
  108118. set facetDepthSortFrom(location: Vector3);
  108119. /**
  108120. * gets a boolean indicating if facetData is enabled
  108121. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108122. */
  108123. get isFacetDataEnabled(): boolean;
  108124. /** @hidden */
  108125. _updateNonUniformScalingState(value: boolean): boolean;
  108126. /**
  108127. * An event triggered when this mesh collides with another one
  108128. */
  108129. onCollideObservable: Observable<AbstractMesh>;
  108130. /** Set a function to call when this mesh collides with another one */
  108131. set onCollide(callback: () => void);
  108132. /**
  108133. * An event triggered when the collision's position changes
  108134. */
  108135. onCollisionPositionChangeObservable: Observable<Vector3>;
  108136. /** Set a function to call when the collision's position changes */
  108137. set onCollisionPositionChange(callback: () => void);
  108138. /**
  108139. * An event triggered when material is changed
  108140. */
  108141. onMaterialChangedObservable: Observable<AbstractMesh>;
  108142. /**
  108143. * Gets or sets the orientation for POV movement & rotation
  108144. */
  108145. definedFacingForward: boolean;
  108146. /** @hidden */
  108147. _occlusionQuery: Nullable<WebGLQuery>;
  108148. /** @hidden */
  108149. _renderingGroup: Nullable<RenderingGroup>;
  108150. /**
  108151. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108152. */
  108153. get visibility(): number;
  108154. /**
  108155. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108156. */
  108157. set visibility(value: number);
  108158. /** Gets or sets the alpha index used to sort transparent meshes
  108159. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  108160. */
  108161. alphaIndex: number;
  108162. /**
  108163. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  108164. */
  108165. isVisible: boolean;
  108166. /**
  108167. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108168. */
  108169. isPickable: boolean;
  108170. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  108171. showSubMeshesBoundingBox: boolean;
  108172. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  108173. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  108174. */
  108175. isBlocker: boolean;
  108176. /**
  108177. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  108178. */
  108179. enablePointerMoveEvents: boolean;
  108180. /**
  108181. * Specifies the rendering group id for this mesh (0 by default)
  108182. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108183. */
  108184. renderingGroupId: number;
  108185. private _material;
  108186. /** Gets or sets current material */
  108187. get material(): Nullable<Material>;
  108188. set material(value: Nullable<Material>);
  108189. /**
  108190. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  108191. * @see http://doc.babylonjs.com/babylon101/shadows
  108192. */
  108193. get receiveShadows(): boolean;
  108194. set receiveShadows(value: boolean);
  108195. /** Defines color to use when rendering outline */
  108196. outlineColor: Color3;
  108197. /** Define width to use when rendering outline */
  108198. outlineWidth: number;
  108199. /** Defines color to use when rendering overlay */
  108200. overlayColor: Color3;
  108201. /** Defines alpha to use when rendering overlay */
  108202. overlayAlpha: number;
  108203. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  108204. get hasVertexAlpha(): boolean;
  108205. set hasVertexAlpha(value: boolean);
  108206. /** 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) */
  108207. get useVertexColors(): boolean;
  108208. set useVertexColors(value: boolean);
  108209. /**
  108210. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  108211. */
  108212. get computeBonesUsingShaders(): boolean;
  108213. set computeBonesUsingShaders(value: boolean);
  108214. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  108215. get numBoneInfluencers(): number;
  108216. set numBoneInfluencers(value: number);
  108217. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  108218. get applyFog(): boolean;
  108219. set applyFog(value: boolean);
  108220. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  108221. useOctreeForRenderingSelection: boolean;
  108222. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  108223. useOctreeForPicking: boolean;
  108224. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  108225. useOctreeForCollisions: boolean;
  108226. /**
  108227. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  108228. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  108229. */
  108230. get layerMask(): number;
  108231. set layerMask(value: number);
  108232. /**
  108233. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  108234. */
  108235. alwaysSelectAsActiveMesh: boolean;
  108236. /**
  108237. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  108238. */
  108239. doNotSyncBoundingInfo: boolean;
  108240. /**
  108241. * Gets or sets the current action manager
  108242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108243. */
  108244. actionManager: Nullable<AbstractActionManager>;
  108245. private _meshCollisionData;
  108246. /**
  108247. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  108248. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108249. */
  108250. ellipsoid: Vector3;
  108251. /**
  108252. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  108253. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108254. */
  108255. ellipsoidOffset: Vector3;
  108256. /**
  108257. * Gets or sets a collision mask used to mask collisions (default is -1).
  108258. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108259. */
  108260. get collisionMask(): number;
  108261. set collisionMask(mask: number);
  108262. /**
  108263. * Gets or sets the current collision group mask (-1 by default).
  108264. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108265. */
  108266. get collisionGroup(): number;
  108267. set collisionGroup(mask: number);
  108268. /**
  108269. * Gets or sets current surrounding meshes (null by default).
  108270. *
  108271. * By default collision detection is tested against every mesh in the scene.
  108272. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  108273. * meshes will be tested for the collision.
  108274. *
  108275. * Note: if set to an empty array no collision will happen when this mesh is moved.
  108276. */
  108277. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  108278. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  108279. /**
  108280. * Defines edge width used when edgesRenderer is enabled
  108281. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108282. */
  108283. edgesWidth: number;
  108284. /**
  108285. * Defines edge color used when edgesRenderer is enabled
  108286. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108287. */
  108288. edgesColor: Color4;
  108289. /** @hidden */
  108290. _edgesRenderer: Nullable<IEdgesRenderer>;
  108291. /** @hidden */
  108292. _masterMesh: Nullable<AbstractMesh>;
  108293. /** @hidden */
  108294. _boundingInfo: Nullable<BoundingInfo>;
  108295. /** @hidden */
  108296. _renderId: number;
  108297. /**
  108298. * Gets or sets the list of subMeshes
  108299. * @see http://doc.babylonjs.com/how_to/multi_materials
  108300. */
  108301. subMeshes: SubMesh[];
  108302. /** @hidden */
  108303. _intersectionsInProgress: AbstractMesh[];
  108304. /** @hidden */
  108305. _unIndexed: boolean;
  108306. /** @hidden */
  108307. _lightSources: Light[];
  108308. /** Gets the list of lights affecting that mesh */
  108309. get lightSources(): Light[];
  108310. /** @hidden */
  108311. get _positions(): Nullable<Vector3[]>;
  108312. /** @hidden */
  108313. _waitingData: {
  108314. lods: Nullable<any>;
  108315. actions: Nullable<any>;
  108316. freezeWorldMatrix: Nullable<boolean>;
  108317. };
  108318. /** @hidden */
  108319. _bonesTransformMatrices: Nullable<Float32Array>;
  108320. /** @hidden */
  108321. _transformMatrixTexture: Nullable<RawTexture>;
  108322. /**
  108323. * Gets or sets a skeleton to apply skining transformations
  108324. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  108325. */
  108326. set skeleton(value: Nullable<Skeleton>);
  108327. get skeleton(): Nullable<Skeleton>;
  108328. /**
  108329. * An event triggered when the mesh is rebuilt.
  108330. */
  108331. onRebuildObservable: Observable<AbstractMesh>;
  108332. /**
  108333. * Creates a new AbstractMesh
  108334. * @param name defines the name of the mesh
  108335. * @param scene defines the hosting scene
  108336. */
  108337. constructor(name: string, scene?: Nullable<Scene>);
  108338. /**
  108339. * Returns the string "AbstractMesh"
  108340. * @returns "AbstractMesh"
  108341. */
  108342. getClassName(): string;
  108343. /**
  108344. * Gets a string representation of the current mesh
  108345. * @param fullDetails defines a boolean indicating if full details must be included
  108346. * @returns a string representation of the current mesh
  108347. */
  108348. toString(fullDetails?: boolean): string;
  108349. /**
  108350. * @hidden
  108351. */
  108352. protected _getEffectiveParent(): Nullable<Node>;
  108353. /** @hidden */
  108354. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  108355. /** @hidden */
  108356. _rebuild(): void;
  108357. /** @hidden */
  108358. _resyncLightSources(): void;
  108359. /** @hidden */
  108360. _resyncLightSource(light: Light): void;
  108361. /** @hidden */
  108362. _unBindEffect(): void;
  108363. /** @hidden */
  108364. _removeLightSource(light: Light, dispose: boolean): void;
  108365. private _markSubMeshesAsDirty;
  108366. /** @hidden */
  108367. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  108368. /** @hidden */
  108369. _markSubMeshesAsAttributesDirty(): void;
  108370. /** @hidden */
  108371. _markSubMeshesAsMiscDirty(): void;
  108372. /**
  108373. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  108374. */
  108375. get scaling(): Vector3;
  108376. set scaling(newScaling: Vector3);
  108377. /**
  108378. * Returns true if the mesh is blocked. Implemented by child classes
  108379. */
  108380. get isBlocked(): boolean;
  108381. /**
  108382. * Returns the mesh itself by default. Implemented by child classes
  108383. * @param camera defines the camera to use to pick the right LOD level
  108384. * @returns the currentAbstractMesh
  108385. */
  108386. getLOD(camera: Camera): Nullable<AbstractMesh>;
  108387. /**
  108388. * Returns 0 by default. Implemented by child classes
  108389. * @returns an integer
  108390. */
  108391. getTotalVertices(): number;
  108392. /**
  108393. * Returns a positive integer : the total number of indices in this mesh geometry.
  108394. * @returns the numner of indices or zero if the mesh has no geometry.
  108395. */
  108396. getTotalIndices(): number;
  108397. /**
  108398. * Returns null by default. Implemented by child classes
  108399. * @returns null
  108400. */
  108401. getIndices(): Nullable<IndicesArray>;
  108402. /**
  108403. * Returns the array of the requested vertex data kind. Implemented by child classes
  108404. * @param kind defines the vertex data kind to use
  108405. * @returns null
  108406. */
  108407. getVerticesData(kind: string): Nullable<FloatArray>;
  108408. /**
  108409. * Sets the vertex data of the mesh geometry for the requested `kind`.
  108410. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  108411. * Note that a new underlying VertexBuffer object is created each call.
  108412. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  108413. * @param kind defines vertex data kind:
  108414. * * VertexBuffer.PositionKind
  108415. * * VertexBuffer.UVKind
  108416. * * VertexBuffer.UV2Kind
  108417. * * VertexBuffer.UV3Kind
  108418. * * VertexBuffer.UV4Kind
  108419. * * VertexBuffer.UV5Kind
  108420. * * VertexBuffer.UV6Kind
  108421. * * VertexBuffer.ColorKind
  108422. * * VertexBuffer.MatricesIndicesKind
  108423. * * VertexBuffer.MatricesIndicesExtraKind
  108424. * * VertexBuffer.MatricesWeightsKind
  108425. * * VertexBuffer.MatricesWeightsExtraKind
  108426. * @param data defines the data source
  108427. * @param updatable defines if the data must be flagged as updatable (or static)
  108428. * @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
  108429. * @returns the current mesh
  108430. */
  108431. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108432. /**
  108433. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  108434. * If the mesh has no geometry, it is simply returned as it is.
  108435. * @param kind defines vertex data kind:
  108436. * * VertexBuffer.PositionKind
  108437. * * VertexBuffer.UVKind
  108438. * * VertexBuffer.UV2Kind
  108439. * * VertexBuffer.UV3Kind
  108440. * * VertexBuffer.UV4Kind
  108441. * * VertexBuffer.UV5Kind
  108442. * * VertexBuffer.UV6Kind
  108443. * * VertexBuffer.ColorKind
  108444. * * VertexBuffer.MatricesIndicesKind
  108445. * * VertexBuffer.MatricesIndicesExtraKind
  108446. * * VertexBuffer.MatricesWeightsKind
  108447. * * VertexBuffer.MatricesWeightsExtraKind
  108448. * @param data defines the data source
  108449. * @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
  108450. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  108451. * @returns the current mesh
  108452. */
  108453. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108454. /**
  108455. * Sets the mesh indices,
  108456. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  108457. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  108458. * @param totalVertices Defines the total number of vertices
  108459. * @returns the current mesh
  108460. */
  108461. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  108462. /**
  108463. * Gets a boolean indicating if specific vertex data is present
  108464. * @param kind defines the vertex data kind to use
  108465. * @returns true is data kind is present
  108466. */
  108467. isVerticesDataPresent(kind: string): boolean;
  108468. /**
  108469. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  108470. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  108471. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  108472. * @returns a BoundingInfo
  108473. */
  108474. getBoundingInfo(): BoundingInfo;
  108475. /**
  108476. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  108477. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  108478. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  108479. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  108480. * @returns the current mesh
  108481. */
  108482. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  108483. /**
  108484. * Overwrite the current bounding info
  108485. * @param boundingInfo defines the new bounding info
  108486. * @returns the current mesh
  108487. */
  108488. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  108489. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  108490. get useBones(): boolean;
  108491. /** @hidden */
  108492. _preActivate(): void;
  108493. /** @hidden */
  108494. _preActivateForIntermediateRendering(renderId: number): void;
  108495. /** @hidden */
  108496. _activate(renderId: number, intermediateRendering: boolean): boolean;
  108497. /** @hidden */
  108498. _postActivate(): void;
  108499. /** @hidden */
  108500. _freeze(): void;
  108501. /** @hidden */
  108502. _unFreeze(): void;
  108503. /**
  108504. * Gets the current world matrix
  108505. * @returns a Matrix
  108506. */
  108507. getWorldMatrix(): Matrix;
  108508. /** @hidden */
  108509. _getWorldMatrixDeterminant(): number;
  108510. /**
  108511. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  108512. */
  108513. get isAnInstance(): boolean;
  108514. /**
  108515. * Gets a boolean indicating if this mesh has instances
  108516. */
  108517. get hasInstances(): boolean;
  108518. /**
  108519. * Gets a boolean indicating if this mesh has thin instances
  108520. */
  108521. get hasThinInstances(): boolean;
  108522. /**
  108523. * Perform relative position change from the point of view of behind the front of the mesh.
  108524. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108525. * Supports definition of mesh facing forward or backward
  108526. * @param amountRight defines the distance on the right axis
  108527. * @param amountUp defines the distance on the up axis
  108528. * @param amountForward defines the distance on the forward axis
  108529. * @returns the current mesh
  108530. */
  108531. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  108532. /**
  108533. * Calculate relative position change from the point of view of behind the front of the mesh.
  108534. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108535. * Supports definition of mesh facing forward or backward
  108536. * @param amountRight defines the distance on the right axis
  108537. * @param amountUp defines the distance on the up axis
  108538. * @param amountForward defines the distance on the forward axis
  108539. * @returns the new displacement vector
  108540. */
  108541. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  108542. /**
  108543. * Perform relative rotation change from the point of view of behind the front of the mesh.
  108544. * Supports definition of mesh facing forward or backward
  108545. * @param flipBack defines the flip
  108546. * @param twirlClockwise defines the twirl
  108547. * @param tiltRight defines the tilt
  108548. * @returns the current mesh
  108549. */
  108550. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  108551. /**
  108552. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  108553. * Supports definition of mesh facing forward or backward.
  108554. * @param flipBack defines the flip
  108555. * @param twirlClockwise defines the twirl
  108556. * @param tiltRight defines the tilt
  108557. * @returns the new rotation vector
  108558. */
  108559. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  108560. /**
  108561. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108562. * This means the mesh underlying bounding box and sphere are recomputed.
  108563. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108564. * @returns the current mesh
  108565. */
  108566. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  108567. /** @hidden */
  108568. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  108569. /** @hidden */
  108570. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  108571. /** @hidden */
  108572. _updateBoundingInfo(): AbstractMesh;
  108573. /** @hidden */
  108574. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  108575. /** @hidden */
  108576. protected _afterComputeWorldMatrix(): void;
  108577. /** @hidden */
  108578. get _effectiveMesh(): AbstractMesh;
  108579. /**
  108580. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108581. * A mesh is in the frustum if its bounding box intersects the frustum
  108582. * @param frustumPlanes defines the frustum to test
  108583. * @returns true if the mesh is in the frustum planes
  108584. */
  108585. isInFrustum(frustumPlanes: Plane[]): boolean;
  108586. /**
  108587. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  108588. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  108589. * @param frustumPlanes defines the frustum to test
  108590. * @returns true if the mesh is completely in the frustum planes
  108591. */
  108592. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  108593. /**
  108594. * True if the mesh intersects another mesh or a SolidParticle object
  108595. * @param mesh defines a target mesh or SolidParticle to test
  108596. * @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)
  108597. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  108598. * @returns true if there is an intersection
  108599. */
  108600. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  108601. /**
  108602. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  108603. * @param point defines the point to test
  108604. * @returns true if there is an intersection
  108605. */
  108606. intersectsPoint(point: Vector3): boolean;
  108607. /**
  108608. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  108609. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108610. */
  108611. get checkCollisions(): boolean;
  108612. set checkCollisions(collisionEnabled: boolean);
  108613. /**
  108614. * Gets Collider object used to compute collisions (not physics)
  108615. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108616. */
  108617. get collider(): Nullable<Collider>;
  108618. /**
  108619. * Move the mesh using collision engine
  108620. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108621. * @param displacement defines the requested displacement vector
  108622. * @returns the current mesh
  108623. */
  108624. moveWithCollisions(displacement: Vector3): AbstractMesh;
  108625. private _onCollisionPositionChange;
  108626. /** @hidden */
  108627. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  108628. /** @hidden */
  108629. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  108630. /** @hidden */
  108631. _checkCollision(collider: Collider): AbstractMesh;
  108632. /** @hidden */
  108633. _generatePointsArray(): boolean;
  108634. /**
  108635. * Checks if the passed Ray intersects with the mesh
  108636. * @param ray defines the ray to use
  108637. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  108638. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108639. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  108640. * @returns the picking info
  108641. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  108642. */
  108643. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  108644. /**
  108645. * Clones the current mesh
  108646. * @param name defines the mesh name
  108647. * @param newParent defines the new mesh parent
  108648. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  108649. * @returns the new mesh
  108650. */
  108651. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  108652. /**
  108653. * Disposes all the submeshes of the current meshnp
  108654. * @returns the current mesh
  108655. */
  108656. releaseSubMeshes(): AbstractMesh;
  108657. /**
  108658. * Releases resources associated with this abstract mesh.
  108659. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108660. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108661. */
  108662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108663. /**
  108664. * Adds the passed mesh as a child to the current mesh
  108665. * @param mesh defines the child mesh
  108666. * @returns the current mesh
  108667. */
  108668. addChild(mesh: AbstractMesh): AbstractMesh;
  108669. /**
  108670. * Removes the passed mesh from the current mesh children list
  108671. * @param mesh defines the child mesh
  108672. * @returns the current mesh
  108673. */
  108674. removeChild(mesh: AbstractMesh): AbstractMesh;
  108675. /** @hidden */
  108676. private _initFacetData;
  108677. /**
  108678. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  108679. * This method can be called within the render loop.
  108680. * 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
  108681. * @returns the current mesh
  108682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108683. */
  108684. updateFacetData(): AbstractMesh;
  108685. /**
  108686. * Returns the facetLocalNormals array.
  108687. * The normals are expressed in the mesh local spac
  108688. * @returns an array of Vector3
  108689. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108690. */
  108691. getFacetLocalNormals(): Vector3[];
  108692. /**
  108693. * Returns the facetLocalPositions array.
  108694. * The facet positions are expressed in the mesh local space
  108695. * @returns an array of Vector3
  108696. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108697. */
  108698. getFacetLocalPositions(): Vector3[];
  108699. /**
  108700. * Returns the facetLocalPartioning array
  108701. * @returns an array of array of numbers
  108702. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108703. */
  108704. getFacetLocalPartitioning(): number[][];
  108705. /**
  108706. * Returns the i-th facet position in the world system.
  108707. * This method allocates a new Vector3 per call
  108708. * @param i defines the facet index
  108709. * @returns a new Vector3
  108710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108711. */
  108712. getFacetPosition(i: number): Vector3;
  108713. /**
  108714. * Sets the reference Vector3 with the i-th facet position in the world system
  108715. * @param i defines the facet index
  108716. * @param ref defines the target vector
  108717. * @returns the current mesh
  108718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108719. */
  108720. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  108721. /**
  108722. * Returns the i-th facet normal in the world system.
  108723. * This method allocates a new Vector3 per call
  108724. * @param i defines the facet index
  108725. * @returns a new Vector3
  108726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108727. */
  108728. getFacetNormal(i: number): Vector3;
  108729. /**
  108730. * Sets the reference Vector3 with the i-th facet normal in the world system
  108731. * @param i defines the facet index
  108732. * @param ref defines the target vector
  108733. * @returns the current mesh
  108734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108735. */
  108736. getFacetNormalToRef(i: number, ref: Vector3): this;
  108737. /**
  108738. * 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)
  108739. * @param x defines x coordinate
  108740. * @param y defines y coordinate
  108741. * @param z defines z coordinate
  108742. * @returns the array of facet indexes
  108743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108744. */
  108745. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  108746. /**
  108747. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  108748. * @param projected sets as the (x,y,z) world projection on the facet
  108749. * @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
  108750. * @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
  108751. * @param x defines x coordinate
  108752. * @param y defines y coordinate
  108753. * @param z defines z coordinate
  108754. * @returns the face index if found (or null instead)
  108755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108756. */
  108757. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108758. /**
  108759. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  108760. * @param projected sets as the (x,y,z) local projection on the facet
  108761. * @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
  108762. * @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
  108763. * @param x defines x coordinate
  108764. * @param y defines y coordinate
  108765. * @param z defines z coordinate
  108766. * @returns the face index if found (or null instead)
  108767. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108768. */
  108769. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108770. /**
  108771. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  108772. * @returns the parameters
  108773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108774. */
  108775. getFacetDataParameters(): any;
  108776. /**
  108777. * Disables the feature FacetData and frees the related memory
  108778. * @returns the current mesh
  108779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108780. */
  108781. disableFacetData(): AbstractMesh;
  108782. /**
  108783. * Updates the AbstractMesh indices array
  108784. * @param indices defines the data source
  108785. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108786. * @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)
  108787. * @returns the current mesh
  108788. */
  108789. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108790. /**
  108791. * Creates new normals data for the mesh
  108792. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  108793. * @returns the current mesh
  108794. */
  108795. createNormals(updatable: boolean): AbstractMesh;
  108796. /**
  108797. * Align the mesh with a normal
  108798. * @param normal defines the normal to use
  108799. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  108800. * @returns the current mesh
  108801. */
  108802. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  108803. /** @hidden */
  108804. _checkOcclusionQuery(): boolean;
  108805. /**
  108806. * Disables the mesh edge rendering mode
  108807. * @returns the currentAbstractMesh
  108808. */
  108809. disableEdgesRendering(): AbstractMesh;
  108810. /**
  108811. * Enables the edge rendering mode on the mesh.
  108812. * This mode makes the mesh edges visible
  108813. * @param epsilon defines the maximal distance between two angles to detect a face
  108814. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  108815. * @returns the currentAbstractMesh
  108816. * @see https://www.babylonjs-playground.com/#19O9TU#0
  108817. */
  108818. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  108819. }
  108820. }
  108821. declare module BABYLON {
  108822. /**
  108823. * Interface used to define ActionEvent
  108824. */
  108825. export interface IActionEvent {
  108826. /** The mesh or sprite that triggered the action */
  108827. source: any;
  108828. /** The X mouse cursor position at the time of the event */
  108829. pointerX: number;
  108830. /** The Y mouse cursor position at the time of the event */
  108831. pointerY: number;
  108832. /** The mesh that is currently pointed at (can be null) */
  108833. meshUnderPointer: Nullable<AbstractMesh>;
  108834. /** the original (browser) event that triggered the ActionEvent */
  108835. sourceEvent?: any;
  108836. /** additional data for the event */
  108837. additionalData?: any;
  108838. }
  108839. /**
  108840. * ActionEvent is the event being sent when an action is triggered.
  108841. */
  108842. export class ActionEvent implements IActionEvent {
  108843. /** The mesh or sprite that triggered the action */
  108844. source: any;
  108845. /** The X mouse cursor position at the time of the event */
  108846. pointerX: number;
  108847. /** The Y mouse cursor position at the time of the event */
  108848. pointerY: number;
  108849. /** The mesh that is currently pointed at (can be null) */
  108850. meshUnderPointer: Nullable<AbstractMesh>;
  108851. /** the original (browser) event that triggered the ActionEvent */
  108852. sourceEvent?: any;
  108853. /** additional data for the event */
  108854. additionalData?: any;
  108855. /**
  108856. * Creates a new ActionEvent
  108857. * @param source The mesh or sprite that triggered the action
  108858. * @param pointerX The X mouse cursor position at the time of the event
  108859. * @param pointerY The Y mouse cursor position at the time of the event
  108860. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  108861. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  108862. * @param additionalData additional data for the event
  108863. */
  108864. constructor(
  108865. /** The mesh or sprite that triggered the action */
  108866. source: any,
  108867. /** The X mouse cursor position at the time of the event */
  108868. pointerX: number,
  108869. /** The Y mouse cursor position at the time of the event */
  108870. pointerY: number,
  108871. /** The mesh that is currently pointed at (can be null) */
  108872. meshUnderPointer: Nullable<AbstractMesh>,
  108873. /** the original (browser) event that triggered the ActionEvent */
  108874. sourceEvent?: any,
  108875. /** additional data for the event */
  108876. additionalData?: any);
  108877. /**
  108878. * Helper function to auto-create an ActionEvent from a source mesh.
  108879. * @param source The source mesh that triggered the event
  108880. * @param evt The original (browser) event
  108881. * @param additionalData additional data for the event
  108882. * @returns the new ActionEvent
  108883. */
  108884. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  108885. /**
  108886. * Helper function to auto-create an ActionEvent from a source sprite
  108887. * @param source The source sprite that triggered the event
  108888. * @param scene Scene associated with the sprite
  108889. * @param evt The original (browser) event
  108890. * @param additionalData additional data for the event
  108891. * @returns the new ActionEvent
  108892. */
  108893. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  108894. /**
  108895. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  108896. * @param scene the scene where the event occurred
  108897. * @param evt The original (browser) event
  108898. * @returns the new ActionEvent
  108899. */
  108900. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  108901. /**
  108902. * Helper function to auto-create an ActionEvent from a primitive
  108903. * @param prim defines the target primitive
  108904. * @param pointerPos defines the pointer position
  108905. * @param evt The original (browser) event
  108906. * @param additionalData additional data for the event
  108907. * @returns the new ActionEvent
  108908. */
  108909. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  108910. }
  108911. }
  108912. declare module BABYLON {
  108913. /**
  108914. * Abstract class used to decouple action Manager from scene and meshes.
  108915. * Do not instantiate.
  108916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108917. */
  108918. export abstract class AbstractActionManager implements IDisposable {
  108919. /** Gets the list of active triggers */
  108920. static Triggers: {
  108921. [key: string]: number;
  108922. };
  108923. /** Gets the cursor to use when hovering items */
  108924. hoverCursor: string;
  108925. /** Gets the list of actions */
  108926. actions: IAction[];
  108927. /**
  108928. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  108929. */
  108930. isRecursive: boolean;
  108931. /**
  108932. * Releases all associated resources
  108933. */
  108934. abstract dispose(): void;
  108935. /**
  108936. * Does this action manager has pointer triggers
  108937. */
  108938. abstract get hasPointerTriggers(): boolean;
  108939. /**
  108940. * Does this action manager has pick triggers
  108941. */
  108942. abstract get hasPickTriggers(): boolean;
  108943. /**
  108944. * Process a specific trigger
  108945. * @param trigger defines the trigger to process
  108946. * @param evt defines the event details to be processed
  108947. */
  108948. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  108949. /**
  108950. * Does this action manager handles actions of any of the given triggers
  108951. * @param triggers defines the triggers to be tested
  108952. * @return a boolean indicating whether one (or more) of the triggers is handled
  108953. */
  108954. abstract hasSpecificTriggers(triggers: number[]): boolean;
  108955. /**
  108956. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  108957. * speed.
  108958. * @param triggerA defines the trigger to be tested
  108959. * @param triggerB defines the trigger to be tested
  108960. * @return a boolean indicating whether one (or more) of the triggers is handled
  108961. */
  108962. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  108963. /**
  108964. * Does this action manager handles actions of a given trigger
  108965. * @param trigger defines the trigger to be tested
  108966. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  108967. * @return whether the trigger is handled
  108968. */
  108969. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  108970. /**
  108971. * Serialize this manager to a JSON object
  108972. * @param name defines the property name to store this manager
  108973. * @returns a JSON representation of this manager
  108974. */
  108975. abstract serialize(name: string): any;
  108976. /**
  108977. * Registers an action to this action manager
  108978. * @param action defines the action to be registered
  108979. * @return the action amended (prepared) after registration
  108980. */
  108981. abstract registerAction(action: IAction): Nullable<IAction>;
  108982. /**
  108983. * Unregisters an action to this action manager
  108984. * @param action defines the action to be unregistered
  108985. * @return a boolean indicating whether the action has been unregistered
  108986. */
  108987. abstract unregisterAction(action: IAction): Boolean;
  108988. /**
  108989. * Does exist one action manager with at least one trigger
  108990. **/
  108991. static get HasTriggers(): boolean;
  108992. /**
  108993. * Does exist one action manager with at least one pick trigger
  108994. **/
  108995. static get HasPickTriggers(): boolean;
  108996. /**
  108997. * Does exist one action manager that handles actions of a given trigger
  108998. * @param trigger defines the trigger to be tested
  108999. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  109000. **/
  109001. static HasSpecificTrigger(trigger: number): boolean;
  109002. }
  109003. }
  109004. declare module BABYLON {
  109005. /**
  109006. * Defines how a node can be built from a string name.
  109007. */
  109008. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  109009. /**
  109010. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  109011. */
  109012. export class Node implements IBehaviorAware<Node> {
  109013. /** @hidden */
  109014. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  109015. private static _NodeConstructors;
  109016. /**
  109017. * Add a new node constructor
  109018. * @param type defines the type name of the node to construct
  109019. * @param constructorFunc defines the constructor function
  109020. */
  109021. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  109022. /**
  109023. * Returns a node constructor based on type name
  109024. * @param type defines the type name
  109025. * @param name defines the new node name
  109026. * @param scene defines the hosting scene
  109027. * @param options defines optional options to transmit to constructors
  109028. * @returns the new constructor or null
  109029. */
  109030. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  109031. /**
  109032. * Gets or sets the name of the node
  109033. */
  109034. name: string;
  109035. /**
  109036. * Gets or sets the id of the node
  109037. */
  109038. id: string;
  109039. /**
  109040. * Gets or sets the unique id of the node
  109041. */
  109042. uniqueId: number;
  109043. /**
  109044. * Gets or sets a string used to store user defined state for the node
  109045. */
  109046. state: string;
  109047. /**
  109048. * Gets or sets an object used to store user defined information for the node
  109049. */
  109050. metadata: any;
  109051. /**
  109052. * For internal use only. Please do not use.
  109053. */
  109054. reservedDataStore: any;
  109055. /**
  109056. * List of inspectable custom properties (used by the Inspector)
  109057. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109058. */
  109059. inspectableCustomProperties: IInspectable[];
  109060. private _doNotSerialize;
  109061. /**
  109062. * Gets or sets a boolean used to define if the node must be serialized
  109063. */
  109064. get doNotSerialize(): boolean;
  109065. set doNotSerialize(value: boolean);
  109066. /** @hidden */
  109067. _isDisposed: boolean;
  109068. /**
  109069. * Gets a list of Animations associated with the node
  109070. */
  109071. animations: Animation[];
  109072. protected _ranges: {
  109073. [name: string]: Nullable<AnimationRange>;
  109074. };
  109075. /**
  109076. * Callback raised when the node is ready to be used
  109077. */
  109078. onReady: Nullable<(node: Node) => void>;
  109079. private _isEnabled;
  109080. private _isParentEnabled;
  109081. private _isReady;
  109082. /** @hidden */
  109083. _currentRenderId: number;
  109084. private _parentUpdateId;
  109085. /** @hidden */
  109086. _childUpdateId: number;
  109087. /** @hidden */
  109088. _waitingParentId: Nullable<string>;
  109089. /** @hidden */
  109090. _scene: Scene;
  109091. /** @hidden */
  109092. _cache: any;
  109093. private _parentNode;
  109094. private _children;
  109095. /** @hidden */
  109096. _worldMatrix: Matrix;
  109097. /** @hidden */
  109098. _worldMatrixDeterminant: number;
  109099. /** @hidden */
  109100. _worldMatrixDeterminantIsDirty: boolean;
  109101. /** @hidden */
  109102. private _sceneRootNodesIndex;
  109103. /**
  109104. * Gets a boolean indicating if the node has been disposed
  109105. * @returns true if the node was disposed
  109106. */
  109107. isDisposed(): boolean;
  109108. /**
  109109. * Gets or sets the parent of the node (without keeping the current position in the scene)
  109110. * @see https://doc.babylonjs.com/how_to/parenting
  109111. */
  109112. set parent(parent: Nullable<Node>);
  109113. get parent(): Nullable<Node>;
  109114. /** @hidden */
  109115. _addToSceneRootNodes(): void;
  109116. /** @hidden */
  109117. _removeFromSceneRootNodes(): void;
  109118. private _animationPropertiesOverride;
  109119. /**
  109120. * Gets or sets the animation properties override
  109121. */
  109122. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109123. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109124. /**
  109125. * Gets a string idenfifying the name of the class
  109126. * @returns "Node" string
  109127. */
  109128. getClassName(): string;
  109129. /** @hidden */
  109130. readonly _isNode: boolean;
  109131. /**
  109132. * An event triggered when the mesh is disposed
  109133. */
  109134. onDisposeObservable: Observable<Node>;
  109135. private _onDisposeObserver;
  109136. /**
  109137. * Sets a callback that will be raised when the node will be disposed
  109138. */
  109139. set onDispose(callback: () => void);
  109140. /**
  109141. * Creates a new Node
  109142. * @param name the name and id to be given to this node
  109143. * @param scene the scene this node will be added to
  109144. */
  109145. constructor(name: string, scene?: Nullable<Scene>);
  109146. /**
  109147. * Gets the scene of the node
  109148. * @returns a scene
  109149. */
  109150. getScene(): Scene;
  109151. /**
  109152. * Gets the engine of the node
  109153. * @returns a Engine
  109154. */
  109155. getEngine(): Engine;
  109156. private _behaviors;
  109157. /**
  109158. * Attach a behavior to the node
  109159. * @see http://doc.babylonjs.com/features/behaviour
  109160. * @param behavior defines the behavior to attach
  109161. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  109162. * @returns the current Node
  109163. */
  109164. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  109165. /**
  109166. * Remove an attached behavior
  109167. * @see http://doc.babylonjs.com/features/behaviour
  109168. * @param behavior defines the behavior to attach
  109169. * @returns the current Node
  109170. */
  109171. removeBehavior(behavior: Behavior<Node>): Node;
  109172. /**
  109173. * Gets the list of attached behaviors
  109174. * @see http://doc.babylonjs.com/features/behaviour
  109175. */
  109176. get behaviors(): Behavior<Node>[];
  109177. /**
  109178. * Gets an attached behavior by name
  109179. * @param name defines the name of the behavior to look for
  109180. * @see http://doc.babylonjs.com/features/behaviour
  109181. * @returns null if behavior was not found else the requested behavior
  109182. */
  109183. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  109184. /**
  109185. * Returns the latest update of the World matrix
  109186. * @returns a Matrix
  109187. */
  109188. getWorldMatrix(): Matrix;
  109189. /** @hidden */
  109190. _getWorldMatrixDeterminant(): number;
  109191. /**
  109192. * Returns directly the latest state of the mesh World matrix.
  109193. * A Matrix is returned.
  109194. */
  109195. get worldMatrixFromCache(): Matrix;
  109196. /** @hidden */
  109197. _initCache(): void;
  109198. /** @hidden */
  109199. updateCache(force?: boolean): void;
  109200. /** @hidden */
  109201. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109202. /** @hidden */
  109203. _updateCache(ignoreParentClass?: boolean): void;
  109204. /** @hidden */
  109205. _isSynchronized(): boolean;
  109206. /** @hidden */
  109207. _markSyncedWithParent(): void;
  109208. /** @hidden */
  109209. isSynchronizedWithParent(): boolean;
  109210. /** @hidden */
  109211. isSynchronized(): boolean;
  109212. /**
  109213. * Is this node ready to be used/rendered
  109214. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109215. * @return true if the node is ready
  109216. */
  109217. isReady(completeCheck?: boolean): boolean;
  109218. /**
  109219. * Is this node enabled?
  109220. * 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
  109221. * @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
  109222. * @return whether this node (and its parent) is enabled
  109223. */
  109224. isEnabled(checkAncestors?: boolean): boolean;
  109225. /** @hidden */
  109226. protected _syncParentEnabledState(): void;
  109227. /**
  109228. * Set the enabled state of this node
  109229. * @param value defines the new enabled state
  109230. */
  109231. setEnabled(value: boolean): void;
  109232. /**
  109233. * Is this node a descendant of the given node?
  109234. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  109235. * @param ancestor defines the parent node to inspect
  109236. * @returns a boolean indicating if this node is a descendant of the given node
  109237. */
  109238. isDescendantOf(ancestor: Node): boolean;
  109239. /** @hidden */
  109240. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  109241. /**
  109242. * Will return all nodes that have this node as ascendant
  109243. * @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
  109244. * @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
  109245. * @return all children nodes of all types
  109246. */
  109247. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  109248. /**
  109249. * Get all child-meshes of this node
  109250. * @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)
  109251. * @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
  109252. * @returns an array of AbstractMesh
  109253. */
  109254. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  109255. /**
  109256. * Get all direct children of this node
  109257. * @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
  109258. * @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)
  109259. * @returns an array of Node
  109260. */
  109261. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  109262. /** @hidden */
  109263. _setReady(state: boolean): void;
  109264. /**
  109265. * Get an animation by name
  109266. * @param name defines the name of the animation to look for
  109267. * @returns null if not found else the requested animation
  109268. */
  109269. getAnimationByName(name: string): Nullable<Animation>;
  109270. /**
  109271. * Creates an animation range for this node
  109272. * @param name defines the name of the range
  109273. * @param from defines the starting key
  109274. * @param to defines the end key
  109275. */
  109276. createAnimationRange(name: string, from: number, to: number): void;
  109277. /**
  109278. * Delete a specific animation range
  109279. * @param name defines the name of the range to delete
  109280. * @param deleteFrames defines if animation frames from the range must be deleted as well
  109281. */
  109282. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  109283. /**
  109284. * Get an animation range by name
  109285. * @param name defines the name of the animation range to look for
  109286. * @returns null if not found else the requested animation range
  109287. */
  109288. getAnimationRange(name: string): Nullable<AnimationRange>;
  109289. /**
  109290. * Gets the list of all animation ranges defined on this node
  109291. * @returns an array
  109292. */
  109293. getAnimationRanges(): Nullable<AnimationRange>[];
  109294. /**
  109295. * Will start the animation sequence
  109296. * @param name defines the range frames for animation sequence
  109297. * @param loop defines if the animation should loop (false by default)
  109298. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  109299. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  109300. * @returns the object created for this animation. If range does not exist, it will return null
  109301. */
  109302. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  109303. /**
  109304. * Serialize animation ranges into a JSON compatible object
  109305. * @returns serialization object
  109306. */
  109307. serializeAnimationRanges(): any;
  109308. /**
  109309. * Computes the world matrix of the node
  109310. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  109311. * @returns the world matrix
  109312. */
  109313. computeWorldMatrix(force?: boolean): Matrix;
  109314. /**
  109315. * Releases resources associated with this node.
  109316. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109317. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109318. */
  109319. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109320. /**
  109321. * Parse animation range data from a serialization object and store them into a given node
  109322. * @param node defines where to store the animation ranges
  109323. * @param parsedNode defines the serialization object to read data from
  109324. * @param scene defines the hosting scene
  109325. */
  109326. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  109327. /**
  109328. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  109329. * @param includeDescendants Include bounding info from descendants as well (true by default)
  109330. * @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
  109331. * @returns the new bounding vectors
  109332. */
  109333. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  109334. min: Vector3;
  109335. max: Vector3;
  109336. };
  109337. }
  109338. }
  109339. declare module BABYLON {
  109340. /**
  109341. * @hidden
  109342. */
  109343. export class _IAnimationState {
  109344. key: number;
  109345. repeatCount: number;
  109346. workValue?: any;
  109347. loopMode?: number;
  109348. offsetValue?: any;
  109349. highLimitValue?: any;
  109350. }
  109351. /**
  109352. * Class used to store any kind of animation
  109353. */
  109354. export class Animation {
  109355. /**Name of the animation */
  109356. name: string;
  109357. /**Property to animate */
  109358. targetProperty: string;
  109359. /**The frames per second of the animation */
  109360. framePerSecond: number;
  109361. /**The data type of the animation */
  109362. dataType: number;
  109363. /**The loop mode of the animation */
  109364. loopMode?: number | undefined;
  109365. /**Specifies if blending should be enabled */
  109366. enableBlending?: boolean | undefined;
  109367. /**
  109368. * Use matrix interpolation instead of using direct key value when animating matrices
  109369. */
  109370. static AllowMatricesInterpolation: boolean;
  109371. /**
  109372. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  109373. */
  109374. static AllowMatrixDecomposeForInterpolation: boolean;
  109375. /**
  109376. * Stores the key frames of the animation
  109377. */
  109378. private _keys;
  109379. /**
  109380. * Stores the easing function of the animation
  109381. */
  109382. private _easingFunction;
  109383. /**
  109384. * @hidden Internal use only
  109385. */
  109386. _runtimeAnimations: RuntimeAnimation[];
  109387. /**
  109388. * The set of event that will be linked to this animation
  109389. */
  109390. private _events;
  109391. /**
  109392. * Stores an array of target property paths
  109393. */
  109394. targetPropertyPath: string[];
  109395. /**
  109396. * Stores the blending speed of the animation
  109397. */
  109398. blendingSpeed: number;
  109399. /**
  109400. * Stores the animation ranges for the animation
  109401. */
  109402. private _ranges;
  109403. /**
  109404. * @hidden Internal use
  109405. */
  109406. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  109407. /**
  109408. * Sets up an animation
  109409. * @param property The property to animate
  109410. * @param animationType The animation type to apply
  109411. * @param framePerSecond The frames per second of the animation
  109412. * @param easingFunction The easing function used in the animation
  109413. * @returns The created animation
  109414. */
  109415. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  109416. /**
  109417. * Create and start an animation on a node
  109418. * @param name defines the name of the global animation that will be run on all nodes
  109419. * @param node defines the root node where the animation will take place
  109420. * @param targetProperty defines property to animate
  109421. * @param framePerSecond defines the number of frame per second yo use
  109422. * @param totalFrame defines the number of frames in total
  109423. * @param from defines the initial value
  109424. * @param to defines the final value
  109425. * @param loopMode defines which loop mode you want to use (off by default)
  109426. * @param easingFunction defines the easing function to use (linear by default)
  109427. * @param onAnimationEnd defines the callback to call when animation end
  109428. * @returns the animatable created for this animation
  109429. */
  109430. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109431. /**
  109432. * Create and start an animation on a node and its descendants
  109433. * @param name defines the name of the global animation that will be run on all nodes
  109434. * @param node defines the root node where the animation will take place
  109435. * @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
  109436. * @param targetProperty defines property to animate
  109437. * @param framePerSecond defines the number of frame per second to use
  109438. * @param totalFrame defines the number of frames in total
  109439. * @param from defines the initial value
  109440. * @param to defines the final value
  109441. * @param loopMode defines which loop mode you want to use (off by default)
  109442. * @param easingFunction defines the easing function to use (linear by default)
  109443. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  109444. * @returns the list of animatables created for all nodes
  109445. * @example https://www.babylonjs-playground.com/#MH0VLI
  109446. */
  109447. 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[]>;
  109448. /**
  109449. * Creates a new animation, merges it with the existing animations and starts it
  109450. * @param name Name of the animation
  109451. * @param node Node which contains the scene that begins the animations
  109452. * @param targetProperty Specifies which property to animate
  109453. * @param framePerSecond The frames per second of the animation
  109454. * @param totalFrame The total number of frames
  109455. * @param from The frame at the beginning of the animation
  109456. * @param to The frame at the end of the animation
  109457. * @param loopMode Specifies the loop mode of the animation
  109458. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  109459. * @param onAnimationEnd Callback to run once the animation is complete
  109460. * @returns Nullable animation
  109461. */
  109462. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109463. /**
  109464. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109465. * @param sourceAnimation defines the Animation containing keyframes to convert
  109466. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109467. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  109468. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  109469. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  109470. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  109471. */
  109472. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  109473. /**
  109474. * Transition property of an host to the target Value
  109475. * @param property The property to transition
  109476. * @param targetValue The target Value of the property
  109477. * @param host The object where the property to animate belongs
  109478. * @param scene Scene used to run the animation
  109479. * @param frameRate Framerate (in frame/s) to use
  109480. * @param transition The transition type we want to use
  109481. * @param duration The duration of the animation, in milliseconds
  109482. * @param onAnimationEnd Callback trigger at the end of the animation
  109483. * @returns Nullable animation
  109484. */
  109485. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  109486. /**
  109487. * Return the array of runtime animations currently using this animation
  109488. */
  109489. get runtimeAnimations(): RuntimeAnimation[];
  109490. /**
  109491. * Specifies if any of the runtime animations are currently running
  109492. */
  109493. get hasRunningRuntimeAnimations(): boolean;
  109494. /**
  109495. * Initializes the animation
  109496. * @param name Name of the animation
  109497. * @param targetProperty Property to animate
  109498. * @param framePerSecond The frames per second of the animation
  109499. * @param dataType The data type of the animation
  109500. * @param loopMode The loop mode of the animation
  109501. * @param enableBlending Specifies if blending should be enabled
  109502. */
  109503. constructor(
  109504. /**Name of the animation */
  109505. name: string,
  109506. /**Property to animate */
  109507. targetProperty: string,
  109508. /**The frames per second of the animation */
  109509. framePerSecond: number,
  109510. /**The data type of the animation */
  109511. dataType: number,
  109512. /**The loop mode of the animation */
  109513. loopMode?: number | undefined,
  109514. /**Specifies if blending should be enabled */
  109515. enableBlending?: boolean | undefined);
  109516. /**
  109517. * Converts the animation to a string
  109518. * @param fullDetails support for multiple levels of logging within scene loading
  109519. * @returns String form of the animation
  109520. */
  109521. toString(fullDetails?: boolean): string;
  109522. /**
  109523. * Add an event to this animation
  109524. * @param event Event to add
  109525. */
  109526. addEvent(event: AnimationEvent): void;
  109527. /**
  109528. * Remove all events found at the given frame
  109529. * @param frame The frame to remove events from
  109530. */
  109531. removeEvents(frame: number): void;
  109532. /**
  109533. * Retrieves all the events from the animation
  109534. * @returns Events from the animation
  109535. */
  109536. getEvents(): AnimationEvent[];
  109537. /**
  109538. * Creates an animation range
  109539. * @param name Name of the animation range
  109540. * @param from Starting frame of the animation range
  109541. * @param to Ending frame of the animation
  109542. */
  109543. createRange(name: string, from: number, to: number): void;
  109544. /**
  109545. * Deletes an animation range by name
  109546. * @param name Name of the animation range to delete
  109547. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  109548. */
  109549. deleteRange(name: string, deleteFrames?: boolean): void;
  109550. /**
  109551. * Gets the animation range by name, or null if not defined
  109552. * @param name Name of the animation range
  109553. * @returns Nullable animation range
  109554. */
  109555. getRange(name: string): Nullable<AnimationRange>;
  109556. /**
  109557. * Gets the key frames from the animation
  109558. * @returns The key frames of the animation
  109559. */
  109560. getKeys(): Array<IAnimationKey>;
  109561. /**
  109562. * Gets the highest frame rate of the animation
  109563. * @returns Highest frame rate of the animation
  109564. */
  109565. getHighestFrame(): number;
  109566. /**
  109567. * Gets the easing function of the animation
  109568. * @returns Easing function of the animation
  109569. */
  109570. getEasingFunction(): IEasingFunction;
  109571. /**
  109572. * Sets the easing function of the animation
  109573. * @param easingFunction A custom mathematical formula for animation
  109574. */
  109575. setEasingFunction(easingFunction: EasingFunction): void;
  109576. /**
  109577. * Interpolates a scalar linearly
  109578. * @param startValue Start value of the animation curve
  109579. * @param endValue End value of the animation curve
  109580. * @param gradient Scalar amount to interpolate
  109581. * @returns Interpolated scalar value
  109582. */
  109583. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  109584. /**
  109585. * Interpolates a scalar cubically
  109586. * @param startValue Start value of the animation curve
  109587. * @param outTangent End tangent of the animation
  109588. * @param endValue End value of the animation curve
  109589. * @param inTangent Start tangent of the animation curve
  109590. * @param gradient Scalar amount to interpolate
  109591. * @returns Interpolated scalar value
  109592. */
  109593. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  109594. /**
  109595. * Interpolates a quaternion using a spherical linear interpolation
  109596. * @param startValue Start value of the animation curve
  109597. * @param endValue End value of the animation curve
  109598. * @param gradient Scalar amount to interpolate
  109599. * @returns Interpolated quaternion value
  109600. */
  109601. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  109602. /**
  109603. * Interpolates a quaternion cubically
  109604. * @param startValue Start value of the animation curve
  109605. * @param outTangent End tangent of the animation curve
  109606. * @param endValue End value of the animation curve
  109607. * @param inTangent Start tangent of the animation curve
  109608. * @param gradient Scalar amount to interpolate
  109609. * @returns Interpolated quaternion value
  109610. */
  109611. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  109612. /**
  109613. * Interpolates a Vector3 linearl
  109614. * @param startValue Start value of the animation curve
  109615. * @param endValue End value of the animation curve
  109616. * @param gradient Scalar amount to interpolate
  109617. * @returns Interpolated scalar value
  109618. */
  109619. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  109620. /**
  109621. * Interpolates a Vector3 cubically
  109622. * @param startValue Start value of the animation curve
  109623. * @param outTangent End tangent of the animation
  109624. * @param endValue End value of the animation curve
  109625. * @param inTangent Start tangent of the animation curve
  109626. * @param gradient Scalar amount to interpolate
  109627. * @returns InterpolatedVector3 value
  109628. */
  109629. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  109630. /**
  109631. * Interpolates a Vector2 linearly
  109632. * @param startValue Start value of the animation curve
  109633. * @param endValue End value of the animation curve
  109634. * @param gradient Scalar amount to interpolate
  109635. * @returns Interpolated Vector2 value
  109636. */
  109637. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  109638. /**
  109639. * Interpolates a Vector2 cubically
  109640. * @param startValue Start value of the animation curve
  109641. * @param outTangent End tangent of the animation
  109642. * @param endValue End value of the animation curve
  109643. * @param inTangent Start tangent of the animation curve
  109644. * @param gradient Scalar amount to interpolate
  109645. * @returns Interpolated Vector2 value
  109646. */
  109647. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  109648. /**
  109649. * Interpolates a size linearly
  109650. * @param startValue Start value of the animation curve
  109651. * @param endValue End value of the animation curve
  109652. * @param gradient Scalar amount to interpolate
  109653. * @returns Interpolated Size value
  109654. */
  109655. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  109656. /**
  109657. * Interpolates a Color3 linearly
  109658. * @param startValue Start value of the animation curve
  109659. * @param endValue End value of the animation curve
  109660. * @param gradient Scalar amount to interpolate
  109661. * @returns Interpolated Color3 value
  109662. */
  109663. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  109664. /**
  109665. * Interpolates a Color4 linearly
  109666. * @param startValue Start value of the animation curve
  109667. * @param endValue End value of the animation curve
  109668. * @param gradient Scalar amount to interpolate
  109669. * @returns Interpolated Color3 value
  109670. */
  109671. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  109672. /**
  109673. * @hidden Internal use only
  109674. */
  109675. _getKeyValue(value: any): any;
  109676. /**
  109677. * @hidden Internal use only
  109678. */
  109679. _interpolate(currentFrame: number, state: _IAnimationState): any;
  109680. /**
  109681. * Defines the function to use to interpolate matrices
  109682. * @param startValue defines the start matrix
  109683. * @param endValue defines the end matrix
  109684. * @param gradient defines the gradient between both matrices
  109685. * @param result defines an optional target matrix where to store the interpolation
  109686. * @returns the interpolated matrix
  109687. */
  109688. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  109689. /**
  109690. * Makes a copy of the animation
  109691. * @returns Cloned animation
  109692. */
  109693. clone(): Animation;
  109694. /**
  109695. * Sets the key frames of the animation
  109696. * @param values The animation key frames to set
  109697. */
  109698. setKeys(values: Array<IAnimationKey>): void;
  109699. /**
  109700. * Serializes the animation to an object
  109701. * @returns Serialized object
  109702. */
  109703. serialize(): any;
  109704. /**
  109705. * Float animation type
  109706. */
  109707. static readonly ANIMATIONTYPE_FLOAT: number;
  109708. /**
  109709. * Vector3 animation type
  109710. */
  109711. static readonly ANIMATIONTYPE_VECTOR3: number;
  109712. /**
  109713. * Quaternion animation type
  109714. */
  109715. static readonly ANIMATIONTYPE_QUATERNION: number;
  109716. /**
  109717. * Matrix animation type
  109718. */
  109719. static readonly ANIMATIONTYPE_MATRIX: number;
  109720. /**
  109721. * Color3 animation type
  109722. */
  109723. static readonly ANIMATIONTYPE_COLOR3: number;
  109724. /**
  109725. * Color3 animation type
  109726. */
  109727. static readonly ANIMATIONTYPE_COLOR4: number;
  109728. /**
  109729. * Vector2 animation type
  109730. */
  109731. static readonly ANIMATIONTYPE_VECTOR2: number;
  109732. /**
  109733. * Size animation type
  109734. */
  109735. static readonly ANIMATIONTYPE_SIZE: number;
  109736. /**
  109737. * Relative Loop Mode
  109738. */
  109739. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  109740. /**
  109741. * Cycle Loop Mode
  109742. */
  109743. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  109744. /**
  109745. * Constant Loop Mode
  109746. */
  109747. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  109748. /** @hidden */
  109749. static _UniversalLerp(left: any, right: any, amount: number): any;
  109750. /**
  109751. * Parses an animation object and creates an animation
  109752. * @param parsedAnimation Parsed animation object
  109753. * @returns Animation object
  109754. */
  109755. static Parse(parsedAnimation: any): Animation;
  109756. /**
  109757. * Appends the serialized animations from the source animations
  109758. * @param source Source containing the animations
  109759. * @param destination Target to store the animations
  109760. */
  109761. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109762. }
  109763. }
  109764. declare module BABYLON {
  109765. /**
  109766. * Interface containing an array of animations
  109767. */
  109768. export interface IAnimatable {
  109769. /**
  109770. * Array of animations
  109771. */
  109772. animations: Nullable<Array<Animation>>;
  109773. }
  109774. }
  109775. declare module BABYLON {
  109776. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  109777. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109778. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109779. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109780. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109781. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109782. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109783. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109784. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109785. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109786. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109787. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109788. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109789. /**
  109790. * Decorator used to define property that can be serialized as reference to a camera
  109791. * @param sourceName defines the name of the property to decorate
  109792. */
  109793. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109794. /**
  109795. * Class used to help serialization objects
  109796. */
  109797. export class SerializationHelper {
  109798. /** @hidden */
  109799. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  109800. /** @hidden */
  109801. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  109802. /** @hidden */
  109803. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  109804. /** @hidden */
  109805. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  109806. /**
  109807. * Appends the serialized animations from the source animations
  109808. * @param source Source containing the animations
  109809. * @param destination Target to store the animations
  109810. */
  109811. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109812. /**
  109813. * Static function used to serialized a specific entity
  109814. * @param entity defines the entity to serialize
  109815. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  109816. * @returns a JSON compatible object representing the serialization of the entity
  109817. */
  109818. static Serialize<T>(entity: T, serializationObject?: any): any;
  109819. /**
  109820. * Creates a new entity from a serialization data object
  109821. * @param creationFunction defines a function used to instanciated the new entity
  109822. * @param source defines the source serialization data
  109823. * @param scene defines the hosting scene
  109824. * @param rootUrl defines the root url for resources
  109825. * @returns a new entity
  109826. */
  109827. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  109828. /**
  109829. * Clones an object
  109830. * @param creationFunction defines the function used to instanciate the new object
  109831. * @param source defines the source object
  109832. * @returns the cloned object
  109833. */
  109834. static Clone<T>(creationFunction: () => T, source: T): T;
  109835. /**
  109836. * Instanciates a new object based on a source one (some data will be shared between both object)
  109837. * @param creationFunction defines the function used to instanciate the new object
  109838. * @param source defines the source object
  109839. * @returns the new object
  109840. */
  109841. static Instanciate<T>(creationFunction: () => T, source: T): T;
  109842. }
  109843. }
  109844. declare module BABYLON {
  109845. /**
  109846. * Base class of all the textures in babylon.
  109847. * It groups all the common properties the materials, post process, lights... might need
  109848. * in order to make a correct use of the texture.
  109849. */
  109850. export class BaseTexture implements IAnimatable {
  109851. /**
  109852. * Default anisotropic filtering level for the application.
  109853. * It is set to 4 as a good tradeoff between perf and quality.
  109854. */
  109855. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  109856. /**
  109857. * Gets or sets the unique id of the texture
  109858. */
  109859. uniqueId: number;
  109860. /**
  109861. * Define the name of the texture.
  109862. */
  109863. name: string;
  109864. /**
  109865. * Gets or sets an object used to store user defined information.
  109866. */
  109867. metadata: any;
  109868. /**
  109869. * For internal use only. Please do not use.
  109870. */
  109871. reservedDataStore: any;
  109872. private _hasAlpha;
  109873. /**
  109874. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  109875. */
  109876. set hasAlpha(value: boolean);
  109877. get hasAlpha(): boolean;
  109878. /**
  109879. * Defines if the alpha value should be determined via the rgb values.
  109880. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  109881. */
  109882. getAlphaFromRGB: boolean;
  109883. /**
  109884. * Intensity or strength of the texture.
  109885. * It is commonly used by materials to fine tune the intensity of the texture
  109886. */
  109887. level: number;
  109888. /**
  109889. * Define the UV chanel to use starting from 0 and defaulting to 0.
  109890. * This is part of the texture as textures usually maps to one uv set.
  109891. */
  109892. coordinatesIndex: number;
  109893. private _coordinatesMode;
  109894. /**
  109895. * How a texture is mapped.
  109896. *
  109897. * | Value | Type | Description |
  109898. * | ----- | ----------------------------------- | ----------- |
  109899. * | 0 | EXPLICIT_MODE | |
  109900. * | 1 | SPHERICAL_MODE | |
  109901. * | 2 | PLANAR_MODE | |
  109902. * | 3 | CUBIC_MODE | |
  109903. * | 4 | PROJECTION_MODE | |
  109904. * | 5 | SKYBOX_MODE | |
  109905. * | 6 | INVCUBIC_MODE | |
  109906. * | 7 | EQUIRECTANGULAR_MODE | |
  109907. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  109908. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  109909. */
  109910. set coordinatesMode(value: number);
  109911. get coordinatesMode(): number;
  109912. /**
  109913. * | Value | Type | Description |
  109914. * | ----- | ------------------ | ----------- |
  109915. * | 0 | CLAMP_ADDRESSMODE | |
  109916. * | 1 | WRAP_ADDRESSMODE | |
  109917. * | 2 | MIRROR_ADDRESSMODE | |
  109918. */
  109919. wrapU: number;
  109920. /**
  109921. * | Value | Type | Description |
  109922. * | ----- | ------------------ | ----------- |
  109923. * | 0 | CLAMP_ADDRESSMODE | |
  109924. * | 1 | WRAP_ADDRESSMODE | |
  109925. * | 2 | MIRROR_ADDRESSMODE | |
  109926. */
  109927. wrapV: number;
  109928. /**
  109929. * | Value | Type | Description |
  109930. * | ----- | ------------------ | ----------- |
  109931. * | 0 | CLAMP_ADDRESSMODE | |
  109932. * | 1 | WRAP_ADDRESSMODE | |
  109933. * | 2 | MIRROR_ADDRESSMODE | |
  109934. */
  109935. wrapR: number;
  109936. /**
  109937. * With compliant hardware and browser (supporting anisotropic filtering)
  109938. * this defines the level of anisotropic filtering in the texture.
  109939. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  109940. */
  109941. anisotropicFilteringLevel: number;
  109942. /**
  109943. * Define if the texture is a cube texture or if false a 2d texture.
  109944. */
  109945. get isCube(): boolean;
  109946. set isCube(value: boolean);
  109947. /**
  109948. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  109949. */
  109950. get is3D(): boolean;
  109951. set is3D(value: boolean);
  109952. /**
  109953. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  109954. */
  109955. get is2DArray(): boolean;
  109956. set is2DArray(value: boolean);
  109957. /**
  109958. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  109959. * HDR texture are usually stored in linear space.
  109960. * This only impacts the PBR and Background materials
  109961. */
  109962. gammaSpace: boolean;
  109963. /**
  109964. * Gets or sets whether or not the texture contains RGBD data.
  109965. */
  109966. get isRGBD(): boolean;
  109967. set isRGBD(value: boolean);
  109968. /**
  109969. * Is Z inverted in the texture (useful in a cube texture).
  109970. */
  109971. invertZ: boolean;
  109972. /**
  109973. * Are mip maps generated for this texture or not.
  109974. */
  109975. get noMipmap(): boolean;
  109976. /**
  109977. * @hidden
  109978. */
  109979. lodLevelInAlpha: boolean;
  109980. /**
  109981. * With prefiltered texture, defined the offset used during the prefiltering steps.
  109982. */
  109983. get lodGenerationOffset(): number;
  109984. set lodGenerationOffset(value: number);
  109985. /**
  109986. * With prefiltered texture, defined the scale used during the prefiltering steps.
  109987. */
  109988. get lodGenerationScale(): number;
  109989. set lodGenerationScale(value: number);
  109990. /**
  109991. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  109992. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  109993. * average roughness values.
  109994. */
  109995. get linearSpecularLOD(): boolean;
  109996. set linearSpecularLOD(value: boolean);
  109997. /**
  109998. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  109999. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  110000. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  110001. */
  110002. get irradianceTexture(): Nullable<BaseTexture>;
  110003. set irradianceTexture(value: Nullable<BaseTexture>);
  110004. /**
  110005. * Define if the texture is a render target.
  110006. */
  110007. isRenderTarget: boolean;
  110008. /**
  110009. * Define the unique id of the texture in the scene.
  110010. */
  110011. get uid(): string;
  110012. /** @hidden */
  110013. _prefiltered: boolean;
  110014. /**
  110015. * Return a string representation of the texture.
  110016. * @returns the texture as a string
  110017. */
  110018. toString(): string;
  110019. /**
  110020. * Get the class name of the texture.
  110021. * @returns "BaseTexture"
  110022. */
  110023. getClassName(): string;
  110024. /**
  110025. * Define the list of animation attached to the texture.
  110026. */
  110027. animations: Animation[];
  110028. /**
  110029. * An event triggered when the texture is disposed.
  110030. */
  110031. onDisposeObservable: Observable<BaseTexture>;
  110032. private _onDisposeObserver;
  110033. /**
  110034. * Callback triggered when the texture has been disposed.
  110035. * Kept for back compatibility, you can use the onDisposeObservable instead.
  110036. */
  110037. set onDispose(callback: () => void);
  110038. /**
  110039. * Define the current state of the loading sequence when in delayed load mode.
  110040. */
  110041. delayLoadState: number;
  110042. private _scene;
  110043. private _engine;
  110044. /** @hidden */
  110045. _texture: Nullable<InternalTexture>;
  110046. private _uid;
  110047. /**
  110048. * Define if the texture is preventinga material to render or not.
  110049. * If not and the texture is not ready, the engine will use a default black texture instead.
  110050. */
  110051. get isBlocking(): boolean;
  110052. /**
  110053. * Instantiates a new BaseTexture.
  110054. * Base class of all the textures in babylon.
  110055. * It groups all the common properties the materials, post process, lights... might need
  110056. * in order to make a correct use of the texture.
  110057. * @param sceneOrEngine Define the scene or engine the texture blongs to
  110058. */
  110059. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  110060. /**
  110061. * Get the scene the texture belongs to.
  110062. * @returns the scene or null if undefined
  110063. */
  110064. getScene(): Nullable<Scene>;
  110065. /** @hidden */
  110066. protected _getEngine(): Nullable<ThinEngine>;
  110067. /**
  110068. * Get the texture transform matrix used to offset tile the texture for istance.
  110069. * @returns the transformation matrix
  110070. */
  110071. getTextureMatrix(): Matrix;
  110072. /**
  110073. * Get the texture reflection matrix used to rotate/transform the reflection.
  110074. * @returns the reflection matrix
  110075. */
  110076. getReflectionTextureMatrix(): Matrix;
  110077. /**
  110078. * Get the underlying lower level texture from Babylon.
  110079. * @returns the insternal texture
  110080. */
  110081. getInternalTexture(): Nullable<InternalTexture>;
  110082. /**
  110083. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  110084. * @returns true if ready or not blocking
  110085. */
  110086. isReadyOrNotBlocking(): boolean;
  110087. /**
  110088. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  110089. * @returns true if fully ready
  110090. */
  110091. isReady(): boolean;
  110092. private _cachedSize;
  110093. /**
  110094. * Get the size of the texture.
  110095. * @returns the texture size.
  110096. */
  110097. getSize(): ISize;
  110098. /**
  110099. * Get the base size of the texture.
  110100. * It can be different from the size if the texture has been resized for POT for instance
  110101. * @returns the base size
  110102. */
  110103. getBaseSize(): ISize;
  110104. /**
  110105. * Update the sampling mode of the texture.
  110106. * Default is Trilinear mode.
  110107. *
  110108. * | Value | Type | Description |
  110109. * | ----- | ------------------ | ----------- |
  110110. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  110111. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  110112. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  110113. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  110114. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  110115. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  110116. * | 7 | NEAREST_LINEAR | |
  110117. * | 8 | NEAREST_NEAREST | |
  110118. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  110119. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  110120. * | 11 | LINEAR_LINEAR | |
  110121. * | 12 | LINEAR_NEAREST | |
  110122. *
  110123. * > _mag_: magnification filter (close to the viewer)
  110124. * > _min_: minification filter (far from the viewer)
  110125. * > _mip_: filter used between mip map levels
  110126. *@param samplingMode Define the new sampling mode of the texture
  110127. */
  110128. updateSamplingMode(samplingMode: number): void;
  110129. /**
  110130. * Scales the texture if is `canRescale()`
  110131. * @param ratio the resize factor we want to use to rescale
  110132. */
  110133. scale(ratio: number): void;
  110134. /**
  110135. * Get if the texture can rescale.
  110136. */
  110137. get canRescale(): boolean;
  110138. /** @hidden */
  110139. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  110140. /** @hidden */
  110141. _rebuild(): void;
  110142. /**
  110143. * Triggers the load sequence in delayed load mode.
  110144. */
  110145. delayLoad(): void;
  110146. /**
  110147. * Clones the texture.
  110148. * @returns the cloned texture
  110149. */
  110150. clone(): Nullable<BaseTexture>;
  110151. /**
  110152. * Get the texture underlying type (INT, FLOAT...)
  110153. */
  110154. get textureType(): number;
  110155. /**
  110156. * Get the texture underlying format (RGB, RGBA...)
  110157. */
  110158. get textureFormat(): number;
  110159. /**
  110160. * Indicates that textures need to be re-calculated for all materials
  110161. */
  110162. protected _markAllSubMeshesAsTexturesDirty(): void;
  110163. /**
  110164. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  110165. * This will returns an RGBA array buffer containing either in values (0-255) or
  110166. * float values (0-1) depending of the underlying buffer type.
  110167. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  110168. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  110169. * @param buffer defines a user defined buffer to fill with data (can be null)
  110170. * @returns The Array buffer containing the pixels data.
  110171. */
  110172. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  110173. /**
  110174. * Release and destroy the underlying lower level texture aka internalTexture.
  110175. */
  110176. releaseInternalTexture(): void;
  110177. /** @hidden */
  110178. get _lodTextureHigh(): Nullable<BaseTexture>;
  110179. /** @hidden */
  110180. get _lodTextureMid(): Nullable<BaseTexture>;
  110181. /** @hidden */
  110182. get _lodTextureLow(): Nullable<BaseTexture>;
  110183. /**
  110184. * Dispose the texture and release its associated resources.
  110185. */
  110186. dispose(): void;
  110187. /**
  110188. * Serialize the texture into a JSON representation that can be parsed later on.
  110189. * @returns the JSON representation of the texture
  110190. */
  110191. serialize(): any;
  110192. /**
  110193. * Helper function to be called back once a list of texture contains only ready textures.
  110194. * @param textures Define the list of textures to wait for
  110195. * @param callback Define the callback triggered once the entire list will be ready
  110196. */
  110197. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  110198. private static _isScene;
  110199. }
  110200. }
  110201. declare module BABYLON {
  110202. /**
  110203. * Options to be used when creating an effect.
  110204. */
  110205. export interface IEffectCreationOptions {
  110206. /**
  110207. * Atrributes that will be used in the shader.
  110208. */
  110209. attributes: string[];
  110210. /**
  110211. * Uniform varible names that will be set in the shader.
  110212. */
  110213. uniformsNames: string[];
  110214. /**
  110215. * Uniform buffer variable names that will be set in the shader.
  110216. */
  110217. uniformBuffersNames: string[];
  110218. /**
  110219. * Sampler texture variable names that will be set in the shader.
  110220. */
  110221. samplers: string[];
  110222. /**
  110223. * Define statements that will be set in the shader.
  110224. */
  110225. defines: any;
  110226. /**
  110227. * Possible fallbacks for this effect to improve performance when needed.
  110228. */
  110229. fallbacks: Nullable<IEffectFallbacks>;
  110230. /**
  110231. * Callback that will be called when the shader is compiled.
  110232. */
  110233. onCompiled: Nullable<(effect: Effect) => void>;
  110234. /**
  110235. * Callback that will be called if an error occurs during shader compilation.
  110236. */
  110237. onError: Nullable<(effect: Effect, errors: string) => void>;
  110238. /**
  110239. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110240. */
  110241. indexParameters?: any;
  110242. /**
  110243. * Max number of lights that can be used in the shader.
  110244. */
  110245. maxSimultaneousLights?: number;
  110246. /**
  110247. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  110248. */
  110249. transformFeedbackVaryings?: Nullable<string[]>;
  110250. /**
  110251. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  110252. */
  110253. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110254. }
  110255. /**
  110256. * Effect containing vertex and fragment shader that can be executed on an object.
  110257. */
  110258. export class Effect implements IDisposable {
  110259. /**
  110260. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  110261. */
  110262. static ShadersRepository: string;
  110263. /**
  110264. * Enable logging of the shader code when a compilation error occurs
  110265. */
  110266. static LogShaderCodeOnCompilationError: boolean;
  110267. /**
  110268. * Name of the effect.
  110269. */
  110270. name: any;
  110271. /**
  110272. * String container all the define statements that should be set on the shader.
  110273. */
  110274. defines: string;
  110275. /**
  110276. * Callback that will be called when the shader is compiled.
  110277. */
  110278. onCompiled: Nullable<(effect: Effect) => void>;
  110279. /**
  110280. * Callback that will be called if an error occurs during shader compilation.
  110281. */
  110282. onError: Nullable<(effect: Effect, errors: string) => void>;
  110283. /**
  110284. * Callback that will be called when effect is bound.
  110285. */
  110286. onBind: Nullable<(effect: Effect) => void>;
  110287. /**
  110288. * Unique ID of the effect.
  110289. */
  110290. uniqueId: number;
  110291. /**
  110292. * Observable that will be called when the shader is compiled.
  110293. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  110294. */
  110295. onCompileObservable: Observable<Effect>;
  110296. /**
  110297. * Observable that will be called if an error occurs during shader compilation.
  110298. */
  110299. onErrorObservable: Observable<Effect>;
  110300. /** @hidden */
  110301. _onBindObservable: Nullable<Observable<Effect>>;
  110302. /**
  110303. * @hidden
  110304. * Specifies if the effect was previously ready
  110305. */
  110306. _wasPreviouslyReady: boolean;
  110307. /**
  110308. * Observable that will be called when effect is bound.
  110309. */
  110310. get onBindObservable(): Observable<Effect>;
  110311. /** @hidden */
  110312. _bonesComputationForcedToCPU: boolean;
  110313. private static _uniqueIdSeed;
  110314. private _engine;
  110315. private _uniformBuffersNames;
  110316. private _uniformBuffersNamesList;
  110317. private _uniformsNames;
  110318. private _samplerList;
  110319. private _samplers;
  110320. private _isReady;
  110321. private _compilationError;
  110322. private _allFallbacksProcessed;
  110323. private _attributesNames;
  110324. private _attributes;
  110325. private _attributeLocationByName;
  110326. private _uniforms;
  110327. /**
  110328. * Key for the effect.
  110329. * @hidden
  110330. */
  110331. _key: string;
  110332. private _indexParameters;
  110333. private _fallbacks;
  110334. private _vertexSourceCode;
  110335. private _fragmentSourceCode;
  110336. private _vertexSourceCodeOverride;
  110337. private _fragmentSourceCodeOverride;
  110338. private _transformFeedbackVaryings;
  110339. /**
  110340. * Compiled shader to webGL program.
  110341. * @hidden
  110342. */
  110343. _pipelineContext: Nullable<IPipelineContext>;
  110344. private _valueCache;
  110345. private static _baseCache;
  110346. /**
  110347. * Instantiates an effect.
  110348. * An effect can be used to create/manage/execute vertex and fragment shaders.
  110349. * @param baseName Name of the effect.
  110350. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  110351. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  110352. * @param samplers List of sampler variables that will be passed to the shader.
  110353. * @param engine Engine to be used to render the effect
  110354. * @param defines Define statements to be added to the shader.
  110355. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  110356. * @param onCompiled Callback that will be called when the shader is compiled.
  110357. * @param onError Callback that will be called if an error occurs during shader compilation.
  110358. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110359. */
  110360. 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);
  110361. private _useFinalCode;
  110362. /**
  110363. * Unique key for this effect
  110364. */
  110365. get key(): string;
  110366. /**
  110367. * If the effect has been compiled and prepared.
  110368. * @returns if the effect is compiled and prepared.
  110369. */
  110370. isReady(): boolean;
  110371. private _isReadyInternal;
  110372. /**
  110373. * The engine the effect was initialized with.
  110374. * @returns the engine.
  110375. */
  110376. getEngine(): Engine;
  110377. /**
  110378. * The pipeline context for this effect
  110379. * @returns the associated pipeline context
  110380. */
  110381. getPipelineContext(): Nullable<IPipelineContext>;
  110382. /**
  110383. * The set of names of attribute variables for the shader.
  110384. * @returns An array of attribute names.
  110385. */
  110386. getAttributesNames(): string[];
  110387. /**
  110388. * Returns the attribute at the given index.
  110389. * @param index The index of the attribute.
  110390. * @returns The location of the attribute.
  110391. */
  110392. getAttributeLocation(index: number): number;
  110393. /**
  110394. * Returns the attribute based on the name of the variable.
  110395. * @param name of the attribute to look up.
  110396. * @returns the attribute location.
  110397. */
  110398. getAttributeLocationByName(name: string): number;
  110399. /**
  110400. * The number of attributes.
  110401. * @returns the numnber of attributes.
  110402. */
  110403. getAttributesCount(): number;
  110404. /**
  110405. * Gets the index of a uniform variable.
  110406. * @param uniformName of the uniform to look up.
  110407. * @returns the index.
  110408. */
  110409. getUniformIndex(uniformName: string): number;
  110410. /**
  110411. * Returns the attribute based on the name of the variable.
  110412. * @param uniformName of the uniform to look up.
  110413. * @returns the location of the uniform.
  110414. */
  110415. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  110416. /**
  110417. * Returns an array of sampler variable names
  110418. * @returns The array of sampler variable names.
  110419. */
  110420. getSamplers(): string[];
  110421. /**
  110422. * Returns an array of uniform variable names
  110423. * @returns The array of uniform variable names.
  110424. */
  110425. getUniformNames(): string[];
  110426. /**
  110427. * Returns an array of uniform buffer variable names
  110428. * @returns The array of uniform buffer variable names.
  110429. */
  110430. getUniformBuffersNames(): string[];
  110431. /**
  110432. * Returns the index parameters used to create the effect
  110433. * @returns The index parameters object
  110434. */
  110435. getIndexParameters(): any;
  110436. /**
  110437. * The error from the last compilation.
  110438. * @returns the error string.
  110439. */
  110440. getCompilationError(): string;
  110441. /**
  110442. * Gets a boolean indicating that all fallbacks were used during compilation
  110443. * @returns true if all fallbacks were used
  110444. */
  110445. allFallbacksProcessed(): boolean;
  110446. /**
  110447. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  110448. * @param func The callback to be used.
  110449. */
  110450. executeWhenCompiled(func: (effect: Effect) => void): void;
  110451. private _checkIsReady;
  110452. private _loadShader;
  110453. /**
  110454. * Gets the vertex shader source code of this effect
  110455. */
  110456. get vertexSourceCode(): string;
  110457. /**
  110458. * Gets the fragment shader source code of this effect
  110459. */
  110460. get fragmentSourceCode(): string;
  110461. /**
  110462. * Recompiles the webGL program
  110463. * @param vertexSourceCode The source code for the vertex shader.
  110464. * @param fragmentSourceCode The source code for the fragment shader.
  110465. * @param onCompiled Callback called when completed.
  110466. * @param onError Callback called on error.
  110467. * @hidden
  110468. */
  110469. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  110470. /**
  110471. * Prepares the effect
  110472. * @hidden
  110473. */
  110474. _prepareEffect(): void;
  110475. private _getShaderCodeAndErrorLine;
  110476. private _processCompilationErrors;
  110477. /**
  110478. * Checks if the effect is supported. (Must be called after compilation)
  110479. */
  110480. get isSupported(): boolean;
  110481. /**
  110482. * Binds a texture to the engine to be used as output of the shader.
  110483. * @param channel Name of the output variable.
  110484. * @param texture Texture to bind.
  110485. * @hidden
  110486. */
  110487. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  110488. /**
  110489. * Sets a texture on the engine to be used in the shader.
  110490. * @param channel Name of the sampler variable.
  110491. * @param texture Texture to set.
  110492. */
  110493. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  110494. /**
  110495. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  110496. * @param channel Name of the sampler variable.
  110497. * @param texture Texture to set.
  110498. */
  110499. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  110500. /**
  110501. * Sets an array of textures on the engine to be used in the shader.
  110502. * @param channel Name of the variable.
  110503. * @param textures Textures to set.
  110504. */
  110505. setTextureArray(channel: string, textures: BaseTexture[]): void;
  110506. /**
  110507. * 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)
  110508. * @param channel Name of the sampler variable.
  110509. * @param postProcess Post process to get the input texture from.
  110510. */
  110511. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  110512. /**
  110513. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  110514. * 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)
  110515. * @param channel Name of the sampler variable.
  110516. * @param postProcess Post process to get the output texture from.
  110517. */
  110518. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  110519. /** @hidden */
  110520. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  110521. /** @hidden */
  110522. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  110523. /** @hidden */
  110524. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  110525. /** @hidden */
  110526. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  110527. /**
  110528. * Binds a buffer to a uniform.
  110529. * @param buffer Buffer to bind.
  110530. * @param name Name of the uniform variable to bind to.
  110531. */
  110532. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  110533. /**
  110534. * Binds block to a uniform.
  110535. * @param blockName Name of the block to bind.
  110536. * @param index Index to bind.
  110537. */
  110538. bindUniformBlock(blockName: string, index: number): void;
  110539. /**
  110540. * Sets an interger value on a uniform variable.
  110541. * @param uniformName Name of the variable.
  110542. * @param value Value to be set.
  110543. * @returns this effect.
  110544. */
  110545. setInt(uniformName: string, value: number): Effect;
  110546. /**
  110547. * Sets an int array on a uniform variable.
  110548. * @param uniformName Name of the variable.
  110549. * @param array array to be set.
  110550. * @returns this effect.
  110551. */
  110552. setIntArray(uniformName: string, array: Int32Array): Effect;
  110553. /**
  110554. * 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)
  110555. * @param uniformName Name of the variable.
  110556. * @param array array to be set.
  110557. * @returns this effect.
  110558. */
  110559. setIntArray2(uniformName: string, array: Int32Array): Effect;
  110560. /**
  110561. * 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)
  110562. * @param uniformName Name of the variable.
  110563. * @param array array to be set.
  110564. * @returns this effect.
  110565. */
  110566. setIntArray3(uniformName: string, array: Int32Array): Effect;
  110567. /**
  110568. * 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)
  110569. * @param uniformName Name of the variable.
  110570. * @param array array to be set.
  110571. * @returns this effect.
  110572. */
  110573. setIntArray4(uniformName: string, array: Int32Array): Effect;
  110574. /**
  110575. * Sets an float array on a uniform variable.
  110576. * @param uniformName Name of the variable.
  110577. * @param array array to be set.
  110578. * @returns this effect.
  110579. */
  110580. setFloatArray(uniformName: string, array: Float32Array): Effect;
  110581. /**
  110582. * 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)
  110583. * @param uniformName Name of the variable.
  110584. * @param array array to be set.
  110585. * @returns this effect.
  110586. */
  110587. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  110588. /**
  110589. * 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)
  110590. * @param uniformName Name of the variable.
  110591. * @param array array to be set.
  110592. * @returns this effect.
  110593. */
  110594. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  110595. /**
  110596. * 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)
  110597. * @param uniformName Name of the variable.
  110598. * @param array array to be set.
  110599. * @returns this effect.
  110600. */
  110601. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  110602. /**
  110603. * Sets an array on a uniform variable.
  110604. * @param uniformName Name of the variable.
  110605. * @param array array to be set.
  110606. * @returns this effect.
  110607. */
  110608. setArray(uniformName: string, array: number[]): Effect;
  110609. /**
  110610. * 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)
  110611. * @param uniformName Name of the variable.
  110612. * @param array array to be set.
  110613. * @returns this effect.
  110614. */
  110615. setArray2(uniformName: string, array: number[]): Effect;
  110616. /**
  110617. * 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)
  110618. * @param uniformName Name of the variable.
  110619. * @param array array to be set.
  110620. * @returns this effect.
  110621. */
  110622. setArray3(uniformName: string, array: number[]): Effect;
  110623. /**
  110624. * 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)
  110625. * @param uniformName Name of the variable.
  110626. * @param array array to be set.
  110627. * @returns this effect.
  110628. */
  110629. setArray4(uniformName: string, array: number[]): Effect;
  110630. /**
  110631. * Sets matrices on a uniform variable.
  110632. * @param uniformName Name of the variable.
  110633. * @param matrices matrices to be set.
  110634. * @returns this effect.
  110635. */
  110636. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  110637. /**
  110638. * Sets matrix on a uniform variable.
  110639. * @param uniformName Name of the variable.
  110640. * @param matrix matrix to be set.
  110641. * @returns this effect.
  110642. */
  110643. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  110644. /**
  110645. * 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)
  110646. * @param uniformName Name of the variable.
  110647. * @param matrix matrix to be set.
  110648. * @returns this effect.
  110649. */
  110650. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  110651. /**
  110652. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  110653. * @param uniformName Name of the variable.
  110654. * @param matrix matrix to be set.
  110655. * @returns this effect.
  110656. */
  110657. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  110658. /**
  110659. * Sets a float on a uniform variable.
  110660. * @param uniformName Name of the variable.
  110661. * @param value value to be set.
  110662. * @returns this effect.
  110663. */
  110664. setFloat(uniformName: string, value: number): Effect;
  110665. /**
  110666. * Sets a boolean on a uniform variable.
  110667. * @param uniformName Name of the variable.
  110668. * @param bool value to be set.
  110669. * @returns this effect.
  110670. */
  110671. setBool(uniformName: string, bool: boolean): Effect;
  110672. /**
  110673. * Sets a Vector2 on a uniform variable.
  110674. * @param uniformName Name of the variable.
  110675. * @param vector2 vector2 to be set.
  110676. * @returns this effect.
  110677. */
  110678. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  110679. /**
  110680. * Sets a float2 on a uniform variable.
  110681. * @param uniformName Name of the variable.
  110682. * @param x First float in float2.
  110683. * @param y Second float in float2.
  110684. * @returns this effect.
  110685. */
  110686. setFloat2(uniformName: string, x: number, y: number): Effect;
  110687. /**
  110688. * Sets a Vector3 on a uniform variable.
  110689. * @param uniformName Name of the variable.
  110690. * @param vector3 Value to be set.
  110691. * @returns this effect.
  110692. */
  110693. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  110694. /**
  110695. * Sets a float3 on a uniform variable.
  110696. * @param uniformName Name of the variable.
  110697. * @param x First float in float3.
  110698. * @param y Second float in float3.
  110699. * @param z Third float in float3.
  110700. * @returns this effect.
  110701. */
  110702. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  110703. /**
  110704. * Sets a Vector4 on a uniform variable.
  110705. * @param uniformName Name of the variable.
  110706. * @param vector4 Value to be set.
  110707. * @returns this effect.
  110708. */
  110709. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  110710. /**
  110711. * Sets a float4 on a uniform variable.
  110712. * @param uniformName Name of the variable.
  110713. * @param x First float in float4.
  110714. * @param y Second float in float4.
  110715. * @param z Third float in float4.
  110716. * @param w Fourth float in float4.
  110717. * @returns this effect.
  110718. */
  110719. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  110720. /**
  110721. * Sets a Color3 on a uniform variable.
  110722. * @param uniformName Name of the variable.
  110723. * @param color3 Value to be set.
  110724. * @returns this effect.
  110725. */
  110726. setColor3(uniformName: string, color3: IColor3Like): Effect;
  110727. /**
  110728. * Sets a Color4 on a uniform variable.
  110729. * @param uniformName Name of the variable.
  110730. * @param color3 Value to be set.
  110731. * @param alpha Alpha value to be set.
  110732. * @returns this effect.
  110733. */
  110734. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  110735. /**
  110736. * Sets a Color4 on a uniform variable
  110737. * @param uniformName defines the name of the variable
  110738. * @param color4 defines the value to be set
  110739. * @returns this effect.
  110740. */
  110741. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  110742. /** Release all associated resources */
  110743. dispose(): void;
  110744. /**
  110745. * This function will add a new shader to the shader store
  110746. * @param name the name of the shader
  110747. * @param pixelShader optional pixel shader content
  110748. * @param vertexShader optional vertex shader content
  110749. */
  110750. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  110751. /**
  110752. * Store of each shader (The can be looked up using effect.key)
  110753. */
  110754. static ShadersStore: {
  110755. [key: string]: string;
  110756. };
  110757. /**
  110758. * Store of each included file for a shader (The can be looked up using effect.key)
  110759. */
  110760. static IncludesShadersStore: {
  110761. [key: string]: string;
  110762. };
  110763. /**
  110764. * Resets the cache of effects.
  110765. */
  110766. static ResetCache(): void;
  110767. }
  110768. }
  110769. declare module BABYLON {
  110770. /**
  110771. * Interface used to describe the capabilities of the engine relatively to the current browser
  110772. */
  110773. export interface EngineCapabilities {
  110774. /** Maximum textures units per fragment shader */
  110775. maxTexturesImageUnits: number;
  110776. /** Maximum texture units per vertex shader */
  110777. maxVertexTextureImageUnits: number;
  110778. /** Maximum textures units in the entire pipeline */
  110779. maxCombinedTexturesImageUnits: number;
  110780. /** Maximum texture size */
  110781. maxTextureSize: number;
  110782. /** Maximum texture samples */
  110783. maxSamples?: number;
  110784. /** Maximum cube texture size */
  110785. maxCubemapTextureSize: number;
  110786. /** Maximum render texture size */
  110787. maxRenderTextureSize: number;
  110788. /** Maximum number of vertex attributes */
  110789. maxVertexAttribs: number;
  110790. /** Maximum number of varyings */
  110791. maxVaryingVectors: number;
  110792. /** Maximum number of uniforms per vertex shader */
  110793. maxVertexUniformVectors: number;
  110794. /** Maximum number of uniforms per fragment shader */
  110795. maxFragmentUniformVectors: number;
  110796. /** Defines if standard derivates (dx/dy) are supported */
  110797. standardDerivatives: boolean;
  110798. /** Defines if s3tc texture compression is supported */
  110799. s3tc?: WEBGL_compressed_texture_s3tc;
  110800. /** Defines if pvrtc texture compression is supported */
  110801. pvrtc: any;
  110802. /** Defines if etc1 texture compression is supported */
  110803. etc1: any;
  110804. /** Defines if etc2 texture compression is supported */
  110805. etc2: any;
  110806. /** Defines if astc texture compression is supported */
  110807. astc: any;
  110808. /** Defines if float textures are supported */
  110809. textureFloat: boolean;
  110810. /** Defines if vertex array objects are supported */
  110811. vertexArrayObject: boolean;
  110812. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  110813. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  110814. /** Gets the maximum level of anisotropy supported */
  110815. maxAnisotropy: number;
  110816. /** Defines if instancing is supported */
  110817. instancedArrays: boolean;
  110818. /** Defines if 32 bits indices are supported */
  110819. uintIndices: boolean;
  110820. /** Defines if high precision shaders are supported */
  110821. highPrecisionShaderSupported: boolean;
  110822. /** Defines if depth reading in the fragment shader is supported */
  110823. fragmentDepthSupported: boolean;
  110824. /** Defines if float texture linear filtering is supported*/
  110825. textureFloatLinearFiltering: boolean;
  110826. /** Defines if rendering to float textures is supported */
  110827. textureFloatRender: boolean;
  110828. /** Defines if half float textures are supported*/
  110829. textureHalfFloat: boolean;
  110830. /** Defines if half float texture linear filtering is supported*/
  110831. textureHalfFloatLinearFiltering: boolean;
  110832. /** Defines if rendering to half float textures is supported */
  110833. textureHalfFloatRender: boolean;
  110834. /** Defines if textureLOD shader command is supported */
  110835. textureLOD: boolean;
  110836. /** Defines if draw buffers extension is supported */
  110837. drawBuffersExtension: boolean;
  110838. /** Defines if depth textures are supported */
  110839. depthTextureExtension: boolean;
  110840. /** Defines if float color buffer are supported */
  110841. colorBufferFloat: boolean;
  110842. /** Gets disjoint timer query extension (null if not supported) */
  110843. timerQuery?: EXT_disjoint_timer_query;
  110844. /** Defines if timestamp can be used with timer query */
  110845. canUseTimestampForTimerQuery: boolean;
  110846. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  110847. multiview?: any;
  110848. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  110849. oculusMultiview?: any;
  110850. /** Function used to let the system compiles shaders in background */
  110851. parallelShaderCompile?: {
  110852. COMPLETION_STATUS_KHR: number;
  110853. };
  110854. /** Max number of texture samples for MSAA */
  110855. maxMSAASamples: number;
  110856. /** Defines if the blend min max extension is supported */
  110857. blendMinMax: boolean;
  110858. }
  110859. }
  110860. declare module BABYLON {
  110861. /**
  110862. * @hidden
  110863. **/
  110864. export class DepthCullingState {
  110865. private _isDepthTestDirty;
  110866. private _isDepthMaskDirty;
  110867. private _isDepthFuncDirty;
  110868. private _isCullFaceDirty;
  110869. private _isCullDirty;
  110870. private _isZOffsetDirty;
  110871. private _isFrontFaceDirty;
  110872. private _depthTest;
  110873. private _depthMask;
  110874. private _depthFunc;
  110875. private _cull;
  110876. private _cullFace;
  110877. private _zOffset;
  110878. private _frontFace;
  110879. /**
  110880. * Initializes the state.
  110881. */
  110882. constructor();
  110883. get isDirty(): boolean;
  110884. get zOffset(): number;
  110885. set zOffset(value: number);
  110886. get cullFace(): Nullable<number>;
  110887. set cullFace(value: Nullable<number>);
  110888. get cull(): Nullable<boolean>;
  110889. set cull(value: Nullable<boolean>);
  110890. get depthFunc(): Nullable<number>;
  110891. set depthFunc(value: Nullable<number>);
  110892. get depthMask(): boolean;
  110893. set depthMask(value: boolean);
  110894. get depthTest(): boolean;
  110895. set depthTest(value: boolean);
  110896. get frontFace(): Nullable<number>;
  110897. set frontFace(value: Nullable<number>);
  110898. reset(): void;
  110899. apply(gl: WebGLRenderingContext): void;
  110900. }
  110901. }
  110902. declare module BABYLON {
  110903. /**
  110904. * @hidden
  110905. **/
  110906. export class StencilState {
  110907. /** 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 */
  110908. static readonly ALWAYS: number;
  110909. /** Passed to stencilOperation to specify that stencil value must be kept */
  110910. static readonly KEEP: number;
  110911. /** Passed to stencilOperation to specify that stencil value must be replaced */
  110912. static readonly REPLACE: number;
  110913. private _isStencilTestDirty;
  110914. private _isStencilMaskDirty;
  110915. private _isStencilFuncDirty;
  110916. private _isStencilOpDirty;
  110917. private _stencilTest;
  110918. private _stencilMask;
  110919. private _stencilFunc;
  110920. private _stencilFuncRef;
  110921. private _stencilFuncMask;
  110922. private _stencilOpStencilFail;
  110923. private _stencilOpDepthFail;
  110924. private _stencilOpStencilDepthPass;
  110925. get isDirty(): boolean;
  110926. get stencilFunc(): number;
  110927. set stencilFunc(value: number);
  110928. get stencilFuncRef(): number;
  110929. set stencilFuncRef(value: number);
  110930. get stencilFuncMask(): number;
  110931. set stencilFuncMask(value: number);
  110932. get stencilOpStencilFail(): number;
  110933. set stencilOpStencilFail(value: number);
  110934. get stencilOpDepthFail(): number;
  110935. set stencilOpDepthFail(value: number);
  110936. get stencilOpStencilDepthPass(): number;
  110937. set stencilOpStencilDepthPass(value: number);
  110938. get stencilMask(): number;
  110939. set stencilMask(value: number);
  110940. get stencilTest(): boolean;
  110941. set stencilTest(value: boolean);
  110942. constructor();
  110943. reset(): void;
  110944. apply(gl: WebGLRenderingContext): void;
  110945. }
  110946. }
  110947. declare module BABYLON {
  110948. /**
  110949. * @hidden
  110950. **/
  110951. export class AlphaState {
  110952. private _isAlphaBlendDirty;
  110953. private _isBlendFunctionParametersDirty;
  110954. private _isBlendEquationParametersDirty;
  110955. private _isBlendConstantsDirty;
  110956. private _alphaBlend;
  110957. private _blendFunctionParameters;
  110958. private _blendEquationParameters;
  110959. private _blendConstants;
  110960. /**
  110961. * Initializes the state.
  110962. */
  110963. constructor();
  110964. get isDirty(): boolean;
  110965. get alphaBlend(): boolean;
  110966. set alphaBlend(value: boolean);
  110967. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  110968. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  110969. setAlphaEquationParameters(rgb: number, alpha: number): void;
  110970. reset(): void;
  110971. apply(gl: WebGLRenderingContext): void;
  110972. }
  110973. }
  110974. declare module BABYLON {
  110975. /** @hidden */
  110976. export class WebGL2ShaderProcessor implements IShaderProcessor {
  110977. attributeProcessor(attribute: string): string;
  110978. varyingProcessor(varying: string, isFragment: boolean): string;
  110979. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  110980. }
  110981. }
  110982. declare module BABYLON {
  110983. /**
  110984. * Interface for attribute information associated with buffer instanciation
  110985. */
  110986. export interface InstancingAttributeInfo {
  110987. /**
  110988. * Name of the GLSL attribute
  110989. * if attribute index is not specified, this is used to retrieve the index from the effect
  110990. */
  110991. attributeName: string;
  110992. /**
  110993. * Index/offset of the attribute in the vertex shader
  110994. * if not specified, this will be computes from the name.
  110995. */
  110996. index?: number;
  110997. /**
  110998. * size of the attribute, 1, 2, 3 or 4
  110999. */
  111000. attributeSize: number;
  111001. /**
  111002. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  111003. */
  111004. offset: number;
  111005. /**
  111006. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  111007. * default to 1
  111008. */
  111009. divisor?: number;
  111010. /**
  111011. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  111012. * default is FLOAT
  111013. */
  111014. attributeType?: number;
  111015. /**
  111016. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  111017. */
  111018. normalized?: boolean;
  111019. }
  111020. }
  111021. declare module BABYLON {
  111022. interface ThinEngine {
  111023. /**
  111024. * Update a video texture
  111025. * @param texture defines the texture to update
  111026. * @param video defines the video element to use
  111027. * @param invertY defines if data must be stored with Y axis inverted
  111028. */
  111029. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  111030. }
  111031. }
  111032. declare module BABYLON {
  111033. /**
  111034. * Settings for finer control over video usage
  111035. */
  111036. export interface VideoTextureSettings {
  111037. /**
  111038. * Applies `autoplay` to video, if specified
  111039. */
  111040. autoPlay?: boolean;
  111041. /**
  111042. * Applies `loop` to video, if specified
  111043. */
  111044. loop?: boolean;
  111045. /**
  111046. * Automatically updates internal texture from video at every frame in the render loop
  111047. */
  111048. autoUpdateTexture: boolean;
  111049. /**
  111050. * Image src displayed during the video loading or until the user interacts with the video.
  111051. */
  111052. poster?: string;
  111053. }
  111054. /**
  111055. * If you want to display a video in your scene, this is the special texture for that.
  111056. * This special texture works similar to other textures, with the exception of a few parameters.
  111057. * @see https://doc.babylonjs.com/how_to/video_texture
  111058. */
  111059. export class VideoTexture extends Texture {
  111060. /**
  111061. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  111062. */
  111063. readonly autoUpdateTexture: boolean;
  111064. /**
  111065. * The video instance used by the texture internally
  111066. */
  111067. readonly video: HTMLVideoElement;
  111068. private _onUserActionRequestedObservable;
  111069. /**
  111070. * Event triggerd when a dom action is required by the user to play the video.
  111071. * This happens due to recent changes in browser policies preventing video to auto start.
  111072. */
  111073. get onUserActionRequestedObservable(): Observable<Texture>;
  111074. private _generateMipMaps;
  111075. private _stillImageCaptured;
  111076. private _displayingPosterTexture;
  111077. private _settings;
  111078. private _createInternalTextureOnEvent;
  111079. private _frameId;
  111080. private _currentSrc;
  111081. /**
  111082. * Creates a video texture.
  111083. * If you want to display a video in your scene, this is the special texture for that.
  111084. * This special texture works similar to other textures, with the exception of a few parameters.
  111085. * @see https://doc.babylonjs.com/how_to/video_texture
  111086. * @param name optional name, will detect from video source, if not defined
  111087. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  111088. * @param scene is obviously the current scene.
  111089. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  111090. * @param invertY is false by default but can be used to invert video on Y axis
  111091. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  111092. * @param settings allows finer control over video usage
  111093. */
  111094. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  111095. private _getName;
  111096. private _getVideo;
  111097. private _createInternalTexture;
  111098. private reset;
  111099. /**
  111100. * @hidden Internal method to initiate `update`.
  111101. */
  111102. _rebuild(): void;
  111103. /**
  111104. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  111105. */
  111106. update(): void;
  111107. /**
  111108. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  111109. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  111110. */
  111111. updateTexture(isVisible: boolean): void;
  111112. protected _updateInternalTexture: () => void;
  111113. /**
  111114. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  111115. * @param url New url.
  111116. */
  111117. updateURL(url: string): void;
  111118. /**
  111119. * Clones the texture.
  111120. * @returns the cloned texture
  111121. */
  111122. clone(): VideoTexture;
  111123. /**
  111124. * Dispose the texture and release its associated resources.
  111125. */
  111126. dispose(): void;
  111127. /**
  111128. * Creates a video texture straight from a stream.
  111129. * @param scene Define the scene the texture should be created in
  111130. * @param stream Define the stream the texture should be created from
  111131. * @returns The created video texture as a promise
  111132. */
  111133. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  111134. /**
  111135. * Creates a video texture straight from your WebCam video feed.
  111136. * @param scene Define the scene the texture should be created in
  111137. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111138. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111139. * @returns The created video texture as a promise
  111140. */
  111141. static CreateFromWebCamAsync(scene: Scene, constraints: {
  111142. minWidth: number;
  111143. maxWidth: number;
  111144. minHeight: number;
  111145. maxHeight: number;
  111146. deviceId: string;
  111147. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  111148. /**
  111149. * Creates a video texture straight from your WebCam video feed.
  111150. * @param scene Define the scene the texture should be created in
  111151. * @param onReady Define a callback to triggered once the texture will be ready
  111152. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111153. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111154. */
  111155. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  111156. minWidth: number;
  111157. maxWidth: number;
  111158. minHeight: number;
  111159. maxHeight: number;
  111160. deviceId: string;
  111161. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  111162. }
  111163. }
  111164. declare module BABYLON {
  111165. /**
  111166. * Defines the interface used by objects working like Scene
  111167. * @hidden
  111168. */
  111169. export interface ISceneLike {
  111170. _addPendingData(data: any): void;
  111171. _removePendingData(data: any): void;
  111172. offlineProvider: IOfflineProvider;
  111173. }
  111174. /** Interface defining initialization parameters for Engine class */
  111175. export interface EngineOptions extends WebGLContextAttributes {
  111176. /**
  111177. * Defines if the engine should no exceed a specified device ratio
  111178. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  111179. */
  111180. limitDeviceRatio?: number;
  111181. /**
  111182. * Defines if webvr should be enabled automatically
  111183. * @see http://doc.babylonjs.com/how_to/webvr_camera
  111184. */
  111185. autoEnableWebVR?: boolean;
  111186. /**
  111187. * Defines if webgl2 should be turned off even if supported
  111188. * @see http://doc.babylonjs.com/features/webgl2
  111189. */
  111190. disableWebGL2Support?: boolean;
  111191. /**
  111192. * Defines if webaudio should be initialized as well
  111193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111194. */
  111195. audioEngine?: boolean;
  111196. /**
  111197. * Defines if animations should run using a deterministic lock step
  111198. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111199. */
  111200. deterministicLockstep?: boolean;
  111201. /** Defines the maximum steps to use with deterministic lock step mode */
  111202. lockstepMaxSteps?: number;
  111203. /** Defines the seconds between each deterministic lock step */
  111204. timeStep?: number;
  111205. /**
  111206. * Defines that engine should ignore context lost events
  111207. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  111208. */
  111209. doNotHandleContextLost?: boolean;
  111210. /**
  111211. * Defines that engine should ignore modifying touch action attribute and style
  111212. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  111213. */
  111214. doNotHandleTouchAction?: boolean;
  111215. /**
  111216. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  111217. */
  111218. useHighPrecisionFloats?: boolean;
  111219. }
  111220. /**
  111221. * The base engine class (root of all engines)
  111222. */
  111223. export class ThinEngine {
  111224. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  111225. static ExceptionList: ({
  111226. key: string;
  111227. capture: string;
  111228. captureConstraint: number;
  111229. targets: string[];
  111230. } | {
  111231. key: string;
  111232. capture: null;
  111233. captureConstraint: null;
  111234. targets: string[];
  111235. })[];
  111236. /** @hidden */
  111237. static _TextureLoaders: IInternalTextureLoader[];
  111238. /**
  111239. * Returns the current npm package of the sdk
  111240. */
  111241. static get NpmPackage(): string;
  111242. /**
  111243. * Returns the current version of the framework
  111244. */
  111245. static get Version(): string;
  111246. /**
  111247. * Returns a string describing the current engine
  111248. */
  111249. get description(): string;
  111250. /**
  111251. * Gets or sets the epsilon value used by collision engine
  111252. */
  111253. static CollisionsEpsilon: number;
  111254. /**
  111255. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111256. */
  111257. static get ShadersRepository(): string;
  111258. static set ShadersRepository(value: string);
  111259. /** @hidden */
  111260. _shaderProcessor: IShaderProcessor;
  111261. /**
  111262. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  111263. */
  111264. forcePOTTextures: boolean;
  111265. /**
  111266. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  111267. */
  111268. isFullscreen: boolean;
  111269. /**
  111270. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  111271. */
  111272. cullBackFaces: boolean;
  111273. /**
  111274. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  111275. */
  111276. renderEvenInBackground: boolean;
  111277. /**
  111278. * Gets or sets a boolean indicating that cache can be kept between frames
  111279. */
  111280. preventCacheWipeBetweenFrames: boolean;
  111281. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  111282. validateShaderPrograms: boolean;
  111283. /**
  111284. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  111285. * This can provide greater z depth for distant objects.
  111286. */
  111287. useReverseDepthBuffer: boolean;
  111288. /**
  111289. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  111290. */
  111291. disableUniformBuffers: boolean;
  111292. /** @hidden */
  111293. _uniformBuffers: UniformBuffer[];
  111294. /**
  111295. * Gets a boolean indicating that the engine supports uniform buffers
  111296. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  111297. */
  111298. get supportsUniformBuffers(): boolean;
  111299. /** @hidden */
  111300. _gl: WebGLRenderingContext;
  111301. /** @hidden */
  111302. _webGLVersion: number;
  111303. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  111304. protected _windowIsBackground: boolean;
  111305. protected _creationOptions: EngineOptions;
  111306. protected _highPrecisionShadersAllowed: boolean;
  111307. /** @hidden */
  111308. get _shouldUseHighPrecisionShader(): boolean;
  111309. /**
  111310. * Gets a boolean indicating that only power of 2 textures are supported
  111311. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  111312. */
  111313. get needPOTTextures(): boolean;
  111314. /** @hidden */
  111315. _badOS: boolean;
  111316. /** @hidden */
  111317. _badDesktopOS: boolean;
  111318. private _hardwareScalingLevel;
  111319. /** @hidden */
  111320. _caps: EngineCapabilities;
  111321. private _isStencilEnable;
  111322. private _glVersion;
  111323. private _glRenderer;
  111324. private _glVendor;
  111325. /** @hidden */
  111326. _videoTextureSupported: boolean;
  111327. protected _renderingQueueLaunched: boolean;
  111328. protected _activeRenderLoops: (() => void)[];
  111329. /**
  111330. * Observable signaled when a context lost event is raised
  111331. */
  111332. onContextLostObservable: Observable<ThinEngine>;
  111333. /**
  111334. * Observable signaled when a context restored event is raised
  111335. */
  111336. onContextRestoredObservable: Observable<ThinEngine>;
  111337. private _onContextLost;
  111338. private _onContextRestored;
  111339. protected _contextWasLost: boolean;
  111340. /** @hidden */
  111341. _doNotHandleContextLost: boolean;
  111342. /**
  111343. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  111344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  111345. */
  111346. get doNotHandleContextLost(): boolean;
  111347. set doNotHandleContextLost(value: boolean);
  111348. /**
  111349. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  111350. */
  111351. disableVertexArrayObjects: boolean;
  111352. /** @hidden */
  111353. protected _colorWrite: boolean;
  111354. /** @hidden */
  111355. protected _colorWriteChanged: boolean;
  111356. /** @hidden */
  111357. protected _depthCullingState: DepthCullingState;
  111358. /** @hidden */
  111359. protected _stencilState: StencilState;
  111360. /** @hidden */
  111361. _alphaState: AlphaState;
  111362. /** @hidden */
  111363. _alphaMode: number;
  111364. /** @hidden */
  111365. _alphaEquation: number;
  111366. /** @hidden */
  111367. _internalTexturesCache: InternalTexture[];
  111368. /** @hidden */
  111369. protected _activeChannel: number;
  111370. private _currentTextureChannel;
  111371. /** @hidden */
  111372. protected _boundTexturesCache: {
  111373. [key: string]: Nullable<InternalTexture>;
  111374. };
  111375. /** @hidden */
  111376. protected _currentEffect: Nullable<Effect>;
  111377. /** @hidden */
  111378. protected _currentProgram: Nullable<WebGLProgram>;
  111379. private _compiledEffects;
  111380. private _vertexAttribArraysEnabled;
  111381. /** @hidden */
  111382. protected _cachedViewport: Nullable<IViewportLike>;
  111383. private _cachedVertexArrayObject;
  111384. /** @hidden */
  111385. protected _cachedVertexBuffers: any;
  111386. /** @hidden */
  111387. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  111388. /** @hidden */
  111389. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  111390. /** @hidden */
  111391. _currentRenderTarget: Nullable<InternalTexture>;
  111392. private _uintIndicesCurrentlySet;
  111393. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  111394. /** @hidden */
  111395. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  111396. /** @hidden */
  111397. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  111398. private _currentBufferPointers;
  111399. private _currentInstanceLocations;
  111400. private _currentInstanceBuffers;
  111401. private _textureUnits;
  111402. /** @hidden */
  111403. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  111404. /** @hidden */
  111405. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  111406. /** @hidden */
  111407. _boundRenderFunction: any;
  111408. private _vaoRecordInProgress;
  111409. private _mustWipeVertexAttributes;
  111410. private _emptyTexture;
  111411. private _emptyCubeTexture;
  111412. private _emptyTexture3D;
  111413. private _emptyTexture2DArray;
  111414. /** @hidden */
  111415. _frameHandler: number;
  111416. private _nextFreeTextureSlots;
  111417. private _maxSimultaneousTextures;
  111418. private _activeRequests;
  111419. /** @hidden */
  111420. _transformTextureUrl: Nullable<(url: string) => string>;
  111421. protected get _supportsHardwareTextureRescaling(): boolean;
  111422. private _framebufferDimensionsObject;
  111423. /**
  111424. * sets the object from which width and height will be taken from when getting render width and height
  111425. * Will fallback to the gl object
  111426. * @param dimensions the framebuffer width and height that will be used.
  111427. */
  111428. set framebufferDimensionsObject(dimensions: Nullable<{
  111429. framebufferWidth: number;
  111430. framebufferHeight: number;
  111431. }>);
  111432. /**
  111433. * Gets the current viewport
  111434. */
  111435. get currentViewport(): Nullable<IViewportLike>;
  111436. /**
  111437. * Gets the default empty texture
  111438. */
  111439. get emptyTexture(): InternalTexture;
  111440. /**
  111441. * Gets the default empty 3D texture
  111442. */
  111443. get emptyTexture3D(): InternalTexture;
  111444. /**
  111445. * Gets the default empty 2D array texture
  111446. */
  111447. get emptyTexture2DArray(): InternalTexture;
  111448. /**
  111449. * Gets the default empty cube texture
  111450. */
  111451. get emptyCubeTexture(): InternalTexture;
  111452. /**
  111453. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  111454. */
  111455. readonly premultipliedAlpha: boolean;
  111456. /**
  111457. * Observable event triggered before each texture is initialized
  111458. */
  111459. onBeforeTextureInitObservable: Observable<Texture>;
  111460. /**
  111461. * Creates a new engine
  111462. * @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
  111463. * @param antialias defines enable antialiasing (default: false)
  111464. * @param options defines further options to be sent to the getContext() function
  111465. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  111466. */
  111467. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  111468. private _rebuildInternalTextures;
  111469. private _rebuildEffects;
  111470. /**
  111471. * Gets a boolean indicating if all created effects are ready
  111472. * @returns true if all effects are ready
  111473. */
  111474. areAllEffectsReady(): boolean;
  111475. protected _rebuildBuffers(): void;
  111476. protected _initGLContext(): void;
  111477. /**
  111478. * Gets version of the current webGL context
  111479. */
  111480. get webGLVersion(): number;
  111481. /**
  111482. * Gets a string idenfifying the name of the class
  111483. * @returns "Engine" string
  111484. */
  111485. getClassName(): string;
  111486. /**
  111487. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  111488. */
  111489. get isStencilEnable(): boolean;
  111490. /** @hidden */
  111491. _prepareWorkingCanvas(): void;
  111492. /**
  111493. * Reset the texture cache to empty state
  111494. */
  111495. resetTextureCache(): void;
  111496. /**
  111497. * Gets an object containing information about the current webGL context
  111498. * @returns an object containing the vender, the renderer and the version of the current webGL context
  111499. */
  111500. getGlInfo(): {
  111501. vendor: string;
  111502. renderer: string;
  111503. version: string;
  111504. };
  111505. /**
  111506. * Defines the hardware scaling level.
  111507. * By default the hardware scaling level is computed from the window device ratio.
  111508. * 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.
  111509. * @param level defines the level to use
  111510. */
  111511. setHardwareScalingLevel(level: number): void;
  111512. /**
  111513. * Gets the current hardware scaling level.
  111514. * By default the hardware scaling level is computed from the window device ratio.
  111515. * 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.
  111516. * @returns a number indicating the current hardware scaling level
  111517. */
  111518. getHardwareScalingLevel(): number;
  111519. /**
  111520. * Gets the list of loaded textures
  111521. * @returns an array containing all loaded textures
  111522. */
  111523. getLoadedTexturesCache(): InternalTexture[];
  111524. /**
  111525. * Gets the object containing all engine capabilities
  111526. * @returns the EngineCapabilities object
  111527. */
  111528. getCaps(): EngineCapabilities;
  111529. /**
  111530. * stop executing a render loop function and remove it from the execution array
  111531. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  111532. */
  111533. stopRenderLoop(renderFunction?: () => void): void;
  111534. /** @hidden */
  111535. _renderLoop(): void;
  111536. /**
  111537. * Gets the HTML canvas attached with the current webGL context
  111538. * @returns a HTML canvas
  111539. */
  111540. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  111541. /**
  111542. * Gets host window
  111543. * @returns the host window object
  111544. */
  111545. getHostWindow(): Nullable<Window>;
  111546. /**
  111547. * Gets the current render width
  111548. * @param useScreen defines if screen size must be used (or the current render target if any)
  111549. * @returns a number defining the current render width
  111550. */
  111551. getRenderWidth(useScreen?: boolean): number;
  111552. /**
  111553. * Gets the current render height
  111554. * @param useScreen defines if screen size must be used (or the current render target if any)
  111555. * @returns a number defining the current render height
  111556. */
  111557. getRenderHeight(useScreen?: boolean): number;
  111558. /**
  111559. * Can be used to override the current requestAnimationFrame requester.
  111560. * @hidden
  111561. */
  111562. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  111563. /**
  111564. * Register and execute a render loop. The engine can have more than one render function
  111565. * @param renderFunction defines the function to continuously execute
  111566. */
  111567. runRenderLoop(renderFunction: () => void): void;
  111568. /**
  111569. * Clear the current render buffer or the current render target (if any is set up)
  111570. * @param color defines the color to use
  111571. * @param backBuffer defines if the back buffer must be cleared
  111572. * @param depth defines if the depth buffer must be cleared
  111573. * @param stencil defines if the stencil buffer must be cleared
  111574. */
  111575. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111576. private _viewportCached;
  111577. /** @hidden */
  111578. _viewport(x: number, y: number, width: number, height: number): void;
  111579. /**
  111580. * Set the WebGL's viewport
  111581. * @param viewport defines the viewport element to be used
  111582. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111583. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111584. */
  111585. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111586. /**
  111587. * Begin a new frame
  111588. */
  111589. beginFrame(): void;
  111590. /**
  111591. * Enf the current frame
  111592. */
  111593. endFrame(): void;
  111594. /**
  111595. * Resize the view according to the canvas' size
  111596. */
  111597. resize(): void;
  111598. /**
  111599. * Force a specific size of the canvas
  111600. * @param width defines the new canvas' width
  111601. * @param height defines the new canvas' height
  111602. */
  111603. setSize(width: number, height: number): void;
  111604. /**
  111605. * Binds the frame buffer to the specified texture.
  111606. * @param texture The texture to render to or null for the default canvas
  111607. * @param faceIndex The face of the texture to render to in case of cube texture
  111608. * @param requiredWidth The width of the target to render to
  111609. * @param requiredHeight The height of the target to render to
  111610. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111611. * @param lodLevel defines the lod level to bind to the frame buffer
  111612. * @param layer defines the 2d array index to bind to frame buffer to
  111613. */
  111614. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  111615. /** @hidden */
  111616. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  111617. /**
  111618. * Unbind the current render target texture from the webGL context
  111619. * @param texture defines the render target texture to unbind
  111620. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111621. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111622. */
  111623. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111624. /**
  111625. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  111626. */
  111627. flushFramebuffer(): void;
  111628. /**
  111629. * Unbind the current render target and bind the default framebuffer
  111630. */
  111631. restoreDefaultFramebuffer(): void;
  111632. /** @hidden */
  111633. protected _resetVertexBufferBinding(): void;
  111634. /**
  111635. * Creates a vertex buffer
  111636. * @param data the data for the vertex buffer
  111637. * @returns the new WebGL static buffer
  111638. */
  111639. createVertexBuffer(data: DataArray): DataBuffer;
  111640. private _createVertexBuffer;
  111641. /**
  111642. * Creates a dynamic vertex buffer
  111643. * @param data the data for the dynamic vertex buffer
  111644. * @returns the new WebGL dynamic buffer
  111645. */
  111646. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111647. protected _resetIndexBufferBinding(): void;
  111648. /**
  111649. * Creates a new index buffer
  111650. * @param indices defines the content of the index buffer
  111651. * @param updatable defines if the index buffer must be updatable
  111652. * @returns a new webGL buffer
  111653. */
  111654. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  111655. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  111656. /**
  111657. * Bind a webGL buffer to the webGL context
  111658. * @param buffer defines the buffer to bind
  111659. */
  111660. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  111661. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  111662. private bindBuffer;
  111663. /**
  111664. * update the bound buffer with the given data
  111665. * @param data defines the data to update
  111666. */
  111667. updateArrayBuffer(data: Float32Array): void;
  111668. private _vertexAttribPointer;
  111669. /** @hidden */
  111670. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  111671. private _bindVertexBuffersAttributes;
  111672. /**
  111673. * Records a vertex array object
  111674. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111675. * @param vertexBuffers defines the list of vertex buffers to store
  111676. * @param indexBuffer defines the index buffer to store
  111677. * @param effect defines the effect to store
  111678. * @returns the new vertex array object
  111679. */
  111680. recordVertexArrayObject(vertexBuffers: {
  111681. [key: string]: VertexBuffer;
  111682. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111683. /**
  111684. * Bind a specific vertex array object
  111685. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111686. * @param vertexArrayObject defines the vertex array object to bind
  111687. * @param indexBuffer defines the index buffer to bind
  111688. */
  111689. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  111690. /**
  111691. * Bind webGl buffers directly to the webGL context
  111692. * @param vertexBuffer defines the vertex buffer to bind
  111693. * @param indexBuffer defines the index buffer to bind
  111694. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111695. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111696. * @param effect defines the effect associated with the vertex buffer
  111697. */
  111698. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  111699. private _unbindVertexArrayObject;
  111700. /**
  111701. * Bind a list of vertex buffers to the webGL context
  111702. * @param vertexBuffers defines the list of vertex buffers to bind
  111703. * @param indexBuffer defines the index buffer to bind
  111704. * @param effect defines the effect associated with the vertex buffers
  111705. */
  111706. bindBuffers(vertexBuffers: {
  111707. [key: string]: Nullable<VertexBuffer>;
  111708. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  111709. /**
  111710. * Unbind all instance attributes
  111711. */
  111712. unbindInstanceAttributes(): void;
  111713. /**
  111714. * Release and free the memory of a vertex array object
  111715. * @param vao defines the vertex array object to delete
  111716. */
  111717. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  111718. /** @hidden */
  111719. _releaseBuffer(buffer: DataBuffer): boolean;
  111720. protected _deleteBuffer(buffer: DataBuffer): void;
  111721. /**
  111722. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  111723. * @param instancesBuffer defines the webGL buffer to update and bind
  111724. * @param data defines the data to store in the buffer
  111725. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  111726. */
  111727. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  111728. /**
  111729. * Bind the content of a webGL buffer used with instantiation
  111730. * @param instancesBuffer defines the webGL buffer to bind
  111731. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  111732. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  111733. */
  111734. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  111735. /**
  111736. * Disable the instance attribute corresponding to the name in parameter
  111737. * @param name defines the name of the attribute to disable
  111738. */
  111739. disableInstanceAttributeByName(name: string): void;
  111740. /**
  111741. * Disable the instance attribute corresponding to the location in parameter
  111742. * @param attributeLocation defines the attribute location of the attribute to disable
  111743. */
  111744. disableInstanceAttribute(attributeLocation: number): void;
  111745. /**
  111746. * Disable the attribute corresponding to the location in parameter
  111747. * @param attributeLocation defines the attribute location of the attribute to disable
  111748. */
  111749. disableAttributeByIndex(attributeLocation: number): void;
  111750. /**
  111751. * Send a draw order
  111752. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111753. * @param indexStart defines the starting index
  111754. * @param indexCount defines the number of index to draw
  111755. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111756. */
  111757. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111758. /**
  111759. * Draw a list of points
  111760. * @param verticesStart defines the index of first vertex to draw
  111761. * @param verticesCount defines the count of vertices to draw
  111762. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111763. */
  111764. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111765. /**
  111766. * Draw a list of unindexed primitives
  111767. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111768. * @param verticesStart defines the index of first vertex to draw
  111769. * @param verticesCount defines the count of vertices to draw
  111770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111771. */
  111772. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111773. /**
  111774. * Draw a list of indexed primitives
  111775. * @param fillMode defines the primitive to use
  111776. * @param indexStart defines the starting index
  111777. * @param indexCount defines the number of index to draw
  111778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111779. */
  111780. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111781. /**
  111782. * Draw a list of unindexed primitives
  111783. * @param fillMode defines the primitive to use
  111784. * @param verticesStart defines the index of first vertex to draw
  111785. * @param verticesCount defines the count of vertices to draw
  111786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111787. */
  111788. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111789. private _drawMode;
  111790. /** @hidden */
  111791. protected _reportDrawCall(): void;
  111792. /** @hidden */
  111793. _releaseEffect(effect: Effect): void;
  111794. /** @hidden */
  111795. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111796. /**
  111797. * Create a new effect (used to store vertex/fragment shaders)
  111798. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  111799. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  111800. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  111801. * @param samplers defines an array of string used to represent textures
  111802. * @param defines defines the string containing the defines to use to compile the shaders
  111803. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111804. * @param onCompiled defines a function to call when the effect creation is successful
  111805. * @param onError defines a function to call when the effect creation has failed
  111806. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  111807. * @returns the new Effect
  111808. */
  111809. 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;
  111810. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  111811. private _compileShader;
  111812. private _compileRawShader;
  111813. /** @hidden */
  111814. _getShaderSource(shader: WebGLShader): Nullable<string>;
  111815. /**
  111816. * Directly creates a webGL program
  111817. * @param pipelineContext defines the pipeline context to attach to
  111818. * @param vertexCode defines the vertex shader code to use
  111819. * @param fragmentCode defines the fragment shader code to use
  111820. * @param context defines the webGL context to use (if not set, the current one will be used)
  111821. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111822. * @returns the new webGL program
  111823. */
  111824. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111825. /**
  111826. * Creates a webGL program
  111827. * @param pipelineContext defines the pipeline context to attach to
  111828. * @param vertexCode defines the vertex shader code to use
  111829. * @param fragmentCode defines the fragment shader code to use
  111830. * @param defines defines the string containing the defines to use to compile the shaders
  111831. * @param context defines the webGL context to use (if not set, the current one will be used)
  111832. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111833. * @returns the new webGL program
  111834. */
  111835. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111836. /**
  111837. * Creates a new pipeline context
  111838. * @returns the new pipeline
  111839. */
  111840. createPipelineContext(): IPipelineContext;
  111841. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111842. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  111843. /** @hidden */
  111844. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111845. /** @hidden */
  111846. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111847. /** @hidden */
  111848. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111849. /**
  111850. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111851. * @param pipelineContext defines the pipeline context to use
  111852. * @param uniformsNames defines the list of uniform names
  111853. * @returns an array of webGL uniform locations
  111854. */
  111855. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111856. /**
  111857. * Gets the lsit of active attributes for a given webGL program
  111858. * @param pipelineContext defines the pipeline context to use
  111859. * @param attributesNames defines the list of attribute names to get
  111860. * @returns an array of indices indicating the offset of each attribute
  111861. */
  111862. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111863. /**
  111864. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111865. * @param effect defines the effect to activate
  111866. */
  111867. enableEffect(effect: Nullable<Effect>): void;
  111868. /**
  111869. * Set the value of an uniform to a number (int)
  111870. * @param uniform defines the webGL uniform location where to store the value
  111871. * @param value defines the int number to store
  111872. */
  111873. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  111874. /**
  111875. * Set the value of an uniform to an array of int32
  111876. * @param uniform defines the webGL uniform location where to store the value
  111877. * @param array defines the array of int32 to store
  111878. */
  111879. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111880. /**
  111881. * Set the value of an uniform to an array of int32 (stored as vec2)
  111882. * @param uniform defines the webGL uniform location where to store the value
  111883. * @param array defines the array of int32 to store
  111884. */
  111885. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111886. /**
  111887. * Set the value of an uniform to an array of int32 (stored as vec3)
  111888. * @param uniform defines the webGL uniform location where to store the value
  111889. * @param array defines the array of int32 to store
  111890. */
  111891. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111892. /**
  111893. * Set the value of an uniform to an array of int32 (stored as vec4)
  111894. * @param uniform defines the webGL uniform location where to store the value
  111895. * @param array defines the array of int32 to store
  111896. */
  111897. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111898. /**
  111899. * Set the value of an uniform to an array of number
  111900. * @param uniform defines the webGL uniform location where to store the value
  111901. * @param array defines the array of number to store
  111902. */
  111903. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111904. /**
  111905. * Set the value of an uniform to an array of number (stored as vec2)
  111906. * @param uniform defines the webGL uniform location where to store the value
  111907. * @param array defines the array of number to store
  111908. */
  111909. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111910. /**
  111911. * Set the value of an uniform to an array of number (stored as vec3)
  111912. * @param uniform defines the webGL uniform location where to store the value
  111913. * @param array defines the array of number to store
  111914. */
  111915. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111916. /**
  111917. * Set the value of an uniform to an array of number (stored as vec4)
  111918. * @param uniform defines the webGL uniform location where to store the value
  111919. * @param array defines the array of number to store
  111920. */
  111921. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111922. /**
  111923. * Set the value of an uniform to an array of float32 (stored as matrices)
  111924. * @param uniform defines the webGL uniform location where to store the value
  111925. * @param matrices defines the array of float32 to store
  111926. */
  111927. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  111928. /**
  111929. * Set the value of an uniform to a matrix (3x3)
  111930. * @param uniform defines the webGL uniform location where to store the value
  111931. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111932. */
  111933. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  111934. /**
  111935. * Set the value of an uniform to a matrix (2x2)
  111936. * @param uniform defines the webGL uniform location where to store the value
  111937. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111938. */
  111939. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  111940. /**
  111941. * Set the value of an uniform to a number (float)
  111942. * @param uniform defines the webGL uniform location where to store the value
  111943. * @param value defines the float number to store
  111944. */
  111945. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  111946. /**
  111947. * Set the value of an uniform to a vec2
  111948. * @param uniform defines the webGL uniform location where to store the value
  111949. * @param x defines the 1st component of the value
  111950. * @param y defines the 2nd component of the value
  111951. */
  111952. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  111953. /**
  111954. * Set the value of an uniform to a vec3
  111955. * @param uniform defines the webGL uniform location where to store the value
  111956. * @param x defines the 1st component of the value
  111957. * @param y defines the 2nd component of the value
  111958. * @param z defines the 3rd component of the value
  111959. */
  111960. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  111961. /**
  111962. * Set the value of an uniform to a vec4
  111963. * @param uniform defines the webGL uniform location where to store the value
  111964. * @param x defines the 1st component of the value
  111965. * @param y defines the 2nd component of the value
  111966. * @param z defines the 3rd component of the value
  111967. * @param w defines the 4th component of the value
  111968. */
  111969. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  111970. /**
  111971. * Apply all cached states (depth, culling, stencil and alpha)
  111972. */
  111973. applyStates(): void;
  111974. /**
  111975. * Enable or disable color writing
  111976. * @param enable defines the state to set
  111977. */
  111978. setColorWrite(enable: boolean): void;
  111979. /**
  111980. * Gets a boolean indicating if color writing is enabled
  111981. * @returns the current color writing state
  111982. */
  111983. getColorWrite(): boolean;
  111984. /**
  111985. * Gets the depth culling state manager
  111986. */
  111987. get depthCullingState(): DepthCullingState;
  111988. /**
  111989. * Gets the alpha state manager
  111990. */
  111991. get alphaState(): AlphaState;
  111992. /**
  111993. * Gets the stencil state manager
  111994. */
  111995. get stencilState(): StencilState;
  111996. /**
  111997. * Clears the list of texture accessible through engine.
  111998. * This can help preventing texture load conflict due to name collision.
  111999. */
  112000. clearInternalTexturesCache(): void;
  112001. /**
  112002. * Force the entire cache to be cleared
  112003. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112004. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112005. */
  112006. wipeCaches(bruteForce?: boolean): void;
  112007. /** @hidden */
  112008. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  112009. min: number;
  112010. mag: number;
  112011. };
  112012. /** @hidden */
  112013. _createTexture(): WebGLTexture;
  112014. /**
  112015. * Usually called from Texture.ts.
  112016. * Passed information to create a WebGLTexture
  112017. * @param url defines a value which contains one of the following:
  112018. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112019. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112020. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112021. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112022. * @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)
  112023. * @param scene needed for loading to the correct scene
  112024. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112025. * @param onLoad optional callback to be called upon successful completion
  112026. * @param onError optional callback to be called upon failure
  112027. * @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
  112028. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112029. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112030. * @param forcedExtension defines the extension to use to pick the right loader
  112031. * @param mimeType defines an optional mime type
  112032. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112033. */
  112034. 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;
  112035. /**
  112036. * Loads an image as an HTMLImageElement.
  112037. * @param input url string, ArrayBuffer, or Blob to load
  112038. * @param onLoad callback called when the image successfully loads
  112039. * @param onError callback called when the image fails to load
  112040. * @param offlineProvider offline provider for caching
  112041. * @param mimeType optional mime type
  112042. * @returns the HTMLImageElement of the loaded image
  112043. * @hidden
  112044. */
  112045. 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>;
  112046. /**
  112047. * @hidden
  112048. */
  112049. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  112050. private _unpackFlipYCached;
  112051. /**
  112052. * In case you are sharing the context with other applications, it might
  112053. * be interested to not cache the unpack flip y state to ensure a consistent
  112054. * value would be set.
  112055. */
  112056. enableUnpackFlipYCached: boolean;
  112057. /** @hidden */
  112058. _unpackFlipY(value: boolean): void;
  112059. /** @hidden */
  112060. _getUnpackAlignement(): number;
  112061. private _getTextureTarget;
  112062. /**
  112063. * Update the sampling mode of a given texture
  112064. * @param samplingMode defines the required sampling mode
  112065. * @param texture defines the texture to update
  112066. * @param generateMipMaps defines whether to generate mipmaps for the texture
  112067. */
  112068. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  112069. /**
  112070. * Update the sampling mode of a given texture
  112071. * @param texture defines the texture to update
  112072. * @param wrapU defines the texture wrap mode of the u coordinates
  112073. * @param wrapV defines the texture wrap mode of the v coordinates
  112074. * @param wrapR defines the texture wrap mode of the r coordinates
  112075. */
  112076. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  112077. /** @hidden */
  112078. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  112079. width: number;
  112080. height: number;
  112081. layers?: number;
  112082. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  112083. /** @hidden */
  112084. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112085. /** @hidden */
  112086. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  112087. /**
  112088. * Update a portion of an internal texture
  112089. * @param texture defines the texture to update
  112090. * @param imageData defines the data to store into the texture
  112091. * @param xOffset defines the x coordinates of the update rectangle
  112092. * @param yOffset defines the y coordinates of the update rectangle
  112093. * @param width defines the width of the update rectangle
  112094. * @param height defines the height of the update rectangle
  112095. * @param faceIndex defines the face index if texture is a cube (0 by default)
  112096. * @param lod defines the lod level to update (0 by default)
  112097. */
  112098. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  112099. /** @hidden */
  112100. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112101. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  112102. private _prepareWebGLTexture;
  112103. /** @hidden */
  112104. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  112105. private _getDepthStencilBuffer;
  112106. /** @hidden */
  112107. _releaseFramebufferObjects(texture: InternalTexture): void;
  112108. /** @hidden */
  112109. _releaseTexture(texture: InternalTexture): void;
  112110. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112111. protected _setProgram(program: WebGLProgram): void;
  112112. protected _boundUniforms: {
  112113. [key: number]: WebGLUniformLocation;
  112114. };
  112115. /**
  112116. * Binds an effect to the webGL context
  112117. * @param effect defines the effect to bind
  112118. */
  112119. bindSamplers(effect: Effect): void;
  112120. private _activateCurrentTexture;
  112121. /** @hidden */
  112122. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  112123. /** @hidden */
  112124. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  112125. /**
  112126. * Unbind all textures from the webGL context
  112127. */
  112128. unbindAllTextures(): void;
  112129. /**
  112130. * Sets a texture to the according uniform.
  112131. * @param channel The texture channel
  112132. * @param uniform The uniform to set
  112133. * @param texture The texture to apply
  112134. */
  112135. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  112136. private _bindSamplerUniformToChannel;
  112137. private _getTextureWrapMode;
  112138. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112139. /**
  112140. * Sets an array of texture to the webGL context
  112141. * @param channel defines the channel where the texture array must be set
  112142. * @param uniform defines the associated uniform location
  112143. * @param textures defines the array of textures to bind
  112144. */
  112145. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  112146. /** @hidden */
  112147. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  112148. private _setTextureParameterFloat;
  112149. private _setTextureParameterInteger;
  112150. /**
  112151. * Unbind all vertex attributes from the webGL context
  112152. */
  112153. unbindAllAttributes(): void;
  112154. /**
  112155. * 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
  112156. */
  112157. releaseEffects(): void;
  112158. /**
  112159. * Dispose and release all associated resources
  112160. */
  112161. dispose(): void;
  112162. /**
  112163. * Attach a new callback raised when context lost event is fired
  112164. * @param callback defines the callback to call
  112165. */
  112166. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112167. /**
  112168. * Attach a new callback raised when context restored event is fired
  112169. * @param callback defines the callback to call
  112170. */
  112171. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112172. /**
  112173. * Get the current error code of the webGL context
  112174. * @returns the error code
  112175. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112176. */
  112177. getError(): number;
  112178. private _canRenderToFloatFramebuffer;
  112179. private _canRenderToHalfFloatFramebuffer;
  112180. private _canRenderToFramebuffer;
  112181. /** @hidden */
  112182. _getWebGLTextureType(type: number): number;
  112183. /** @hidden */
  112184. _getInternalFormat(format: number): number;
  112185. /** @hidden */
  112186. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  112187. /** @hidden */
  112188. _getRGBAMultiSampleBufferFormat(type: number): number;
  112189. /** @hidden */
  112190. _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;
  112191. /**
  112192. * Loads a file from a url
  112193. * @param url url to load
  112194. * @param onSuccess callback called when the file successfully loads
  112195. * @param onProgress callback called while file is loading (if the server supports this mode)
  112196. * @param offlineProvider defines the offline provider for caching
  112197. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  112198. * @param onError callback called when the file fails to load
  112199. * @returns a file request object
  112200. * @hidden
  112201. */
  112202. 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;
  112203. /**
  112204. * Reads pixels from the current frame buffer. Please note that this function can be slow
  112205. * @param x defines the x coordinate of the rectangle where pixels must be read
  112206. * @param y defines the y coordinate of the rectangle where pixels must be read
  112207. * @param width defines the width of the rectangle where pixels must be read
  112208. * @param height defines the height of the rectangle where pixels must be read
  112209. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  112210. * @returns a Uint8Array containing RGBA colors
  112211. */
  112212. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  112213. private static _isSupported;
  112214. /**
  112215. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  112216. * @returns true if the engine can be created
  112217. * @ignorenaming
  112218. */
  112219. static isSupported(): boolean;
  112220. /**
  112221. * Find the next highest power of two.
  112222. * @param x Number to start search from.
  112223. * @return Next highest power of two.
  112224. */
  112225. static CeilingPOT(x: number): number;
  112226. /**
  112227. * Find the next lowest power of two.
  112228. * @param x Number to start search from.
  112229. * @return Next lowest power of two.
  112230. */
  112231. static FloorPOT(x: number): number;
  112232. /**
  112233. * Find the nearest power of two.
  112234. * @param x Number to start search from.
  112235. * @return Next nearest power of two.
  112236. */
  112237. static NearestPOT(x: number): number;
  112238. /**
  112239. * Get the closest exponent of two
  112240. * @param value defines the value to approximate
  112241. * @param max defines the maximum value to return
  112242. * @param mode defines how to define the closest value
  112243. * @returns closest exponent of two of the given value
  112244. */
  112245. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  112246. /**
  112247. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  112248. * @param func - the function to be called
  112249. * @param requester - the object that will request the next frame. Falls back to window.
  112250. * @returns frame number
  112251. */
  112252. static QueueNewFrame(func: () => void, requester?: any): number;
  112253. /**
  112254. * Gets host document
  112255. * @returns the host document object
  112256. */
  112257. getHostDocument(): Nullable<Document>;
  112258. }
  112259. }
  112260. declare module BABYLON {
  112261. /**
  112262. * Class representing spherical harmonics coefficients to the 3rd degree
  112263. */
  112264. export class SphericalHarmonics {
  112265. /**
  112266. * Defines whether or not the harmonics have been prescaled for rendering.
  112267. */
  112268. preScaled: boolean;
  112269. /**
  112270. * The l0,0 coefficients of the spherical harmonics
  112271. */
  112272. l00: Vector3;
  112273. /**
  112274. * The l1,-1 coefficients of the spherical harmonics
  112275. */
  112276. l1_1: Vector3;
  112277. /**
  112278. * The l1,0 coefficients of the spherical harmonics
  112279. */
  112280. l10: Vector3;
  112281. /**
  112282. * The l1,1 coefficients of the spherical harmonics
  112283. */
  112284. l11: Vector3;
  112285. /**
  112286. * The l2,-2 coefficients of the spherical harmonics
  112287. */
  112288. l2_2: Vector3;
  112289. /**
  112290. * The l2,-1 coefficients of the spherical harmonics
  112291. */
  112292. l2_1: Vector3;
  112293. /**
  112294. * The l2,0 coefficients of the spherical harmonics
  112295. */
  112296. l20: Vector3;
  112297. /**
  112298. * The l2,1 coefficients of the spherical harmonics
  112299. */
  112300. l21: Vector3;
  112301. /**
  112302. * The l2,2 coefficients of the spherical harmonics
  112303. */
  112304. l22: Vector3;
  112305. /**
  112306. * Adds a light to the spherical harmonics
  112307. * @param direction the direction of the light
  112308. * @param color the color of the light
  112309. * @param deltaSolidAngle the delta solid angle of the light
  112310. */
  112311. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  112312. /**
  112313. * Scales the spherical harmonics by the given amount
  112314. * @param scale the amount to scale
  112315. */
  112316. scaleInPlace(scale: number): void;
  112317. /**
  112318. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  112319. *
  112320. * ```
  112321. * E_lm = A_l * L_lm
  112322. * ```
  112323. *
  112324. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  112325. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  112326. * the scaling factors are given in equation 9.
  112327. */
  112328. convertIncidentRadianceToIrradiance(): void;
  112329. /**
  112330. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  112331. *
  112332. * ```
  112333. * L = (1/pi) * E * rho
  112334. * ```
  112335. *
  112336. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  112337. */
  112338. convertIrradianceToLambertianRadiance(): void;
  112339. /**
  112340. * Integrates the reconstruction coefficients directly in to the SH preventing further
  112341. * required operations at run time.
  112342. *
  112343. * This is simply done by scaling back the SH with Ylm constants parameter.
  112344. * The trigonometric part being applied by the shader at run time.
  112345. */
  112346. preScaleForRendering(): void;
  112347. /**
  112348. * Constructs a spherical harmonics from an array.
  112349. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  112350. * @returns the spherical harmonics
  112351. */
  112352. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  112353. /**
  112354. * Gets the spherical harmonics from polynomial
  112355. * @param polynomial the spherical polynomial
  112356. * @returns the spherical harmonics
  112357. */
  112358. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  112359. }
  112360. /**
  112361. * Class representing spherical polynomial coefficients to the 3rd degree
  112362. */
  112363. export class SphericalPolynomial {
  112364. private _harmonics;
  112365. /**
  112366. * The spherical harmonics used to create the polynomials.
  112367. */
  112368. get preScaledHarmonics(): SphericalHarmonics;
  112369. /**
  112370. * The x coefficients of the spherical polynomial
  112371. */
  112372. x: Vector3;
  112373. /**
  112374. * The y coefficients of the spherical polynomial
  112375. */
  112376. y: Vector3;
  112377. /**
  112378. * The z coefficients of the spherical polynomial
  112379. */
  112380. z: Vector3;
  112381. /**
  112382. * The xx coefficients of the spherical polynomial
  112383. */
  112384. xx: Vector3;
  112385. /**
  112386. * The yy coefficients of the spherical polynomial
  112387. */
  112388. yy: Vector3;
  112389. /**
  112390. * The zz coefficients of the spherical polynomial
  112391. */
  112392. zz: Vector3;
  112393. /**
  112394. * The xy coefficients of the spherical polynomial
  112395. */
  112396. xy: Vector3;
  112397. /**
  112398. * The yz coefficients of the spherical polynomial
  112399. */
  112400. yz: Vector3;
  112401. /**
  112402. * The zx coefficients of the spherical polynomial
  112403. */
  112404. zx: Vector3;
  112405. /**
  112406. * Adds an ambient color to the spherical polynomial
  112407. * @param color the color to add
  112408. */
  112409. addAmbient(color: Color3): void;
  112410. /**
  112411. * Scales the spherical polynomial by the given amount
  112412. * @param scale the amount to scale
  112413. */
  112414. scaleInPlace(scale: number): void;
  112415. /**
  112416. * Gets the spherical polynomial from harmonics
  112417. * @param harmonics the spherical harmonics
  112418. * @returns the spherical polynomial
  112419. */
  112420. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  112421. /**
  112422. * Constructs a spherical polynomial from an array.
  112423. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  112424. * @returns the spherical polynomial
  112425. */
  112426. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  112427. }
  112428. }
  112429. declare module BABYLON {
  112430. /**
  112431. * Defines the source of the internal texture
  112432. */
  112433. export enum InternalTextureSource {
  112434. /**
  112435. * The source of the texture data is unknown
  112436. */
  112437. Unknown = 0,
  112438. /**
  112439. * Texture data comes from an URL
  112440. */
  112441. Url = 1,
  112442. /**
  112443. * Texture data is only used for temporary storage
  112444. */
  112445. Temp = 2,
  112446. /**
  112447. * Texture data comes from raw data (ArrayBuffer)
  112448. */
  112449. Raw = 3,
  112450. /**
  112451. * Texture content is dynamic (video or dynamic texture)
  112452. */
  112453. Dynamic = 4,
  112454. /**
  112455. * Texture content is generated by rendering to it
  112456. */
  112457. RenderTarget = 5,
  112458. /**
  112459. * Texture content is part of a multi render target process
  112460. */
  112461. MultiRenderTarget = 6,
  112462. /**
  112463. * Texture data comes from a cube data file
  112464. */
  112465. Cube = 7,
  112466. /**
  112467. * Texture data comes from a raw cube data
  112468. */
  112469. CubeRaw = 8,
  112470. /**
  112471. * Texture data come from a prefiltered cube data file
  112472. */
  112473. CubePrefiltered = 9,
  112474. /**
  112475. * Texture content is raw 3D data
  112476. */
  112477. Raw3D = 10,
  112478. /**
  112479. * Texture content is raw 2D array data
  112480. */
  112481. Raw2DArray = 11,
  112482. /**
  112483. * Texture content is a depth texture
  112484. */
  112485. Depth = 12,
  112486. /**
  112487. * Texture data comes from a raw cube data encoded with RGBD
  112488. */
  112489. CubeRawRGBD = 13
  112490. }
  112491. /**
  112492. * Class used to store data associated with WebGL texture data for the engine
  112493. * This class should not be used directly
  112494. */
  112495. export class InternalTexture {
  112496. /** @hidden */
  112497. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  112498. /**
  112499. * Defines if the texture is ready
  112500. */
  112501. isReady: boolean;
  112502. /**
  112503. * Defines if the texture is a cube texture
  112504. */
  112505. isCube: boolean;
  112506. /**
  112507. * Defines if the texture contains 3D data
  112508. */
  112509. is3D: boolean;
  112510. /**
  112511. * Defines if the texture contains 2D array data
  112512. */
  112513. is2DArray: boolean;
  112514. /**
  112515. * Defines if the texture contains multiview data
  112516. */
  112517. isMultiview: boolean;
  112518. /**
  112519. * Gets the URL used to load this texture
  112520. */
  112521. url: string;
  112522. /**
  112523. * Gets the sampling mode of the texture
  112524. */
  112525. samplingMode: number;
  112526. /**
  112527. * Gets a boolean indicating if the texture needs mipmaps generation
  112528. */
  112529. generateMipMaps: boolean;
  112530. /**
  112531. * Gets the number of samples used by the texture (WebGL2+ only)
  112532. */
  112533. samples: number;
  112534. /**
  112535. * Gets the type of the texture (int, float...)
  112536. */
  112537. type: number;
  112538. /**
  112539. * Gets the format of the texture (RGB, RGBA...)
  112540. */
  112541. format: number;
  112542. /**
  112543. * Observable called when the texture is loaded
  112544. */
  112545. onLoadedObservable: Observable<InternalTexture>;
  112546. /**
  112547. * Gets the width of the texture
  112548. */
  112549. width: number;
  112550. /**
  112551. * Gets the height of the texture
  112552. */
  112553. height: number;
  112554. /**
  112555. * Gets the depth of the texture
  112556. */
  112557. depth: number;
  112558. /**
  112559. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  112560. */
  112561. baseWidth: number;
  112562. /**
  112563. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  112564. */
  112565. baseHeight: number;
  112566. /**
  112567. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  112568. */
  112569. baseDepth: number;
  112570. /**
  112571. * Gets a boolean indicating if the texture is inverted on Y axis
  112572. */
  112573. invertY: boolean;
  112574. /** @hidden */
  112575. _invertVScale: boolean;
  112576. /** @hidden */
  112577. _associatedChannel: number;
  112578. /** @hidden */
  112579. _source: InternalTextureSource;
  112580. /** @hidden */
  112581. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  112582. /** @hidden */
  112583. _bufferView: Nullable<ArrayBufferView>;
  112584. /** @hidden */
  112585. _bufferViewArray: Nullable<ArrayBufferView[]>;
  112586. /** @hidden */
  112587. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  112588. /** @hidden */
  112589. _size: number;
  112590. /** @hidden */
  112591. _extension: string;
  112592. /** @hidden */
  112593. _files: Nullable<string[]>;
  112594. /** @hidden */
  112595. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112596. /** @hidden */
  112597. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112598. /** @hidden */
  112599. _framebuffer: Nullable<WebGLFramebuffer>;
  112600. /** @hidden */
  112601. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  112602. /** @hidden */
  112603. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  112604. /** @hidden */
  112605. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  112606. /** @hidden */
  112607. _attachments: Nullable<number[]>;
  112608. /** @hidden */
  112609. _cachedCoordinatesMode: Nullable<number>;
  112610. /** @hidden */
  112611. _cachedWrapU: Nullable<number>;
  112612. /** @hidden */
  112613. _cachedWrapV: Nullable<number>;
  112614. /** @hidden */
  112615. _cachedWrapR: Nullable<number>;
  112616. /** @hidden */
  112617. _cachedAnisotropicFilteringLevel: Nullable<number>;
  112618. /** @hidden */
  112619. _isDisabled: boolean;
  112620. /** @hidden */
  112621. _compression: Nullable<string>;
  112622. /** @hidden */
  112623. _generateStencilBuffer: boolean;
  112624. /** @hidden */
  112625. _generateDepthBuffer: boolean;
  112626. /** @hidden */
  112627. _comparisonFunction: number;
  112628. /** @hidden */
  112629. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  112630. /** @hidden */
  112631. _lodGenerationScale: number;
  112632. /** @hidden */
  112633. _lodGenerationOffset: number;
  112634. /** @hidden */
  112635. _depthStencilTexture: Nullable<InternalTexture>;
  112636. /** @hidden */
  112637. _colorTextureArray: Nullable<WebGLTexture>;
  112638. /** @hidden */
  112639. _depthStencilTextureArray: Nullable<WebGLTexture>;
  112640. /** @hidden */
  112641. _lodTextureHigh: Nullable<BaseTexture>;
  112642. /** @hidden */
  112643. _lodTextureMid: Nullable<BaseTexture>;
  112644. /** @hidden */
  112645. _lodTextureLow: Nullable<BaseTexture>;
  112646. /** @hidden */
  112647. _isRGBD: boolean;
  112648. /** @hidden */
  112649. _linearSpecularLOD: boolean;
  112650. /** @hidden */
  112651. _irradianceTexture: Nullable<BaseTexture>;
  112652. /** @hidden */
  112653. _webGLTexture: Nullable<WebGLTexture>;
  112654. /** @hidden */
  112655. _references: number;
  112656. private _engine;
  112657. /**
  112658. * Gets the Engine the texture belongs to.
  112659. * @returns The babylon engine
  112660. */
  112661. getEngine(): ThinEngine;
  112662. /**
  112663. * Gets the data source type of the texture
  112664. */
  112665. get source(): InternalTextureSource;
  112666. /**
  112667. * Creates a new InternalTexture
  112668. * @param engine defines the engine to use
  112669. * @param source defines the type of data that will be used
  112670. * @param delayAllocation if the texture allocation should be delayed (default: false)
  112671. */
  112672. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  112673. /**
  112674. * Increments the number of references (ie. the number of Texture that point to it)
  112675. */
  112676. incrementReferences(): void;
  112677. /**
  112678. * Change the size of the texture (not the size of the content)
  112679. * @param width defines the new width
  112680. * @param height defines the new height
  112681. * @param depth defines the new depth (1 by default)
  112682. */
  112683. updateSize(width: int, height: int, depth?: int): void;
  112684. /** @hidden */
  112685. _rebuild(): void;
  112686. /** @hidden */
  112687. _swapAndDie(target: InternalTexture): void;
  112688. /**
  112689. * Dispose the current allocated resources
  112690. */
  112691. dispose(): void;
  112692. }
  112693. }
  112694. declare module BABYLON {
  112695. /**
  112696. * Class used to work with sound analyzer using fast fourier transform (FFT)
  112697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112698. */
  112699. export class Analyser {
  112700. /**
  112701. * Gets or sets the smoothing
  112702. * @ignorenaming
  112703. */
  112704. SMOOTHING: number;
  112705. /**
  112706. * Gets or sets the FFT table size
  112707. * @ignorenaming
  112708. */
  112709. FFT_SIZE: number;
  112710. /**
  112711. * Gets or sets the bar graph amplitude
  112712. * @ignorenaming
  112713. */
  112714. BARGRAPHAMPLITUDE: number;
  112715. /**
  112716. * Gets or sets the position of the debug canvas
  112717. * @ignorenaming
  112718. */
  112719. DEBUGCANVASPOS: {
  112720. x: number;
  112721. y: number;
  112722. };
  112723. /**
  112724. * Gets or sets the debug canvas size
  112725. * @ignorenaming
  112726. */
  112727. DEBUGCANVASSIZE: {
  112728. width: number;
  112729. height: number;
  112730. };
  112731. private _byteFreqs;
  112732. private _byteTime;
  112733. private _floatFreqs;
  112734. private _webAudioAnalyser;
  112735. private _debugCanvas;
  112736. private _debugCanvasContext;
  112737. private _scene;
  112738. private _registerFunc;
  112739. private _audioEngine;
  112740. /**
  112741. * Creates a new analyser
  112742. * @param scene defines hosting scene
  112743. */
  112744. constructor(scene: Scene);
  112745. /**
  112746. * Get the number of data values you will have to play with for the visualization
  112747. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  112748. * @returns a number
  112749. */
  112750. getFrequencyBinCount(): number;
  112751. /**
  112752. * Gets the current frequency data as a byte array
  112753. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112754. * @returns a Uint8Array
  112755. */
  112756. getByteFrequencyData(): Uint8Array;
  112757. /**
  112758. * Gets the current waveform as a byte array
  112759. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  112760. * @returns a Uint8Array
  112761. */
  112762. getByteTimeDomainData(): Uint8Array;
  112763. /**
  112764. * Gets the current frequency data as a float array
  112765. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112766. * @returns a Float32Array
  112767. */
  112768. getFloatFrequencyData(): Float32Array;
  112769. /**
  112770. * Renders the debug canvas
  112771. */
  112772. drawDebugCanvas(): void;
  112773. /**
  112774. * Stops rendering the debug canvas and removes it
  112775. */
  112776. stopDebugCanvas(): void;
  112777. /**
  112778. * Connects two audio nodes
  112779. * @param inputAudioNode defines first node to connect
  112780. * @param outputAudioNode defines second node to connect
  112781. */
  112782. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  112783. /**
  112784. * Releases all associated resources
  112785. */
  112786. dispose(): void;
  112787. }
  112788. }
  112789. declare module BABYLON {
  112790. /**
  112791. * This represents an audio engine and it is responsible
  112792. * to play, synchronize and analyse sounds throughout the application.
  112793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112794. */
  112795. export interface IAudioEngine extends IDisposable {
  112796. /**
  112797. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  112798. */
  112799. readonly canUseWebAudio: boolean;
  112800. /**
  112801. * Gets the current AudioContext if available.
  112802. */
  112803. readonly audioContext: Nullable<AudioContext>;
  112804. /**
  112805. * The master gain node defines the global audio volume of your audio engine.
  112806. */
  112807. readonly masterGain: GainNode;
  112808. /**
  112809. * Gets whether or not mp3 are supported by your browser.
  112810. */
  112811. readonly isMP3supported: boolean;
  112812. /**
  112813. * Gets whether or not ogg are supported by your browser.
  112814. */
  112815. readonly isOGGsupported: boolean;
  112816. /**
  112817. * Defines if Babylon should emit a warning if WebAudio is not supported.
  112818. * @ignoreNaming
  112819. */
  112820. WarnedWebAudioUnsupported: boolean;
  112821. /**
  112822. * Defines if the audio engine relies on a custom unlocked button.
  112823. * In this case, the embedded button will not be displayed.
  112824. */
  112825. useCustomUnlockedButton: boolean;
  112826. /**
  112827. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  112828. */
  112829. readonly unlocked: boolean;
  112830. /**
  112831. * Event raised when audio has been unlocked on the browser.
  112832. */
  112833. onAudioUnlockedObservable: Observable<AudioEngine>;
  112834. /**
  112835. * Event raised when audio has been locked on the browser.
  112836. */
  112837. onAudioLockedObservable: Observable<AudioEngine>;
  112838. /**
  112839. * Flags the audio engine in Locked state.
  112840. * This happens due to new browser policies preventing audio to autoplay.
  112841. */
  112842. lock(): void;
  112843. /**
  112844. * Unlocks the audio engine once a user action has been done on the dom.
  112845. * This is helpful to resume play once browser policies have been satisfied.
  112846. */
  112847. unlock(): void;
  112848. /**
  112849. * Gets the global volume sets on the master gain.
  112850. * @returns the global volume if set or -1 otherwise
  112851. */
  112852. getGlobalVolume(): number;
  112853. /**
  112854. * Sets the global volume of your experience (sets on the master gain).
  112855. * @param newVolume Defines the new global volume of the application
  112856. */
  112857. setGlobalVolume(newVolume: number): void;
  112858. /**
  112859. * Connect the audio engine to an audio analyser allowing some amazing
  112860. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112862. * @param analyser The analyser to connect to the engine
  112863. */
  112864. connectToAnalyser(analyser: Analyser): void;
  112865. }
  112866. /**
  112867. * This represents the default audio engine used in babylon.
  112868. * It is responsible to play, synchronize and analyse sounds throughout the application.
  112869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112870. */
  112871. export class AudioEngine implements IAudioEngine {
  112872. private _audioContext;
  112873. private _audioContextInitialized;
  112874. private _muteButton;
  112875. private _hostElement;
  112876. /**
  112877. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  112878. */
  112879. canUseWebAudio: boolean;
  112880. /**
  112881. * The master gain node defines the global audio volume of your audio engine.
  112882. */
  112883. masterGain: GainNode;
  112884. /**
  112885. * Defines if Babylon should emit a warning if WebAudio is not supported.
  112886. * @ignoreNaming
  112887. */
  112888. WarnedWebAudioUnsupported: boolean;
  112889. /**
  112890. * Gets whether or not mp3 are supported by your browser.
  112891. */
  112892. isMP3supported: boolean;
  112893. /**
  112894. * Gets whether or not ogg are supported by your browser.
  112895. */
  112896. isOGGsupported: boolean;
  112897. /**
  112898. * Gets whether audio has been unlocked on the device.
  112899. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  112900. * a user interaction has happened.
  112901. */
  112902. unlocked: boolean;
  112903. /**
  112904. * Defines if the audio engine relies on a custom unlocked button.
  112905. * In this case, the embedded button will not be displayed.
  112906. */
  112907. useCustomUnlockedButton: boolean;
  112908. /**
  112909. * Event raised when audio has been unlocked on the browser.
  112910. */
  112911. onAudioUnlockedObservable: Observable<AudioEngine>;
  112912. /**
  112913. * Event raised when audio has been locked on the browser.
  112914. */
  112915. onAudioLockedObservable: Observable<AudioEngine>;
  112916. /**
  112917. * Gets the current AudioContext if available.
  112918. */
  112919. get audioContext(): Nullable<AudioContext>;
  112920. private _connectedAnalyser;
  112921. /**
  112922. * Instantiates a new audio engine.
  112923. *
  112924. * There should be only one per page as some browsers restrict the number
  112925. * of audio contexts you can create.
  112926. * @param hostElement defines the host element where to display the mute icon if necessary
  112927. */
  112928. constructor(hostElement?: Nullable<HTMLElement>);
  112929. /**
  112930. * Flags the audio engine in Locked state.
  112931. * This happens due to new browser policies preventing audio to autoplay.
  112932. */
  112933. lock(): void;
  112934. /**
  112935. * Unlocks the audio engine once a user action has been done on the dom.
  112936. * This is helpful to resume play once browser policies have been satisfied.
  112937. */
  112938. unlock(): void;
  112939. private _resumeAudioContext;
  112940. private _initializeAudioContext;
  112941. private _tryToRun;
  112942. private _triggerRunningState;
  112943. private _triggerSuspendedState;
  112944. private _displayMuteButton;
  112945. private _moveButtonToTopLeft;
  112946. private _onResize;
  112947. private _hideMuteButton;
  112948. /**
  112949. * Destroy and release the resources associated with the audio ccontext.
  112950. */
  112951. dispose(): void;
  112952. /**
  112953. * Gets the global volume sets on the master gain.
  112954. * @returns the global volume if set or -1 otherwise
  112955. */
  112956. getGlobalVolume(): number;
  112957. /**
  112958. * Sets the global volume of your experience (sets on the master gain).
  112959. * @param newVolume Defines the new global volume of the application
  112960. */
  112961. setGlobalVolume(newVolume: number): void;
  112962. /**
  112963. * Connect the audio engine to an audio analyser allowing some amazing
  112964. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112966. * @param analyser The analyser to connect to the engine
  112967. */
  112968. connectToAnalyser(analyser: Analyser): void;
  112969. }
  112970. }
  112971. declare module BABYLON {
  112972. /**
  112973. * Interface used to present a loading screen while loading a scene
  112974. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112975. */
  112976. export interface ILoadingScreen {
  112977. /**
  112978. * Function called to display the loading screen
  112979. */
  112980. displayLoadingUI: () => void;
  112981. /**
  112982. * Function called to hide the loading screen
  112983. */
  112984. hideLoadingUI: () => void;
  112985. /**
  112986. * Gets or sets the color to use for the background
  112987. */
  112988. loadingUIBackgroundColor: string;
  112989. /**
  112990. * Gets or sets the text to display while loading
  112991. */
  112992. loadingUIText: string;
  112993. }
  112994. /**
  112995. * Class used for the default loading screen
  112996. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112997. */
  112998. export class DefaultLoadingScreen implements ILoadingScreen {
  112999. private _renderingCanvas;
  113000. private _loadingText;
  113001. private _loadingDivBackgroundColor;
  113002. private _loadingDiv;
  113003. private _loadingTextDiv;
  113004. /** Gets or sets the logo url to use for the default loading screen */
  113005. static DefaultLogoUrl: string;
  113006. /** Gets or sets the spinner url to use for the default loading screen */
  113007. static DefaultSpinnerUrl: string;
  113008. /**
  113009. * Creates a new default loading screen
  113010. * @param _renderingCanvas defines the canvas used to render the scene
  113011. * @param _loadingText defines the default text to display
  113012. * @param _loadingDivBackgroundColor defines the default background color
  113013. */
  113014. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  113015. /**
  113016. * Function called to display the loading screen
  113017. */
  113018. displayLoadingUI(): void;
  113019. /**
  113020. * Function called to hide the loading screen
  113021. */
  113022. hideLoadingUI(): void;
  113023. /**
  113024. * Gets or sets the text to display while loading
  113025. */
  113026. set loadingUIText(text: string);
  113027. get loadingUIText(): string;
  113028. /**
  113029. * Gets or sets the color to use for the background
  113030. */
  113031. get loadingUIBackgroundColor(): string;
  113032. set loadingUIBackgroundColor(color: string);
  113033. private _resizeLoadingUI;
  113034. }
  113035. }
  113036. declare module BABYLON {
  113037. /**
  113038. * Interface for any object that can request an animation frame
  113039. */
  113040. export interface ICustomAnimationFrameRequester {
  113041. /**
  113042. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  113043. */
  113044. renderFunction?: Function;
  113045. /**
  113046. * Called to request the next frame to render to
  113047. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  113048. */
  113049. requestAnimationFrame: Function;
  113050. /**
  113051. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  113052. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  113053. */
  113054. requestID?: number;
  113055. }
  113056. }
  113057. declare module BABYLON {
  113058. /**
  113059. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  113060. */
  113061. export class PerformanceMonitor {
  113062. private _enabled;
  113063. private _rollingFrameTime;
  113064. private _lastFrameTimeMs;
  113065. /**
  113066. * constructor
  113067. * @param frameSampleSize The number of samples required to saturate the sliding window
  113068. */
  113069. constructor(frameSampleSize?: number);
  113070. /**
  113071. * Samples current frame
  113072. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  113073. */
  113074. sampleFrame(timeMs?: number): void;
  113075. /**
  113076. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113077. */
  113078. get averageFrameTime(): number;
  113079. /**
  113080. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113081. */
  113082. get averageFrameTimeVariance(): number;
  113083. /**
  113084. * Returns the frame time of the most recent frame
  113085. */
  113086. get instantaneousFrameTime(): number;
  113087. /**
  113088. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  113089. */
  113090. get averageFPS(): number;
  113091. /**
  113092. * Returns the average framerate in frames per second using the most recent frame time
  113093. */
  113094. get instantaneousFPS(): number;
  113095. /**
  113096. * Returns true if enough samples have been taken to completely fill the sliding window
  113097. */
  113098. get isSaturated(): boolean;
  113099. /**
  113100. * Enables contributions to the sliding window sample set
  113101. */
  113102. enable(): void;
  113103. /**
  113104. * Disables contributions to the sliding window sample set
  113105. * Samples will not be interpolated over the disabled period
  113106. */
  113107. disable(): void;
  113108. /**
  113109. * Returns true if sampling is enabled
  113110. */
  113111. get isEnabled(): boolean;
  113112. /**
  113113. * Resets performance monitor
  113114. */
  113115. reset(): void;
  113116. }
  113117. /**
  113118. * RollingAverage
  113119. *
  113120. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  113121. */
  113122. export class RollingAverage {
  113123. /**
  113124. * Current average
  113125. */
  113126. average: number;
  113127. /**
  113128. * Current variance
  113129. */
  113130. variance: number;
  113131. protected _samples: Array<number>;
  113132. protected _sampleCount: number;
  113133. protected _pos: number;
  113134. protected _m2: number;
  113135. /**
  113136. * constructor
  113137. * @param length The number of samples required to saturate the sliding window
  113138. */
  113139. constructor(length: number);
  113140. /**
  113141. * Adds a sample to the sample set
  113142. * @param v The sample value
  113143. */
  113144. add(v: number): void;
  113145. /**
  113146. * Returns previously added values or null if outside of history or outside the sliding window domain
  113147. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  113148. * @return Value previously recorded with add() or null if outside of range
  113149. */
  113150. history(i: number): number;
  113151. /**
  113152. * Returns true if enough samples have been taken to completely fill the sliding window
  113153. * @return true if sample-set saturated
  113154. */
  113155. isSaturated(): boolean;
  113156. /**
  113157. * Resets the rolling average (equivalent to 0 samples taken so far)
  113158. */
  113159. reset(): void;
  113160. /**
  113161. * Wraps a value around the sample range boundaries
  113162. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  113163. * @return Wrapped position in sample range
  113164. */
  113165. protected _wrapPosition(i: number): number;
  113166. }
  113167. }
  113168. declare module BABYLON {
  113169. /**
  113170. * This class is used to track a performance counter which is number based.
  113171. * The user has access to many properties which give statistics of different nature.
  113172. *
  113173. * The implementer can track two kinds of Performance Counter: time and count.
  113174. * 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.
  113175. * 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.
  113176. */
  113177. export class PerfCounter {
  113178. /**
  113179. * Gets or sets a global boolean to turn on and off all the counters
  113180. */
  113181. static Enabled: boolean;
  113182. /**
  113183. * Returns the smallest value ever
  113184. */
  113185. get min(): number;
  113186. /**
  113187. * Returns the biggest value ever
  113188. */
  113189. get max(): number;
  113190. /**
  113191. * Returns the average value since the performance counter is running
  113192. */
  113193. get average(): number;
  113194. /**
  113195. * Returns the average value of the last second the counter was monitored
  113196. */
  113197. get lastSecAverage(): number;
  113198. /**
  113199. * Returns the current value
  113200. */
  113201. get current(): number;
  113202. /**
  113203. * Gets the accumulated total
  113204. */
  113205. get total(): number;
  113206. /**
  113207. * Gets the total value count
  113208. */
  113209. get count(): number;
  113210. /**
  113211. * Creates a new counter
  113212. */
  113213. constructor();
  113214. /**
  113215. * Call this method to start monitoring a new frame.
  113216. * 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.
  113217. */
  113218. fetchNewFrame(): void;
  113219. /**
  113220. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  113221. * @param newCount the count value to add to the monitored count
  113222. * @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.
  113223. */
  113224. addCount(newCount: number, fetchResult: boolean): void;
  113225. /**
  113226. * Start monitoring this performance counter
  113227. */
  113228. beginMonitoring(): void;
  113229. /**
  113230. * Compute the time lapsed since the previous beginMonitoring() call.
  113231. * @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
  113232. */
  113233. endMonitoring(newFrame?: boolean): void;
  113234. private _fetchResult;
  113235. private _startMonitoringTime;
  113236. private _min;
  113237. private _max;
  113238. private _average;
  113239. private _current;
  113240. private _totalValueCount;
  113241. private _totalAccumulated;
  113242. private _lastSecAverage;
  113243. private _lastSecAccumulated;
  113244. private _lastSecTime;
  113245. private _lastSecValueCount;
  113246. }
  113247. }
  113248. declare module BABYLON {
  113249. interface ThinEngine {
  113250. /**
  113251. * Sets alpha constants used by some alpha blending modes
  113252. * @param r defines the red component
  113253. * @param g defines the green component
  113254. * @param b defines the blue component
  113255. * @param a defines the alpha component
  113256. */
  113257. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113258. /**
  113259. * Sets the current alpha mode
  113260. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113261. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113262. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113263. */
  113264. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113265. /**
  113266. * Gets the current alpha mode
  113267. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113268. * @returns the current alpha mode
  113269. */
  113270. getAlphaMode(): number;
  113271. /**
  113272. * Sets the current alpha equation
  113273. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  113274. */
  113275. setAlphaEquation(equation: number): void;
  113276. /**
  113277. * Gets the current alpha equation.
  113278. * @returns the current alpha equation
  113279. */
  113280. getAlphaEquation(): number;
  113281. }
  113282. }
  113283. declare module BABYLON {
  113284. interface ThinEngine {
  113285. /** @hidden */
  113286. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  113287. }
  113288. }
  113289. declare module BABYLON {
  113290. /**
  113291. * Defines the interface used by display changed events
  113292. */
  113293. export interface IDisplayChangedEventArgs {
  113294. /** Gets the vrDisplay object (if any) */
  113295. vrDisplay: Nullable<any>;
  113296. /** Gets a boolean indicating if webVR is supported */
  113297. vrSupported: boolean;
  113298. }
  113299. /**
  113300. * Defines the interface used by objects containing a viewport (like a camera)
  113301. */
  113302. interface IViewportOwnerLike {
  113303. /**
  113304. * Gets or sets the viewport
  113305. */
  113306. viewport: IViewportLike;
  113307. }
  113308. /**
  113309. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  113310. */
  113311. export class Engine extends ThinEngine {
  113312. /** Defines that alpha blending is disabled */
  113313. static readonly ALPHA_DISABLE: number;
  113314. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  113315. static readonly ALPHA_ADD: number;
  113316. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  113317. static readonly ALPHA_COMBINE: number;
  113318. /** Defines that alpha blending to DEST - SRC * DEST */
  113319. static readonly ALPHA_SUBTRACT: number;
  113320. /** Defines that alpha blending to SRC * DEST */
  113321. static readonly ALPHA_MULTIPLY: number;
  113322. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  113323. static readonly ALPHA_MAXIMIZED: number;
  113324. /** Defines that alpha blending to SRC + DEST */
  113325. static readonly ALPHA_ONEONE: number;
  113326. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  113327. static readonly ALPHA_PREMULTIPLIED: number;
  113328. /**
  113329. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  113330. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  113331. */
  113332. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  113333. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  113334. static readonly ALPHA_INTERPOLATE: number;
  113335. /**
  113336. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  113337. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  113338. */
  113339. static readonly ALPHA_SCREENMODE: number;
  113340. /** Defines that the ressource is not delayed*/
  113341. static readonly DELAYLOADSTATE_NONE: number;
  113342. /** Defines that the ressource was successfully delay loaded */
  113343. static readonly DELAYLOADSTATE_LOADED: number;
  113344. /** Defines that the ressource is currently delay loading */
  113345. static readonly DELAYLOADSTATE_LOADING: number;
  113346. /** Defines that the ressource is delayed and has not started loading */
  113347. static readonly DELAYLOADSTATE_NOTLOADED: number;
  113348. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  113349. static readonly NEVER: number;
  113350. /** 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 */
  113351. static readonly ALWAYS: number;
  113352. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  113353. static readonly LESS: number;
  113354. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  113355. static readonly EQUAL: number;
  113356. /** 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 */
  113357. static readonly LEQUAL: number;
  113358. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  113359. static readonly GREATER: number;
  113360. /** 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 */
  113361. static readonly GEQUAL: number;
  113362. /** 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 */
  113363. static readonly NOTEQUAL: number;
  113364. /** Passed to stencilOperation to specify that stencil value must be kept */
  113365. static readonly KEEP: number;
  113366. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113367. static readonly REPLACE: number;
  113368. /** Passed to stencilOperation to specify that stencil value must be incremented */
  113369. static readonly INCR: number;
  113370. /** Passed to stencilOperation to specify that stencil value must be decremented */
  113371. static readonly DECR: number;
  113372. /** Passed to stencilOperation to specify that stencil value must be inverted */
  113373. static readonly INVERT: number;
  113374. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  113375. static readonly INCR_WRAP: number;
  113376. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  113377. static readonly DECR_WRAP: number;
  113378. /** Texture is not repeating outside of 0..1 UVs */
  113379. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  113380. /** Texture is repeating outside of 0..1 UVs */
  113381. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  113382. /** Texture is repeating and mirrored */
  113383. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  113384. /** ALPHA */
  113385. static readonly TEXTUREFORMAT_ALPHA: number;
  113386. /** LUMINANCE */
  113387. static readonly TEXTUREFORMAT_LUMINANCE: number;
  113388. /** LUMINANCE_ALPHA */
  113389. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  113390. /** RGB */
  113391. static readonly TEXTUREFORMAT_RGB: number;
  113392. /** RGBA */
  113393. static readonly TEXTUREFORMAT_RGBA: number;
  113394. /** RED */
  113395. static readonly TEXTUREFORMAT_RED: number;
  113396. /** RED (2nd reference) */
  113397. static readonly TEXTUREFORMAT_R: number;
  113398. /** RG */
  113399. static readonly TEXTUREFORMAT_RG: number;
  113400. /** RED_INTEGER */
  113401. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  113402. /** RED_INTEGER (2nd reference) */
  113403. static readonly TEXTUREFORMAT_R_INTEGER: number;
  113404. /** RG_INTEGER */
  113405. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  113406. /** RGB_INTEGER */
  113407. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  113408. /** RGBA_INTEGER */
  113409. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  113410. /** UNSIGNED_BYTE */
  113411. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  113412. /** UNSIGNED_BYTE (2nd reference) */
  113413. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  113414. /** FLOAT */
  113415. static readonly TEXTURETYPE_FLOAT: number;
  113416. /** HALF_FLOAT */
  113417. static readonly TEXTURETYPE_HALF_FLOAT: number;
  113418. /** BYTE */
  113419. static readonly TEXTURETYPE_BYTE: number;
  113420. /** SHORT */
  113421. static readonly TEXTURETYPE_SHORT: number;
  113422. /** UNSIGNED_SHORT */
  113423. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  113424. /** INT */
  113425. static readonly TEXTURETYPE_INT: number;
  113426. /** UNSIGNED_INT */
  113427. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  113428. /** UNSIGNED_SHORT_4_4_4_4 */
  113429. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  113430. /** UNSIGNED_SHORT_5_5_5_1 */
  113431. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  113432. /** UNSIGNED_SHORT_5_6_5 */
  113433. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  113434. /** UNSIGNED_INT_2_10_10_10_REV */
  113435. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  113436. /** UNSIGNED_INT_24_8 */
  113437. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  113438. /** UNSIGNED_INT_10F_11F_11F_REV */
  113439. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  113440. /** UNSIGNED_INT_5_9_9_9_REV */
  113441. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  113442. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  113443. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  113444. /** nearest is mag = nearest and min = nearest and mip = linear */
  113445. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  113446. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113447. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  113448. /** Trilinear is mag = linear and min = linear and mip = linear */
  113449. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  113450. /** nearest is mag = nearest and min = nearest and mip = linear */
  113451. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  113452. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113453. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  113454. /** Trilinear is mag = linear and min = linear and mip = linear */
  113455. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  113456. /** mag = nearest and min = nearest and mip = nearest */
  113457. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  113458. /** mag = nearest and min = linear and mip = nearest */
  113459. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  113460. /** mag = nearest and min = linear and mip = linear */
  113461. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  113462. /** mag = nearest and min = linear and mip = none */
  113463. static readonly TEXTURE_NEAREST_LINEAR: number;
  113464. /** mag = nearest and min = nearest and mip = none */
  113465. static readonly TEXTURE_NEAREST_NEAREST: number;
  113466. /** mag = linear and min = nearest and mip = nearest */
  113467. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  113468. /** mag = linear and min = nearest and mip = linear */
  113469. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  113470. /** mag = linear and min = linear and mip = none */
  113471. static readonly TEXTURE_LINEAR_LINEAR: number;
  113472. /** mag = linear and min = nearest and mip = none */
  113473. static readonly TEXTURE_LINEAR_NEAREST: number;
  113474. /** Explicit coordinates mode */
  113475. static readonly TEXTURE_EXPLICIT_MODE: number;
  113476. /** Spherical coordinates mode */
  113477. static readonly TEXTURE_SPHERICAL_MODE: number;
  113478. /** Planar coordinates mode */
  113479. static readonly TEXTURE_PLANAR_MODE: number;
  113480. /** Cubic coordinates mode */
  113481. static readonly TEXTURE_CUBIC_MODE: number;
  113482. /** Projection coordinates mode */
  113483. static readonly TEXTURE_PROJECTION_MODE: number;
  113484. /** Skybox coordinates mode */
  113485. static readonly TEXTURE_SKYBOX_MODE: number;
  113486. /** Inverse Cubic coordinates mode */
  113487. static readonly TEXTURE_INVCUBIC_MODE: number;
  113488. /** Equirectangular coordinates mode */
  113489. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  113490. /** Equirectangular Fixed coordinates mode */
  113491. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  113492. /** Equirectangular Fixed Mirrored coordinates mode */
  113493. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  113494. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  113495. static readonly SCALEMODE_FLOOR: number;
  113496. /** Defines that texture rescaling will look for the nearest power of 2 size */
  113497. static readonly SCALEMODE_NEAREST: number;
  113498. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  113499. static readonly SCALEMODE_CEILING: number;
  113500. /**
  113501. * Returns the current npm package of the sdk
  113502. */
  113503. static get NpmPackage(): string;
  113504. /**
  113505. * Returns the current version of the framework
  113506. */
  113507. static get Version(): string;
  113508. /** Gets the list of created engines */
  113509. static get Instances(): Engine[];
  113510. /**
  113511. * Gets the latest created engine
  113512. */
  113513. static get LastCreatedEngine(): Nullable<Engine>;
  113514. /**
  113515. * Gets the latest created scene
  113516. */
  113517. static get LastCreatedScene(): Nullable<Scene>;
  113518. /**
  113519. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  113520. * @param flag defines which part of the materials must be marked as dirty
  113521. * @param predicate defines a predicate used to filter which materials should be affected
  113522. */
  113523. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113524. /**
  113525. * Method called to create the default loading screen.
  113526. * This can be overriden in your own app.
  113527. * @param canvas The rendering canvas element
  113528. * @returns The loading screen
  113529. */
  113530. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  113531. /**
  113532. * Method called to create the default rescale post process on each engine.
  113533. */
  113534. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  113535. /**
  113536. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  113537. **/
  113538. enableOfflineSupport: boolean;
  113539. /**
  113540. * 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)
  113541. **/
  113542. disableManifestCheck: boolean;
  113543. /**
  113544. * Gets the list of created scenes
  113545. */
  113546. scenes: Scene[];
  113547. /**
  113548. * Event raised when a new scene is created
  113549. */
  113550. onNewSceneAddedObservable: Observable<Scene>;
  113551. /**
  113552. * Gets the list of created postprocesses
  113553. */
  113554. postProcesses: PostProcess[];
  113555. /**
  113556. * Gets a boolean indicating if the pointer is currently locked
  113557. */
  113558. isPointerLock: boolean;
  113559. /**
  113560. * Observable event triggered each time the rendering canvas is resized
  113561. */
  113562. onResizeObservable: Observable<Engine>;
  113563. /**
  113564. * Observable event triggered each time the canvas loses focus
  113565. */
  113566. onCanvasBlurObservable: Observable<Engine>;
  113567. /**
  113568. * Observable event triggered each time the canvas gains focus
  113569. */
  113570. onCanvasFocusObservable: Observable<Engine>;
  113571. /**
  113572. * Observable event triggered each time the canvas receives pointerout event
  113573. */
  113574. onCanvasPointerOutObservable: Observable<PointerEvent>;
  113575. /**
  113576. * Observable raised when the engine begins a new frame
  113577. */
  113578. onBeginFrameObservable: Observable<Engine>;
  113579. /**
  113580. * If set, will be used to request the next animation frame for the render loop
  113581. */
  113582. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  113583. /**
  113584. * Observable raised when the engine ends the current frame
  113585. */
  113586. onEndFrameObservable: Observable<Engine>;
  113587. /**
  113588. * Observable raised when the engine is about to compile a shader
  113589. */
  113590. onBeforeShaderCompilationObservable: Observable<Engine>;
  113591. /**
  113592. * Observable raised when the engine has jsut compiled a shader
  113593. */
  113594. onAfterShaderCompilationObservable: Observable<Engine>;
  113595. /**
  113596. * Gets the audio engine
  113597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113598. * @ignorenaming
  113599. */
  113600. static audioEngine: IAudioEngine;
  113601. /**
  113602. * Default AudioEngine factory responsible of creating the Audio Engine.
  113603. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  113604. */
  113605. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  113606. /**
  113607. * Default offline support factory responsible of creating a tool used to store data locally.
  113608. * By default, this will create a Database object if the workload has been embedded.
  113609. */
  113610. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  113611. private _loadingScreen;
  113612. private _pointerLockRequested;
  113613. private _rescalePostProcess;
  113614. private _deterministicLockstep;
  113615. private _lockstepMaxSteps;
  113616. private _timeStep;
  113617. protected get _supportsHardwareTextureRescaling(): boolean;
  113618. private _fps;
  113619. private _deltaTime;
  113620. /** @hidden */
  113621. _drawCalls: PerfCounter;
  113622. /** 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 */
  113623. canvasTabIndex: number;
  113624. /**
  113625. * Turn this value on if you want to pause FPS computation when in background
  113626. */
  113627. disablePerformanceMonitorInBackground: boolean;
  113628. private _performanceMonitor;
  113629. /**
  113630. * Gets the performance monitor attached to this engine
  113631. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113632. */
  113633. get performanceMonitor(): PerformanceMonitor;
  113634. private _onFocus;
  113635. private _onBlur;
  113636. private _onCanvasPointerOut;
  113637. private _onCanvasBlur;
  113638. private _onCanvasFocus;
  113639. private _onFullscreenChange;
  113640. private _onPointerLockChange;
  113641. /**
  113642. * Gets the HTML element used to attach event listeners
  113643. * @returns a HTML element
  113644. */
  113645. getInputElement(): Nullable<HTMLElement>;
  113646. /**
  113647. * Creates a new engine
  113648. * @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
  113649. * @param antialias defines enable antialiasing (default: false)
  113650. * @param options defines further options to be sent to the getContext() function
  113651. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  113652. */
  113653. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  113654. /**
  113655. * Gets current aspect ratio
  113656. * @param viewportOwner defines the camera to use to get the aspect ratio
  113657. * @param useScreen defines if screen size must be used (or the current render target if any)
  113658. * @returns a number defining the aspect ratio
  113659. */
  113660. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  113661. /**
  113662. * Gets current screen aspect ratio
  113663. * @returns a number defining the aspect ratio
  113664. */
  113665. getScreenAspectRatio(): number;
  113666. /**
  113667. * Gets the client rect of the HTML canvas attached with the current webGL context
  113668. * @returns a client rectanglee
  113669. */
  113670. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  113671. /**
  113672. * Gets the client rect of the HTML element used for events
  113673. * @returns a client rectanglee
  113674. */
  113675. getInputElementClientRect(): Nullable<ClientRect>;
  113676. /**
  113677. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113678. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113679. * @returns true if engine is in deterministic lock step mode
  113680. */
  113681. isDeterministicLockStep(): boolean;
  113682. /**
  113683. * Gets the max steps when engine is running in deterministic lock step
  113684. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113685. * @returns the max steps
  113686. */
  113687. getLockstepMaxSteps(): number;
  113688. /**
  113689. * Returns the time in ms between steps when using deterministic lock step.
  113690. * @returns time step in (ms)
  113691. */
  113692. getTimeStep(): number;
  113693. /**
  113694. * Force the mipmap generation for the given render target texture
  113695. * @param texture defines the render target texture to use
  113696. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  113697. */
  113698. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  113699. /** States */
  113700. /**
  113701. * Set various states to the webGL context
  113702. * @param culling defines backface culling state
  113703. * @param zOffset defines the value to apply to zOffset (0 by default)
  113704. * @param force defines if states must be applied even if cache is up to date
  113705. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113706. */
  113707. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113708. /**
  113709. * Set the z offset to apply to current rendering
  113710. * @param value defines the offset to apply
  113711. */
  113712. setZOffset(value: number): void;
  113713. /**
  113714. * Gets the current value of the zOffset
  113715. * @returns the current zOffset state
  113716. */
  113717. getZOffset(): number;
  113718. /**
  113719. * Enable or disable depth buffering
  113720. * @param enable defines the state to set
  113721. */
  113722. setDepthBuffer(enable: boolean): void;
  113723. /**
  113724. * Gets a boolean indicating if depth writing is enabled
  113725. * @returns the current depth writing state
  113726. */
  113727. getDepthWrite(): boolean;
  113728. /**
  113729. * Enable or disable depth writing
  113730. * @param enable defines the state to set
  113731. */
  113732. setDepthWrite(enable: boolean): void;
  113733. /**
  113734. * Gets a boolean indicating if stencil buffer is enabled
  113735. * @returns the current stencil buffer state
  113736. */
  113737. getStencilBuffer(): boolean;
  113738. /**
  113739. * Enable or disable the stencil buffer
  113740. * @param enable defines if the stencil buffer must be enabled or disabled
  113741. */
  113742. setStencilBuffer(enable: boolean): void;
  113743. /**
  113744. * Gets the current stencil mask
  113745. * @returns a number defining the new stencil mask to use
  113746. */
  113747. getStencilMask(): number;
  113748. /**
  113749. * Sets the current stencil mask
  113750. * @param mask defines the new stencil mask to use
  113751. */
  113752. setStencilMask(mask: number): void;
  113753. /**
  113754. * Gets the current stencil function
  113755. * @returns a number defining the stencil function to use
  113756. */
  113757. getStencilFunction(): number;
  113758. /**
  113759. * Gets the current stencil reference value
  113760. * @returns a number defining the stencil reference value to use
  113761. */
  113762. getStencilFunctionReference(): number;
  113763. /**
  113764. * Gets the current stencil mask
  113765. * @returns a number defining the stencil mask to use
  113766. */
  113767. getStencilFunctionMask(): number;
  113768. /**
  113769. * Sets the current stencil function
  113770. * @param stencilFunc defines the new stencil function to use
  113771. */
  113772. setStencilFunction(stencilFunc: number): void;
  113773. /**
  113774. * Sets the current stencil reference
  113775. * @param reference defines the new stencil reference to use
  113776. */
  113777. setStencilFunctionReference(reference: number): void;
  113778. /**
  113779. * Sets the current stencil mask
  113780. * @param mask defines the new stencil mask to use
  113781. */
  113782. setStencilFunctionMask(mask: number): void;
  113783. /**
  113784. * Gets the current stencil operation when stencil fails
  113785. * @returns a number defining stencil operation to use when stencil fails
  113786. */
  113787. getStencilOperationFail(): number;
  113788. /**
  113789. * Gets the current stencil operation when depth fails
  113790. * @returns a number defining stencil operation to use when depth fails
  113791. */
  113792. getStencilOperationDepthFail(): number;
  113793. /**
  113794. * Gets the current stencil operation when stencil passes
  113795. * @returns a number defining stencil operation to use when stencil passes
  113796. */
  113797. getStencilOperationPass(): number;
  113798. /**
  113799. * Sets the stencil operation to use when stencil fails
  113800. * @param operation defines the stencil operation to use when stencil fails
  113801. */
  113802. setStencilOperationFail(operation: number): void;
  113803. /**
  113804. * Sets the stencil operation to use when depth fails
  113805. * @param operation defines the stencil operation to use when depth fails
  113806. */
  113807. setStencilOperationDepthFail(operation: number): void;
  113808. /**
  113809. * Sets the stencil operation to use when stencil passes
  113810. * @param operation defines the stencil operation to use when stencil passes
  113811. */
  113812. setStencilOperationPass(operation: number): void;
  113813. /**
  113814. * Sets a boolean indicating if the dithering state is enabled or disabled
  113815. * @param value defines the dithering state
  113816. */
  113817. setDitheringState(value: boolean): void;
  113818. /**
  113819. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  113820. * @param value defines the rasterizer state
  113821. */
  113822. setRasterizerState(value: boolean): void;
  113823. /**
  113824. * Gets the current depth function
  113825. * @returns a number defining the depth function
  113826. */
  113827. getDepthFunction(): Nullable<number>;
  113828. /**
  113829. * Sets the current depth function
  113830. * @param depthFunc defines the function to use
  113831. */
  113832. setDepthFunction(depthFunc: number): void;
  113833. /**
  113834. * Sets the current depth function to GREATER
  113835. */
  113836. setDepthFunctionToGreater(): void;
  113837. /**
  113838. * Sets the current depth function to GEQUAL
  113839. */
  113840. setDepthFunctionToGreaterOrEqual(): void;
  113841. /**
  113842. * Sets the current depth function to LESS
  113843. */
  113844. setDepthFunctionToLess(): void;
  113845. /**
  113846. * Sets the current depth function to LEQUAL
  113847. */
  113848. setDepthFunctionToLessOrEqual(): void;
  113849. private _cachedStencilBuffer;
  113850. private _cachedStencilFunction;
  113851. private _cachedStencilMask;
  113852. private _cachedStencilOperationPass;
  113853. private _cachedStencilOperationFail;
  113854. private _cachedStencilOperationDepthFail;
  113855. private _cachedStencilReference;
  113856. /**
  113857. * Caches the the state of the stencil buffer
  113858. */
  113859. cacheStencilState(): void;
  113860. /**
  113861. * Restores the state of the stencil buffer
  113862. */
  113863. restoreStencilState(): void;
  113864. /**
  113865. * Directly set the WebGL Viewport
  113866. * @param x defines the x coordinate of the viewport (in screen space)
  113867. * @param y defines the y coordinate of the viewport (in screen space)
  113868. * @param width defines the width of the viewport (in screen space)
  113869. * @param height defines the height of the viewport (in screen space)
  113870. * @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
  113871. */
  113872. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  113873. /**
  113874. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  113875. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  113876. * @param y defines the y-coordinate of the corner of the clear rectangle
  113877. * @param width defines the width of the clear rectangle
  113878. * @param height defines the height of the clear rectangle
  113879. * @param clearColor defines the clear color
  113880. */
  113881. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  113882. /**
  113883. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  113884. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  113885. * @param y defines the y-coordinate of the corner of the clear rectangle
  113886. * @param width defines the width of the clear rectangle
  113887. * @param height defines the height of the clear rectangle
  113888. */
  113889. enableScissor(x: number, y: number, width: number, height: number): void;
  113890. /**
  113891. * Disable previously set scissor test rectangle
  113892. */
  113893. disableScissor(): void;
  113894. protected _reportDrawCall(): void;
  113895. /**
  113896. * Initializes a webVR display and starts listening to display change events
  113897. * The onVRDisplayChangedObservable will be notified upon these changes
  113898. * @returns The onVRDisplayChangedObservable
  113899. */
  113900. initWebVR(): Observable<IDisplayChangedEventArgs>;
  113901. /** @hidden */
  113902. _prepareVRComponent(): void;
  113903. /** @hidden */
  113904. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  113905. /** @hidden */
  113906. _submitVRFrame(): void;
  113907. /**
  113908. * Call this function to leave webVR mode
  113909. * Will do nothing if webVR is not supported or if there is no webVR device
  113910. * @see http://doc.babylonjs.com/how_to/webvr_camera
  113911. */
  113912. disableVR(): void;
  113913. /**
  113914. * Gets a boolean indicating that the system is in VR mode and is presenting
  113915. * @returns true if VR mode is engaged
  113916. */
  113917. isVRPresenting(): boolean;
  113918. /** @hidden */
  113919. _requestVRFrame(): void;
  113920. /** @hidden */
  113921. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113922. /**
  113923. * Gets the source code of the vertex shader associated with a specific webGL program
  113924. * @param program defines the program to use
  113925. * @returns a string containing the source code of the vertex shader associated with the program
  113926. */
  113927. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  113928. /**
  113929. * Gets the source code of the fragment shader associated with a specific webGL program
  113930. * @param program defines the program to use
  113931. * @returns a string containing the source code of the fragment shader associated with the program
  113932. */
  113933. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  113934. /**
  113935. * Sets a depth stencil texture from a render target to the according uniform.
  113936. * @param channel The texture channel
  113937. * @param uniform The uniform to set
  113938. * @param texture The render target texture containing the depth stencil texture to apply
  113939. */
  113940. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  113941. /**
  113942. * Sets a texture to the webGL context from a postprocess
  113943. * @param channel defines the channel to use
  113944. * @param postProcess defines the source postprocess
  113945. */
  113946. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  113947. /**
  113948. * Binds the output of the passed in post process to the texture channel specified
  113949. * @param channel The channel the texture should be bound to
  113950. * @param postProcess The post process which's output should be bound
  113951. */
  113952. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  113953. protected _rebuildBuffers(): void;
  113954. /** @hidden */
  113955. _renderFrame(): void;
  113956. _renderLoop(): void;
  113957. /** @hidden */
  113958. _renderViews(): boolean;
  113959. /**
  113960. * Toggle full screen mode
  113961. * @param requestPointerLock defines if a pointer lock should be requested from the user
  113962. */
  113963. switchFullscreen(requestPointerLock: boolean): void;
  113964. /**
  113965. * Enters full screen mode
  113966. * @param requestPointerLock defines if a pointer lock should be requested from the user
  113967. */
  113968. enterFullscreen(requestPointerLock: boolean): void;
  113969. /**
  113970. * Exits full screen mode
  113971. */
  113972. exitFullscreen(): void;
  113973. /**
  113974. * Enters Pointerlock mode
  113975. */
  113976. enterPointerlock(): void;
  113977. /**
  113978. * Exits Pointerlock mode
  113979. */
  113980. exitPointerlock(): void;
  113981. /**
  113982. * Begin a new frame
  113983. */
  113984. beginFrame(): void;
  113985. /**
  113986. * Enf the current frame
  113987. */
  113988. endFrame(): void;
  113989. resize(): void;
  113990. /**
  113991. * Force a specific size of the canvas
  113992. * @param width defines the new canvas' width
  113993. * @param height defines the new canvas' height
  113994. */
  113995. setSize(width: number, height: number): void;
  113996. /**
  113997. * Updates a dynamic vertex buffer.
  113998. * @param vertexBuffer the vertex buffer to update
  113999. * @param data the data used to update the vertex buffer
  114000. * @param byteOffset the byte offset of the data
  114001. * @param byteLength the byte length of the data
  114002. */
  114003. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114004. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114005. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114006. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114007. _releaseTexture(texture: InternalTexture): void;
  114008. /**
  114009. * @hidden
  114010. * Rescales a texture
  114011. * @param source input texutre
  114012. * @param destination destination texture
  114013. * @param scene scene to use to render the resize
  114014. * @param internalFormat format to use when resizing
  114015. * @param onComplete callback to be called when resize has completed
  114016. */
  114017. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114018. /**
  114019. * Gets the current framerate
  114020. * @returns a number representing the framerate
  114021. */
  114022. getFps(): number;
  114023. /**
  114024. * Gets the time spent between current and previous frame
  114025. * @returns a number representing the delta time in ms
  114026. */
  114027. getDeltaTime(): number;
  114028. private _measureFps;
  114029. /** @hidden */
  114030. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  114031. /**
  114032. * Update a dynamic index buffer
  114033. * @param indexBuffer defines the target index buffer
  114034. * @param indices defines the data to update
  114035. * @param offset defines the offset in the target index buffer where update should start
  114036. */
  114037. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114038. /**
  114039. * Updates the sample count of a render target texture
  114040. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114041. * @param texture defines the texture to update
  114042. * @param samples defines the sample count to set
  114043. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114044. */
  114045. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  114046. /**
  114047. * Updates a depth texture Comparison Mode and Function.
  114048. * If the comparison Function is equal to 0, the mode will be set to none.
  114049. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  114050. * @param texture The texture to set the comparison function for
  114051. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  114052. */
  114053. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  114054. /**
  114055. * Creates a webGL buffer to use with instanciation
  114056. * @param capacity defines the size of the buffer
  114057. * @returns the webGL buffer
  114058. */
  114059. createInstancesBuffer(capacity: number): DataBuffer;
  114060. /**
  114061. * Delete a webGL buffer used with instanciation
  114062. * @param buffer defines the webGL buffer to delete
  114063. */
  114064. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  114065. private _clientWaitAsync;
  114066. /** @hidden */
  114067. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  114068. dispose(): void;
  114069. private _disableTouchAction;
  114070. /**
  114071. * Display the loading screen
  114072. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114073. */
  114074. displayLoadingUI(): void;
  114075. /**
  114076. * Hide the loading screen
  114077. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114078. */
  114079. hideLoadingUI(): void;
  114080. /**
  114081. * Gets the current loading screen object
  114082. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114083. */
  114084. get loadingScreen(): ILoadingScreen;
  114085. /**
  114086. * Sets the current loading screen object
  114087. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114088. */
  114089. set loadingScreen(loadingScreen: ILoadingScreen);
  114090. /**
  114091. * Sets the current loading screen text
  114092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114093. */
  114094. set loadingUIText(text: string);
  114095. /**
  114096. * Sets the current loading screen background color
  114097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114098. */
  114099. set loadingUIBackgroundColor(color: string);
  114100. /** Pointerlock and fullscreen */
  114101. /**
  114102. * Ask the browser to promote the current element to pointerlock mode
  114103. * @param element defines the DOM element to promote
  114104. */
  114105. static _RequestPointerlock(element: HTMLElement): void;
  114106. /**
  114107. * Asks the browser to exit pointerlock mode
  114108. */
  114109. static _ExitPointerlock(): void;
  114110. /**
  114111. * Ask the browser to promote the current element to fullscreen rendering mode
  114112. * @param element defines the DOM element to promote
  114113. */
  114114. static _RequestFullscreen(element: HTMLElement): void;
  114115. /**
  114116. * Asks the browser to exit fullscreen mode
  114117. */
  114118. static _ExitFullscreen(): void;
  114119. }
  114120. }
  114121. declare module BABYLON {
  114122. /**
  114123. * The engine store class is responsible to hold all the instances of Engine and Scene created
  114124. * during the life time of the application.
  114125. */
  114126. export class EngineStore {
  114127. /** Gets the list of created engines */
  114128. static Instances: Engine[];
  114129. /** @hidden */
  114130. static _LastCreatedScene: Nullable<Scene>;
  114131. /**
  114132. * Gets the latest created engine
  114133. */
  114134. static get LastCreatedEngine(): Nullable<Engine>;
  114135. /**
  114136. * Gets the latest created scene
  114137. */
  114138. static get LastCreatedScene(): Nullable<Scene>;
  114139. /**
  114140. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114141. * @ignorenaming
  114142. */
  114143. static UseFallbackTexture: boolean;
  114144. /**
  114145. * Texture content used if a texture cannot loaded
  114146. * @ignorenaming
  114147. */
  114148. static FallbackTexture: string;
  114149. }
  114150. }
  114151. declare module BABYLON {
  114152. /**
  114153. * Helper class that provides a small promise polyfill
  114154. */
  114155. export class PromisePolyfill {
  114156. /**
  114157. * Static function used to check if the polyfill is required
  114158. * If this is the case then the function will inject the polyfill to window.Promise
  114159. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  114160. */
  114161. static Apply(force?: boolean): void;
  114162. }
  114163. }
  114164. declare module BABYLON {
  114165. /**
  114166. * Interface for screenshot methods with describe argument called `size` as object with options
  114167. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  114168. */
  114169. export interface IScreenshotSize {
  114170. /**
  114171. * number in pixels for canvas height
  114172. */
  114173. height?: number;
  114174. /**
  114175. * multiplier allowing render at a higher or lower resolution
  114176. * If value is defined then height and width will be ignored and taken from camera
  114177. */
  114178. precision?: number;
  114179. /**
  114180. * number in pixels for canvas width
  114181. */
  114182. width?: number;
  114183. }
  114184. }
  114185. declare module BABYLON {
  114186. interface IColor4Like {
  114187. r: float;
  114188. g: float;
  114189. b: float;
  114190. a: float;
  114191. }
  114192. /**
  114193. * Class containing a set of static utilities functions
  114194. */
  114195. export class Tools {
  114196. /**
  114197. * Gets or sets the base URL to use to load assets
  114198. */
  114199. static get BaseUrl(): string;
  114200. static set BaseUrl(value: string);
  114201. /**
  114202. * Enable/Disable Custom HTTP Request Headers globally.
  114203. * default = false
  114204. * @see CustomRequestHeaders
  114205. */
  114206. static UseCustomRequestHeaders: boolean;
  114207. /**
  114208. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  114209. * i.e. when loading files, where the server/service expects an Authorization header
  114210. */
  114211. static CustomRequestHeaders: {
  114212. [key: string]: string;
  114213. };
  114214. /**
  114215. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  114216. */
  114217. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  114218. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  114219. /**
  114220. * Default behaviour for cors in the application.
  114221. * It can be a string if the expected behavior is identical in the entire app.
  114222. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  114223. */
  114224. static get CorsBehavior(): string | ((url: string | string[]) => string);
  114225. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  114226. /**
  114227. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114228. * @ignorenaming
  114229. */
  114230. static get UseFallbackTexture(): boolean;
  114231. static set UseFallbackTexture(value: boolean);
  114232. /**
  114233. * Use this object to register external classes like custom textures or material
  114234. * to allow the laoders to instantiate them
  114235. */
  114236. static get RegisteredExternalClasses(): {
  114237. [key: string]: Object;
  114238. };
  114239. static set RegisteredExternalClasses(classes: {
  114240. [key: string]: Object;
  114241. });
  114242. /**
  114243. * Texture content used if a texture cannot loaded
  114244. * @ignorenaming
  114245. */
  114246. static get fallbackTexture(): string;
  114247. static set fallbackTexture(value: string);
  114248. /**
  114249. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  114250. * @param u defines the coordinate on X axis
  114251. * @param v defines the coordinate on Y axis
  114252. * @param width defines the width of the source data
  114253. * @param height defines the height of the source data
  114254. * @param pixels defines the source byte array
  114255. * @param color defines the output color
  114256. */
  114257. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  114258. /**
  114259. * Interpolates between a and b via alpha
  114260. * @param a The lower value (returned when alpha = 0)
  114261. * @param b The upper value (returned when alpha = 1)
  114262. * @param alpha The interpolation-factor
  114263. * @return The mixed value
  114264. */
  114265. static Mix(a: number, b: number, alpha: number): number;
  114266. /**
  114267. * Tries to instantiate a new object from a given class name
  114268. * @param className defines the class name to instantiate
  114269. * @returns the new object or null if the system was not able to do the instantiation
  114270. */
  114271. static Instantiate(className: string): any;
  114272. /**
  114273. * Provides a slice function that will work even on IE
  114274. * @param data defines the array to slice
  114275. * @param start defines the start of the data (optional)
  114276. * @param end defines the end of the data (optional)
  114277. * @returns the new sliced array
  114278. */
  114279. static Slice<T>(data: T, start?: number, end?: number): T;
  114280. /**
  114281. * Polyfill for setImmediate
  114282. * @param action defines the action to execute after the current execution block
  114283. */
  114284. static SetImmediate(action: () => void): void;
  114285. /**
  114286. * Function indicating if a number is an exponent of 2
  114287. * @param value defines the value to test
  114288. * @returns true if the value is an exponent of 2
  114289. */
  114290. static IsExponentOfTwo(value: number): boolean;
  114291. private static _tmpFloatArray;
  114292. /**
  114293. * Returns the nearest 32-bit single precision float representation of a Number
  114294. * @param value A Number. If the parameter is of a different type, it will get converted
  114295. * to a number or to NaN if it cannot be converted
  114296. * @returns number
  114297. */
  114298. static FloatRound(value: number): number;
  114299. /**
  114300. * Extracts the filename from a path
  114301. * @param path defines the path to use
  114302. * @returns the filename
  114303. */
  114304. static GetFilename(path: string): string;
  114305. /**
  114306. * Extracts the "folder" part of a path (everything before the filename).
  114307. * @param uri The URI to extract the info from
  114308. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  114309. * @returns The "folder" part of the path
  114310. */
  114311. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  114312. /**
  114313. * Extracts text content from a DOM element hierarchy
  114314. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  114315. */
  114316. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  114317. /**
  114318. * Convert an angle in radians to degrees
  114319. * @param angle defines the angle to convert
  114320. * @returns the angle in degrees
  114321. */
  114322. static ToDegrees(angle: number): number;
  114323. /**
  114324. * Convert an angle in degrees to radians
  114325. * @param angle defines the angle to convert
  114326. * @returns the angle in radians
  114327. */
  114328. static ToRadians(angle: number): number;
  114329. /**
  114330. * Returns an array if obj is not an array
  114331. * @param obj defines the object to evaluate as an array
  114332. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  114333. * @returns either obj directly if obj is an array or a new array containing obj
  114334. */
  114335. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  114336. /**
  114337. * Gets the pointer prefix to use
  114338. * @param engine defines the engine we are finding the prefix for
  114339. * @returns "pointer" if touch is enabled. Else returns "mouse"
  114340. */
  114341. static GetPointerPrefix(engine: Engine): string;
  114342. /**
  114343. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  114344. * @param url define the url we are trying
  114345. * @param element define the dom element where to configure the cors policy
  114346. */
  114347. static SetCorsBehavior(url: string | string[], element: {
  114348. crossOrigin: string | null;
  114349. }): void;
  114350. /**
  114351. * Removes unwanted characters from an url
  114352. * @param url defines the url to clean
  114353. * @returns the cleaned url
  114354. */
  114355. static CleanUrl(url: string): string;
  114356. /**
  114357. * Gets or sets a function used to pre-process url before using them to load assets
  114358. */
  114359. static get PreprocessUrl(): (url: string) => string;
  114360. static set PreprocessUrl(processor: (url: string) => string);
  114361. /**
  114362. * Loads an image as an HTMLImageElement.
  114363. * @param input url string, ArrayBuffer, or Blob to load
  114364. * @param onLoad callback called when the image successfully loads
  114365. * @param onError callback called when the image fails to load
  114366. * @param offlineProvider offline provider for caching
  114367. * @param mimeType optional mime type
  114368. * @returns the HTMLImageElement of the loaded image
  114369. */
  114370. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  114371. /**
  114372. * Loads a file from a url
  114373. * @param url url string, ArrayBuffer, or Blob to load
  114374. * @param onSuccess callback called when the file successfully loads
  114375. * @param onProgress callback called while file is loading (if the server supports this mode)
  114376. * @param offlineProvider defines the offline provider for caching
  114377. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114378. * @param onError callback called when the file fails to load
  114379. * @returns a file request object
  114380. */
  114381. 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;
  114382. /**
  114383. * Loads a file from a url
  114384. * @param url the file url to load
  114385. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114386. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  114387. */
  114388. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  114389. /**
  114390. * Load a script (identified by an url). When the url returns, the
  114391. * content of this file is added into a new script element, attached to the DOM (body element)
  114392. * @param scriptUrl defines the url of the script to laod
  114393. * @param onSuccess defines the callback called when the script is loaded
  114394. * @param onError defines the callback to call if an error occurs
  114395. * @param scriptId defines the id of the script element
  114396. */
  114397. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  114398. /**
  114399. * Load an asynchronous script (identified by an url). When the url returns, the
  114400. * content of this file is added into a new script element, attached to the DOM (body element)
  114401. * @param scriptUrl defines the url of the script to laod
  114402. * @param scriptId defines the id of the script element
  114403. * @returns a promise request object
  114404. */
  114405. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  114406. /**
  114407. * Loads a file from a blob
  114408. * @param fileToLoad defines the blob to use
  114409. * @param callback defines the callback to call when data is loaded
  114410. * @param progressCallback defines the callback to call during loading process
  114411. * @returns a file request object
  114412. */
  114413. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  114414. /**
  114415. * Reads a file from a File object
  114416. * @param file defines the file to load
  114417. * @param onSuccess defines the callback to call when data is loaded
  114418. * @param onProgress defines the callback to call during loading process
  114419. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  114420. * @param onError defines the callback to call when an error occurs
  114421. * @returns a file request object
  114422. */
  114423. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  114424. /**
  114425. * Creates a data url from a given string content
  114426. * @param content defines the content to convert
  114427. * @returns the new data url link
  114428. */
  114429. static FileAsURL(content: string): string;
  114430. /**
  114431. * Format the given number to a specific decimal format
  114432. * @param value defines the number to format
  114433. * @param decimals defines the number of decimals to use
  114434. * @returns the formatted string
  114435. */
  114436. static Format(value: number, decimals?: number): string;
  114437. /**
  114438. * Tries to copy an object by duplicating every property
  114439. * @param source defines the source object
  114440. * @param destination defines the target object
  114441. * @param doNotCopyList defines a list of properties to avoid
  114442. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  114443. */
  114444. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  114445. /**
  114446. * Gets a boolean indicating if the given object has no own property
  114447. * @param obj defines the object to test
  114448. * @returns true if object has no own property
  114449. */
  114450. static IsEmpty(obj: any): boolean;
  114451. /**
  114452. * Function used to register events at window level
  114453. * @param windowElement defines the Window object to use
  114454. * @param events defines the events to register
  114455. */
  114456. static RegisterTopRootEvents(windowElement: Window, events: {
  114457. name: string;
  114458. handler: Nullable<(e: FocusEvent) => any>;
  114459. }[]): void;
  114460. /**
  114461. * Function used to unregister events from window level
  114462. * @param windowElement defines the Window object to use
  114463. * @param events defines the events to unregister
  114464. */
  114465. static UnregisterTopRootEvents(windowElement: Window, events: {
  114466. name: string;
  114467. handler: Nullable<(e: FocusEvent) => any>;
  114468. }[]): void;
  114469. /**
  114470. * @ignore
  114471. */
  114472. static _ScreenshotCanvas: HTMLCanvasElement;
  114473. /**
  114474. * Dumps the current bound framebuffer
  114475. * @param width defines the rendering width
  114476. * @param height defines the rendering height
  114477. * @param engine defines the hosting engine
  114478. * @param successCallback defines the callback triggered once the data are available
  114479. * @param mimeType defines the mime type of the result
  114480. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  114481. */
  114482. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114483. /**
  114484. * Converts the canvas data to blob.
  114485. * This acts as a polyfill for browsers not supporting the to blob function.
  114486. * @param canvas Defines the canvas to extract the data from
  114487. * @param successCallback Defines the callback triggered once the data are available
  114488. * @param mimeType Defines the mime type of the result
  114489. */
  114490. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  114491. /**
  114492. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  114493. * @param successCallback defines the callback triggered once the data are available
  114494. * @param mimeType defines the mime type of the result
  114495. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  114496. */
  114497. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114498. /**
  114499. * Downloads a blob in the browser
  114500. * @param blob defines the blob to download
  114501. * @param fileName defines the name of the downloaded file
  114502. */
  114503. static Download(blob: Blob, fileName: string): void;
  114504. /**
  114505. * Captures a screenshot of the current rendering
  114506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114507. * @param engine defines the rendering engine
  114508. * @param camera defines the source camera
  114509. * @param size This parameter can be set to a single number or to an object with the
  114510. * following (optional) properties: precision, width, height. If a single number is passed,
  114511. * it will be used for both width and height. If an object is passed, the screenshot size
  114512. * will be derived from the parameters. The precision property is a multiplier allowing
  114513. * rendering at a higher or lower resolution
  114514. * @param successCallback defines the callback receives a single parameter which contains the
  114515. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114516. * src parameter of an <img> to display it
  114517. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114518. * Check your browser for supported MIME types
  114519. */
  114520. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  114521. /**
  114522. * Captures a screenshot of the current rendering
  114523. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114524. * @param engine defines the rendering engine
  114525. * @param camera defines the source camera
  114526. * @param size This parameter can be set to a single number or to an object with the
  114527. * following (optional) properties: precision, width, height. If a single number is passed,
  114528. * it will be used for both width and height. If an object is passed, the screenshot size
  114529. * will be derived from the parameters. The precision property is a multiplier allowing
  114530. * rendering at a higher or lower resolution
  114531. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114532. * Check your browser for supported MIME types
  114533. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114534. * to the src parameter of an <img> to display it
  114535. */
  114536. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  114537. /**
  114538. * Generates an image screenshot from the specified camera.
  114539. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114540. * @param engine The engine to use for rendering
  114541. * @param camera The camera to use for rendering
  114542. * @param size This parameter can be set to a single number or to an object with the
  114543. * following (optional) properties: precision, width, height. If a single number is passed,
  114544. * it will be used for both width and height. If an object is passed, the screenshot size
  114545. * will be derived from the parameters. The precision property is a multiplier allowing
  114546. * rendering at a higher or lower resolution
  114547. * @param successCallback The callback receives a single parameter which contains the
  114548. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114549. * src parameter of an <img> to display it
  114550. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114551. * Check your browser for supported MIME types
  114552. * @param samples Texture samples (default: 1)
  114553. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114554. * @param fileName A name for for the downloaded file.
  114555. */
  114556. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  114557. /**
  114558. * Generates an image screenshot from the specified camera.
  114559. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114560. * @param engine The engine to use for rendering
  114561. * @param camera The camera to use for rendering
  114562. * @param size This parameter can be set to a single number or to an object with the
  114563. * following (optional) properties: precision, width, height. If a single number is passed,
  114564. * it will be used for both width and height. If an object is passed, the screenshot size
  114565. * will be derived from the parameters. The precision property is a multiplier allowing
  114566. * rendering at a higher or lower resolution
  114567. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114568. * Check your browser for supported MIME types
  114569. * @param samples Texture samples (default: 1)
  114570. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114571. * @param fileName A name for for the downloaded file.
  114572. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114573. * to the src parameter of an <img> to display it
  114574. */
  114575. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  114576. /**
  114577. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  114578. * Be aware Math.random() could cause collisions, but:
  114579. * "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"
  114580. * @returns a pseudo random id
  114581. */
  114582. static RandomId(): string;
  114583. /**
  114584. * Test if the given uri is a base64 string
  114585. * @param uri The uri to test
  114586. * @return True if the uri is a base64 string or false otherwise
  114587. */
  114588. static IsBase64(uri: string): boolean;
  114589. /**
  114590. * Decode the given base64 uri.
  114591. * @param uri The uri to decode
  114592. * @return The decoded base64 data.
  114593. */
  114594. static DecodeBase64(uri: string): ArrayBuffer;
  114595. /**
  114596. * Gets the absolute url.
  114597. * @param url the input url
  114598. * @return the absolute url
  114599. */
  114600. static GetAbsoluteUrl(url: string): string;
  114601. /**
  114602. * No log
  114603. */
  114604. static readonly NoneLogLevel: number;
  114605. /**
  114606. * Only message logs
  114607. */
  114608. static readonly MessageLogLevel: number;
  114609. /**
  114610. * Only warning logs
  114611. */
  114612. static readonly WarningLogLevel: number;
  114613. /**
  114614. * Only error logs
  114615. */
  114616. static readonly ErrorLogLevel: number;
  114617. /**
  114618. * All logs
  114619. */
  114620. static readonly AllLogLevel: number;
  114621. /**
  114622. * Gets a value indicating the number of loading errors
  114623. * @ignorenaming
  114624. */
  114625. static get errorsCount(): number;
  114626. /**
  114627. * Callback called when a new log is added
  114628. */
  114629. static OnNewCacheEntry: (entry: string) => void;
  114630. /**
  114631. * Log a message to the console
  114632. * @param message defines the message to log
  114633. */
  114634. static Log(message: string): void;
  114635. /**
  114636. * Write a warning message to the console
  114637. * @param message defines the message to log
  114638. */
  114639. static Warn(message: string): void;
  114640. /**
  114641. * Write an error message to the console
  114642. * @param message defines the message to log
  114643. */
  114644. static Error(message: string): void;
  114645. /**
  114646. * Gets current log cache (list of logs)
  114647. */
  114648. static get LogCache(): string;
  114649. /**
  114650. * Clears the log cache
  114651. */
  114652. static ClearLogCache(): void;
  114653. /**
  114654. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  114655. */
  114656. static set LogLevels(level: number);
  114657. /**
  114658. * Checks if the window object exists
  114659. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  114660. */
  114661. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  114662. /**
  114663. * No performance log
  114664. */
  114665. static readonly PerformanceNoneLogLevel: number;
  114666. /**
  114667. * Use user marks to log performance
  114668. */
  114669. static readonly PerformanceUserMarkLogLevel: number;
  114670. /**
  114671. * Log performance to the console
  114672. */
  114673. static readonly PerformanceConsoleLogLevel: number;
  114674. private static _performance;
  114675. /**
  114676. * Sets the current performance log level
  114677. */
  114678. static set PerformanceLogLevel(level: number);
  114679. private static _StartPerformanceCounterDisabled;
  114680. private static _EndPerformanceCounterDisabled;
  114681. private static _StartUserMark;
  114682. private static _EndUserMark;
  114683. private static _StartPerformanceConsole;
  114684. private static _EndPerformanceConsole;
  114685. /**
  114686. * Starts a performance counter
  114687. */
  114688. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114689. /**
  114690. * Ends a specific performance coutner
  114691. */
  114692. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114693. /**
  114694. * Gets either window.performance.now() if supported or Date.now() else
  114695. */
  114696. static get Now(): number;
  114697. /**
  114698. * This method will return the name of the class used to create the instance of the given object.
  114699. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  114700. * @param object the object to get the class name from
  114701. * @param isType defines if the object is actually a type
  114702. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  114703. */
  114704. static GetClassName(object: any, isType?: boolean): string;
  114705. /**
  114706. * Gets the first element of an array satisfying a given predicate
  114707. * @param array defines the array to browse
  114708. * @param predicate defines the predicate to use
  114709. * @returns null if not found or the element
  114710. */
  114711. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  114712. /**
  114713. * This method will return the name of the full name of the class, including its owning module (if any).
  114714. * 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).
  114715. * @param object the object to get the class name from
  114716. * @param isType defines if the object is actually a type
  114717. * @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.
  114718. * @ignorenaming
  114719. */
  114720. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  114721. /**
  114722. * Returns a promise that resolves after the given amount of time.
  114723. * @param delay Number of milliseconds to delay
  114724. * @returns Promise that resolves after the given amount of time
  114725. */
  114726. static DelayAsync(delay: number): Promise<void>;
  114727. /**
  114728. * Utility function to detect if the current user agent is Safari
  114729. * @returns whether or not the current user agent is safari
  114730. */
  114731. static IsSafari(): boolean;
  114732. }
  114733. /**
  114734. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  114735. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  114736. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  114737. * @param name The name of the class, case should be preserved
  114738. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  114739. */
  114740. export function className(name: string, module?: string): (target: Object) => void;
  114741. /**
  114742. * An implementation of a loop for asynchronous functions.
  114743. */
  114744. export class AsyncLoop {
  114745. /**
  114746. * Defines the number of iterations for the loop
  114747. */
  114748. iterations: number;
  114749. /**
  114750. * Defines the current index of the loop.
  114751. */
  114752. index: number;
  114753. private _done;
  114754. private _fn;
  114755. private _successCallback;
  114756. /**
  114757. * Constructor.
  114758. * @param iterations the number of iterations.
  114759. * @param func the function to run each iteration
  114760. * @param successCallback the callback that will be called upon succesful execution
  114761. * @param offset starting offset.
  114762. */
  114763. constructor(
  114764. /**
  114765. * Defines the number of iterations for the loop
  114766. */
  114767. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  114768. /**
  114769. * Execute the next iteration. Must be called after the last iteration was finished.
  114770. */
  114771. executeNext(): void;
  114772. /**
  114773. * Break the loop and run the success callback.
  114774. */
  114775. breakLoop(): void;
  114776. /**
  114777. * Create and run an async loop.
  114778. * @param iterations the number of iterations.
  114779. * @param fn the function to run each iteration
  114780. * @param successCallback the callback that will be called upon succesful execution
  114781. * @param offset starting offset.
  114782. * @returns the created async loop object
  114783. */
  114784. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  114785. /**
  114786. * A for-loop that will run a given number of iterations synchronous and the rest async.
  114787. * @param iterations total number of iterations
  114788. * @param syncedIterations number of synchronous iterations in each async iteration.
  114789. * @param fn the function to call each iteration.
  114790. * @param callback a success call back that will be called when iterating stops.
  114791. * @param breakFunction a break condition (optional)
  114792. * @param timeout timeout settings for the setTimeout function. default - 0.
  114793. * @returns the created async loop object
  114794. */
  114795. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  114796. }
  114797. }
  114798. declare module BABYLON {
  114799. /**
  114800. * This class implement a typical dictionary using a string as key and the generic type T as value.
  114801. * The underlying implementation relies on an associative array to ensure the best performances.
  114802. * The value can be anything including 'null' but except 'undefined'
  114803. */
  114804. export class StringDictionary<T> {
  114805. /**
  114806. * This will clear this dictionary and copy the content from the 'source' one.
  114807. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  114808. * @param source the dictionary to take the content from and copy to this dictionary
  114809. */
  114810. copyFrom(source: StringDictionary<T>): void;
  114811. /**
  114812. * Get a value based from its key
  114813. * @param key the given key to get the matching value from
  114814. * @return the value if found, otherwise undefined is returned
  114815. */
  114816. get(key: string): T | undefined;
  114817. /**
  114818. * Get a value from its key or add it if it doesn't exist.
  114819. * This method will ensure you that a given key/data will be present in the dictionary.
  114820. * @param key the given key to get the matching value from
  114821. * @param factory the factory that will create the value if the key is not present in the dictionary.
  114822. * The factory will only be invoked if there's no data for the given key.
  114823. * @return the value corresponding to the key.
  114824. */
  114825. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  114826. /**
  114827. * Get a value from its key if present in the dictionary otherwise add it
  114828. * @param key the key to get the value from
  114829. * @param val if there's no such key/value pair in the dictionary add it with this value
  114830. * @return the value corresponding to the key
  114831. */
  114832. getOrAdd(key: string, val: T): T;
  114833. /**
  114834. * Check if there's a given key in the dictionary
  114835. * @param key the key to check for
  114836. * @return true if the key is present, false otherwise
  114837. */
  114838. contains(key: string): boolean;
  114839. /**
  114840. * Add a new key and its corresponding value
  114841. * @param key the key to add
  114842. * @param value the value corresponding to the key
  114843. * @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
  114844. */
  114845. add(key: string, value: T): boolean;
  114846. /**
  114847. * Update a specific value associated to a key
  114848. * @param key defines the key to use
  114849. * @param value defines the value to store
  114850. * @returns true if the value was updated (or false if the key was not found)
  114851. */
  114852. set(key: string, value: T): boolean;
  114853. /**
  114854. * Get the element of the given key and remove it from the dictionary
  114855. * @param key defines the key to search
  114856. * @returns the value associated with the key or null if not found
  114857. */
  114858. getAndRemove(key: string): Nullable<T>;
  114859. /**
  114860. * Remove a key/value from the dictionary.
  114861. * @param key the key to remove
  114862. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  114863. */
  114864. remove(key: string): boolean;
  114865. /**
  114866. * Clear the whole content of the dictionary
  114867. */
  114868. clear(): void;
  114869. /**
  114870. * Gets the current count
  114871. */
  114872. get count(): number;
  114873. /**
  114874. * Execute a callback on each key/val of the dictionary.
  114875. * Note that you can remove any element in this dictionary in the callback implementation
  114876. * @param callback the callback to execute on a given key/value pair
  114877. */
  114878. forEach(callback: (key: string, val: T) => void): void;
  114879. /**
  114880. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  114881. * If the callback returns null or undefined the method will iterate to the next key/value pair
  114882. * Note that you can remove any element in this dictionary in the callback implementation
  114883. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  114884. * @returns the first item
  114885. */
  114886. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  114887. private _count;
  114888. private _data;
  114889. }
  114890. }
  114891. declare module BABYLON {
  114892. /** @hidden */
  114893. export interface ICollisionCoordinator {
  114894. createCollider(): Collider;
  114895. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  114896. init(scene: Scene): void;
  114897. }
  114898. /** @hidden */
  114899. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  114900. private _scene;
  114901. private _scaledPosition;
  114902. private _scaledVelocity;
  114903. private _finalPosition;
  114904. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  114905. createCollider(): Collider;
  114906. init(scene: Scene): void;
  114907. private _collideWithWorld;
  114908. }
  114909. }
  114910. declare module BABYLON {
  114911. /**
  114912. * Class used to manage all inputs for the scene.
  114913. */
  114914. export class InputManager {
  114915. /** The distance in pixel that you have to move to prevent some events */
  114916. static DragMovementThreshold: number;
  114917. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  114918. static LongPressDelay: number;
  114919. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  114920. static DoubleClickDelay: number;
  114921. /** If you need to check double click without raising a single click at first click, enable this flag */
  114922. static ExclusiveDoubleClickMode: boolean;
  114923. private _wheelEventName;
  114924. private _onPointerMove;
  114925. private _onPointerDown;
  114926. private _onPointerUp;
  114927. private _initClickEvent;
  114928. private _initActionManager;
  114929. private _delayedSimpleClick;
  114930. private _delayedSimpleClickTimeout;
  114931. private _previousDelayedSimpleClickTimeout;
  114932. private _meshPickProceed;
  114933. private _previousButtonPressed;
  114934. private _currentPickResult;
  114935. private _previousPickResult;
  114936. private _totalPointersPressed;
  114937. private _doubleClickOccured;
  114938. private _pointerOverMesh;
  114939. private _pickedDownMesh;
  114940. private _pickedUpMesh;
  114941. private _pointerX;
  114942. private _pointerY;
  114943. private _unTranslatedPointerX;
  114944. private _unTranslatedPointerY;
  114945. private _startingPointerPosition;
  114946. private _previousStartingPointerPosition;
  114947. private _startingPointerTime;
  114948. private _previousStartingPointerTime;
  114949. private _pointerCaptures;
  114950. private _onKeyDown;
  114951. private _onKeyUp;
  114952. private _onCanvasFocusObserver;
  114953. private _onCanvasBlurObserver;
  114954. private _scene;
  114955. /**
  114956. * Creates a new InputManager
  114957. * @param scene defines the hosting scene
  114958. */
  114959. constructor(scene: Scene);
  114960. /**
  114961. * Gets the mesh that is currently under the pointer
  114962. */
  114963. get meshUnderPointer(): Nullable<AbstractMesh>;
  114964. /**
  114965. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  114966. */
  114967. get unTranslatedPointer(): Vector2;
  114968. /**
  114969. * Gets or sets the current on-screen X position of the pointer
  114970. */
  114971. get pointerX(): number;
  114972. set pointerX(value: number);
  114973. /**
  114974. * Gets or sets the current on-screen Y position of the pointer
  114975. */
  114976. get pointerY(): number;
  114977. set pointerY(value: number);
  114978. private _updatePointerPosition;
  114979. private _processPointerMove;
  114980. private _setRayOnPointerInfo;
  114981. private _checkPrePointerObservable;
  114982. /**
  114983. * Use this method to simulate a pointer move on a mesh
  114984. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  114985. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  114986. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  114987. */
  114988. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  114989. /**
  114990. * Use this method to simulate a pointer down on a mesh
  114991. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  114992. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  114993. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  114994. */
  114995. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  114996. private _processPointerDown;
  114997. /** @hidden */
  114998. _isPointerSwiping(): boolean;
  114999. /**
  115000. * Use this method to simulate a pointer up on a mesh
  115001. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115002. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115003. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115004. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  115005. */
  115006. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  115007. private _processPointerUp;
  115008. /**
  115009. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  115010. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  115011. * @returns true if the pointer was captured
  115012. */
  115013. isPointerCaptured(pointerId?: number): boolean;
  115014. /**
  115015. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  115016. * @param attachUp defines if you want to attach events to pointerup
  115017. * @param attachDown defines if you want to attach events to pointerdown
  115018. * @param attachMove defines if you want to attach events to pointermove
  115019. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  115020. */
  115021. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  115022. /**
  115023. * Detaches all event handlers
  115024. */
  115025. detachControl(): void;
  115026. /**
  115027. * Force the value of meshUnderPointer
  115028. * @param mesh defines the mesh to use
  115029. */
  115030. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  115031. /**
  115032. * Gets the mesh under the pointer
  115033. * @returns a Mesh or null if no mesh is under the pointer
  115034. */
  115035. getPointerOverMesh(): Nullable<AbstractMesh>;
  115036. }
  115037. }
  115038. declare module BABYLON {
  115039. /**
  115040. * This class defines the direct association between an animation and a target
  115041. */
  115042. export class TargetedAnimation {
  115043. /**
  115044. * Animation to perform
  115045. */
  115046. animation: Animation;
  115047. /**
  115048. * Target to animate
  115049. */
  115050. target: any;
  115051. /**
  115052. * Serialize the object
  115053. * @returns the JSON object representing the current entity
  115054. */
  115055. serialize(): any;
  115056. }
  115057. /**
  115058. * Use this class to create coordinated animations on multiple targets
  115059. */
  115060. export class AnimationGroup implements IDisposable {
  115061. /** The name of the animation group */
  115062. name: string;
  115063. private _scene;
  115064. private _targetedAnimations;
  115065. private _animatables;
  115066. private _from;
  115067. private _to;
  115068. private _isStarted;
  115069. private _isPaused;
  115070. private _speedRatio;
  115071. private _loopAnimation;
  115072. private _isAdditive;
  115073. /**
  115074. * Gets or sets the unique id of the node
  115075. */
  115076. uniqueId: number;
  115077. /**
  115078. * This observable will notify when one animation have ended
  115079. */
  115080. onAnimationEndObservable: Observable<TargetedAnimation>;
  115081. /**
  115082. * Observer raised when one animation loops
  115083. */
  115084. onAnimationLoopObservable: Observable<TargetedAnimation>;
  115085. /**
  115086. * Observer raised when all animations have looped
  115087. */
  115088. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  115089. /**
  115090. * This observable will notify when all animations have ended.
  115091. */
  115092. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  115093. /**
  115094. * This observable will notify when all animations have paused.
  115095. */
  115096. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  115097. /**
  115098. * This observable will notify when all animations are playing.
  115099. */
  115100. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  115101. /**
  115102. * Gets the first frame
  115103. */
  115104. get from(): number;
  115105. /**
  115106. * Gets the last frame
  115107. */
  115108. get to(): number;
  115109. /**
  115110. * Define if the animations are started
  115111. */
  115112. get isStarted(): boolean;
  115113. /**
  115114. * Gets a value indicating that the current group is playing
  115115. */
  115116. get isPlaying(): boolean;
  115117. /**
  115118. * Gets or sets the speed ratio to use for all animations
  115119. */
  115120. get speedRatio(): number;
  115121. /**
  115122. * Gets or sets the speed ratio to use for all animations
  115123. */
  115124. set speedRatio(value: number);
  115125. /**
  115126. * Gets or sets if all animations should loop or not
  115127. */
  115128. get loopAnimation(): boolean;
  115129. set loopAnimation(value: boolean);
  115130. /**
  115131. * Gets or sets if all animations should be evaluated additively
  115132. */
  115133. get isAdditive(): boolean;
  115134. set isAdditive(value: boolean);
  115135. /**
  115136. * Gets the targeted animations for this animation group
  115137. */
  115138. get targetedAnimations(): Array<TargetedAnimation>;
  115139. /**
  115140. * returning the list of animatables controlled by this animation group.
  115141. */
  115142. get animatables(): Array<Animatable>;
  115143. /**
  115144. * Instantiates a new Animation Group.
  115145. * This helps managing several animations at once.
  115146. * @see http://doc.babylonjs.com/how_to/group
  115147. * @param name Defines the name of the group
  115148. * @param scene Defines the scene the group belongs to
  115149. */
  115150. constructor(
  115151. /** The name of the animation group */
  115152. name: string, scene?: Nullable<Scene>);
  115153. /**
  115154. * Add an animation (with its target) in the group
  115155. * @param animation defines the animation we want to add
  115156. * @param target defines the target of the animation
  115157. * @returns the TargetedAnimation object
  115158. */
  115159. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  115160. /**
  115161. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  115162. * It can add constant keys at begin or end
  115163. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  115164. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  115165. * @returns the animation group
  115166. */
  115167. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  115168. private _animationLoopCount;
  115169. private _animationLoopFlags;
  115170. private _processLoop;
  115171. /**
  115172. * Start all animations on given targets
  115173. * @param loop defines if animations must loop
  115174. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  115175. * @param from defines the from key (optional)
  115176. * @param to defines the to key (optional)
  115177. * @param isAdditive defines the additive state for the resulting animatables (optional)
  115178. * @returns the current animation group
  115179. */
  115180. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  115181. /**
  115182. * Pause all animations
  115183. * @returns the animation group
  115184. */
  115185. pause(): AnimationGroup;
  115186. /**
  115187. * Play all animations to initial state
  115188. * This function will start() the animations if they were not started or will restart() them if they were paused
  115189. * @param loop defines if animations must loop
  115190. * @returns the animation group
  115191. */
  115192. play(loop?: boolean): AnimationGroup;
  115193. /**
  115194. * Reset all animations to initial state
  115195. * @returns the animation group
  115196. */
  115197. reset(): AnimationGroup;
  115198. /**
  115199. * Restart animations from key 0
  115200. * @returns the animation group
  115201. */
  115202. restart(): AnimationGroup;
  115203. /**
  115204. * Stop all animations
  115205. * @returns the animation group
  115206. */
  115207. stop(): AnimationGroup;
  115208. /**
  115209. * Set animation weight for all animatables
  115210. * @param weight defines the weight to use
  115211. * @return the animationGroup
  115212. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115213. */
  115214. setWeightForAllAnimatables(weight: number): AnimationGroup;
  115215. /**
  115216. * Synchronize and normalize all animatables with a source animatable
  115217. * @param root defines the root animatable to synchronize with
  115218. * @return the animationGroup
  115219. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115220. */
  115221. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  115222. /**
  115223. * Goes to a specific frame in this animation group
  115224. * @param frame the frame number to go to
  115225. * @return the animationGroup
  115226. */
  115227. goToFrame(frame: number): AnimationGroup;
  115228. /**
  115229. * Dispose all associated resources
  115230. */
  115231. dispose(): void;
  115232. private _checkAnimationGroupEnded;
  115233. /**
  115234. * Clone the current animation group and returns a copy
  115235. * @param newName defines the name of the new group
  115236. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  115237. * @returns the new aniamtion group
  115238. */
  115239. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  115240. /**
  115241. * Serializes the animationGroup to an object
  115242. * @returns Serialized object
  115243. */
  115244. serialize(): any;
  115245. /**
  115246. * Returns a new AnimationGroup object parsed from the source provided.
  115247. * @param parsedAnimationGroup defines the source
  115248. * @param scene defines the scene that will receive the animationGroup
  115249. * @returns a new AnimationGroup
  115250. */
  115251. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  115252. /**
  115253. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  115254. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  115255. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  115256. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  115257. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  115258. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  115259. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  115260. */
  115261. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  115262. /**
  115263. * Returns the string "AnimationGroup"
  115264. * @returns "AnimationGroup"
  115265. */
  115266. getClassName(): string;
  115267. /**
  115268. * Creates a detailled string about the object
  115269. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  115270. * @returns a string representing the object
  115271. */
  115272. toString(fullDetails?: boolean): string;
  115273. }
  115274. }
  115275. declare module BABYLON {
  115276. /**
  115277. * Define an interface for all classes that will hold resources
  115278. */
  115279. export interface IDisposable {
  115280. /**
  115281. * Releases all held resources
  115282. */
  115283. dispose(): void;
  115284. }
  115285. /** Interface defining initialization parameters for Scene class */
  115286. export interface SceneOptions {
  115287. /**
  115288. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  115289. * It will improve performance when the number of geometries becomes important.
  115290. */
  115291. useGeometryUniqueIdsMap?: boolean;
  115292. /**
  115293. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  115294. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115295. */
  115296. useMaterialMeshMap?: boolean;
  115297. /**
  115298. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  115299. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115300. */
  115301. useClonedMeshMap?: boolean;
  115302. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  115303. virtual?: boolean;
  115304. }
  115305. /**
  115306. * Represents a scene to be rendered by the engine.
  115307. * @see http://doc.babylonjs.com/features/scene
  115308. */
  115309. export class Scene extends AbstractScene implements IAnimatable {
  115310. /** The fog is deactivated */
  115311. static readonly FOGMODE_NONE: number;
  115312. /** The fog density is following an exponential function */
  115313. static readonly FOGMODE_EXP: number;
  115314. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  115315. static readonly FOGMODE_EXP2: number;
  115316. /** The fog density is following a linear function. */
  115317. static readonly FOGMODE_LINEAR: number;
  115318. /**
  115319. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  115320. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115321. */
  115322. static MinDeltaTime: number;
  115323. /**
  115324. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  115325. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115326. */
  115327. static MaxDeltaTime: number;
  115328. /**
  115329. * Factory used to create the default material.
  115330. * @param name The name of the material to create
  115331. * @param scene The scene to create the material for
  115332. * @returns The default material
  115333. */
  115334. static DefaultMaterialFactory(scene: Scene): Material;
  115335. /**
  115336. * Factory used to create the a collision coordinator.
  115337. * @returns The collision coordinator
  115338. */
  115339. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  115340. /** @hidden */
  115341. _inputManager: InputManager;
  115342. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  115343. cameraToUseForPointers: Nullable<Camera>;
  115344. /** @hidden */
  115345. readonly _isScene: boolean;
  115346. /** @hidden */
  115347. _blockEntityCollection: boolean;
  115348. /**
  115349. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  115350. */
  115351. autoClear: boolean;
  115352. /**
  115353. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  115354. */
  115355. autoClearDepthAndStencil: boolean;
  115356. /**
  115357. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  115358. */
  115359. clearColor: Color4;
  115360. /**
  115361. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  115362. */
  115363. ambientColor: Color3;
  115364. /**
  115365. * This is use to store the default BRDF lookup for PBR materials in your scene.
  115366. * It should only be one of the following (if not the default embedded one):
  115367. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115368. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  115369. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115370. * The material properties need to be setup according to the type of texture in use.
  115371. */
  115372. environmentBRDFTexture: BaseTexture;
  115373. /** @hidden */
  115374. protected _environmentTexture: Nullable<BaseTexture>;
  115375. /**
  115376. * Texture used in all pbr material as the reflection texture.
  115377. * As in the majority of the scene they are the same (exception for multi room and so on),
  115378. * this is easier to reference from here than from all the materials.
  115379. */
  115380. get environmentTexture(): Nullable<BaseTexture>;
  115381. /**
  115382. * Texture used in all pbr material as the reflection texture.
  115383. * As in the majority of the scene they are the same (exception for multi room and so on),
  115384. * this is easier to set here than in all the materials.
  115385. */
  115386. set environmentTexture(value: Nullable<BaseTexture>);
  115387. /** @hidden */
  115388. protected _environmentIntensity: number;
  115389. /**
  115390. * Intensity of the environment in all pbr material.
  115391. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115392. * As in the majority of the scene they are the same (exception for multi room and so on),
  115393. * this is easier to reference from here than from all the materials.
  115394. */
  115395. get environmentIntensity(): number;
  115396. /**
  115397. * Intensity of the environment in all pbr material.
  115398. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115399. * As in the majority of the scene they are the same (exception for multi room and so on),
  115400. * this is easier to set here than in all the materials.
  115401. */
  115402. set environmentIntensity(value: number);
  115403. /** @hidden */
  115404. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115405. /**
  115406. * Default image processing configuration used either in the rendering
  115407. * Forward main pass or through the imageProcessingPostProcess if present.
  115408. * As in the majority of the scene they are the same (exception for multi camera),
  115409. * this is easier to reference from here than from all the materials and post process.
  115410. *
  115411. * No setter as we it is a shared configuration, you can set the values instead.
  115412. */
  115413. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115414. private _forceWireframe;
  115415. /**
  115416. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  115417. */
  115418. set forceWireframe(value: boolean);
  115419. get forceWireframe(): boolean;
  115420. private _skipFrustumClipping;
  115421. /**
  115422. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  115423. */
  115424. set skipFrustumClipping(value: boolean);
  115425. get skipFrustumClipping(): boolean;
  115426. private _forcePointsCloud;
  115427. /**
  115428. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  115429. */
  115430. set forcePointsCloud(value: boolean);
  115431. get forcePointsCloud(): boolean;
  115432. /**
  115433. * Gets or sets the active clipplane 1
  115434. */
  115435. clipPlane: Nullable<Plane>;
  115436. /**
  115437. * Gets or sets the active clipplane 2
  115438. */
  115439. clipPlane2: Nullable<Plane>;
  115440. /**
  115441. * Gets or sets the active clipplane 3
  115442. */
  115443. clipPlane3: Nullable<Plane>;
  115444. /**
  115445. * Gets or sets the active clipplane 4
  115446. */
  115447. clipPlane4: Nullable<Plane>;
  115448. /**
  115449. * Gets or sets the active clipplane 5
  115450. */
  115451. clipPlane5: Nullable<Plane>;
  115452. /**
  115453. * Gets or sets the active clipplane 6
  115454. */
  115455. clipPlane6: Nullable<Plane>;
  115456. /**
  115457. * Gets or sets a boolean indicating if animations are enabled
  115458. */
  115459. animationsEnabled: boolean;
  115460. private _animationPropertiesOverride;
  115461. /**
  115462. * Gets or sets the animation properties override
  115463. */
  115464. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  115465. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  115466. /**
  115467. * Gets or sets a boolean indicating if a constant deltatime has to be used
  115468. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  115469. */
  115470. useConstantAnimationDeltaTime: boolean;
  115471. /**
  115472. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  115473. * Please note that it requires to run a ray cast through the scene on every frame
  115474. */
  115475. constantlyUpdateMeshUnderPointer: boolean;
  115476. /**
  115477. * Defines the HTML cursor to use when hovering over interactive elements
  115478. */
  115479. hoverCursor: string;
  115480. /**
  115481. * Defines the HTML default cursor to use (empty by default)
  115482. */
  115483. defaultCursor: string;
  115484. /**
  115485. * Defines whether cursors are handled by the scene.
  115486. */
  115487. doNotHandleCursors: boolean;
  115488. /**
  115489. * This is used to call preventDefault() on pointer down
  115490. * in order to block unwanted artifacts like system double clicks
  115491. */
  115492. preventDefaultOnPointerDown: boolean;
  115493. /**
  115494. * This is used to call preventDefault() on pointer up
  115495. * in order to block unwanted artifacts like system double clicks
  115496. */
  115497. preventDefaultOnPointerUp: boolean;
  115498. /**
  115499. * Gets or sets user defined metadata
  115500. */
  115501. metadata: any;
  115502. /**
  115503. * For internal use only. Please do not use.
  115504. */
  115505. reservedDataStore: any;
  115506. /**
  115507. * Gets the name of the plugin used to load this scene (null by default)
  115508. */
  115509. loadingPluginName: string;
  115510. /**
  115511. * Use this array to add regular expressions used to disable offline support for specific urls
  115512. */
  115513. disableOfflineSupportExceptionRules: RegExp[];
  115514. /**
  115515. * An event triggered when the scene is disposed.
  115516. */
  115517. onDisposeObservable: Observable<Scene>;
  115518. private _onDisposeObserver;
  115519. /** Sets a function to be executed when this scene is disposed. */
  115520. set onDispose(callback: () => void);
  115521. /**
  115522. * An event triggered before rendering the scene (right after animations and physics)
  115523. */
  115524. onBeforeRenderObservable: Observable<Scene>;
  115525. private _onBeforeRenderObserver;
  115526. /** Sets a function to be executed before rendering this scene */
  115527. set beforeRender(callback: Nullable<() => void>);
  115528. /**
  115529. * An event triggered after rendering the scene
  115530. */
  115531. onAfterRenderObservable: Observable<Scene>;
  115532. /**
  115533. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  115534. */
  115535. onAfterRenderCameraObservable: Observable<Camera>;
  115536. private _onAfterRenderObserver;
  115537. /** Sets a function to be executed after rendering this scene */
  115538. set afterRender(callback: Nullable<() => void>);
  115539. /**
  115540. * An event triggered before animating the scene
  115541. */
  115542. onBeforeAnimationsObservable: Observable<Scene>;
  115543. /**
  115544. * An event triggered after animations processing
  115545. */
  115546. onAfterAnimationsObservable: Observable<Scene>;
  115547. /**
  115548. * An event triggered before draw calls are ready to be sent
  115549. */
  115550. onBeforeDrawPhaseObservable: Observable<Scene>;
  115551. /**
  115552. * An event triggered after draw calls have been sent
  115553. */
  115554. onAfterDrawPhaseObservable: Observable<Scene>;
  115555. /**
  115556. * An event triggered when the scene is ready
  115557. */
  115558. onReadyObservable: Observable<Scene>;
  115559. /**
  115560. * An event triggered before rendering a camera
  115561. */
  115562. onBeforeCameraRenderObservable: Observable<Camera>;
  115563. private _onBeforeCameraRenderObserver;
  115564. /** Sets a function to be executed before rendering a camera*/
  115565. set beforeCameraRender(callback: () => void);
  115566. /**
  115567. * An event triggered after rendering a camera
  115568. */
  115569. onAfterCameraRenderObservable: Observable<Camera>;
  115570. private _onAfterCameraRenderObserver;
  115571. /** Sets a function to be executed after rendering a camera*/
  115572. set afterCameraRender(callback: () => void);
  115573. /**
  115574. * An event triggered when active meshes evaluation is about to start
  115575. */
  115576. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  115577. /**
  115578. * An event triggered when active meshes evaluation is done
  115579. */
  115580. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  115581. /**
  115582. * An event triggered when particles rendering is about to start
  115583. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115584. */
  115585. onBeforeParticlesRenderingObservable: Observable<Scene>;
  115586. /**
  115587. * An event triggered when particles rendering is done
  115588. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115589. */
  115590. onAfterParticlesRenderingObservable: Observable<Scene>;
  115591. /**
  115592. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  115593. */
  115594. onDataLoadedObservable: Observable<Scene>;
  115595. /**
  115596. * An event triggered when a camera is created
  115597. */
  115598. onNewCameraAddedObservable: Observable<Camera>;
  115599. /**
  115600. * An event triggered when a camera is removed
  115601. */
  115602. onCameraRemovedObservable: Observable<Camera>;
  115603. /**
  115604. * An event triggered when a light is created
  115605. */
  115606. onNewLightAddedObservable: Observable<Light>;
  115607. /**
  115608. * An event triggered when a light is removed
  115609. */
  115610. onLightRemovedObservable: Observable<Light>;
  115611. /**
  115612. * An event triggered when a geometry is created
  115613. */
  115614. onNewGeometryAddedObservable: Observable<Geometry>;
  115615. /**
  115616. * An event triggered when a geometry is removed
  115617. */
  115618. onGeometryRemovedObservable: Observable<Geometry>;
  115619. /**
  115620. * An event triggered when a transform node is created
  115621. */
  115622. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  115623. /**
  115624. * An event triggered when a transform node is removed
  115625. */
  115626. onTransformNodeRemovedObservable: Observable<TransformNode>;
  115627. /**
  115628. * An event triggered when a mesh is created
  115629. */
  115630. onNewMeshAddedObservable: Observable<AbstractMesh>;
  115631. /**
  115632. * An event triggered when a mesh is removed
  115633. */
  115634. onMeshRemovedObservable: Observable<AbstractMesh>;
  115635. /**
  115636. * An event triggered when a skeleton is created
  115637. */
  115638. onNewSkeletonAddedObservable: Observable<Skeleton>;
  115639. /**
  115640. * An event triggered when a skeleton is removed
  115641. */
  115642. onSkeletonRemovedObservable: Observable<Skeleton>;
  115643. /**
  115644. * An event triggered when a material is created
  115645. */
  115646. onNewMaterialAddedObservable: Observable<Material>;
  115647. /**
  115648. * An event triggered when a material is removed
  115649. */
  115650. onMaterialRemovedObservable: Observable<Material>;
  115651. /**
  115652. * An event triggered when a texture is created
  115653. */
  115654. onNewTextureAddedObservable: Observable<BaseTexture>;
  115655. /**
  115656. * An event triggered when a texture is removed
  115657. */
  115658. onTextureRemovedObservable: Observable<BaseTexture>;
  115659. /**
  115660. * An event triggered when render targets are about to be rendered
  115661. * Can happen multiple times per frame.
  115662. */
  115663. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  115664. /**
  115665. * An event triggered when render targets were rendered.
  115666. * Can happen multiple times per frame.
  115667. */
  115668. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  115669. /**
  115670. * An event triggered before calculating deterministic simulation step
  115671. */
  115672. onBeforeStepObservable: Observable<Scene>;
  115673. /**
  115674. * An event triggered after calculating deterministic simulation step
  115675. */
  115676. onAfterStepObservable: Observable<Scene>;
  115677. /**
  115678. * An event triggered when the activeCamera property is updated
  115679. */
  115680. onActiveCameraChanged: Observable<Scene>;
  115681. /**
  115682. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  115683. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115684. * 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)
  115685. */
  115686. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115687. /**
  115688. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  115689. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115690. * 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)
  115691. */
  115692. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115693. /**
  115694. * This Observable will when a mesh has been imported into the scene.
  115695. */
  115696. onMeshImportedObservable: Observable<AbstractMesh>;
  115697. /**
  115698. * This Observable will when an animation file has been imported into the scene.
  115699. */
  115700. onAnimationFileImportedObservable: Observable<Scene>;
  115701. /**
  115702. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  115703. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  115704. */
  115705. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  115706. /** @hidden */
  115707. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  115708. /**
  115709. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  115710. */
  115711. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  115712. /**
  115713. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  115714. */
  115715. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  115716. /**
  115717. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  115718. */
  115719. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  115720. /** Callback called when a pointer move is detected */
  115721. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115722. /** Callback called when a pointer down is detected */
  115723. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115724. /** Callback called when a pointer up is detected */
  115725. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  115726. /** Callback called when a pointer pick is detected */
  115727. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  115728. /**
  115729. * 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).
  115730. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  115731. */
  115732. onPrePointerObservable: Observable<PointerInfoPre>;
  115733. /**
  115734. * Observable event triggered each time an input event is received from the rendering canvas
  115735. */
  115736. onPointerObservable: Observable<PointerInfo>;
  115737. /**
  115738. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  115739. */
  115740. get unTranslatedPointer(): Vector2;
  115741. /**
  115742. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  115743. */
  115744. static get DragMovementThreshold(): number;
  115745. static set DragMovementThreshold(value: number);
  115746. /**
  115747. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  115748. */
  115749. static get LongPressDelay(): number;
  115750. static set LongPressDelay(value: number);
  115751. /**
  115752. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  115753. */
  115754. static get DoubleClickDelay(): number;
  115755. static set DoubleClickDelay(value: number);
  115756. /** If you need to check double click without raising a single click at first click, enable this flag */
  115757. static get ExclusiveDoubleClickMode(): boolean;
  115758. static set ExclusiveDoubleClickMode(value: boolean);
  115759. /** @hidden */
  115760. _mirroredCameraPosition: Nullable<Vector3>;
  115761. /**
  115762. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  115763. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  115764. */
  115765. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  115766. /**
  115767. * Observable event triggered each time an keyboard event is received from the hosting window
  115768. */
  115769. onKeyboardObservable: Observable<KeyboardInfo>;
  115770. private _useRightHandedSystem;
  115771. /**
  115772. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  115773. */
  115774. set useRightHandedSystem(value: boolean);
  115775. get useRightHandedSystem(): boolean;
  115776. private _timeAccumulator;
  115777. private _currentStepId;
  115778. private _currentInternalStep;
  115779. /**
  115780. * Sets the step Id used by deterministic lock step
  115781. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115782. * @param newStepId defines the step Id
  115783. */
  115784. setStepId(newStepId: number): void;
  115785. /**
  115786. * Gets the step Id used by deterministic lock step
  115787. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115788. * @returns the step Id
  115789. */
  115790. getStepId(): number;
  115791. /**
  115792. * Gets the internal step used by deterministic lock step
  115793. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115794. * @returns the internal step
  115795. */
  115796. getInternalStep(): number;
  115797. private _fogEnabled;
  115798. /**
  115799. * Gets or sets a boolean indicating if fog is enabled on this scene
  115800. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115801. * (Default is true)
  115802. */
  115803. set fogEnabled(value: boolean);
  115804. get fogEnabled(): boolean;
  115805. private _fogMode;
  115806. /**
  115807. * Gets or sets the fog mode to use
  115808. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115809. * | mode | value |
  115810. * | --- | --- |
  115811. * | FOGMODE_NONE | 0 |
  115812. * | FOGMODE_EXP | 1 |
  115813. * | FOGMODE_EXP2 | 2 |
  115814. * | FOGMODE_LINEAR | 3 |
  115815. */
  115816. set fogMode(value: number);
  115817. get fogMode(): number;
  115818. /**
  115819. * Gets or sets the fog color to use
  115820. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115821. * (Default is Color3(0.2, 0.2, 0.3))
  115822. */
  115823. fogColor: Color3;
  115824. /**
  115825. * Gets or sets the fog density to use
  115826. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115827. * (Default is 0.1)
  115828. */
  115829. fogDensity: number;
  115830. /**
  115831. * Gets or sets the fog start distance to use
  115832. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115833. * (Default is 0)
  115834. */
  115835. fogStart: number;
  115836. /**
  115837. * Gets or sets the fog end distance to use
  115838. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115839. * (Default is 1000)
  115840. */
  115841. fogEnd: number;
  115842. private _shadowsEnabled;
  115843. /**
  115844. * Gets or sets a boolean indicating if shadows are enabled on this scene
  115845. */
  115846. set shadowsEnabled(value: boolean);
  115847. get shadowsEnabled(): boolean;
  115848. private _lightsEnabled;
  115849. /**
  115850. * Gets or sets a boolean indicating if lights are enabled on this scene
  115851. */
  115852. set lightsEnabled(value: boolean);
  115853. get lightsEnabled(): boolean;
  115854. /** All of the active cameras added to this scene. */
  115855. activeCameras: Camera[];
  115856. /** @hidden */
  115857. _activeCamera: Nullable<Camera>;
  115858. /** Gets or sets the current active camera */
  115859. get activeCamera(): Nullable<Camera>;
  115860. set activeCamera(value: Nullable<Camera>);
  115861. private _defaultMaterial;
  115862. /** The default material used on meshes when no material is affected */
  115863. get defaultMaterial(): Material;
  115864. /** The default material used on meshes when no material is affected */
  115865. set defaultMaterial(value: Material);
  115866. private _texturesEnabled;
  115867. /**
  115868. * Gets or sets a boolean indicating if textures are enabled on this scene
  115869. */
  115870. set texturesEnabled(value: boolean);
  115871. get texturesEnabled(): boolean;
  115872. /**
  115873. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  115874. */
  115875. physicsEnabled: boolean;
  115876. /**
  115877. * Gets or sets a boolean indicating if particles are enabled on this scene
  115878. */
  115879. particlesEnabled: boolean;
  115880. /**
  115881. * Gets or sets a boolean indicating if sprites are enabled on this scene
  115882. */
  115883. spritesEnabled: boolean;
  115884. private _skeletonsEnabled;
  115885. /**
  115886. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  115887. */
  115888. set skeletonsEnabled(value: boolean);
  115889. get skeletonsEnabled(): boolean;
  115890. /**
  115891. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  115892. */
  115893. lensFlaresEnabled: boolean;
  115894. /**
  115895. * Gets or sets a boolean indicating if collisions are enabled on this scene
  115896. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115897. */
  115898. collisionsEnabled: boolean;
  115899. private _collisionCoordinator;
  115900. /** @hidden */
  115901. get collisionCoordinator(): ICollisionCoordinator;
  115902. /**
  115903. * Defines the gravity applied to this scene (used only for collisions)
  115904. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115905. */
  115906. gravity: Vector3;
  115907. /**
  115908. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  115909. */
  115910. postProcessesEnabled: boolean;
  115911. /**
  115912. * The list of postprocesses added to the scene
  115913. */
  115914. postProcesses: PostProcess[];
  115915. /**
  115916. * Gets the current postprocess manager
  115917. */
  115918. postProcessManager: PostProcessManager;
  115919. /**
  115920. * Gets or sets a boolean indicating if render targets are enabled on this scene
  115921. */
  115922. renderTargetsEnabled: boolean;
  115923. /**
  115924. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  115925. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  115926. */
  115927. dumpNextRenderTargets: boolean;
  115928. /**
  115929. * The list of user defined render targets added to the scene
  115930. */
  115931. customRenderTargets: RenderTargetTexture[];
  115932. /**
  115933. * Defines if texture loading must be delayed
  115934. * If true, textures will only be loaded when they need to be rendered
  115935. */
  115936. useDelayedTextureLoading: boolean;
  115937. /**
  115938. * Gets the list of meshes imported to the scene through SceneLoader
  115939. */
  115940. importedMeshesFiles: String[];
  115941. /**
  115942. * Gets or sets a boolean indicating if probes are enabled on this scene
  115943. */
  115944. probesEnabled: boolean;
  115945. /**
  115946. * Gets or sets the current offline provider to use to store scene data
  115947. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  115948. */
  115949. offlineProvider: IOfflineProvider;
  115950. /**
  115951. * Gets or sets the action manager associated with the scene
  115952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  115953. */
  115954. actionManager: AbstractActionManager;
  115955. private _meshesForIntersections;
  115956. /**
  115957. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  115958. */
  115959. proceduralTexturesEnabled: boolean;
  115960. private _engine;
  115961. private _totalVertices;
  115962. /** @hidden */
  115963. _activeIndices: PerfCounter;
  115964. /** @hidden */
  115965. _activeParticles: PerfCounter;
  115966. /** @hidden */
  115967. _activeBones: PerfCounter;
  115968. private _animationRatio;
  115969. /** @hidden */
  115970. _animationTimeLast: number;
  115971. /** @hidden */
  115972. _animationTime: number;
  115973. /**
  115974. * Gets or sets a general scale for animation speed
  115975. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  115976. */
  115977. animationTimeScale: number;
  115978. /** @hidden */
  115979. _cachedMaterial: Nullable<Material>;
  115980. /** @hidden */
  115981. _cachedEffect: Nullable<Effect>;
  115982. /** @hidden */
  115983. _cachedVisibility: Nullable<number>;
  115984. private _renderId;
  115985. private _frameId;
  115986. private _executeWhenReadyTimeoutId;
  115987. private _intermediateRendering;
  115988. private _viewUpdateFlag;
  115989. private _projectionUpdateFlag;
  115990. /** @hidden */
  115991. _toBeDisposed: Nullable<IDisposable>[];
  115992. private _activeRequests;
  115993. /** @hidden */
  115994. _pendingData: any[];
  115995. private _isDisposed;
  115996. /**
  115997. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  115998. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  115999. */
  116000. dispatchAllSubMeshesOfActiveMeshes: boolean;
  116001. private _activeMeshes;
  116002. private _processedMaterials;
  116003. private _renderTargets;
  116004. /** @hidden */
  116005. _activeParticleSystems: SmartArray<IParticleSystem>;
  116006. private _activeSkeletons;
  116007. private _softwareSkinnedMeshes;
  116008. private _renderingManager;
  116009. /** @hidden */
  116010. _activeAnimatables: Animatable[];
  116011. private _transformMatrix;
  116012. private _sceneUbo;
  116013. /** @hidden */
  116014. _viewMatrix: Matrix;
  116015. private _projectionMatrix;
  116016. /** @hidden */
  116017. _forcedViewPosition: Nullable<Vector3>;
  116018. /** @hidden */
  116019. _frustumPlanes: Plane[];
  116020. /**
  116021. * Gets the list of frustum planes (built from the active camera)
  116022. */
  116023. get frustumPlanes(): Plane[];
  116024. /**
  116025. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  116026. * This is useful if there are more lights that the maximum simulteanous authorized
  116027. */
  116028. requireLightSorting: boolean;
  116029. /** @hidden */
  116030. readonly useMaterialMeshMap: boolean;
  116031. /** @hidden */
  116032. readonly useClonedMeshMap: boolean;
  116033. private _externalData;
  116034. private _uid;
  116035. /**
  116036. * @hidden
  116037. * Backing store of defined scene components.
  116038. */
  116039. _components: ISceneComponent[];
  116040. /**
  116041. * @hidden
  116042. * Backing store of defined scene components.
  116043. */
  116044. _serializableComponents: ISceneSerializableComponent[];
  116045. /**
  116046. * List of components to register on the next registration step.
  116047. */
  116048. private _transientComponents;
  116049. /**
  116050. * Registers the transient components if needed.
  116051. */
  116052. private _registerTransientComponents;
  116053. /**
  116054. * @hidden
  116055. * Add a component to the scene.
  116056. * Note that the ccomponent could be registered on th next frame if this is called after
  116057. * the register component stage.
  116058. * @param component Defines the component to add to the scene
  116059. */
  116060. _addComponent(component: ISceneComponent): void;
  116061. /**
  116062. * @hidden
  116063. * Gets a component from the scene.
  116064. * @param name defines the name of the component to retrieve
  116065. * @returns the component or null if not present
  116066. */
  116067. _getComponent(name: string): Nullable<ISceneComponent>;
  116068. /**
  116069. * @hidden
  116070. * Defines the actions happening before camera updates.
  116071. */
  116072. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  116073. /**
  116074. * @hidden
  116075. * Defines the actions happening before clear the canvas.
  116076. */
  116077. _beforeClearStage: Stage<SimpleStageAction>;
  116078. /**
  116079. * @hidden
  116080. * Defines the actions when collecting render targets for the frame.
  116081. */
  116082. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116083. /**
  116084. * @hidden
  116085. * Defines the actions happening for one camera in the frame.
  116086. */
  116087. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116088. /**
  116089. * @hidden
  116090. * Defines the actions happening during the per mesh ready checks.
  116091. */
  116092. _isReadyForMeshStage: Stage<MeshStageAction>;
  116093. /**
  116094. * @hidden
  116095. * Defines the actions happening before evaluate active mesh checks.
  116096. */
  116097. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  116098. /**
  116099. * @hidden
  116100. * Defines the actions happening during the evaluate sub mesh checks.
  116101. */
  116102. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  116103. /**
  116104. * @hidden
  116105. * Defines the actions happening during the active mesh stage.
  116106. */
  116107. _activeMeshStage: Stage<ActiveMeshStageAction>;
  116108. /**
  116109. * @hidden
  116110. * Defines the actions happening during the per camera render target step.
  116111. */
  116112. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  116113. /**
  116114. * @hidden
  116115. * Defines the actions happening just before the active camera is drawing.
  116116. */
  116117. _beforeCameraDrawStage: Stage<CameraStageAction>;
  116118. /**
  116119. * @hidden
  116120. * Defines the actions happening just before a render target is drawing.
  116121. */
  116122. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116123. /**
  116124. * @hidden
  116125. * Defines the actions happening just before a rendering group is drawing.
  116126. */
  116127. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116128. /**
  116129. * @hidden
  116130. * Defines the actions happening just before a mesh is drawing.
  116131. */
  116132. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116133. /**
  116134. * @hidden
  116135. * Defines the actions happening just after a mesh has been drawn.
  116136. */
  116137. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116138. /**
  116139. * @hidden
  116140. * Defines the actions happening just after a rendering group has been drawn.
  116141. */
  116142. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116143. /**
  116144. * @hidden
  116145. * Defines the actions happening just after the active camera has been drawn.
  116146. */
  116147. _afterCameraDrawStage: Stage<CameraStageAction>;
  116148. /**
  116149. * @hidden
  116150. * Defines the actions happening just after a render target has been drawn.
  116151. */
  116152. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116153. /**
  116154. * @hidden
  116155. * Defines the actions happening just after rendering all cameras and computing intersections.
  116156. */
  116157. _afterRenderStage: Stage<SimpleStageAction>;
  116158. /**
  116159. * @hidden
  116160. * Defines the actions happening when a pointer move event happens.
  116161. */
  116162. _pointerMoveStage: Stage<PointerMoveStageAction>;
  116163. /**
  116164. * @hidden
  116165. * Defines the actions happening when a pointer down event happens.
  116166. */
  116167. _pointerDownStage: Stage<PointerUpDownStageAction>;
  116168. /**
  116169. * @hidden
  116170. * Defines the actions happening when a pointer up event happens.
  116171. */
  116172. _pointerUpStage: Stage<PointerUpDownStageAction>;
  116173. /**
  116174. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  116175. */
  116176. private geometriesByUniqueId;
  116177. /**
  116178. * Creates a new Scene
  116179. * @param engine defines the engine to use to render this scene
  116180. * @param options defines the scene options
  116181. */
  116182. constructor(engine: Engine, options?: SceneOptions);
  116183. /**
  116184. * Gets a string idenfifying the name of the class
  116185. * @returns "Scene" string
  116186. */
  116187. getClassName(): string;
  116188. private _defaultMeshCandidates;
  116189. /**
  116190. * @hidden
  116191. */
  116192. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116193. private _defaultSubMeshCandidates;
  116194. /**
  116195. * @hidden
  116196. */
  116197. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116198. /**
  116199. * Sets the default candidate providers for the scene.
  116200. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  116201. * and getCollidingSubMeshCandidates to their default function
  116202. */
  116203. setDefaultCandidateProviders(): void;
  116204. /**
  116205. * Gets the mesh that is currently under the pointer
  116206. */
  116207. get meshUnderPointer(): Nullable<AbstractMesh>;
  116208. /**
  116209. * Gets or sets the current on-screen X position of the pointer
  116210. */
  116211. get pointerX(): number;
  116212. set pointerX(value: number);
  116213. /**
  116214. * Gets or sets the current on-screen Y position of the pointer
  116215. */
  116216. get pointerY(): number;
  116217. set pointerY(value: number);
  116218. /**
  116219. * Gets the cached material (ie. the latest rendered one)
  116220. * @returns the cached material
  116221. */
  116222. getCachedMaterial(): Nullable<Material>;
  116223. /**
  116224. * Gets the cached effect (ie. the latest rendered one)
  116225. * @returns the cached effect
  116226. */
  116227. getCachedEffect(): Nullable<Effect>;
  116228. /**
  116229. * Gets the cached visibility state (ie. the latest rendered one)
  116230. * @returns the cached visibility state
  116231. */
  116232. getCachedVisibility(): Nullable<number>;
  116233. /**
  116234. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  116235. * @param material defines the current material
  116236. * @param effect defines the current effect
  116237. * @param visibility defines the current visibility state
  116238. * @returns true if one parameter is not cached
  116239. */
  116240. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  116241. /**
  116242. * Gets the engine associated with the scene
  116243. * @returns an Engine
  116244. */
  116245. getEngine(): Engine;
  116246. /**
  116247. * Gets the total number of vertices rendered per frame
  116248. * @returns the total number of vertices rendered per frame
  116249. */
  116250. getTotalVertices(): number;
  116251. /**
  116252. * Gets the performance counter for total vertices
  116253. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116254. */
  116255. get totalVerticesPerfCounter(): PerfCounter;
  116256. /**
  116257. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  116258. * @returns the total number of active indices rendered per frame
  116259. */
  116260. getActiveIndices(): number;
  116261. /**
  116262. * Gets the performance counter for active indices
  116263. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116264. */
  116265. get totalActiveIndicesPerfCounter(): PerfCounter;
  116266. /**
  116267. * Gets the total number of active particles rendered per frame
  116268. * @returns the total number of active particles rendered per frame
  116269. */
  116270. getActiveParticles(): number;
  116271. /**
  116272. * Gets the performance counter for active particles
  116273. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116274. */
  116275. get activeParticlesPerfCounter(): PerfCounter;
  116276. /**
  116277. * Gets the total number of active bones rendered per frame
  116278. * @returns the total number of active bones rendered per frame
  116279. */
  116280. getActiveBones(): number;
  116281. /**
  116282. * Gets the performance counter for active bones
  116283. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116284. */
  116285. get activeBonesPerfCounter(): PerfCounter;
  116286. /**
  116287. * Gets the array of active meshes
  116288. * @returns an array of AbstractMesh
  116289. */
  116290. getActiveMeshes(): SmartArray<AbstractMesh>;
  116291. /**
  116292. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  116293. * @returns a number
  116294. */
  116295. getAnimationRatio(): number;
  116296. /**
  116297. * Gets an unique Id for the current render phase
  116298. * @returns a number
  116299. */
  116300. getRenderId(): number;
  116301. /**
  116302. * Gets an unique Id for the current frame
  116303. * @returns a number
  116304. */
  116305. getFrameId(): number;
  116306. /** Call this function if you want to manually increment the render Id*/
  116307. incrementRenderId(): void;
  116308. private _createUbo;
  116309. /**
  116310. * Use this method to simulate a pointer move on a mesh
  116311. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116312. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116313. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116314. * @returns the current scene
  116315. */
  116316. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116317. /**
  116318. * Use this method to simulate a pointer down on a mesh
  116319. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116320. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116321. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116322. * @returns the current scene
  116323. */
  116324. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116325. /**
  116326. * Use this method to simulate a pointer up on a mesh
  116327. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116328. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116329. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116330. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116331. * @returns the current scene
  116332. */
  116333. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  116334. /**
  116335. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116336. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116337. * @returns true if the pointer was captured
  116338. */
  116339. isPointerCaptured(pointerId?: number): boolean;
  116340. /**
  116341. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116342. * @param attachUp defines if you want to attach events to pointerup
  116343. * @param attachDown defines if you want to attach events to pointerdown
  116344. * @param attachMove defines if you want to attach events to pointermove
  116345. */
  116346. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  116347. /** Detaches all event handlers*/
  116348. detachControl(): void;
  116349. /**
  116350. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  116351. * Delay loaded resources are not taking in account
  116352. * @return true if all required resources are ready
  116353. */
  116354. isReady(): boolean;
  116355. /** Resets all cached information relative to material (including effect and visibility) */
  116356. resetCachedMaterial(): void;
  116357. /**
  116358. * Registers a function to be called before every frame render
  116359. * @param func defines the function to register
  116360. */
  116361. registerBeforeRender(func: () => void): void;
  116362. /**
  116363. * Unregisters a function called before every frame render
  116364. * @param func defines the function to unregister
  116365. */
  116366. unregisterBeforeRender(func: () => void): void;
  116367. /**
  116368. * Registers a function to be called after every frame render
  116369. * @param func defines the function to register
  116370. */
  116371. registerAfterRender(func: () => void): void;
  116372. /**
  116373. * Unregisters a function called after every frame render
  116374. * @param func defines the function to unregister
  116375. */
  116376. unregisterAfterRender(func: () => void): void;
  116377. private _executeOnceBeforeRender;
  116378. /**
  116379. * The provided function will run before render once and will be disposed afterwards.
  116380. * A timeout delay can be provided so that the function will be executed in N ms.
  116381. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  116382. * @param func The function to be executed.
  116383. * @param timeout optional delay in ms
  116384. */
  116385. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  116386. /** @hidden */
  116387. _addPendingData(data: any): void;
  116388. /** @hidden */
  116389. _removePendingData(data: any): void;
  116390. /**
  116391. * Returns the number of items waiting to be loaded
  116392. * @returns the number of items waiting to be loaded
  116393. */
  116394. getWaitingItemsCount(): number;
  116395. /**
  116396. * Returns a boolean indicating if the scene is still loading data
  116397. */
  116398. get isLoading(): boolean;
  116399. /**
  116400. * Registers a function to be executed when the scene is ready
  116401. * @param {Function} func - the function to be executed
  116402. */
  116403. executeWhenReady(func: () => void): void;
  116404. /**
  116405. * Returns a promise that resolves when the scene is ready
  116406. * @returns A promise that resolves when the scene is ready
  116407. */
  116408. whenReadyAsync(): Promise<void>;
  116409. /** @hidden */
  116410. _checkIsReady(): void;
  116411. /**
  116412. * Gets all animatable attached to the scene
  116413. */
  116414. get animatables(): Animatable[];
  116415. /**
  116416. * Resets the last animation time frame.
  116417. * Useful to override when animations start running when loading a scene for the first time.
  116418. */
  116419. resetLastAnimationTimeFrame(): void;
  116420. /**
  116421. * Gets the current view matrix
  116422. * @returns a Matrix
  116423. */
  116424. getViewMatrix(): Matrix;
  116425. /**
  116426. * Gets the current projection matrix
  116427. * @returns a Matrix
  116428. */
  116429. getProjectionMatrix(): Matrix;
  116430. /**
  116431. * Gets the current transform matrix
  116432. * @returns a Matrix made of View * Projection
  116433. */
  116434. getTransformMatrix(): Matrix;
  116435. /**
  116436. * Sets the current transform matrix
  116437. * @param viewL defines the View matrix to use
  116438. * @param projectionL defines the Projection matrix to use
  116439. * @param viewR defines the right View matrix to use (if provided)
  116440. * @param projectionR defines the right Projection matrix to use (if provided)
  116441. */
  116442. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  116443. /**
  116444. * Gets the uniform buffer used to store scene data
  116445. * @returns a UniformBuffer
  116446. */
  116447. getSceneUniformBuffer(): UniformBuffer;
  116448. /**
  116449. * Gets an unique (relatively to the current scene) Id
  116450. * @returns an unique number for the scene
  116451. */
  116452. getUniqueId(): number;
  116453. /**
  116454. * Add a mesh to the list of scene's meshes
  116455. * @param newMesh defines the mesh to add
  116456. * @param recursive if all child meshes should also be added to the scene
  116457. */
  116458. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  116459. /**
  116460. * Remove a mesh for the list of scene's meshes
  116461. * @param toRemove defines the mesh to remove
  116462. * @param recursive if all child meshes should also be removed from the scene
  116463. * @returns the index where the mesh was in the mesh list
  116464. */
  116465. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  116466. /**
  116467. * Add a transform node to the list of scene's transform nodes
  116468. * @param newTransformNode defines the transform node to add
  116469. */
  116470. addTransformNode(newTransformNode: TransformNode): void;
  116471. /**
  116472. * Remove a transform node for the list of scene's transform nodes
  116473. * @param toRemove defines the transform node to remove
  116474. * @returns the index where the transform node was in the transform node list
  116475. */
  116476. removeTransformNode(toRemove: TransformNode): number;
  116477. /**
  116478. * Remove a skeleton for the list of scene's skeletons
  116479. * @param toRemove defines the skeleton to remove
  116480. * @returns the index where the skeleton was in the skeleton list
  116481. */
  116482. removeSkeleton(toRemove: Skeleton): number;
  116483. /**
  116484. * Remove a morph target for the list of scene's morph targets
  116485. * @param toRemove defines the morph target to remove
  116486. * @returns the index where the morph target was in the morph target list
  116487. */
  116488. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  116489. /**
  116490. * Remove a light for the list of scene's lights
  116491. * @param toRemove defines the light to remove
  116492. * @returns the index where the light was in the light list
  116493. */
  116494. removeLight(toRemove: Light): number;
  116495. /**
  116496. * Remove a camera for the list of scene's cameras
  116497. * @param toRemove defines the camera to remove
  116498. * @returns the index where the camera was in the camera list
  116499. */
  116500. removeCamera(toRemove: Camera): number;
  116501. /**
  116502. * Remove a particle system for the list of scene's particle systems
  116503. * @param toRemove defines the particle system to remove
  116504. * @returns the index where the particle system was in the particle system list
  116505. */
  116506. removeParticleSystem(toRemove: IParticleSystem): number;
  116507. /**
  116508. * Remove a animation for the list of scene's animations
  116509. * @param toRemove defines the animation to remove
  116510. * @returns the index where the animation was in the animation list
  116511. */
  116512. removeAnimation(toRemove: Animation): number;
  116513. /**
  116514. * Will stop the animation of the given target
  116515. * @param target - the target
  116516. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  116517. * @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)
  116518. */
  116519. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  116520. /**
  116521. * Removes the given animation group from this scene.
  116522. * @param toRemove The animation group to remove
  116523. * @returns The index of the removed animation group
  116524. */
  116525. removeAnimationGroup(toRemove: AnimationGroup): number;
  116526. /**
  116527. * Removes the given multi-material from this scene.
  116528. * @param toRemove The multi-material to remove
  116529. * @returns The index of the removed multi-material
  116530. */
  116531. removeMultiMaterial(toRemove: MultiMaterial): number;
  116532. /**
  116533. * Removes the given material from this scene.
  116534. * @param toRemove The material to remove
  116535. * @returns The index of the removed material
  116536. */
  116537. removeMaterial(toRemove: Material): number;
  116538. /**
  116539. * Removes the given action manager from this scene.
  116540. * @param toRemove The action manager to remove
  116541. * @returns The index of the removed action manager
  116542. */
  116543. removeActionManager(toRemove: AbstractActionManager): number;
  116544. /**
  116545. * Removes the given texture from this scene.
  116546. * @param toRemove The texture to remove
  116547. * @returns The index of the removed texture
  116548. */
  116549. removeTexture(toRemove: BaseTexture): number;
  116550. /**
  116551. * Adds the given light to this scene
  116552. * @param newLight The light to add
  116553. */
  116554. addLight(newLight: Light): void;
  116555. /**
  116556. * Sorts the list list based on light priorities
  116557. */
  116558. sortLightsByPriority(): void;
  116559. /**
  116560. * Adds the given camera to this scene
  116561. * @param newCamera The camera to add
  116562. */
  116563. addCamera(newCamera: Camera): void;
  116564. /**
  116565. * Adds the given skeleton to this scene
  116566. * @param newSkeleton The skeleton to add
  116567. */
  116568. addSkeleton(newSkeleton: Skeleton): void;
  116569. /**
  116570. * Adds the given particle system to this scene
  116571. * @param newParticleSystem The particle system to add
  116572. */
  116573. addParticleSystem(newParticleSystem: IParticleSystem): void;
  116574. /**
  116575. * Adds the given animation to this scene
  116576. * @param newAnimation The animation to add
  116577. */
  116578. addAnimation(newAnimation: Animation): void;
  116579. /**
  116580. * Adds the given animation group to this scene.
  116581. * @param newAnimationGroup The animation group to add
  116582. */
  116583. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  116584. /**
  116585. * Adds the given multi-material to this scene
  116586. * @param newMultiMaterial The multi-material to add
  116587. */
  116588. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  116589. /**
  116590. * Adds the given material to this scene
  116591. * @param newMaterial The material to add
  116592. */
  116593. addMaterial(newMaterial: Material): void;
  116594. /**
  116595. * Adds the given morph target to this scene
  116596. * @param newMorphTargetManager The morph target to add
  116597. */
  116598. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  116599. /**
  116600. * Adds the given geometry to this scene
  116601. * @param newGeometry The geometry to add
  116602. */
  116603. addGeometry(newGeometry: Geometry): void;
  116604. /**
  116605. * Adds the given action manager to this scene
  116606. * @param newActionManager The action manager to add
  116607. */
  116608. addActionManager(newActionManager: AbstractActionManager): void;
  116609. /**
  116610. * Adds the given texture to this scene.
  116611. * @param newTexture The texture to add
  116612. */
  116613. addTexture(newTexture: BaseTexture): void;
  116614. /**
  116615. * Switch active camera
  116616. * @param newCamera defines the new active camera
  116617. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  116618. */
  116619. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  116620. /**
  116621. * sets the active camera of the scene using its ID
  116622. * @param id defines the camera's ID
  116623. * @return the new active camera or null if none found.
  116624. */
  116625. setActiveCameraByID(id: string): Nullable<Camera>;
  116626. /**
  116627. * sets the active camera of the scene using its name
  116628. * @param name defines the camera's name
  116629. * @returns the new active camera or null if none found.
  116630. */
  116631. setActiveCameraByName(name: string): Nullable<Camera>;
  116632. /**
  116633. * get an animation group using its name
  116634. * @param name defines the material's name
  116635. * @return the animation group or null if none found.
  116636. */
  116637. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  116638. /**
  116639. * Get a material using its unique id
  116640. * @param uniqueId defines the material's unique id
  116641. * @return the material or null if none found.
  116642. */
  116643. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  116644. /**
  116645. * get a material using its id
  116646. * @param id defines the material's ID
  116647. * @return the material or null if none found.
  116648. */
  116649. getMaterialByID(id: string): Nullable<Material>;
  116650. /**
  116651. * Gets a the last added material using a given id
  116652. * @param id defines the material's ID
  116653. * @return the last material with the given id or null if none found.
  116654. */
  116655. getLastMaterialByID(id: string): Nullable<Material>;
  116656. /**
  116657. * Gets a material using its name
  116658. * @param name defines the material's name
  116659. * @return the material or null if none found.
  116660. */
  116661. getMaterialByName(name: string): Nullable<Material>;
  116662. /**
  116663. * Get a texture using its unique id
  116664. * @param uniqueId defines the texture's unique id
  116665. * @return the texture or null if none found.
  116666. */
  116667. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  116668. /**
  116669. * Gets a camera using its id
  116670. * @param id defines the id to look for
  116671. * @returns the camera or null if not found
  116672. */
  116673. getCameraByID(id: string): Nullable<Camera>;
  116674. /**
  116675. * Gets a camera using its unique id
  116676. * @param uniqueId defines the unique id to look for
  116677. * @returns the camera or null if not found
  116678. */
  116679. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  116680. /**
  116681. * Gets a camera using its name
  116682. * @param name defines the camera's name
  116683. * @return the camera or null if none found.
  116684. */
  116685. getCameraByName(name: string): Nullable<Camera>;
  116686. /**
  116687. * Gets a bone using its id
  116688. * @param id defines the bone's id
  116689. * @return the bone or null if not found
  116690. */
  116691. getBoneByID(id: string): Nullable<Bone>;
  116692. /**
  116693. * Gets a bone using its id
  116694. * @param name defines the bone's name
  116695. * @return the bone or null if not found
  116696. */
  116697. getBoneByName(name: string): Nullable<Bone>;
  116698. /**
  116699. * Gets a light node using its name
  116700. * @param name defines the the light's name
  116701. * @return the light or null if none found.
  116702. */
  116703. getLightByName(name: string): Nullable<Light>;
  116704. /**
  116705. * Gets a light node using its id
  116706. * @param id defines the light's id
  116707. * @return the light or null if none found.
  116708. */
  116709. getLightByID(id: string): Nullable<Light>;
  116710. /**
  116711. * Gets a light node using its scene-generated unique ID
  116712. * @param uniqueId defines the light's unique id
  116713. * @return the light or null if none found.
  116714. */
  116715. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  116716. /**
  116717. * Gets a particle system by id
  116718. * @param id defines the particle system id
  116719. * @return the corresponding system or null if none found
  116720. */
  116721. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  116722. /**
  116723. * Gets a geometry using its ID
  116724. * @param id defines the geometry's id
  116725. * @return the geometry or null if none found.
  116726. */
  116727. getGeometryByID(id: string): Nullable<Geometry>;
  116728. private _getGeometryByUniqueID;
  116729. /**
  116730. * Add a new geometry to this scene
  116731. * @param geometry defines the geometry to be added to the scene.
  116732. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  116733. * @return a boolean defining if the geometry was added or not
  116734. */
  116735. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  116736. /**
  116737. * Removes an existing geometry
  116738. * @param geometry defines the geometry to be removed from the scene
  116739. * @return a boolean defining if the geometry was removed or not
  116740. */
  116741. removeGeometry(geometry: Geometry): boolean;
  116742. /**
  116743. * Gets the list of geometries attached to the scene
  116744. * @returns an array of Geometry
  116745. */
  116746. getGeometries(): Geometry[];
  116747. /**
  116748. * Gets the first added mesh found of a given ID
  116749. * @param id defines the id to search for
  116750. * @return the mesh found or null if not found at all
  116751. */
  116752. getMeshByID(id: string): Nullable<AbstractMesh>;
  116753. /**
  116754. * Gets a list of meshes using their id
  116755. * @param id defines the id to search for
  116756. * @returns a list of meshes
  116757. */
  116758. getMeshesByID(id: string): Array<AbstractMesh>;
  116759. /**
  116760. * Gets the first added transform node found of a given ID
  116761. * @param id defines the id to search for
  116762. * @return the found transform node or null if not found at all.
  116763. */
  116764. getTransformNodeByID(id: string): Nullable<TransformNode>;
  116765. /**
  116766. * Gets a transform node with its auto-generated unique id
  116767. * @param uniqueId efines the unique id to search for
  116768. * @return the found transform node or null if not found at all.
  116769. */
  116770. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  116771. /**
  116772. * Gets a list of transform nodes using their id
  116773. * @param id defines the id to search for
  116774. * @returns a list of transform nodes
  116775. */
  116776. getTransformNodesByID(id: string): Array<TransformNode>;
  116777. /**
  116778. * Gets a mesh with its auto-generated unique id
  116779. * @param uniqueId defines the unique id to search for
  116780. * @return the found mesh or null if not found at all.
  116781. */
  116782. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  116783. /**
  116784. * Gets a the last added mesh using a given id
  116785. * @param id defines the id to search for
  116786. * @return the found mesh or null if not found at all.
  116787. */
  116788. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  116789. /**
  116790. * Gets a the last added node (Mesh, Camera, Light) using a given id
  116791. * @param id defines the id to search for
  116792. * @return the found node or null if not found at all
  116793. */
  116794. getLastEntryByID(id: string): Nullable<Node>;
  116795. /**
  116796. * Gets a node (Mesh, Camera, Light) using a given id
  116797. * @param id defines the id to search for
  116798. * @return the found node or null if not found at all
  116799. */
  116800. getNodeByID(id: string): Nullable<Node>;
  116801. /**
  116802. * Gets a node (Mesh, Camera, Light) using a given name
  116803. * @param name defines the name to search for
  116804. * @return the found node or null if not found at all.
  116805. */
  116806. getNodeByName(name: string): Nullable<Node>;
  116807. /**
  116808. * Gets a mesh using a given name
  116809. * @param name defines the name to search for
  116810. * @return the found mesh or null if not found at all.
  116811. */
  116812. getMeshByName(name: string): Nullable<AbstractMesh>;
  116813. /**
  116814. * Gets a transform node using a given name
  116815. * @param name defines the name to search for
  116816. * @return the found transform node or null if not found at all.
  116817. */
  116818. getTransformNodeByName(name: string): Nullable<TransformNode>;
  116819. /**
  116820. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  116821. * @param id defines the id to search for
  116822. * @return the found skeleton or null if not found at all.
  116823. */
  116824. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  116825. /**
  116826. * Gets a skeleton using a given auto generated unique id
  116827. * @param uniqueId defines the unique id to search for
  116828. * @return the found skeleton or null if not found at all.
  116829. */
  116830. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  116831. /**
  116832. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  116833. * @param id defines the id to search for
  116834. * @return the found skeleton or null if not found at all.
  116835. */
  116836. getSkeletonById(id: string): Nullable<Skeleton>;
  116837. /**
  116838. * Gets a skeleton using a given name
  116839. * @param name defines the name to search for
  116840. * @return the found skeleton or null if not found at all.
  116841. */
  116842. getSkeletonByName(name: string): Nullable<Skeleton>;
  116843. /**
  116844. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  116845. * @param id defines the id to search for
  116846. * @return the found morph target manager or null if not found at all.
  116847. */
  116848. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  116849. /**
  116850. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  116851. * @param id defines the id to search for
  116852. * @return the found morph target or null if not found at all.
  116853. */
  116854. getMorphTargetById(id: string): Nullable<MorphTarget>;
  116855. /**
  116856. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  116857. * @param name defines the name to search for
  116858. * @return the found morph target or null if not found at all.
  116859. */
  116860. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  116861. /**
  116862. * Gets a boolean indicating if the given mesh is active
  116863. * @param mesh defines the mesh to look for
  116864. * @returns true if the mesh is in the active list
  116865. */
  116866. isActiveMesh(mesh: AbstractMesh): boolean;
  116867. /**
  116868. * Return a unique id as a string which can serve as an identifier for the scene
  116869. */
  116870. get uid(): string;
  116871. /**
  116872. * Add an externaly attached data from its key.
  116873. * This method call will fail and return false, if such key already exists.
  116874. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  116875. * @param key the unique key that identifies the data
  116876. * @param data the data object to associate to the key for this Engine instance
  116877. * @return true if no such key were already present and the data was added successfully, false otherwise
  116878. */
  116879. addExternalData<T>(key: string, data: T): boolean;
  116880. /**
  116881. * Get an externaly attached data from its key
  116882. * @param key the unique key that identifies the data
  116883. * @return the associated data, if present (can be null), or undefined if not present
  116884. */
  116885. getExternalData<T>(key: string): Nullable<T>;
  116886. /**
  116887. * Get an externaly attached data from its key, create it using a factory if it's not already present
  116888. * @param key the unique key that identifies the data
  116889. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  116890. * @return the associated data, can be null if the factory returned null.
  116891. */
  116892. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  116893. /**
  116894. * Remove an externaly attached data from the Engine instance
  116895. * @param key the unique key that identifies the data
  116896. * @return true if the data was successfully removed, false if it doesn't exist
  116897. */
  116898. removeExternalData(key: string): boolean;
  116899. private _evaluateSubMesh;
  116900. /**
  116901. * Clear the processed materials smart array preventing retention point in material dispose.
  116902. */
  116903. freeProcessedMaterials(): void;
  116904. private _preventFreeActiveMeshesAndRenderingGroups;
  116905. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  116906. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  116907. * when disposing several meshes in a row or a hierarchy of meshes.
  116908. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  116909. */
  116910. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  116911. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  116912. /**
  116913. * Clear the active meshes smart array preventing retention point in mesh dispose.
  116914. */
  116915. freeActiveMeshes(): void;
  116916. /**
  116917. * Clear the info related to rendering groups preventing retention points during dispose.
  116918. */
  116919. freeRenderingGroups(): void;
  116920. /** @hidden */
  116921. _isInIntermediateRendering(): boolean;
  116922. /**
  116923. * Lambda returning the list of potentially active meshes.
  116924. */
  116925. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  116926. /**
  116927. * Lambda returning the list of potentially active sub meshes.
  116928. */
  116929. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  116930. /**
  116931. * Lambda returning the list of potentially intersecting sub meshes.
  116932. */
  116933. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  116934. /**
  116935. * Lambda returning the list of potentially colliding sub meshes.
  116936. */
  116937. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  116938. private _activeMeshesFrozen;
  116939. private _skipEvaluateActiveMeshesCompletely;
  116940. /**
  116941. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  116942. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  116943. * @returns the current scene
  116944. */
  116945. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  116946. /**
  116947. * Use this function to restart evaluating active meshes on every frame
  116948. * @returns the current scene
  116949. */
  116950. unfreezeActiveMeshes(): Scene;
  116951. private _evaluateActiveMeshes;
  116952. private _activeMesh;
  116953. /**
  116954. * Update the transform matrix to update from the current active camera
  116955. * @param force defines a boolean used to force the update even if cache is up to date
  116956. */
  116957. updateTransformMatrix(force?: boolean): void;
  116958. private _bindFrameBuffer;
  116959. /** @hidden */
  116960. _allowPostProcessClearColor: boolean;
  116961. /** @hidden */
  116962. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  116963. private _processSubCameras;
  116964. private _checkIntersections;
  116965. /** @hidden */
  116966. _advancePhysicsEngineStep(step: number): void;
  116967. /**
  116968. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  116969. */
  116970. getDeterministicFrameTime: () => number;
  116971. /** @hidden */
  116972. _animate(): void;
  116973. /** Execute all animations (for a frame) */
  116974. animate(): void;
  116975. /**
  116976. * Render the scene
  116977. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  116978. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  116979. */
  116980. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  116981. /**
  116982. * Freeze all materials
  116983. * A frozen material will not be updatable but should be faster to render
  116984. */
  116985. freezeMaterials(): void;
  116986. /**
  116987. * Unfreeze all materials
  116988. * A frozen material will not be updatable but should be faster to render
  116989. */
  116990. unfreezeMaterials(): void;
  116991. /**
  116992. * Releases all held ressources
  116993. */
  116994. dispose(): void;
  116995. /**
  116996. * Gets if the scene is already disposed
  116997. */
  116998. get isDisposed(): boolean;
  116999. /**
  117000. * Call this function to reduce memory footprint of the scene.
  117001. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  117002. */
  117003. clearCachedVertexData(): void;
  117004. /**
  117005. * This function will remove the local cached buffer data from texture.
  117006. * It will save memory but will prevent the texture from being rebuilt
  117007. */
  117008. cleanCachedTextureBuffer(): void;
  117009. /**
  117010. * Get the world extend vectors with an optional filter
  117011. *
  117012. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  117013. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  117014. */
  117015. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  117016. min: Vector3;
  117017. max: Vector3;
  117018. };
  117019. /**
  117020. * Creates a ray that can be used to pick in the scene
  117021. * @param x defines the x coordinate of the origin (on-screen)
  117022. * @param y defines the y coordinate of the origin (on-screen)
  117023. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117024. * @param camera defines the camera to use for the picking
  117025. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117026. * @returns a Ray
  117027. */
  117028. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  117029. /**
  117030. * Creates a ray that can be used to pick in the scene
  117031. * @param x defines the x coordinate of the origin (on-screen)
  117032. * @param y defines the y coordinate of the origin (on-screen)
  117033. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117034. * @param result defines the ray where to store the picking ray
  117035. * @param camera defines the camera to use for the picking
  117036. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117037. * @returns the current scene
  117038. */
  117039. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  117040. /**
  117041. * Creates a ray that can be used to pick in the scene
  117042. * @param x defines the x coordinate of the origin (on-screen)
  117043. * @param y defines the y coordinate of the origin (on-screen)
  117044. * @param camera defines the camera to use for the picking
  117045. * @returns a Ray
  117046. */
  117047. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  117048. /**
  117049. * Creates a ray that can be used to pick in the scene
  117050. * @param x defines the x coordinate of the origin (on-screen)
  117051. * @param y defines the y coordinate of the origin (on-screen)
  117052. * @param result defines the ray where to store the picking ray
  117053. * @param camera defines the camera to use for the picking
  117054. * @returns the current scene
  117055. */
  117056. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  117057. /** Launch a ray to try to pick a mesh in the scene
  117058. * @param x position on screen
  117059. * @param y position on screen
  117060. * @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
  117061. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117062. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117063. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117064. * @returns a PickingInfo
  117065. */
  117066. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117067. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  117068. * @param x position on screen
  117069. * @param y position on screen
  117070. * @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
  117071. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117072. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117073. * @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)
  117074. */
  117075. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  117076. /** Use the given ray to pick a mesh in the scene
  117077. * @param ray The ray to use to pick meshes
  117078. * @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
  117079. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117080. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117081. * @returns a PickingInfo
  117082. */
  117083. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117084. /**
  117085. * Launch a ray to try to pick a mesh in the scene
  117086. * @param x X position on screen
  117087. * @param y Y position on screen
  117088. * @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
  117089. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117090. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117091. * @returns an array of PickingInfo
  117092. */
  117093. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117094. /**
  117095. * Launch a ray to try to pick a mesh in the scene
  117096. * @param ray Ray to use
  117097. * @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
  117098. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117099. * @returns an array of PickingInfo
  117100. */
  117101. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117102. /**
  117103. * Force the value of meshUnderPointer
  117104. * @param mesh defines the mesh to use
  117105. */
  117106. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117107. /**
  117108. * Gets the mesh under the pointer
  117109. * @returns a Mesh or null if no mesh is under the pointer
  117110. */
  117111. getPointerOverMesh(): Nullable<AbstractMesh>;
  117112. /** @hidden */
  117113. _rebuildGeometries(): void;
  117114. /** @hidden */
  117115. _rebuildTextures(): void;
  117116. private _getByTags;
  117117. /**
  117118. * Get a list of meshes by tags
  117119. * @param tagsQuery defines the tags query to use
  117120. * @param forEach defines a predicate used to filter results
  117121. * @returns an array of Mesh
  117122. */
  117123. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  117124. /**
  117125. * Get a list of cameras by tags
  117126. * @param tagsQuery defines the tags query to use
  117127. * @param forEach defines a predicate used to filter results
  117128. * @returns an array of Camera
  117129. */
  117130. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  117131. /**
  117132. * Get a list of lights by tags
  117133. * @param tagsQuery defines the tags query to use
  117134. * @param forEach defines a predicate used to filter results
  117135. * @returns an array of Light
  117136. */
  117137. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  117138. /**
  117139. * Get a list of materials by tags
  117140. * @param tagsQuery defines the tags query to use
  117141. * @param forEach defines a predicate used to filter results
  117142. * @returns an array of Material
  117143. */
  117144. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  117145. /**
  117146. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  117147. * This allowed control for front to back rendering or reversly depending of the special needs.
  117148. *
  117149. * @param renderingGroupId The rendering group id corresponding to its index
  117150. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  117151. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  117152. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  117153. */
  117154. 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;
  117155. /**
  117156. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  117157. *
  117158. * @param renderingGroupId The rendering group id corresponding to its index
  117159. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117160. * @param depth Automatically clears depth between groups if true and autoClear is true.
  117161. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  117162. */
  117163. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  117164. /**
  117165. * Gets the current auto clear configuration for one rendering group of the rendering
  117166. * manager.
  117167. * @param index the rendering group index to get the information for
  117168. * @returns The auto clear setup for the requested rendering group
  117169. */
  117170. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  117171. private _blockMaterialDirtyMechanism;
  117172. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  117173. get blockMaterialDirtyMechanism(): boolean;
  117174. set blockMaterialDirtyMechanism(value: boolean);
  117175. /**
  117176. * Will flag all materials as dirty to trigger new shader compilation
  117177. * @param flag defines the flag used to specify which material part must be marked as dirty
  117178. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  117179. */
  117180. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117181. /** @hidden */
  117182. _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;
  117183. /** @hidden */
  117184. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117185. /** @hidden */
  117186. _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;
  117187. /** @hidden */
  117188. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  117189. /** @hidden */
  117190. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117191. /** @hidden */
  117192. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117193. }
  117194. }
  117195. declare module BABYLON {
  117196. /**
  117197. * Set of assets to keep when moving a scene into an asset container.
  117198. */
  117199. export class KeepAssets extends AbstractScene {
  117200. }
  117201. /**
  117202. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  117203. */
  117204. export class InstantiatedEntries {
  117205. /**
  117206. * List of new root nodes (eg. nodes with no parent)
  117207. */
  117208. rootNodes: TransformNode[];
  117209. /**
  117210. * List of new skeletons
  117211. */
  117212. skeletons: Skeleton[];
  117213. /**
  117214. * List of new animation groups
  117215. */
  117216. animationGroups: AnimationGroup[];
  117217. }
  117218. /**
  117219. * Container with a set of assets that can be added or removed from a scene.
  117220. */
  117221. export class AssetContainer extends AbstractScene {
  117222. private _wasAddedToScene;
  117223. /**
  117224. * The scene the AssetContainer belongs to.
  117225. */
  117226. scene: Scene;
  117227. /**
  117228. * Instantiates an AssetContainer.
  117229. * @param scene The scene the AssetContainer belongs to.
  117230. */
  117231. constructor(scene: Scene);
  117232. /**
  117233. * Instantiate or clone all meshes and add the new ones to the scene.
  117234. * Skeletons and animation groups will all be cloned
  117235. * @param nameFunction defines an optional function used to get new names for clones
  117236. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  117237. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  117238. */
  117239. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  117240. /**
  117241. * Adds all the assets from the container to the scene.
  117242. */
  117243. addAllToScene(): void;
  117244. /**
  117245. * Removes all the assets in the container from the scene
  117246. */
  117247. removeAllFromScene(): void;
  117248. /**
  117249. * Disposes all the assets in the container
  117250. */
  117251. dispose(): void;
  117252. private _moveAssets;
  117253. /**
  117254. * Removes all the assets contained in the scene and adds them to the container.
  117255. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  117256. */
  117257. moveAllFromScene(keepAssets?: KeepAssets): void;
  117258. /**
  117259. * 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.
  117260. * @returns the root mesh
  117261. */
  117262. createRootMesh(): Mesh;
  117263. /**
  117264. * Merge animations (direct and animation groups) from this asset container into a scene
  117265. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117266. * @param animatables set of animatables to retarget to a node from the scene
  117267. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  117268. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  117269. */
  117270. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  117271. }
  117272. }
  117273. declare module BABYLON {
  117274. /**
  117275. * Defines how the parser contract is defined.
  117276. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  117277. */
  117278. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  117279. /**
  117280. * Defines how the individual parser contract is defined.
  117281. * These parser can parse an individual asset
  117282. */
  117283. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  117284. /**
  117285. * Base class of the scene acting as a container for the different elements composing a scene.
  117286. * This class is dynamically extended by the different components of the scene increasing
  117287. * flexibility and reducing coupling
  117288. */
  117289. export abstract class AbstractScene {
  117290. /**
  117291. * Stores the list of available parsers in the application.
  117292. */
  117293. private static _BabylonFileParsers;
  117294. /**
  117295. * Stores the list of available individual parsers in the application.
  117296. */
  117297. private static _IndividualBabylonFileParsers;
  117298. /**
  117299. * Adds a parser in the list of available ones
  117300. * @param name Defines the name of the parser
  117301. * @param parser Defines the parser to add
  117302. */
  117303. static AddParser(name: string, parser: BabylonFileParser): void;
  117304. /**
  117305. * Gets a general parser from the list of avaialble ones
  117306. * @param name Defines the name of the parser
  117307. * @returns the requested parser or null
  117308. */
  117309. static GetParser(name: string): Nullable<BabylonFileParser>;
  117310. /**
  117311. * Adds n individual parser in the list of available ones
  117312. * @param name Defines the name of the parser
  117313. * @param parser Defines the parser to add
  117314. */
  117315. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  117316. /**
  117317. * Gets an individual parser from the list of avaialble ones
  117318. * @param name Defines the name of the parser
  117319. * @returns the requested parser or null
  117320. */
  117321. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  117322. /**
  117323. * Parser json data and populate both a scene and its associated container object
  117324. * @param jsonData Defines the data to parse
  117325. * @param scene Defines the scene to parse the data for
  117326. * @param container Defines the container attached to the parsing sequence
  117327. * @param rootUrl Defines the root url of the data
  117328. */
  117329. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  117330. /**
  117331. * Gets the list of root nodes (ie. nodes with no parent)
  117332. */
  117333. rootNodes: Node[];
  117334. /** All of the cameras added to this scene
  117335. * @see http://doc.babylonjs.com/babylon101/cameras
  117336. */
  117337. cameras: Camera[];
  117338. /**
  117339. * All of the lights added to this scene
  117340. * @see http://doc.babylonjs.com/babylon101/lights
  117341. */
  117342. lights: Light[];
  117343. /**
  117344. * All of the (abstract) meshes added to this scene
  117345. */
  117346. meshes: AbstractMesh[];
  117347. /**
  117348. * The list of skeletons added to the scene
  117349. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  117350. */
  117351. skeletons: Skeleton[];
  117352. /**
  117353. * All of the particle systems added to this scene
  117354. * @see http://doc.babylonjs.com/babylon101/particles
  117355. */
  117356. particleSystems: IParticleSystem[];
  117357. /**
  117358. * Gets a list of Animations associated with the scene
  117359. */
  117360. animations: Animation[];
  117361. /**
  117362. * All of the animation groups added to this scene
  117363. * @see http://doc.babylonjs.com/how_to/group
  117364. */
  117365. animationGroups: AnimationGroup[];
  117366. /**
  117367. * All of the multi-materials added to this scene
  117368. * @see http://doc.babylonjs.com/how_to/multi_materials
  117369. */
  117370. multiMaterials: MultiMaterial[];
  117371. /**
  117372. * All of the materials added to this scene
  117373. * In the context of a Scene, it is not supposed to be modified manually.
  117374. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  117375. * Note also that the order of the Material within the array is not significant and might change.
  117376. * @see http://doc.babylonjs.com/babylon101/materials
  117377. */
  117378. materials: Material[];
  117379. /**
  117380. * The list of morph target managers added to the scene
  117381. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  117382. */
  117383. morphTargetManagers: MorphTargetManager[];
  117384. /**
  117385. * The list of geometries used in the scene.
  117386. */
  117387. geometries: Geometry[];
  117388. /**
  117389. * All of the tranform nodes added to this scene
  117390. * In the context of a Scene, it is not supposed to be modified manually.
  117391. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  117392. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  117393. * @see http://doc.babylonjs.com/how_to/transformnode
  117394. */
  117395. transformNodes: TransformNode[];
  117396. /**
  117397. * ActionManagers available on the scene.
  117398. */
  117399. actionManagers: AbstractActionManager[];
  117400. /**
  117401. * Textures to keep.
  117402. */
  117403. textures: BaseTexture[];
  117404. /**
  117405. * Environment texture for the scene
  117406. */
  117407. environmentTexture: Nullable<BaseTexture>;
  117408. /**
  117409. * @returns all meshes, lights, cameras, transformNodes and bones
  117410. */
  117411. getNodes(): Array<Node>;
  117412. }
  117413. }
  117414. declare module BABYLON {
  117415. /**
  117416. * Interface used to define options for Sound class
  117417. */
  117418. export interface ISoundOptions {
  117419. /**
  117420. * Does the sound autoplay once loaded.
  117421. */
  117422. autoplay?: boolean;
  117423. /**
  117424. * Does the sound loop after it finishes playing once.
  117425. */
  117426. loop?: boolean;
  117427. /**
  117428. * Sound's volume
  117429. */
  117430. volume?: number;
  117431. /**
  117432. * Is it a spatial sound?
  117433. */
  117434. spatialSound?: boolean;
  117435. /**
  117436. * Maximum distance to hear that sound
  117437. */
  117438. maxDistance?: number;
  117439. /**
  117440. * Uses user defined attenuation function
  117441. */
  117442. useCustomAttenuation?: boolean;
  117443. /**
  117444. * Define the roll off factor of spatial sounds.
  117445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117446. */
  117447. rolloffFactor?: number;
  117448. /**
  117449. * Define the reference distance the sound should be heard perfectly.
  117450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117451. */
  117452. refDistance?: number;
  117453. /**
  117454. * Define the distance attenuation model the sound will follow.
  117455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117456. */
  117457. distanceModel?: string;
  117458. /**
  117459. * Defines the playback speed (1 by default)
  117460. */
  117461. playbackRate?: number;
  117462. /**
  117463. * Defines if the sound is from a streaming source
  117464. */
  117465. streaming?: boolean;
  117466. /**
  117467. * Defines an optional length (in seconds) inside the sound file
  117468. */
  117469. length?: number;
  117470. /**
  117471. * Defines an optional offset (in seconds) inside the sound file
  117472. */
  117473. offset?: number;
  117474. /**
  117475. * If true, URLs will not be required to state the audio file codec to use.
  117476. */
  117477. skipCodecCheck?: boolean;
  117478. }
  117479. /**
  117480. * Defines a sound that can be played in the application.
  117481. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  117482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117483. */
  117484. export class Sound {
  117485. /**
  117486. * The name of the sound in the scene.
  117487. */
  117488. name: string;
  117489. /**
  117490. * Does the sound autoplay once loaded.
  117491. */
  117492. autoplay: boolean;
  117493. /**
  117494. * Does the sound loop after it finishes playing once.
  117495. */
  117496. loop: boolean;
  117497. /**
  117498. * Does the sound use a custom attenuation curve to simulate the falloff
  117499. * happening when the source gets further away from the camera.
  117500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117501. */
  117502. useCustomAttenuation: boolean;
  117503. /**
  117504. * The sound track id this sound belongs to.
  117505. */
  117506. soundTrackId: number;
  117507. /**
  117508. * Is this sound currently played.
  117509. */
  117510. isPlaying: boolean;
  117511. /**
  117512. * Is this sound currently paused.
  117513. */
  117514. isPaused: boolean;
  117515. /**
  117516. * Does this sound enables spatial sound.
  117517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117518. */
  117519. spatialSound: boolean;
  117520. /**
  117521. * Define the reference distance the sound should be heard perfectly.
  117522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117523. */
  117524. refDistance: number;
  117525. /**
  117526. * Define the roll off factor of spatial sounds.
  117527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117528. */
  117529. rolloffFactor: number;
  117530. /**
  117531. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  117532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117533. */
  117534. maxDistance: number;
  117535. /**
  117536. * Define the distance attenuation model the sound will follow.
  117537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117538. */
  117539. distanceModel: string;
  117540. /**
  117541. * @hidden
  117542. * Back Compat
  117543. **/
  117544. onended: () => any;
  117545. /**
  117546. * Gets or sets an object used to store user defined information for the sound.
  117547. */
  117548. metadata: any;
  117549. /**
  117550. * Observable event when the current playing sound finishes.
  117551. */
  117552. onEndedObservable: Observable<Sound>;
  117553. private _panningModel;
  117554. private _playbackRate;
  117555. private _streaming;
  117556. private _startTime;
  117557. private _startOffset;
  117558. private _position;
  117559. /** @hidden */
  117560. _positionInEmitterSpace: boolean;
  117561. private _localDirection;
  117562. private _volume;
  117563. private _isReadyToPlay;
  117564. private _isDirectional;
  117565. private _readyToPlayCallback;
  117566. private _audioBuffer;
  117567. private _soundSource;
  117568. private _streamingSource;
  117569. private _soundPanner;
  117570. private _soundGain;
  117571. private _inputAudioNode;
  117572. private _outputAudioNode;
  117573. private _coneInnerAngle;
  117574. private _coneOuterAngle;
  117575. private _coneOuterGain;
  117576. private _scene;
  117577. private _connectedTransformNode;
  117578. private _customAttenuationFunction;
  117579. private _registerFunc;
  117580. private _isOutputConnected;
  117581. private _htmlAudioElement;
  117582. private _urlType;
  117583. private _length?;
  117584. private _offset?;
  117585. /** @hidden */
  117586. static _SceneComponentInitialization: (scene: Scene) => void;
  117587. /**
  117588. * Create a sound and attach it to a scene
  117589. * @param name Name of your sound
  117590. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  117591. * @param scene defines the scene the sound belongs to
  117592. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  117593. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  117594. */
  117595. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  117596. /**
  117597. * Release the sound and its associated resources
  117598. */
  117599. dispose(): void;
  117600. /**
  117601. * Gets if the sounds is ready to be played or not.
  117602. * @returns true if ready, otherwise false
  117603. */
  117604. isReady(): boolean;
  117605. private _soundLoaded;
  117606. /**
  117607. * Sets the data of the sound from an audiobuffer
  117608. * @param audioBuffer The audioBuffer containing the data
  117609. */
  117610. setAudioBuffer(audioBuffer: AudioBuffer): void;
  117611. /**
  117612. * Updates the current sounds options such as maxdistance, loop...
  117613. * @param options A JSON object containing values named as the object properties
  117614. */
  117615. updateOptions(options: ISoundOptions): void;
  117616. private _createSpatialParameters;
  117617. private _updateSpatialParameters;
  117618. /**
  117619. * Switch the panning model to HRTF:
  117620. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  117621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117622. */
  117623. switchPanningModelToHRTF(): void;
  117624. /**
  117625. * Switch the panning model to Equal Power:
  117626. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  117627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117628. */
  117629. switchPanningModelToEqualPower(): void;
  117630. private _switchPanningModel;
  117631. /**
  117632. * Connect this sound to a sound track audio node like gain...
  117633. * @param soundTrackAudioNode the sound track audio node to connect to
  117634. */
  117635. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  117636. /**
  117637. * Transform this sound into a directional source
  117638. * @param coneInnerAngle Size of the inner cone in degree
  117639. * @param coneOuterAngle Size of the outer cone in degree
  117640. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  117641. */
  117642. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  117643. /**
  117644. * Gets or sets the inner angle for the directional cone.
  117645. */
  117646. get directionalConeInnerAngle(): number;
  117647. /**
  117648. * Gets or sets the inner angle for the directional cone.
  117649. */
  117650. set directionalConeInnerAngle(value: number);
  117651. /**
  117652. * Gets or sets the outer angle for the directional cone.
  117653. */
  117654. get directionalConeOuterAngle(): number;
  117655. /**
  117656. * Gets or sets the outer angle for the directional cone.
  117657. */
  117658. set directionalConeOuterAngle(value: number);
  117659. /**
  117660. * Sets the position of the emitter if spatial sound is enabled
  117661. * @param newPosition Defines the new posisiton
  117662. */
  117663. setPosition(newPosition: Vector3): void;
  117664. /**
  117665. * Sets the local direction of the emitter if spatial sound is enabled
  117666. * @param newLocalDirection Defines the new local direction
  117667. */
  117668. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  117669. private _updateDirection;
  117670. /** @hidden */
  117671. updateDistanceFromListener(): void;
  117672. /**
  117673. * Sets a new custom attenuation function for the sound.
  117674. * @param callback Defines the function used for the attenuation
  117675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117676. */
  117677. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  117678. /**
  117679. * Play the sound
  117680. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  117681. * @param offset (optional) Start the sound at a specific time in seconds
  117682. * @param length (optional) Sound duration (in seconds)
  117683. */
  117684. play(time?: number, offset?: number, length?: number): void;
  117685. private _onended;
  117686. /**
  117687. * Stop the sound
  117688. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  117689. */
  117690. stop(time?: number): void;
  117691. /**
  117692. * Put the sound in pause
  117693. */
  117694. pause(): void;
  117695. /**
  117696. * Sets a dedicated volume for this sounds
  117697. * @param newVolume Define the new volume of the sound
  117698. * @param time Define time for gradual change to new volume
  117699. */
  117700. setVolume(newVolume: number, time?: number): void;
  117701. /**
  117702. * Set the sound play back rate
  117703. * @param newPlaybackRate Define the playback rate the sound should be played at
  117704. */
  117705. setPlaybackRate(newPlaybackRate: number): void;
  117706. /**
  117707. * Gets the volume of the sound.
  117708. * @returns the volume of the sound
  117709. */
  117710. getVolume(): number;
  117711. /**
  117712. * Attach the sound to a dedicated mesh
  117713. * @param transformNode The transform node to connect the sound with
  117714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117715. */
  117716. attachToMesh(transformNode: TransformNode): void;
  117717. /**
  117718. * Detach the sound from the previously attached mesh
  117719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117720. */
  117721. detachFromMesh(): void;
  117722. private _onRegisterAfterWorldMatrixUpdate;
  117723. /**
  117724. * Clone the current sound in the scene.
  117725. * @returns the new sound clone
  117726. */
  117727. clone(): Nullable<Sound>;
  117728. /**
  117729. * Gets the current underlying audio buffer containing the data
  117730. * @returns the audio buffer
  117731. */
  117732. getAudioBuffer(): Nullable<AudioBuffer>;
  117733. /**
  117734. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  117735. * @returns the source node
  117736. */
  117737. getSoundSource(): Nullable<AudioBufferSourceNode>;
  117738. /**
  117739. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  117740. * @returns the gain node
  117741. */
  117742. getSoundGain(): Nullable<GainNode>;
  117743. /**
  117744. * Serializes the Sound in a JSON representation
  117745. * @returns the JSON representation of the sound
  117746. */
  117747. serialize(): any;
  117748. /**
  117749. * Parse a JSON representation of a sound to innstantiate in a given scene
  117750. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  117751. * @param scene Define the scene the new parsed sound should be created in
  117752. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  117753. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  117754. * @returns the newly parsed sound
  117755. */
  117756. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  117757. }
  117758. }
  117759. declare module BABYLON {
  117760. /**
  117761. * This defines an action helpful to play a defined sound on a triggered action.
  117762. */
  117763. export class PlaySoundAction extends Action {
  117764. private _sound;
  117765. /**
  117766. * Instantiate the action
  117767. * @param triggerOptions defines the trigger options
  117768. * @param sound defines the sound to play
  117769. * @param condition defines the trigger related conditions
  117770. */
  117771. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117772. /** @hidden */
  117773. _prepare(): void;
  117774. /**
  117775. * Execute the action and play the sound.
  117776. */
  117777. execute(): void;
  117778. /**
  117779. * Serializes the actions and its related information.
  117780. * @param parent defines the object to serialize in
  117781. * @returns the serialized object
  117782. */
  117783. serialize(parent: any): any;
  117784. }
  117785. /**
  117786. * This defines an action helpful to stop a defined sound on a triggered action.
  117787. */
  117788. export class StopSoundAction extends Action {
  117789. private _sound;
  117790. /**
  117791. * Instantiate the action
  117792. * @param triggerOptions defines the trigger options
  117793. * @param sound defines the sound to stop
  117794. * @param condition defines the trigger related conditions
  117795. */
  117796. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117797. /** @hidden */
  117798. _prepare(): void;
  117799. /**
  117800. * Execute the action and stop the sound.
  117801. */
  117802. execute(): void;
  117803. /**
  117804. * Serializes the actions and its related information.
  117805. * @param parent defines the object to serialize in
  117806. * @returns the serialized object
  117807. */
  117808. serialize(parent: any): any;
  117809. }
  117810. }
  117811. declare module BABYLON {
  117812. /**
  117813. * This defines an action responsible to change the value of a property
  117814. * by interpolating between its current value and the newly set one once triggered.
  117815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  117816. */
  117817. export class InterpolateValueAction extends Action {
  117818. /**
  117819. * Defines the path of the property where the value should be interpolated
  117820. */
  117821. propertyPath: string;
  117822. /**
  117823. * Defines the target value at the end of the interpolation.
  117824. */
  117825. value: any;
  117826. /**
  117827. * Defines the time it will take for the property to interpolate to the value.
  117828. */
  117829. duration: number;
  117830. /**
  117831. * Defines if the other scene animations should be stopped when the action has been triggered
  117832. */
  117833. stopOtherAnimations?: boolean;
  117834. /**
  117835. * Defines a callback raised once the interpolation animation has been done.
  117836. */
  117837. onInterpolationDone?: () => void;
  117838. /**
  117839. * Observable triggered once the interpolation animation has been done.
  117840. */
  117841. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  117842. private _target;
  117843. private _effectiveTarget;
  117844. private _property;
  117845. /**
  117846. * Instantiate the action
  117847. * @param triggerOptions defines the trigger options
  117848. * @param target defines the object containing the value to interpolate
  117849. * @param propertyPath defines the path to the property in the target object
  117850. * @param value defines the target value at the end of the interpolation
  117851. * @param duration deines the time it will take for the property to interpolate to the value.
  117852. * @param condition defines the trigger related conditions
  117853. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  117854. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  117855. */
  117856. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  117857. /** @hidden */
  117858. _prepare(): void;
  117859. /**
  117860. * Execute the action starts the value interpolation.
  117861. */
  117862. execute(): void;
  117863. /**
  117864. * Serializes the actions and its related information.
  117865. * @param parent defines the object to serialize in
  117866. * @returns the serialized object
  117867. */
  117868. serialize(parent: any): any;
  117869. }
  117870. }
  117871. declare module BABYLON {
  117872. /**
  117873. * Options allowed during the creation of a sound track.
  117874. */
  117875. export interface ISoundTrackOptions {
  117876. /**
  117877. * The volume the sound track should take during creation
  117878. */
  117879. volume?: number;
  117880. /**
  117881. * Define if the sound track is the main sound track of the scene
  117882. */
  117883. mainTrack?: boolean;
  117884. }
  117885. /**
  117886. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  117887. * It will be also used in a future release to apply effects on a specific track.
  117888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  117889. */
  117890. export class SoundTrack {
  117891. /**
  117892. * The unique identifier of the sound track in the scene.
  117893. */
  117894. id: number;
  117895. /**
  117896. * The list of sounds included in the sound track.
  117897. */
  117898. soundCollection: Array<Sound>;
  117899. private _outputAudioNode;
  117900. private _scene;
  117901. private _connectedAnalyser;
  117902. private _options;
  117903. private _isInitialized;
  117904. /**
  117905. * Creates a new sound track.
  117906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  117907. * @param scene Define the scene the sound track belongs to
  117908. * @param options
  117909. */
  117910. constructor(scene: Scene, options?: ISoundTrackOptions);
  117911. private _initializeSoundTrackAudioGraph;
  117912. /**
  117913. * Release the sound track and its associated resources
  117914. */
  117915. dispose(): void;
  117916. /**
  117917. * Adds a sound to this sound track
  117918. * @param sound define the cound to add
  117919. * @ignoreNaming
  117920. */
  117921. AddSound(sound: Sound): void;
  117922. /**
  117923. * Removes a sound to this sound track
  117924. * @param sound define the cound to remove
  117925. * @ignoreNaming
  117926. */
  117927. RemoveSound(sound: Sound): void;
  117928. /**
  117929. * Set a global volume for the full sound track.
  117930. * @param newVolume Define the new volume of the sound track
  117931. */
  117932. setVolume(newVolume: number): void;
  117933. /**
  117934. * Switch the panning model to HRTF:
  117935. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  117936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117937. */
  117938. switchPanningModelToHRTF(): void;
  117939. /**
  117940. * Switch the panning model to Equal Power:
  117941. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  117942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117943. */
  117944. switchPanningModelToEqualPower(): void;
  117945. /**
  117946. * Connect the sound track to an audio analyser allowing some amazing
  117947. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117949. * @param analyser The analyser to connect to the engine
  117950. */
  117951. connectToAnalyser(analyser: Analyser): void;
  117952. }
  117953. }
  117954. declare module BABYLON {
  117955. interface AbstractScene {
  117956. /**
  117957. * The list of sounds used in the scene.
  117958. */
  117959. sounds: Nullable<Array<Sound>>;
  117960. }
  117961. interface Scene {
  117962. /**
  117963. * @hidden
  117964. * Backing field
  117965. */
  117966. _mainSoundTrack: SoundTrack;
  117967. /**
  117968. * The main sound track played by the scene.
  117969. * It cotains your primary collection of sounds.
  117970. */
  117971. mainSoundTrack: SoundTrack;
  117972. /**
  117973. * The list of sound tracks added to the scene
  117974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117975. */
  117976. soundTracks: Nullable<Array<SoundTrack>>;
  117977. /**
  117978. * Gets a sound using a given name
  117979. * @param name defines the name to search for
  117980. * @return the found sound or null if not found at all.
  117981. */
  117982. getSoundByName(name: string): Nullable<Sound>;
  117983. /**
  117984. * Gets or sets if audio support is enabled
  117985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117986. */
  117987. audioEnabled: boolean;
  117988. /**
  117989. * Gets or sets if audio will be output to headphones
  117990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117991. */
  117992. headphone: boolean;
  117993. /**
  117994. * Gets or sets custom audio listener position provider
  117995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117996. */
  117997. audioListenerPositionProvider: Nullable<() => Vector3>;
  117998. /**
  117999. * Gets or sets a refresh rate when using 3D audio positioning
  118000. */
  118001. audioPositioningRefreshRate: number;
  118002. }
  118003. /**
  118004. * Defines the sound scene component responsible to manage any sounds
  118005. * in a given scene.
  118006. */
  118007. export class AudioSceneComponent implements ISceneSerializableComponent {
  118008. /**
  118009. * The component name helpfull to identify the component in the list of scene components.
  118010. */
  118011. readonly name: string;
  118012. /**
  118013. * The scene the component belongs to.
  118014. */
  118015. scene: Scene;
  118016. private _audioEnabled;
  118017. /**
  118018. * Gets whether audio is enabled or not.
  118019. * Please use related enable/disable method to switch state.
  118020. */
  118021. get audioEnabled(): boolean;
  118022. private _headphone;
  118023. /**
  118024. * Gets whether audio is outputing to headphone or not.
  118025. * Please use the according Switch methods to change output.
  118026. */
  118027. get headphone(): boolean;
  118028. /**
  118029. * Gets or sets a refresh rate when using 3D audio positioning
  118030. */
  118031. audioPositioningRefreshRate: number;
  118032. private _audioListenerPositionProvider;
  118033. /**
  118034. * Gets the current audio listener position provider
  118035. */
  118036. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  118037. /**
  118038. * Sets a custom listener position for all sounds in the scene
  118039. * By default, this is the position of the first active camera
  118040. */
  118041. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  118042. /**
  118043. * Creates a new instance of the component for the given scene
  118044. * @param scene Defines the scene to register the component in
  118045. */
  118046. constructor(scene: Scene);
  118047. /**
  118048. * Registers the component in a given scene
  118049. */
  118050. register(): void;
  118051. /**
  118052. * Rebuilds the elements related to this component in case of
  118053. * context lost for instance.
  118054. */
  118055. rebuild(): void;
  118056. /**
  118057. * Serializes the component data to the specified json object
  118058. * @param serializationObject The object to serialize to
  118059. */
  118060. serialize(serializationObject: any): void;
  118061. /**
  118062. * Adds all the elements from the container to the scene
  118063. * @param container the container holding the elements
  118064. */
  118065. addFromContainer(container: AbstractScene): void;
  118066. /**
  118067. * Removes all the elements in the container from the scene
  118068. * @param container contains the elements to remove
  118069. * @param dispose if the removed element should be disposed (default: false)
  118070. */
  118071. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118072. /**
  118073. * Disposes the component and the associated ressources.
  118074. */
  118075. dispose(): void;
  118076. /**
  118077. * Disables audio in the associated scene.
  118078. */
  118079. disableAudio(): void;
  118080. /**
  118081. * Enables audio in the associated scene.
  118082. */
  118083. enableAudio(): void;
  118084. /**
  118085. * Switch audio to headphone output.
  118086. */
  118087. switchAudioModeForHeadphones(): void;
  118088. /**
  118089. * Switch audio to normal speakers.
  118090. */
  118091. switchAudioModeForNormalSpeakers(): void;
  118092. private _cachedCameraDirection;
  118093. private _cachedCameraPosition;
  118094. private _lastCheck;
  118095. private _afterRender;
  118096. }
  118097. }
  118098. declare module BABYLON {
  118099. /**
  118100. * Wraps one or more Sound objects and selects one with random weight for playback.
  118101. */
  118102. export class WeightedSound {
  118103. /** When true a Sound will be selected and played when the current playing Sound completes. */
  118104. loop: boolean;
  118105. private _coneInnerAngle;
  118106. private _coneOuterAngle;
  118107. private _volume;
  118108. /** A Sound is currently playing. */
  118109. isPlaying: boolean;
  118110. /** A Sound is currently paused. */
  118111. isPaused: boolean;
  118112. private _sounds;
  118113. private _weights;
  118114. private _currentIndex?;
  118115. /**
  118116. * Creates a new WeightedSound from the list of sounds given.
  118117. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  118118. * @param sounds Array of Sounds that will be selected from.
  118119. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  118120. */
  118121. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  118122. /**
  118123. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  118124. */
  118125. get directionalConeInnerAngle(): number;
  118126. /**
  118127. * The size of cone in degress for a directional sound in which there will be no attenuation.
  118128. */
  118129. set directionalConeInnerAngle(value: number);
  118130. /**
  118131. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118132. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118133. */
  118134. get directionalConeOuterAngle(): number;
  118135. /**
  118136. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118137. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118138. */
  118139. set directionalConeOuterAngle(value: number);
  118140. /**
  118141. * Playback volume.
  118142. */
  118143. get volume(): number;
  118144. /**
  118145. * Playback volume.
  118146. */
  118147. set volume(value: number);
  118148. private _onended;
  118149. /**
  118150. * Suspend playback
  118151. */
  118152. pause(): void;
  118153. /**
  118154. * Stop playback
  118155. */
  118156. stop(): void;
  118157. /**
  118158. * Start playback.
  118159. * @param startOffset Position the clip head at a specific time in seconds.
  118160. */
  118161. play(startOffset?: number): void;
  118162. }
  118163. }
  118164. declare module BABYLON {
  118165. /**
  118166. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  118167. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118168. */
  118169. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  118170. /**
  118171. * Gets the name of the behavior.
  118172. */
  118173. get name(): string;
  118174. /**
  118175. * The easing function used by animations
  118176. */
  118177. static EasingFunction: BackEase;
  118178. /**
  118179. * The easing mode used by animations
  118180. */
  118181. static EasingMode: number;
  118182. /**
  118183. * The duration of the animation, in milliseconds
  118184. */
  118185. transitionDuration: number;
  118186. /**
  118187. * Length of the distance animated by the transition when lower radius is reached
  118188. */
  118189. lowerRadiusTransitionRange: number;
  118190. /**
  118191. * Length of the distance animated by the transition when upper radius is reached
  118192. */
  118193. upperRadiusTransitionRange: number;
  118194. private _autoTransitionRange;
  118195. /**
  118196. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118197. */
  118198. get autoTransitionRange(): boolean;
  118199. /**
  118200. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118201. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  118202. */
  118203. set autoTransitionRange(value: boolean);
  118204. private _attachedCamera;
  118205. private _onAfterCheckInputsObserver;
  118206. private _onMeshTargetChangedObserver;
  118207. /**
  118208. * Initializes the behavior.
  118209. */
  118210. init(): void;
  118211. /**
  118212. * Attaches the behavior to its arc rotate camera.
  118213. * @param camera Defines the camera to attach the behavior to
  118214. */
  118215. attach(camera: ArcRotateCamera): void;
  118216. /**
  118217. * Detaches the behavior from its current arc rotate camera.
  118218. */
  118219. detach(): void;
  118220. private _radiusIsAnimating;
  118221. private _radiusBounceTransition;
  118222. private _animatables;
  118223. private _cachedWheelPrecision;
  118224. /**
  118225. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  118226. * @param radiusLimit The limit to check against.
  118227. * @return Bool to indicate if at limit.
  118228. */
  118229. private _isRadiusAtLimit;
  118230. /**
  118231. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  118232. * @param radiusDelta The delta by which to animate to. Can be negative.
  118233. */
  118234. private _applyBoundRadiusAnimation;
  118235. /**
  118236. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  118237. */
  118238. protected _clearAnimationLocks(): void;
  118239. /**
  118240. * Stops and removes all animations that have been applied to the camera
  118241. */
  118242. stopAllAnimations(): void;
  118243. }
  118244. }
  118245. declare module BABYLON {
  118246. /**
  118247. * 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.
  118248. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  118249. */
  118250. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  118251. /**
  118252. * Gets the name of the behavior.
  118253. */
  118254. get name(): string;
  118255. private _mode;
  118256. private _radiusScale;
  118257. private _positionScale;
  118258. private _defaultElevation;
  118259. private _elevationReturnTime;
  118260. private _elevationReturnWaitTime;
  118261. private _zoomStopsAnimation;
  118262. private _framingTime;
  118263. /**
  118264. * The easing function used by animations
  118265. */
  118266. static EasingFunction: ExponentialEase;
  118267. /**
  118268. * The easing mode used by animations
  118269. */
  118270. static EasingMode: number;
  118271. /**
  118272. * Sets the current mode used by the behavior
  118273. */
  118274. set mode(mode: number);
  118275. /**
  118276. * Gets current mode used by the behavior.
  118277. */
  118278. get mode(): number;
  118279. /**
  118280. * Sets the scale applied to the radius (1 by default)
  118281. */
  118282. set radiusScale(radius: number);
  118283. /**
  118284. * Gets the scale applied to the radius
  118285. */
  118286. get radiusScale(): number;
  118287. /**
  118288. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118289. */
  118290. set positionScale(scale: number);
  118291. /**
  118292. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118293. */
  118294. get positionScale(): number;
  118295. /**
  118296. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118297. * behaviour is triggered, in radians.
  118298. */
  118299. set defaultElevation(elevation: number);
  118300. /**
  118301. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118302. * behaviour is triggered, in radians.
  118303. */
  118304. get defaultElevation(): number;
  118305. /**
  118306. * Sets the time (in milliseconds) taken to return to the default beta position.
  118307. * Negative value indicates camera should not return to default.
  118308. */
  118309. set elevationReturnTime(speed: number);
  118310. /**
  118311. * Gets the time (in milliseconds) taken to return to the default beta position.
  118312. * Negative value indicates camera should not return to default.
  118313. */
  118314. get elevationReturnTime(): number;
  118315. /**
  118316. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118317. */
  118318. set elevationReturnWaitTime(time: number);
  118319. /**
  118320. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118321. */
  118322. get elevationReturnWaitTime(): number;
  118323. /**
  118324. * Sets the flag that indicates if user zooming should stop animation.
  118325. */
  118326. set zoomStopsAnimation(flag: boolean);
  118327. /**
  118328. * Gets the flag that indicates if user zooming should stop animation.
  118329. */
  118330. get zoomStopsAnimation(): boolean;
  118331. /**
  118332. * Sets the transition time when framing the mesh, in milliseconds
  118333. */
  118334. set framingTime(time: number);
  118335. /**
  118336. * Gets the transition time when framing the mesh, in milliseconds
  118337. */
  118338. get framingTime(): number;
  118339. /**
  118340. * Define if the behavior should automatically change the configured
  118341. * camera limits and sensibilities.
  118342. */
  118343. autoCorrectCameraLimitsAndSensibility: boolean;
  118344. private _onPrePointerObservableObserver;
  118345. private _onAfterCheckInputsObserver;
  118346. private _onMeshTargetChangedObserver;
  118347. private _attachedCamera;
  118348. private _isPointerDown;
  118349. private _lastInteractionTime;
  118350. /**
  118351. * Initializes the behavior.
  118352. */
  118353. init(): void;
  118354. /**
  118355. * Attaches the behavior to its arc rotate camera.
  118356. * @param camera Defines the camera to attach the behavior to
  118357. */
  118358. attach(camera: ArcRotateCamera): void;
  118359. /**
  118360. * Detaches the behavior from its current arc rotate camera.
  118361. */
  118362. detach(): void;
  118363. private _animatables;
  118364. private _betaIsAnimating;
  118365. private _betaTransition;
  118366. private _radiusTransition;
  118367. private _vectorTransition;
  118368. /**
  118369. * Targets the given mesh and updates zoom level accordingly.
  118370. * @param mesh The mesh to target.
  118371. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118372. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118373. */
  118374. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118375. /**
  118376. * Targets the given mesh with its children and updates zoom level accordingly.
  118377. * @param mesh The mesh to target.
  118378. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118379. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118380. */
  118381. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118382. /**
  118383. * Targets the given meshes with their children and updates zoom level accordingly.
  118384. * @param meshes The mesh to target.
  118385. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118386. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118387. */
  118388. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118389. /**
  118390. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  118391. * @param minimumWorld Determines the smaller position of the bounding box extend
  118392. * @param maximumWorld Determines the bigger position of the bounding box extend
  118393. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118394. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118395. */
  118396. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118397. /**
  118398. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  118399. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  118400. * frustum width.
  118401. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  118402. * to fully enclose the mesh in the viewing frustum.
  118403. */
  118404. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  118405. /**
  118406. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  118407. * is automatically returned to its default position (expected to be above ground plane).
  118408. */
  118409. private _maintainCameraAboveGround;
  118410. /**
  118411. * Returns the frustum slope based on the canvas ratio and camera FOV
  118412. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  118413. */
  118414. private _getFrustumSlope;
  118415. /**
  118416. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  118417. */
  118418. private _clearAnimationLocks;
  118419. /**
  118420. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  118421. */
  118422. private _applyUserInteraction;
  118423. /**
  118424. * Stops and removes all animations that have been applied to the camera
  118425. */
  118426. stopAllAnimations(): void;
  118427. /**
  118428. * Gets a value indicating if the user is moving the camera
  118429. */
  118430. get isUserIsMoving(): boolean;
  118431. /**
  118432. * The camera can move all the way towards the mesh.
  118433. */
  118434. static IgnoreBoundsSizeMode: number;
  118435. /**
  118436. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  118437. */
  118438. static FitFrustumSidesMode: number;
  118439. }
  118440. }
  118441. declare module BABYLON {
  118442. /**
  118443. * Base class for Camera Pointer Inputs.
  118444. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  118445. * for example usage.
  118446. */
  118447. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  118448. /**
  118449. * Defines the camera the input is attached to.
  118450. */
  118451. abstract camera: Camera;
  118452. /**
  118453. * Whether keyboard modifier keys are pressed at time of last mouse event.
  118454. */
  118455. protected _altKey: boolean;
  118456. protected _ctrlKey: boolean;
  118457. protected _metaKey: boolean;
  118458. protected _shiftKey: boolean;
  118459. /**
  118460. * Which mouse buttons were pressed at time of last mouse event.
  118461. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  118462. */
  118463. protected _buttonsPressed: number;
  118464. /**
  118465. * Defines the buttons associated with the input to handle camera move.
  118466. */
  118467. buttons: number[];
  118468. /**
  118469. * Attach the input controls to a specific dom element to get the input from.
  118470. * @param element Defines the element the controls should be listened from
  118471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118472. */
  118473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118474. /**
  118475. * Detach the current controls from the specified dom element.
  118476. * @param element Defines the element to stop listening the inputs from
  118477. */
  118478. detachControl(element: Nullable<HTMLElement>): void;
  118479. /**
  118480. * Gets the class name of the current input.
  118481. * @returns the class name
  118482. */
  118483. getClassName(): string;
  118484. /**
  118485. * Get the friendly name associated with the input class.
  118486. * @returns the input friendly name
  118487. */
  118488. getSimpleName(): string;
  118489. /**
  118490. * Called on pointer POINTERDOUBLETAP event.
  118491. * Override this method to provide functionality on POINTERDOUBLETAP event.
  118492. */
  118493. protected onDoubleTap(type: string): void;
  118494. /**
  118495. * Called on pointer POINTERMOVE event if only a single touch is active.
  118496. * Override this method to provide functionality.
  118497. */
  118498. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118499. /**
  118500. * Called on pointer POINTERMOVE event if multiple touches are active.
  118501. * Override this method to provide functionality.
  118502. */
  118503. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118504. /**
  118505. * Called on JS contextmenu event.
  118506. * Override this method to provide functionality.
  118507. */
  118508. protected onContextMenu(evt: PointerEvent): void;
  118509. /**
  118510. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118511. * press.
  118512. * Override this method to provide functionality.
  118513. */
  118514. protected onButtonDown(evt: PointerEvent): void;
  118515. /**
  118516. * Called each time a new POINTERUP event occurs. Ie, for each button
  118517. * release.
  118518. * Override this method to provide functionality.
  118519. */
  118520. protected onButtonUp(evt: PointerEvent): void;
  118521. /**
  118522. * Called when window becomes inactive.
  118523. * Override this method to provide functionality.
  118524. */
  118525. protected onLostFocus(): void;
  118526. private _pointerInput;
  118527. private _observer;
  118528. private _onLostFocus;
  118529. private pointA;
  118530. private pointB;
  118531. }
  118532. }
  118533. declare module BABYLON {
  118534. /**
  118535. * Manage the pointers inputs to control an arc rotate camera.
  118536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118537. */
  118538. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  118539. /**
  118540. * Defines the camera the input is attached to.
  118541. */
  118542. camera: ArcRotateCamera;
  118543. /**
  118544. * Gets the class name of the current input.
  118545. * @returns the class name
  118546. */
  118547. getClassName(): string;
  118548. /**
  118549. * Defines the buttons associated with the input to handle camera move.
  118550. */
  118551. buttons: number[];
  118552. /**
  118553. * Defines the pointer angular sensibility along the X axis or how fast is
  118554. * the camera rotating.
  118555. */
  118556. angularSensibilityX: number;
  118557. /**
  118558. * Defines the pointer angular sensibility along the Y axis or how fast is
  118559. * the camera rotating.
  118560. */
  118561. angularSensibilityY: number;
  118562. /**
  118563. * Defines the pointer pinch precision or how fast is the camera zooming.
  118564. */
  118565. pinchPrecision: number;
  118566. /**
  118567. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  118568. * from 0.
  118569. * It defines the percentage of current camera.radius to use as delta when
  118570. * pinch zoom is used.
  118571. */
  118572. pinchDeltaPercentage: number;
  118573. /**
  118574. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  118575. * that any object in the plane at the camera's target point will scale
  118576. * perfectly with finger motion.
  118577. * Overrides pinchDeltaPercentage and pinchPrecision.
  118578. */
  118579. useNaturalPinchZoom: boolean;
  118580. /**
  118581. * Defines the pointer panning sensibility or how fast is the camera moving.
  118582. */
  118583. panningSensibility: number;
  118584. /**
  118585. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  118586. */
  118587. multiTouchPanning: boolean;
  118588. /**
  118589. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  118590. * zoom (pinch) through multitouch.
  118591. */
  118592. multiTouchPanAndZoom: boolean;
  118593. /**
  118594. * Revers pinch action direction.
  118595. */
  118596. pinchInwards: boolean;
  118597. private _isPanClick;
  118598. private _twoFingerActivityCount;
  118599. private _isPinching;
  118600. /**
  118601. * Called on pointer POINTERMOVE event if only a single touch is active.
  118602. */
  118603. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118604. /**
  118605. * Called on pointer POINTERDOUBLETAP event.
  118606. */
  118607. protected onDoubleTap(type: string): void;
  118608. /**
  118609. * Called on pointer POINTERMOVE event if multiple touches are active.
  118610. */
  118611. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118612. /**
  118613. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118614. * press.
  118615. */
  118616. protected onButtonDown(evt: PointerEvent): void;
  118617. /**
  118618. * Called each time a new POINTERUP event occurs. Ie, for each button
  118619. * release.
  118620. */
  118621. protected onButtonUp(evt: PointerEvent): void;
  118622. /**
  118623. * Called when window becomes inactive.
  118624. */
  118625. protected onLostFocus(): void;
  118626. }
  118627. }
  118628. declare module BABYLON {
  118629. /**
  118630. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  118631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118632. */
  118633. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  118634. /**
  118635. * Defines the camera the input is attached to.
  118636. */
  118637. camera: ArcRotateCamera;
  118638. /**
  118639. * Defines the list of key codes associated with the up action (increase alpha)
  118640. */
  118641. keysUp: number[];
  118642. /**
  118643. * Defines the list of key codes associated with the down action (decrease alpha)
  118644. */
  118645. keysDown: number[];
  118646. /**
  118647. * Defines the list of key codes associated with the left action (increase beta)
  118648. */
  118649. keysLeft: number[];
  118650. /**
  118651. * Defines the list of key codes associated with the right action (decrease beta)
  118652. */
  118653. keysRight: number[];
  118654. /**
  118655. * Defines the list of key codes associated with the reset action.
  118656. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  118657. */
  118658. keysReset: number[];
  118659. /**
  118660. * Defines the panning sensibility of the inputs.
  118661. * (How fast is the camera panning)
  118662. */
  118663. panningSensibility: number;
  118664. /**
  118665. * Defines the zooming sensibility of the inputs.
  118666. * (How fast is the camera zooming)
  118667. */
  118668. zoomingSensibility: number;
  118669. /**
  118670. * Defines whether maintaining the alt key down switch the movement mode from
  118671. * orientation to zoom.
  118672. */
  118673. useAltToZoom: boolean;
  118674. /**
  118675. * Rotation speed of the camera
  118676. */
  118677. angularSpeed: number;
  118678. private _keys;
  118679. private _ctrlPressed;
  118680. private _altPressed;
  118681. private _onCanvasBlurObserver;
  118682. private _onKeyboardObserver;
  118683. private _engine;
  118684. private _scene;
  118685. /**
  118686. * Attach the input controls to a specific dom element to get the input from.
  118687. * @param element Defines the element the controls should be listened from
  118688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118689. */
  118690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118691. /**
  118692. * Detach the current controls from the specified dom element.
  118693. * @param element Defines the element to stop listening the inputs from
  118694. */
  118695. detachControl(element: Nullable<HTMLElement>): void;
  118696. /**
  118697. * Update the current camera state depending on the inputs that have been used this frame.
  118698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  118699. */
  118700. checkInputs(): void;
  118701. /**
  118702. * Gets the class name of the current intput.
  118703. * @returns the class name
  118704. */
  118705. getClassName(): string;
  118706. /**
  118707. * Get the friendly name associated with the input class.
  118708. * @returns the input friendly name
  118709. */
  118710. getSimpleName(): string;
  118711. }
  118712. }
  118713. declare module BABYLON {
  118714. /**
  118715. * Manage the mouse wheel inputs to control an arc rotate camera.
  118716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118717. */
  118718. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  118719. /**
  118720. * Defines the camera the input is attached to.
  118721. */
  118722. camera: ArcRotateCamera;
  118723. /**
  118724. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  118725. */
  118726. wheelPrecision: number;
  118727. /**
  118728. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  118729. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  118730. */
  118731. wheelDeltaPercentage: number;
  118732. private _wheel;
  118733. private _observer;
  118734. private computeDeltaFromMouseWheelLegacyEvent;
  118735. /**
  118736. * Attach the input controls to a specific dom element to get the input from.
  118737. * @param element Defines the element the controls should be listened from
  118738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118739. */
  118740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118741. /**
  118742. * Detach the current controls from the specified dom element.
  118743. * @param element Defines the element to stop listening the inputs from
  118744. */
  118745. detachControl(element: Nullable<HTMLElement>): void;
  118746. /**
  118747. * Gets the class name of the current intput.
  118748. * @returns the class name
  118749. */
  118750. getClassName(): string;
  118751. /**
  118752. * Get the friendly name associated with the input class.
  118753. * @returns the input friendly name
  118754. */
  118755. getSimpleName(): string;
  118756. }
  118757. }
  118758. declare module BABYLON {
  118759. /**
  118760. * Default Inputs manager for the ArcRotateCamera.
  118761. * It groups all the default supported inputs for ease of use.
  118762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118763. */
  118764. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  118765. /**
  118766. * Instantiates a new ArcRotateCameraInputsManager.
  118767. * @param camera Defines the camera the inputs belong to
  118768. */
  118769. constructor(camera: ArcRotateCamera);
  118770. /**
  118771. * Add mouse wheel input support to the input manager.
  118772. * @returns the current input manager
  118773. */
  118774. addMouseWheel(): ArcRotateCameraInputsManager;
  118775. /**
  118776. * Add pointers input support to the input manager.
  118777. * @returns the current input manager
  118778. */
  118779. addPointers(): ArcRotateCameraInputsManager;
  118780. /**
  118781. * Add keyboard input support to the input manager.
  118782. * @returns the current input manager
  118783. */
  118784. addKeyboard(): ArcRotateCameraInputsManager;
  118785. }
  118786. }
  118787. declare module BABYLON {
  118788. /**
  118789. * This represents an orbital type of camera.
  118790. *
  118791. * 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.
  118792. * 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.
  118793. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  118794. */
  118795. export class ArcRotateCamera extends TargetCamera {
  118796. /**
  118797. * Defines the rotation angle of the camera along the longitudinal axis.
  118798. */
  118799. alpha: number;
  118800. /**
  118801. * Defines the rotation angle of the camera along the latitudinal axis.
  118802. */
  118803. beta: number;
  118804. /**
  118805. * Defines the radius of the camera from it s target point.
  118806. */
  118807. radius: number;
  118808. protected _target: Vector3;
  118809. protected _targetHost: Nullable<AbstractMesh>;
  118810. /**
  118811. * Defines the target point of the camera.
  118812. * The camera looks towards it form the radius distance.
  118813. */
  118814. get target(): Vector3;
  118815. set target(value: Vector3);
  118816. /**
  118817. * Define the current local position of the camera in the scene
  118818. */
  118819. get position(): Vector3;
  118820. set position(newPosition: Vector3);
  118821. protected _upVector: Vector3;
  118822. protected _upToYMatrix: Matrix;
  118823. protected _YToUpMatrix: Matrix;
  118824. /**
  118825. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  118826. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  118827. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  118828. */
  118829. set upVector(vec: Vector3);
  118830. get upVector(): Vector3;
  118831. /**
  118832. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  118833. */
  118834. setMatUp(): void;
  118835. /**
  118836. * Current inertia value on the longitudinal axis.
  118837. * The bigger this number the longer it will take for the camera to stop.
  118838. */
  118839. inertialAlphaOffset: number;
  118840. /**
  118841. * Current inertia value on the latitudinal axis.
  118842. * The bigger this number the longer it will take for the camera to stop.
  118843. */
  118844. inertialBetaOffset: number;
  118845. /**
  118846. * Current inertia value on the radius axis.
  118847. * The bigger this number the longer it will take for the camera to stop.
  118848. */
  118849. inertialRadiusOffset: number;
  118850. /**
  118851. * Minimum allowed angle on the longitudinal axis.
  118852. * This can help limiting how the Camera is able to move in the scene.
  118853. */
  118854. lowerAlphaLimit: Nullable<number>;
  118855. /**
  118856. * Maximum allowed angle on the longitudinal axis.
  118857. * This can help limiting how the Camera is able to move in the scene.
  118858. */
  118859. upperAlphaLimit: Nullable<number>;
  118860. /**
  118861. * Minimum allowed angle on the latitudinal axis.
  118862. * This can help limiting how the Camera is able to move in the scene.
  118863. */
  118864. lowerBetaLimit: number;
  118865. /**
  118866. * Maximum allowed angle on the latitudinal axis.
  118867. * This can help limiting how the Camera is able to move in the scene.
  118868. */
  118869. upperBetaLimit: number;
  118870. /**
  118871. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  118872. * This can help limiting how the Camera is able to move in the scene.
  118873. */
  118874. lowerRadiusLimit: Nullable<number>;
  118875. /**
  118876. * Maximum allowed distance of the camera to the target (The camera can not get further).
  118877. * This can help limiting how the Camera is able to move in the scene.
  118878. */
  118879. upperRadiusLimit: Nullable<number>;
  118880. /**
  118881. * Defines the current inertia value used during panning of the camera along the X axis.
  118882. */
  118883. inertialPanningX: number;
  118884. /**
  118885. * Defines the current inertia value used during panning of the camera along the Y axis.
  118886. */
  118887. inertialPanningY: number;
  118888. /**
  118889. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  118890. * Basically if your fingers moves away from more than this distance you will be considered
  118891. * in pinch mode.
  118892. */
  118893. pinchToPanMaxDistance: number;
  118894. /**
  118895. * Defines the maximum distance the camera can pan.
  118896. * This could help keeping the cammera always in your scene.
  118897. */
  118898. panningDistanceLimit: Nullable<number>;
  118899. /**
  118900. * Defines the target of the camera before paning.
  118901. */
  118902. panningOriginTarget: Vector3;
  118903. /**
  118904. * Defines the value of the inertia used during panning.
  118905. * 0 would mean stop inertia and one would mean no decelleration at all.
  118906. */
  118907. panningInertia: number;
  118908. /**
  118909. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  118910. */
  118911. get angularSensibilityX(): number;
  118912. set angularSensibilityX(value: number);
  118913. /**
  118914. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  118915. */
  118916. get angularSensibilityY(): number;
  118917. set angularSensibilityY(value: number);
  118918. /**
  118919. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  118920. */
  118921. get pinchPrecision(): number;
  118922. set pinchPrecision(value: number);
  118923. /**
  118924. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  118925. * It will be used instead of pinchDeltaPrecision if different from 0.
  118926. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  118927. */
  118928. get pinchDeltaPercentage(): number;
  118929. set pinchDeltaPercentage(value: number);
  118930. /**
  118931. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  118932. * and pinch delta percentage.
  118933. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  118934. * that any object in the plane at the camera's target point will scale
  118935. * perfectly with finger motion.
  118936. */
  118937. get useNaturalPinchZoom(): boolean;
  118938. set useNaturalPinchZoom(value: boolean);
  118939. /**
  118940. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  118941. */
  118942. get panningSensibility(): number;
  118943. set panningSensibility(value: number);
  118944. /**
  118945. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  118946. */
  118947. get keysUp(): number[];
  118948. set keysUp(value: number[]);
  118949. /**
  118950. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  118951. */
  118952. get keysDown(): number[];
  118953. set keysDown(value: number[]);
  118954. /**
  118955. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  118956. */
  118957. get keysLeft(): number[];
  118958. set keysLeft(value: number[]);
  118959. /**
  118960. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  118961. */
  118962. get keysRight(): number[];
  118963. set keysRight(value: number[]);
  118964. /**
  118965. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  118966. */
  118967. get wheelPrecision(): number;
  118968. set wheelPrecision(value: number);
  118969. /**
  118970. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  118971. * It will be used instead of pinchDeltaPrecision if different from 0.
  118972. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  118973. */
  118974. get wheelDeltaPercentage(): number;
  118975. set wheelDeltaPercentage(value: number);
  118976. /**
  118977. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  118978. */
  118979. zoomOnFactor: number;
  118980. /**
  118981. * Defines a screen offset for the camera position.
  118982. */
  118983. targetScreenOffset: Vector2;
  118984. /**
  118985. * Allows the camera to be completely reversed.
  118986. * If false the camera can not arrive upside down.
  118987. */
  118988. allowUpsideDown: boolean;
  118989. /**
  118990. * Define if double tap/click is used to restore the previously saved state of the camera.
  118991. */
  118992. useInputToRestoreState: boolean;
  118993. /** @hidden */
  118994. _viewMatrix: Matrix;
  118995. /** @hidden */
  118996. _useCtrlForPanning: boolean;
  118997. /** @hidden */
  118998. _panningMouseButton: number;
  118999. /**
  119000. * Defines the input associated to the camera.
  119001. */
  119002. inputs: ArcRotateCameraInputsManager;
  119003. /** @hidden */
  119004. _reset: () => void;
  119005. /**
  119006. * Defines the allowed panning axis.
  119007. */
  119008. panningAxis: Vector3;
  119009. protected _localDirection: Vector3;
  119010. protected _transformedDirection: Vector3;
  119011. private _bouncingBehavior;
  119012. /**
  119013. * Gets the bouncing behavior of the camera if it has been enabled.
  119014. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119015. */
  119016. get bouncingBehavior(): Nullable<BouncingBehavior>;
  119017. /**
  119018. * Defines if the bouncing behavior of the camera is enabled on the camera.
  119019. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119020. */
  119021. get useBouncingBehavior(): boolean;
  119022. set useBouncingBehavior(value: boolean);
  119023. private _framingBehavior;
  119024. /**
  119025. * Gets the framing behavior of the camera if it has been enabled.
  119026. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119027. */
  119028. get framingBehavior(): Nullable<FramingBehavior>;
  119029. /**
  119030. * Defines if the framing behavior of the camera is enabled on the camera.
  119031. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119032. */
  119033. get useFramingBehavior(): boolean;
  119034. set useFramingBehavior(value: boolean);
  119035. private _autoRotationBehavior;
  119036. /**
  119037. * Gets the auto rotation behavior of the camera if it has been enabled.
  119038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119039. */
  119040. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  119041. /**
  119042. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  119043. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119044. */
  119045. get useAutoRotationBehavior(): boolean;
  119046. set useAutoRotationBehavior(value: boolean);
  119047. /**
  119048. * Observable triggered when the mesh target has been changed on the camera.
  119049. */
  119050. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  119051. /**
  119052. * Event raised when the camera is colliding with a mesh.
  119053. */
  119054. onCollide: (collidedMesh: AbstractMesh) => void;
  119055. /**
  119056. * Defines whether the camera should check collision with the objects oh the scene.
  119057. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  119058. */
  119059. checkCollisions: boolean;
  119060. /**
  119061. * Defines the collision radius of the camera.
  119062. * This simulates a sphere around the camera.
  119063. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119064. */
  119065. collisionRadius: Vector3;
  119066. protected _collider: Collider;
  119067. protected _previousPosition: Vector3;
  119068. protected _collisionVelocity: Vector3;
  119069. protected _newPosition: Vector3;
  119070. protected _previousAlpha: number;
  119071. protected _previousBeta: number;
  119072. protected _previousRadius: number;
  119073. protected _collisionTriggered: boolean;
  119074. protected _targetBoundingCenter: Nullable<Vector3>;
  119075. private _computationVector;
  119076. /**
  119077. * Instantiates a new ArcRotateCamera in a given scene
  119078. * @param name Defines the name of the camera
  119079. * @param alpha Defines the camera rotation along the logitudinal axis
  119080. * @param beta Defines the camera rotation along the latitudinal axis
  119081. * @param radius Defines the camera distance from its target
  119082. * @param target Defines the camera target
  119083. * @param scene Defines the scene the camera belongs to
  119084. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  119085. */
  119086. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  119087. /** @hidden */
  119088. _initCache(): void;
  119089. /** @hidden */
  119090. _updateCache(ignoreParentClass?: boolean): void;
  119091. protected _getTargetPosition(): Vector3;
  119092. private _storedAlpha;
  119093. private _storedBeta;
  119094. private _storedRadius;
  119095. private _storedTarget;
  119096. private _storedTargetScreenOffset;
  119097. /**
  119098. * Stores the current state of the camera (alpha, beta, radius and target)
  119099. * @returns the camera itself
  119100. */
  119101. storeState(): Camera;
  119102. /**
  119103. * @hidden
  119104. * Restored camera state. You must call storeState() first
  119105. */
  119106. _restoreStateValues(): boolean;
  119107. /** @hidden */
  119108. _isSynchronizedViewMatrix(): boolean;
  119109. /**
  119110. * Attached controls to the current camera.
  119111. * @param element Defines the element the controls should be listened from
  119112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119113. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  119114. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  119115. */
  119116. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  119117. /**
  119118. * Detach the current controls from the camera.
  119119. * The camera will stop reacting to inputs.
  119120. * @param element Defines the element to stop listening the inputs from
  119121. */
  119122. detachControl(element: HTMLElement): void;
  119123. /** @hidden */
  119124. _checkInputs(): void;
  119125. protected _checkLimits(): void;
  119126. /**
  119127. * Rebuilds angles (alpha, beta) and radius from the give position and target
  119128. */
  119129. rebuildAnglesAndRadius(): void;
  119130. /**
  119131. * Use a position to define the current camera related information like alpha, beta and radius
  119132. * @param position Defines the position to set the camera at
  119133. */
  119134. setPosition(position: Vector3): void;
  119135. /**
  119136. * Defines the target the camera should look at.
  119137. * This will automatically adapt alpha beta and radius to fit within the new target.
  119138. * @param target Defines the new target as a Vector or a mesh
  119139. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  119140. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  119141. */
  119142. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  119143. /** @hidden */
  119144. _getViewMatrix(): Matrix;
  119145. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  119146. /**
  119147. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  119148. * @param meshes Defines the mesh to zoom on
  119149. * @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)
  119150. */
  119151. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  119152. /**
  119153. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  119154. * The target will be changed but the radius
  119155. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  119156. * @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)
  119157. */
  119158. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  119159. min: Vector3;
  119160. max: Vector3;
  119161. distance: number;
  119162. }, doNotUpdateMaxZ?: boolean): void;
  119163. /**
  119164. * @override
  119165. * Override Camera.createRigCamera
  119166. */
  119167. createRigCamera(name: string, cameraIndex: number): Camera;
  119168. /**
  119169. * @hidden
  119170. * @override
  119171. * Override Camera._updateRigCameras
  119172. */
  119173. _updateRigCameras(): void;
  119174. /**
  119175. * Destroy the camera and release the current resources hold by it.
  119176. */
  119177. dispose(): void;
  119178. /**
  119179. * Gets the current object class name.
  119180. * @return the class name
  119181. */
  119182. getClassName(): string;
  119183. }
  119184. }
  119185. declare module BABYLON {
  119186. /**
  119187. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  119188. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119189. */
  119190. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  119191. /**
  119192. * Gets the name of the behavior.
  119193. */
  119194. get name(): string;
  119195. private _zoomStopsAnimation;
  119196. private _idleRotationSpeed;
  119197. private _idleRotationWaitTime;
  119198. private _idleRotationSpinupTime;
  119199. /**
  119200. * Sets the flag that indicates if user zooming should stop animation.
  119201. */
  119202. set zoomStopsAnimation(flag: boolean);
  119203. /**
  119204. * Gets the flag that indicates if user zooming should stop animation.
  119205. */
  119206. get zoomStopsAnimation(): boolean;
  119207. /**
  119208. * Sets the default speed at which the camera rotates around the model.
  119209. */
  119210. set idleRotationSpeed(speed: number);
  119211. /**
  119212. * Gets the default speed at which the camera rotates around the model.
  119213. */
  119214. get idleRotationSpeed(): number;
  119215. /**
  119216. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  119217. */
  119218. set idleRotationWaitTime(time: number);
  119219. /**
  119220. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  119221. */
  119222. get idleRotationWaitTime(): number;
  119223. /**
  119224. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119225. */
  119226. set idleRotationSpinupTime(time: number);
  119227. /**
  119228. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119229. */
  119230. get idleRotationSpinupTime(): number;
  119231. /**
  119232. * Gets a value indicating if the camera is currently rotating because of this behavior
  119233. */
  119234. get rotationInProgress(): boolean;
  119235. private _onPrePointerObservableObserver;
  119236. private _onAfterCheckInputsObserver;
  119237. private _attachedCamera;
  119238. private _isPointerDown;
  119239. private _lastFrameTime;
  119240. private _lastInteractionTime;
  119241. private _cameraRotationSpeed;
  119242. /**
  119243. * Initializes the behavior.
  119244. */
  119245. init(): void;
  119246. /**
  119247. * Attaches the behavior to its arc rotate camera.
  119248. * @param camera Defines the camera to attach the behavior to
  119249. */
  119250. attach(camera: ArcRotateCamera): void;
  119251. /**
  119252. * Detaches the behavior from its current arc rotate camera.
  119253. */
  119254. detach(): void;
  119255. /**
  119256. * Returns true if user is scrolling.
  119257. * @return true if user is scrolling.
  119258. */
  119259. private _userIsZooming;
  119260. private _lastFrameRadius;
  119261. private _shouldAnimationStopForInteraction;
  119262. /**
  119263. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119264. */
  119265. private _applyUserInteraction;
  119266. private _userIsMoving;
  119267. }
  119268. }
  119269. declare module BABYLON {
  119270. /**
  119271. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  119272. */
  119273. export class AttachToBoxBehavior implements Behavior<Mesh> {
  119274. private ui;
  119275. /**
  119276. * The name of the behavior
  119277. */
  119278. name: string;
  119279. /**
  119280. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  119281. */
  119282. distanceAwayFromFace: number;
  119283. /**
  119284. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  119285. */
  119286. distanceAwayFromBottomOfFace: number;
  119287. private _faceVectors;
  119288. private _target;
  119289. private _scene;
  119290. private _onRenderObserver;
  119291. private _tmpMatrix;
  119292. private _tmpVector;
  119293. /**
  119294. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  119295. * @param ui The transform node that should be attched to the mesh
  119296. */
  119297. constructor(ui: TransformNode);
  119298. /**
  119299. * Initializes the behavior
  119300. */
  119301. init(): void;
  119302. private _closestFace;
  119303. private _zeroVector;
  119304. private _lookAtTmpMatrix;
  119305. private _lookAtToRef;
  119306. /**
  119307. * Attaches the AttachToBoxBehavior to the passed in mesh
  119308. * @param target The mesh that the specified node will be attached to
  119309. */
  119310. attach(target: Mesh): void;
  119311. /**
  119312. * Detaches the behavior from the mesh
  119313. */
  119314. detach(): void;
  119315. }
  119316. }
  119317. declare module BABYLON {
  119318. /**
  119319. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  119320. */
  119321. export class FadeInOutBehavior implements Behavior<Mesh> {
  119322. /**
  119323. * Time in milliseconds to delay before fading in (Default: 0)
  119324. */
  119325. delay: number;
  119326. /**
  119327. * Time in milliseconds for the mesh to fade in (Default: 300)
  119328. */
  119329. fadeInTime: number;
  119330. private _millisecondsPerFrame;
  119331. private _hovered;
  119332. private _hoverValue;
  119333. private _ownerNode;
  119334. /**
  119335. * Instatiates the FadeInOutBehavior
  119336. */
  119337. constructor();
  119338. /**
  119339. * The name of the behavior
  119340. */
  119341. get name(): string;
  119342. /**
  119343. * Initializes the behavior
  119344. */
  119345. init(): void;
  119346. /**
  119347. * Attaches the fade behavior on the passed in mesh
  119348. * @param ownerNode The mesh that will be faded in/out once attached
  119349. */
  119350. attach(ownerNode: Mesh): void;
  119351. /**
  119352. * Detaches the behavior from the mesh
  119353. */
  119354. detach(): void;
  119355. /**
  119356. * Triggers the mesh to begin fading in or out
  119357. * @param value if the object should fade in or out (true to fade in)
  119358. */
  119359. fadeIn(value: boolean): void;
  119360. private _update;
  119361. private _setAllVisibility;
  119362. }
  119363. }
  119364. declare module BABYLON {
  119365. /**
  119366. * Class containing a set of static utilities functions for managing Pivots
  119367. * @hidden
  119368. */
  119369. export class PivotTools {
  119370. private static _PivotCached;
  119371. private static _OldPivotPoint;
  119372. private static _PivotTranslation;
  119373. private static _PivotTmpVector;
  119374. /** @hidden */
  119375. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  119376. /** @hidden */
  119377. static _RestorePivotPoint(mesh: AbstractMesh): void;
  119378. }
  119379. }
  119380. declare module BABYLON {
  119381. /**
  119382. * Class containing static functions to help procedurally build meshes
  119383. */
  119384. export class PlaneBuilder {
  119385. /**
  119386. * Creates a plane mesh
  119387. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  119388. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  119389. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  119390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119393. * @param name defines the name of the mesh
  119394. * @param options defines the options used to create the mesh
  119395. * @param scene defines the hosting scene
  119396. * @returns the plane mesh
  119397. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119398. */
  119399. static CreatePlane(name: string, options: {
  119400. size?: number;
  119401. width?: number;
  119402. height?: number;
  119403. sideOrientation?: number;
  119404. frontUVs?: Vector4;
  119405. backUVs?: Vector4;
  119406. updatable?: boolean;
  119407. sourcePlane?: Plane;
  119408. }, scene?: Nullable<Scene>): Mesh;
  119409. }
  119410. }
  119411. declare module BABYLON {
  119412. /**
  119413. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  119414. */
  119415. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  119416. private static _AnyMouseID;
  119417. /**
  119418. * Abstract mesh the behavior is set on
  119419. */
  119420. attachedNode: AbstractMesh;
  119421. private _dragPlane;
  119422. private _scene;
  119423. private _pointerObserver;
  119424. private _beforeRenderObserver;
  119425. private static _planeScene;
  119426. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  119427. /**
  119428. * 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)
  119429. */
  119430. maxDragAngle: number;
  119431. /**
  119432. * @hidden
  119433. */
  119434. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  119435. /**
  119436. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119437. */
  119438. currentDraggingPointerID: number;
  119439. /**
  119440. * The last position where the pointer hit the drag plane in world space
  119441. */
  119442. lastDragPosition: Vector3;
  119443. /**
  119444. * If the behavior is currently in a dragging state
  119445. */
  119446. dragging: boolean;
  119447. /**
  119448. * 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)
  119449. */
  119450. dragDeltaRatio: number;
  119451. /**
  119452. * If the drag plane orientation should be updated during the dragging (Default: true)
  119453. */
  119454. updateDragPlane: boolean;
  119455. private _debugMode;
  119456. private _moving;
  119457. /**
  119458. * Fires each time the attached mesh is dragged with the pointer
  119459. * * delta between last drag position and current drag position in world space
  119460. * * dragDistance along the drag axis
  119461. * * dragPlaneNormal normal of the current drag plane used during the drag
  119462. * * dragPlanePoint in world space where the drag intersects the drag plane
  119463. */
  119464. onDragObservable: Observable<{
  119465. delta: Vector3;
  119466. dragPlanePoint: Vector3;
  119467. dragPlaneNormal: Vector3;
  119468. dragDistance: number;
  119469. pointerId: number;
  119470. }>;
  119471. /**
  119472. * Fires each time a drag begins (eg. mouse down on mesh)
  119473. */
  119474. onDragStartObservable: Observable<{
  119475. dragPlanePoint: Vector3;
  119476. pointerId: number;
  119477. }>;
  119478. /**
  119479. * Fires each time a drag ends (eg. mouse release after drag)
  119480. */
  119481. onDragEndObservable: Observable<{
  119482. dragPlanePoint: Vector3;
  119483. pointerId: number;
  119484. }>;
  119485. /**
  119486. * If the attached mesh should be moved when dragged
  119487. */
  119488. moveAttached: boolean;
  119489. /**
  119490. * If the drag behavior will react to drag events (Default: true)
  119491. */
  119492. enabled: boolean;
  119493. /**
  119494. * If pointer events should start and release the drag (Default: true)
  119495. */
  119496. startAndReleaseDragOnPointerEvents: boolean;
  119497. /**
  119498. * If camera controls should be detached during the drag
  119499. */
  119500. detachCameraControls: boolean;
  119501. /**
  119502. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  119503. */
  119504. useObjectOrientationForDragging: boolean;
  119505. private _options;
  119506. /**
  119507. * Gets the options used by the behavior
  119508. */
  119509. get options(): {
  119510. dragAxis?: Vector3;
  119511. dragPlaneNormal?: Vector3;
  119512. };
  119513. /**
  119514. * Sets the options used by the behavior
  119515. */
  119516. set options(options: {
  119517. dragAxis?: Vector3;
  119518. dragPlaneNormal?: Vector3;
  119519. });
  119520. /**
  119521. * Creates a pointer drag behavior that can be attached to a mesh
  119522. * @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)
  119523. */
  119524. constructor(options?: {
  119525. dragAxis?: Vector3;
  119526. dragPlaneNormal?: Vector3;
  119527. });
  119528. /**
  119529. * Predicate to determine if it is valid to move the object to a new position when it is moved
  119530. */
  119531. validateDrag: (targetPosition: Vector3) => boolean;
  119532. /**
  119533. * The name of the behavior
  119534. */
  119535. get name(): string;
  119536. /**
  119537. * Initializes the behavior
  119538. */
  119539. init(): void;
  119540. private _tmpVector;
  119541. private _alternatePickedPoint;
  119542. private _worldDragAxis;
  119543. private _targetPosition;
  119544. private _attachedElement;
  119545. /**
  119546. * Attaches the drag behavior the passed in mesh
  119547. * @param ownerNode The mesh that will be dragged around once attached
  119548. * @param predicate Predicate to use for pick filtering
  119549. */
  119550. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  119551. /**
  119552. * Force relase the drag action by code.
  119553. */
  119554. releaseDrag(): void;
  119555. private _startDragRay;
  119556. private _lastPointerRay;
  119557. /**
  119558. * Simulates the start of a pointer drag event on the behavior
  119559. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  119560. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  119561. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  119562. */
  119563. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  119564. private _startDrag;
  119565. private _dragDelta;
  119566. private _moveDrag;
  119567. private _pickWithRayOnDragPlane;
  119568. private _pointA;
  119569. private _pointB;
  119570. private _pointC;
  119571. private _lineA;
  119572. private _lineB;
  119573. private _localAxis;
  119574. private _lookAt;
  119575. private _updateDragPlanePosition;
  119576. /**
  119577. * Detaches the behavior from the mesh
  119578. */
  119579. detach(): void;
  119580. }
  119581. }
  119582. declare module BABYLON {
  119583. /**
  119584. * A behavior that when attached to a mesh will allow the mesh to be scaled
  119585. */
  119586. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  119587. private _dragBehaviorA;
  119588. private _dragBehaviorB;
  119589. private _startDistance;
  119590. private _initialScale;
  119591. private _targetScale;
  119592. private _ownerNode;
  119593. private _sceneRenderObserver;
  119594. /**
  119595. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  119596. */
  119597. constructor();
  119598. /**
  119599. * The name of the behavior
  119600. */
  119601. get name(): string;
  119602. /**
  119603. * Initializes the behavior
  119604. */
  119605. init(): void;
  119606. private _getCurrentDistance;
  119607. /**
  119608. * Attaches the scale behavior the passed in mesh
  119609. * @param ownerNode The mesh that will be scaled around once attached
  119610. */
  119611. attach(ownerNode: Mesh): void;
  119612. /**
  119613. * Detaches the behavior from the mesh
  119614. */
  119615. detach(): void;
  119616. }
  119617. }
  119618. declare module BABYLON {
  119619. /**
  119620. * 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
  119621. */
  119622. export class SixDofDragBehavior implements Behavior<Mesh> {
  119623. private static _virtualScene;
  119624. private _ownerNode;
  119625. private _sceneRenderObserver;
  119626. private _scene;
  119627. private _targetPosition;
  119628. private _virtualOriginMesh;
  119629. private _virtualDragMesh;
  119630. private _pointerObserver;
  119631. private _moving;
  119632. private _startingOrientation;
  119633. private _attachedElement;
  119634. /**
  119635. * 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)
  119636. */
  119637. private zDragFactor;
  119638. /**
  119639. * If the object should rotate to face the drag origin
  119640. */
  119641. rotateDraggedObject: boolean;
  119642. /**
  119643. * If the behavior is currently in a dragging state
  119644. */
  119645. dragging: boolean;
  119646. /**
  119647. * 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)
  119648. */
  119649. dragDeltaRatio: number;
  119650. /**
  119651. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119652. */
  119653. currentDraggingPointerID: number;
  119654. /**
  119655. * If camera controls should be detached during the drag
  119656. */
  119657. detachCameraControls: boolean;
  119658. /**
  119659. * Fires each time a drag starts
  119660. */
  119661. onDragStartObservable: Observable<{}>;
  119662. /**
  119663. * Fires each time a drag ends (eg. mouse release after drag)
  119664. */
  119665. onDragEndObservable: Observable<{}>;
  119666. /**
  119667. * 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
  119668. */
  119669. constructor();
  119670. /**
  119671. * The name of the behavior
  119672. */
  119673. get name(): string;
  119674. /**
  119675. * Initializes the behavior
  119676. */
  119677. init(): void;
  119678. /**
  119679. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  119680. */
  119681. private get _pointerCamera();
  119682. /**
  119683. * Attaches the scale behavior the passed in mesh
  119684. * @param ownerNode The mesh that will be scaled around once attached
  119685. */
  119686. attach(ownerNode: Mesh): void;
  119687. /**
  119688. * Detaches the behavior from the mesh
  119689. */
  119690. detach(): void;
  119691. }
  119692. }
  119693. declare module BABYLON {
  119694. /**
  119695. * Class used to apply inverse kinematics to bones
  119696. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  119697. */
  119698. export class BoneIKController {
  119699. private static _tmpVecs;
  119700. private static _tmpQuat;
  119701. private static _tmpMats;
  119702. /**
  119703. * Gets or sets the target mesh
  119704. */
  119705. targetMesh: AbstractMesh;
  119706. /** Gets or sets the mesh used as pole */
  119707. poleTargetMesh: AbstractMesh;
  119708. /**
  119709. * Gets or sets the bone used as pole
  119710. */
  119711. poleTargetBone: Nullable<Bone>;
  119712. /**
  119713. * Gets or sets the target position
  119714. */
  119715. targetPosition: Vector3;
  119716. /**
  119717. * Gets or sets the pole target position
  119718. */
  119719. poleTargetPosition: Vector3;
  119720. /**
  119721. * Gets or sets the pole target local offset
  119722. */
  119723. poleTargetLocalOffset: Vector3;
  119724. /**
  119725. * Gets or sets the pole angle
  119726. */
  119727. poleAngle: number;
  119728. /**
  119729. * Gets or sets the mesh associated with the controller
  119730. */
  119731. mesh: AbstractMesh;
  119732. /**
  119733. * 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)
  119734. */
  119735. slerpAmount: number;
  119736. private _bone1Quat;
  119737. private _bone1Mat;
  119738. private _bone2Ang;
  119739. private _bone1;
  119740. private _bone2;
  119741. private _bone1Length;
  119742. private _bone2Length;
  119743. private _maxAngle;
  119744. private _maxReach;
  119745. private _rightHandedSystem;
  119746. private _bendAxis;
  119747. private _slerping;
  119748. private _adjustRoll;
  119749. /**
  119750. * Gets or sets maximum allowed angle
  119751. */
  119752. get maxAngle(): number;
  119753. set maxAngle(value: number);
  119754. /**
  119755. * Creates a new BoneIKController
  119756. * @param mesh defines the mesh to control
  119757. * @param bone defines the bone to control
  119758. * @param options defines options to set up the controller
  119759. */
  119760. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  119761. targetMesh?: AbstractMesh;
  119762. poleTargetMesh?: AbstractMesh;
  119763. poleTargetBone?: Bone;
  119764. poleTargetLocalOffset?: Vector3;
  119765. poleAngle?: number;
  119766. bendAxis?: Vector3;
  119767. maxAngle?: number;
  119768. slerpAmount?: number;
  119769. });
  119770. private _setMaxAngle;
  119771. /**
  119772. * Force the controller to update the bones
  119773. */
  119774. update(): void;
  119775. }
  119776. }
  119777. declare module BABYLON {
  119778. /**
  119779. * Class used to make a bone look toward a point in space
  119780. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  119781. */
  119782. export class BoneLookController {
  119783. private static _tmpVecs;
  119784. private static _tmpQuat;
  119785. private static _tmpMats;
  119786. /**
  119787. * The target Vector3 that the bone will look at
  119788. */
  119789. target: Vector3;
  119790. /**
  119791. * The mesh that the bone is attached to
  119792. */
  119793. mesh: AbstractMesh;
  119794. /**
  119795. * The bone that will be looking to the target
  119796. */
  119797. bone: Bone;
  119798. /**
  119799. * The up axis of the coordinate system that is used when the bone is rotated
  119800. */
  119801. upAxis: Vector3;
  119802. /**
  119803. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  119804. */
  119805. upAxisSpace: Space;
  119806. /**
  119807. * Used to make an adjustment to the yaw of the bone
  119808. */
  119809. adjustYaw: number;
  119810. /**
  119811. * Used to make an adjustment to the pitch of the bone
  119812. */
  119813. adjustPitch: number;
  119814. /**
  119815. * Used to make an adjustment to the roll of the bone
  119816. */
  119817. adjustRoll: number;
  119818. /**
  119819. * 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)
  119820. */
  119821. slerpAmount: number;
  119822. private _minYaw;
  119823. private _maxYaw;
  119824. private _minPitch;
  119825. private _maxPitch;
  119826. private _minYawSin;
  119827. private _minYawCos;
  119828. private _maxYawSin;
  119829. private _maxYawCos;
  119830. private _midYawConstraint;
  119831. private _minPitchTan;
  119832. private _maxPitchTan;
  119833. private _boneQuat;
  119834. private _slerping;
  119835. private _transformYawPitch;
  119836. private _transformYawPitchInv;
  119837. private _firstFrameSkipped;
  119838. private _yawRange;
  119839. private _fowardAxis;
  119840. /**
  119841. * Gets or sets the minimum yaw angle that the bone can look to
  119842. */
  119843. get minYaw(): number;
  119844. set minYaw(value: number);
  119845. /**
  119846. * Gets or sets the maximum yaw angle that the bone can look to
  119847. */
  119848. get maxYaw(): number;
  119849. set maxYaw(value: number);
  119850. /**
  119851. * Gets or sets the minimum pitch angle that the bone can look to
  119852. */
  119853. get minPitch(): number;
  119854. set minPitch(value: number);
  119855. /**
  119856. * Gets or sets the maximum pitch angle that the bone can look to
  119857. */
  119858. get maxPitch(): number;
  119859. set maxPitch(value: number);
  119860. /**
  119861. * Create a BoneLookController
  119862. * @param mesh the mesh that the bone belongs to
  119863. * @param bone the bone that will be looking to the target
  119864. * @param target the target Vector3 to look at
  119865. * @param options optional settings:
  119866. * * maxYaw: the maximum angle the bone will yaw to
  119867. * * minYaw: the minimum angle the bone will yaw to
  119868. * * maxPitch: the maximum angle the bone will pitch to
  119869. * * minPitch: the minimum angle the bone will yaw to
  119870. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  119871. * * upAxis: the up axis of the coordinate system
  119872. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  119873. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  119874. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  119875. * * adjustYaw: used to make an adjustment to the yaw of the bone
  119876. * * adjustPitch: used to make an adjustment to the pitch of the bone
  119877. * * adjustRoll: used to make an adjustment to the roll of the bone
  119878. **/
  119879. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  119880. maxYaw?: number;
  119881. minYaw?: number;
  119882. maxPitch?: number;
  119883. minPitch?: number;
  119884. slerpAmount?: number;
  119885. upAxis?: Vector3;
  119886. upAxisSpace?: Space;
  119887. yawAxis?: Vector3;
  119888. pitchAxis?: Vector3;
  119889. adjustYaw?: number;
  119890. adjustPitch?: number;
  119891. adjustRoll?: number;
  119892. });
  119893. /**
  119894. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  119895. */
  119896. update(): void;
  119897. private _getAngleDiff;
  119898. private _getAngleBetween;
  119899. private _isAngleBetween;
  119900. }
  119901. }
  119902. declare module BABYLON {
  119903. /**
  119904. * Manage the gamepad inputs to control an arc rotate camera.
  119905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119906. */
  119907. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  119908. /**
  119909. * Defines the camera the input is attached to.
  119910. */
  119911. camera: ArcRotateCamera;
  119912. /**
  119913. * Defines the gamepad the input is gathering event from.
  119914. */
  119915. gamepad: Nullable<Gamepad>;
  119916. /**
  119917. * Defines the gamepad rotation sensiblity.
  119918. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  119919. */
  119920. gamepadRotationSensibility: number;
  119921. /**
  119922. * Defines the gamepad move sensiblity.
  119923. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  119924. */
  119925. gamepadMoveSensibility: number;
  119926. private _yAxisScale;
  119927. /**
  119928. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  119929. */
  119930. get invertYAxis(): boolean;
  119931. set invertYAxis(value: boolean);
  119932. private _onGamepadConnectedObserver;
  119933. private _onGamepadDisconnectedObserver;
  119934. /**
  119935. * Attach the input controls to a specific dom element to get the input from.
  119936. * @param element Defines the element the controls should be listened from
  119937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119938. */
  119939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119940. /**
  119941. * Detach the current controls from the specified dom element.
  119942. * @param element Defines the element to stop listening the inputs from
  119943. */
  119944. detachControl(element: Nullable<HTMLElement>): void;
  119945. /**
  119946. * Update the current camera state depending on the inputs that have been used this frame.
  119947. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119948. */
  119949. checkInputs(): void;
  119950. /**
  119951. * Gets the class name of the current intput.
  119952. * @returns the class name
  119953. */
  119954. getClassName(): string;
  119955. /**
  119956. * Get the friendly name associated with the input class.
  119957. * @returns the input friendly name
  119958. */
  119959. getSimpleName(): string;
  119960. }
  119961. }
  119962. declare module BABYLON {
  119963. interface ArcRotateCameraInputsManager {
  119964. /**
  119965. * Add orientation input support to the input manager.
  119966. * @returns the current input manager
  119967. */
  119968. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  119969. }
  119970. /**
  119971. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  119972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119973. */
  119974. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  119975. /**
  119976. * Defines the camera the input is attached to.
  119977. */
  119978. camera: ArcRotateCamera;
  119979. /**
  119980. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  119981. */
  119982. alphaCorrection: number;
  119983. /**
  119984. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  119985. */
  119986. gammaCorrection: number;
  119987. private _alpha;
  119988. private _gamma;
  119989. private _dirty;
  119990. private _deviceOrientationHandler;
  119991. /**
  119992. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  119993. */
  119994. constructor();
  119995. /**
  119996. * Attach the input controls to a specific dom element to get the input from.
  119997. * @param element Defines the element the controls should be listened from
  119998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119999. */
  120000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120001. /** @hidden */
  120002. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  120003. /**
  120004. * Update the current camera state depending on the inputs that have been used this frame.
  120005. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120006. */
  120007. checkInputs(): void;
  120008. /**
  120009. * Detach the current controls from the specified dom element.
  120010. * @param element Defines the element to stop listening the inputs from
  120011. */
  120012. detachControl(element: Nullable<HTMLElement>): void;
  120013. /**
  120014. * Gets the class name of the current intput.
  120015. * @returns the class name
  120016. */
  120017. getClassName(): string;
  120018. /**
  120019. * Get the friendly name associated with the input class.
  120020. * @returns the input friendly name
  120021. */
  120022. getSimpleName(): string;
  120023. }
  120024. }
  120025. declare module BABYLON {
  120026. /**
  120027. * Listen to mouse events to control the camera.
  120028. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120029. */
  120030. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  120031. /**
  120032. * Defines the camera the input is attached to.
  120033. */
  120034. camera: FlyCamera;
  120035. /**
  120036. * Defines if touch is enabled. (Default is true.)
  120037. */
  120038. touchEnabled: boolean;
  120039. /**
  120040. * Defines the buttons associated with the input to handle camera rotation.
  120041. */
  120042. buttons: number[];
  120043. /**
  120044. * Assign buttons for Yaw control.
  120045. */
  120046. buttonsYaw: number[];
  120047. /**
  120048. * Assign buttons for Pitch control.
  120049. */
  120050. buttonsPitch: number[];
  120051. /**
  120052. * Assign buttons for Roll control.
  120053. */
  120054. buttonsRoll: number[];
  120055. /**
  120056. * Detect if any button is being pressed while mouse is moved.
  120057. * -1 = Mouse locked.
  120058. * 0 = Left button.
  120059. * 1 = Middle Button.
  120060. * 2 = Right Button.
  120061. */
  120062. activeButton: number;
  120063. /**
  120064. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  120065. * Higher values reduce its sensitivity.
  120066. */
  120067. angularSensibility: number;
  120068. private _mousemoveCallback;
  120069. private _observer;
  120070. private _rollObserver;
  120071. private previousPosition;
  120072. private noPreventDefault;
  120073. private element;
  120074. /**
  120075. * Listen to mouse events to control the camera.
  120076. * @param touchEnabled Define if touch is enabled. (Default is true.)
  120077. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120078. */
  120079. constructor(touchEnabled?: boolean);
  120080. /**
  120081. * Attach the mouse control to the HTML DOM element.
  120082. * @param element Defines the element that listens to the input events.
  120083. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  120084. */
  120085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120086. /**
  120087. * Detach the current controls from the specified dom element.
  120088. * @param element Defines the element to stop listening the inputs from
  120089. */
  120090. detachControl(element: Nullable<HTMLElement>): void;
  120091. /**
  120092. * Gets the class name of the current input.
  120093. * @returns the class name.
  120094. */
  120095. getClassName(): string;
  120096. /**
  120097. * Get the friendly name associated with the input class.
  120098. * @returns the input's friendly name.
  120099. */
  120100. getSimpleName(): string;
  120101. private _pointerInput;
  120102. private _onMouseMove;
  120103. /**
  120104. * Rotate camera by mouse offset.
  120105. */
  120106. private rotateCamera;
  120107. }
  120108. }
  120109. declare module BABYLON {
  120110. /**
  120111. * Default Inputs manager for the FlyCamera.
  120112. * It groups all the default supported inputs for ease of use.
  120113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120114. */
  120115. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  120116. /**
  120117. * Instantiates a new FlyCameraInputsManager.
  120118. * @param camera Defines the camera the inputs belong to.
  120119. */
  120120. constructor(camera: FlyCamera);
  120121. /**
  120122. * Add keyboard input support to the input manager.
  120123. * @returns the new FlyCameraKeyboardMoveInput().
  120124. */
  120125. addKeyboard(): FlyCameraInputsManager;
  120126. /**
  120127. * Add mouse input support to the input manager.
  120128. * @param touchEnabled Enable touch screen support.
  120129. * @returns the new FlyCameraMouseInput().
  120130. */
  120131. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  120132. }
  120133. }
  120134. declare module BABYLON {
  120135. /**
  120136. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120137. * such as in a 3D Space Shooter or a Flight Simulator.
  120138. */
  120139. export class FlyCamera extends TargetCamera {
  120140. /**
  120141. * Define the collision ellipsoid of the camera.
  120142. * This is helpful for simulating a camera body, like a player's body.
  120143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120144. */
  120145. ellipsoid: Vector3;
  120146. /**
  120147. * Define an offset for the position of the ellipsoid around the camera.
  120148. * This can be helpful if the camera is attached away from the player's body center,
  120149. * such as at its head.
  120150. */
  120151. ellipsoidOffset: Vector3;
  120152. /**
  120153. * Enable or disable collisions of the camera with the rest of the scene objects.
  120154. */
  120155. checkCollisions: boolean;
  120156. /**
  120157. * Enable or disable gravity on the camera.
  120158. */
  120159. applyGravity: boolean;
  120160. /**
  120161. * Define the current direction the camera is moving to.
  120162. */
  120163. cameraDirection: Vector3;
  120164. /**
  120165. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  120166. * This overrides and empties cameraRotation.
  120167. */
  120168. rotationQuaternion: Quaternion;
  120169. /**
  120170. * Track Roll to maintain the wanted Rolling when looking around.
  120171. */
  120172. _trackRoll: number;
  120173. /**
  120174. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  120175. */
  120176. rollCorrect: number;
  120177. /**
  120178. * Mimic a banked turn, Rolling the camera when Yawing.
  120179. * It's recommended to use rollCorrect = 10 for faster banking correction.
  120180. */
  120181. bankedTurn: boolean;
  120182. /**
  120183. * Limit in radians for how much Roll banking will add. (Default: 90°)
  120184. */
  120185. bankedTurnLimit: number;
  120186. /**
  120187. * Value of 0 disables the banked Roll.
  120188. * Value of 1 is equal to the Yaw angle in radians.
  120189. */
  120190. bankedTurnMultiplier: number;
  120191. /**
  120192. * The inputs manager loads all the input sources, such as keyboard and mouse.
  120193. */
  120194. inputs: FlyCameraInputsManager;
  120195. /**
  120196. * Gets the input sensibility for mouse input.
  120197. * Higher values reduce sensitivity.
  120198. */
  120199. get angularSensibility(): number;
  120200. /**
  120201. * Sets the input sensibility for a mouse input.
  120202. * Higher values reduce sensitivity.
  120203. */
  120204. set angularSensibility(value: number);
  120205. /**
  120206. * Get the keys for camera movement forward.
  120207. */
  120208. get keysForward(): number[];
  120209. /**
  120210. * Set the keys for camera movement forward.
  120211. */
  120212. set keysForward(value: number[]);
  120213. /**
  120214. * Get the keys for camera movement backward.
  120215. */
  120216. get keysBackward(): number[];
  120217. set keysBackward(value: number[]);
  120218. /**
  120219. * Get the keys for camera movement up.
  120220. */
  120221. get keysUp(): number[];
  120222. /**
  120223. * Set the keys for camera movement up.
  120224. */
  120225. set keysUp(value: number[]);
  120226. /**
  120227. * Get the keys for camera movement down.
  120228. */
  120229. get keysDown(): number[];
  120230. /**
  120231. * Set the keys for camera movement down.
  120232. */
  120233. set keysDown(value: number[]);
  120234. /**
  120235. * Get the keys for camera movement left.
  120236. */
  120237. get keysLeft(): number[];
  120238. /**
  120239. * Set the keys for camera movement left.
  120240. */
  120241. set keysLeft(value: number[]);
  120242. /**
  120243. * Set the keys for camera movement right.
  120244. */
  120245. get keysRight(): number[];
  120246. /**
  120247. * Set the keys for camera movement right.
  120248. */
  120249. set keysRight(value: number[]);
  120250. /**
  120251. * Event raised when the camera collides with a mesh in the scene.
  120252. */
  120253. onCollide: (collidedMesh: AbstractMesh) => void;
  120254. private _collider;
  120255. private _needMoveForGravity;
  120256. private _oldPosition;
  120257. private _diffPosition;
  120258. private _newPosition;
  120259. /** @hidden */
  120260. _localDirection: Vector3;
  120261. /** @hidden */
  120262. _transformedDirection: Vector3;
  120263. /**
  120264. * Instantiates a FlyCamera.
  120265. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120266. * such as in a 3D Space Shooter or a Flight Simulator.
  120267. * @param name Define the name of the camera in the scene.
  120268. * @param position Define the starting position of the camera in the scene.
  120269. * @param scene Define the scene the camera belongs to.
  120270. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  120271. */
  120272. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120273. /**
  120274. * Attach a control to the HTML DOM element.
  120275. * @param element Defines the element that listens to the input events.
  120276. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  120277. */
  120278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120279. /**
  120280. * Detach a control from the HTML DOM element.
  120281. * The camera will stop reacting to that input.
  120282. * @param element Defines the element that listens to the input events.
  120283. */
  120284. detachControl(element: HTMLElement): void;
  120285. private _collisionMask;
  120286. /**
  120287. * Get the mask that the camera ignores in collision events.
  120288. */
  120289. get collisionMask(): number;
  120290. /**
  120291. * Set the mask that the camera ignores in collision events.
  120292. */
  120293. set collisionMask(mask: number);
  120294. /** @hidden */
  120295. _collideWithWorld(displacement: Vector3): void;
  120296. /** @hidden */
  120297. private _onCollisionPositionChange;
  120298. /** @hidden */
  120299. _checkInputs(): void;
  120300. /** @hidden */
  120301. _decideIfNeedsToMove(): boolean;
  120302. /** @hidden */
  120303. _updatePosition(): void;
  120304. /**
  120305. * Restore the Roll to its target value at the rate specified.
  120306. * @param rate - Higher means slower restoring.
  120307. * @hidden
  120308. */
  120309. restoreRoll(rate: number): void;
  120310. /**
  120311. * Destroy the camera and release the current resources held by it.
  120312. */
  120313. dispose(): void;
  120314. /**
  120315. * Get the current object class name.
  120316. * @returns the class name.
  120317. */
  120318. getClassName(): string;
  120319. }
  120320. }
  120321. declare module BABYLON {
  120322. /**
  120323. * Listen to keyboard events to control the camera.
  120324. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120325. */
  120326. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  120327. /**
  120328. * Defines the camera the input is attached to.
  120329. */
  120330. camera: FlyCamera;
  120331. /**
  120332. * The list of keyboard keys used to control the forward move of the camera.
  120333. */
  120334. keysForward: number[];
  120335. /**
  120336. * The list of keyboard keys used to control the backward move of the camera.
  120337. */
  120338. keysBackward: number[];
  120339. /**
  120340. * The list of keyboard keys used to control the forward move of the camera.
  120341. */
  120342. keysUp: number[];
  120343. /**
  120344. * The list of keyboard keys used to control the backward move of the camera.
  120345. */
  120346. keysDown: number[];
  120347. /**
  120348. * The list of keyboard keys used to control the right strafe move of the camera.
  120349. */
  120350. keysRight: number[];
  120351. /**
  120352. * The list of keyboard keys used to control the left strafe move of the camera.
  120353. */
  120354. keysLeft: number[];
  120355. private _keys;
  120356. private _onCanvasBlurObserver;
  120357. private _onKeyboardObserver;
  120358. private _engine;
  120359. private _scene;
  120360. /**
  120361. * Attach the input controls to a specific dom element to get the input from.
  120362. * @param element Defines the element the controls should be listened from
  120363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120364. */
  120365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120366. /**
  120367. * Detach the current controls from the specified dom element.
  120368. * @param element Defines the element to stop listening the inputs from
  120369. */
  120370. detachControl(element: Nullable<HTMLElement>): void;
  120371. /**
  120372. * Gets the class name of the current intput.
  120373. * @returns the class name
  120374. */
  120375. getClassName(): string;
  120376. /** @hidden */
  120377. _onLostFocus(e: FocusEvent): void;
  120378. /**
  120379. * Get the friendly name associated with the input class.
  120380. * @returns the input friendly name
  120381. */
  120382. getSimpleName(): string;
  120383. /**
  120384. * Update the current camera state depending on the inputs that have been used this frame.
  120385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120386. */
  120387. checkInputs(): void;
  120388. }
  120389. }
  120390. declare module BABYLON {
  120391. /**
  120392. * Manage the mouse wheel inputs to control a follow camera.
  120393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120394. */
  120395. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  120396. /**
  120397. * Defines the camera the input is attached to.
  120398. */
  120399. camera: FollowCamera;
  120400. /**
  120401. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  120402. */
  120403. axisControlRadius: boolean;
  120404. /**
  120405. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  120406. */
  120407. axisControlHeight: boolean;
  120408. /**
  120409. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  120410. */
  120411. axisControlRotation: boolean;
  120412. /**
  120413. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  120414. * relation to mouseWheel events.
  120415. */
  120416. wheelPrecision: number;
  120417. /**
  120418. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120419. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120420. */
  120421. wheelDeltaPercentage: number;
  120422. private _wheel;
  120423. private _observer;
  120424. /**
  120425. * Attach the input controls to a specific dom element to get the input from.
  120426. * @param element Defines the element the controls should be listened from
  120427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120428. */
  120429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120430. /**
  120431. * Detach the current controls from the specified dom element.
  120432. * @param element Defines the element to stop listening the inputs from
  120433. */
  120434. detachControl(element: Nullable<HTMLElement>): void;
  120435. /**
  120436. * Gets the class name of the current intput.
  120437. * @returns the class name
  120438. */
  120439. getClassName(): string;
  120440. /**
  120441. * Get the friendly name associated with the input class.
  120442. * @returns the input friendly name
  120443. */
  120444. getSimpleName(): string;
  120445. }
  120446. }
  120447. declare module BABYLON {
  120448. /**
  120449. * Manage the pointers inputs to control an follow camera.
  120450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120451. */
  120452. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  120453. /**
  120454. * Defines the camera the input is attached to.
  120455. */
  120456. camera: FollowCamera;
  120457. /**
  120458. * Gets the class name of the current input.
  120459. * @returns the class name
  120460. */
  120461. getClassName(): string;
  120462. /**
  120463. * Defines the pointer angular sensibility along the X axis or how fast is
  120464. * the camera rotating.
  120465. * A negative number will reverse the axis direction.
  120466. */
  120467. angularSensibilityX: number;
  120468. /**
  120469. * Defines the pointer angular sensibility along the Y axis or how fast is
  120470. * the camera rotating.
  120471. * A negative number will reverse the axis direction.
  120472. */
  120473. angularSensibilityY: number;
  120474. /**
  120475. * Defines the pointer pinch precision or how fast is the camera zooming.
  120476. * A negative number will reverse the axis direction.
  120477. */
  120478. pinchPrecision: number;
  120479. /**
  120480. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  120481. * from 0.
  120482. * It defines the percentage of current camera.radius to use as delta when
  120483. * pinch zoom is used.
  120484. */
  120485. pinchDeltaPercentage: number;
  120486. /**
  120487. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  120488. */
  120489. axisXControlRadius: boolean;
  120490. /**
  120491. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  120492. */
  120493. axisXControlHeight: boolean;
  120494. /**
  120495. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  120496. */
  120497. axisXControlRotation: boolean;
  120498. /**
  120499. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  120500. */
  120501. axisYControlRadius: boolean;
  120502. /**
  120503. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  120504. */
  120505. axisYControlHeight: boolean;
  120506. /**
  120507. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  120508. */
  120509. axisYControlRotation: boolean;
  120510. /**
  120511. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  120512. */
  120513. axisPinchControlRadius: boolean;
  120514. /**
  120515. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  120516. */
  120517. axisPinchControlHeight: boolean;
  120518. /**
  120519. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  120520. */
  120521. axisPinchControlRotation: boolean;
  120522. /**
  120523. * Log error messages if basic misconfiguration has occurred.
  120524. */
  120525. warningEnable: boolean;
  120526. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120527. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120528. private _warningCounter;
  120529. private _warning;
  120530. }
  120531. }
  120532. declare module BABYLON {
  120533. /**
  120534. * Default Inputs manager for the FollowCamera.
  120535. * It groups all the default supported inputs for ease of use.
  120536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120537. */
  120538. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  120539. /**
  120540. * Instantiates a new FollowCameraInputsManager.
  120541. * @param camera Defines the camera the inputs belong to
  120542. */
  120543. constructor(camera: FollowCamera);
  120544. /**
  120545. * Add keyboard input support to the input manager.
  120546. * @returns the current input manager
  120547. */
  120548. addKeyboard(): FollowCameraInputsManager;
  120549. /**
  120550. * Add mouse wheel input support to the input manager.
  120551. * @returns the current input manager
  120552. */
  120553. addMouseWheel(): FollowCameraInputsManager;
  120554. /**
  120555. * Add pointers input support to the input manager.
  120556. * @returns the current input manager
  120557. */
  120558. addPointers(): FollowCameraInputsManager;
  120559. /**
  120560. * Add orientation input support to the input manager.
  120561. * @returns the current input manager
  120562. */
  120563. addVRDeviceOrientation(): FollowCameraInputsManager;
  120564. }
  120565. }
  120566. declare module BABYLON {
  120567. /**
  120568. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  120569. * an arc rotate version arcFollowCamera are available.
  120570. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120571. */
  120572. export class FollowCamera extends TargetCamera {
  120573. /**
  120574. * Distance the follow camera should follow an object at
  120575. */
  120576. radius: number;
  120577. /**
  120578. * Minimum allowed distance of the camera to the axis of rotation
  120579. * (The camera can not get closer).
  120580. * This can help limiting how the Camera is able to move in the scene.
  120581. */
  120582. lowerRadiusLimit: Nullable<number>;
  120583. /**
  120584. * Maximum allowed distance of the camera to the axis of rotation
  120585. * (The camera can not get further).
  120586. * This can help limiting how the Camera is able to move in the scene.
  120587. */
  120588. upperRadiusLimit: Nullable<number>;
  120589. /**
  120590. * Define a rotation offset between the camera and the object it follows
  120591. */
  120592. rotationOffset: number;
  120593. /**
  120594. * Minimum allowed angle to camera position relative to target object.
  120595. * This can help limiting how the Camera is able to move in the scene.
  120596. */
  120597. lowerRotationOffsetLimit: Nullable<number>;
  120598. /**
  120599. * Maximum allowed angle to camera position relative to target object.
  120600. * This can help limiting how the Camera is able to move in the scene.
  120601. */
  120602. upperRotationOffsetLimit: Nullable<number>;
  120603. /**
  120604. * Define a height offset between the camera and the object it follows.
  120605. * It can help following an object from the top (like a car chaing a plane)
  120606. */
  120607. heightOffset: number;
  120608. /**
  120609. * Minimum allowed height of camera position relative to target object.
  120610. * This can help limiting how the Camera is able to move in the scene.
  120611. */
  120612. lowerHeightOffsetLimit: Nullable<number>;
  120613. /**
  120614. * Maximum allowed height of camera position relative to target object.
  120615. * This can help limiting how the Camera is able to move in the scene.
  120616. */
  120617. upperHeightOffsetLimit: Nullable<number>;
  120618. /**
  120619. * Define how fast the camera can accelerate to follow it s target.
  120620. */
  120621. cameraAcceleration: number;
  120622. /**
  120623. * Define the speed limit of the camera following an object.
  120624. */
  120625. maxCameraSpeed: number;
  120626. /**
  120627. * Define the target of the camera.
  120628. */
  120629. lockedTarget: Nullable<AbstractMesh>;
  120630. /**
  120631. * Defines the input associated with the camera.
  120632. */
  120633. inputs: FollowCameraInputsManager;
  120634. /**
  120635. * Instantiates the follow camera.
  120636. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120637. * @param name Define the name of the camera in the scene
  120638. * @param position Define the position of the camera
  120639. * @param scene Define the scene the camera belong to
  120640. * @param lockedTarget Define the target of the camera
  120641. */
  120642. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  120643. private _follow;
  120644. /**
  120645. * Attached controls to the current camera.
  120646. * @param element Defines the element the controls should be listened from
  120647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120648. */
  120649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120650. /**
  120651. * Detach the current controls from the camera.
  120652. * The camera will stop reacting to inputs.
  120653. * @param element Defines the element to stop listening the inputs from
  120654. */
  120655. detachControl(element: HTMLElement): void;
  120656. /** @hidden */
  120657. _checkInputs(): void;
  120658. private _checkLimits;
  120659. /**
  120660. * Gets the camera class name.
  120661. * @returns the class name
  120662. */
  120663. getClassName(): string;
  120664. }
  120665. /**
  120666. * Arc Rotate version of the follow camera.
  120667. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  120668. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120669. */
  120670. export class ArcFollowCamera extends TargetCamera {
  120671. /** The longitudinal angle of the camera */
  120672. alpha: number;
  120673. /** The latitudinal angle of the camera */
  120674. beta: number;
  120675. /** The radius of the camera from its target */
  120676. radius: number;
  120677. /** Define the camera target (the messh it should follow) */
  120678. target: Nullable<AbstractMesh>;
  120679. private _cartesianCoordinates;
  120680. /**
  120681. * Instantiates a new ArcFollowCamera
  120682. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120683. * @param name Define the name of the camera
  120684. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  120685. * @param beta Define the rotation angle of the camera around the elevation axis
  120686. * @param radius Define the radius of the camera from its target point
  120687. * @param target Define the target of the camera
  120688. * @param scene Define the scene the camera belongs to
  120689. */
  120690. constructor(name: string,
  120691. /** The longitudinal angle of the camera */
  120692. alpha: number,
  120693. /** The latitudinal angle of the camera */
  120694. beta: number,
  120695. /** The radius of the camera from its target */
  120696. radius: number,
  120697. /** Define the camera target (the messh it should follow) */
  120698. target: Nullable<AbstractMesh>, scene: Scene);
  120699. private _follow;
  120700. /** @hidden */
  120701. _checkInputs(): void;
  120702. /**
  120703. * Returns the class name of the object.
  120704. * It is mostly used internally for serialization purposes.
  120705. */
  120706. getClassName(): string;
  120707. }
  120708. }
  120709. declare module BABYLON {
  120710. /**
  120711. * Manage the keyboard inputs to control the movement of a follow camera.
  120712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120713. */
  120714. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  120715. /**
  120716. * Defines the camera the input is attached to.
  120717. */
  120718. camera: FollowCamera;
  120719. /**
  120720. * Defines the list of key codes associated with the up action (increase heightOffset)
  120721. */
  120722. keysHeightOffsetIncr: number[];
  120723. /**
  120724. * Defines the list of key codes associated with the down action (decrease heightOffset)
  120725. */
  120726. keysHeightOffsetDecr: number[];
  120727. /**
  120728. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  120729. */
  120730. keysHeightOffsetModifierAlt: boolean;
  120731. /**
  120732. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  120733. */
  120734. keysHeightOffsetModifierCtrl: boolean;
  120735. /**
  120736. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  120737. */
  120738. keysHeightOffsetModifierShift: boolean;
  120739. /**
  120740. * Defines the list of key codes associated with the left action (increase rotationOffset)
  120741. */
  120742. keysRotationOffsetIncr: number[];
  120743. /**
  120744. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  120745. */
  120746. keysRotationOffsetDecr: number[];
  120747. /**
  120748. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  120749. */
  120750. keysRotationOffsetModifierAlt: boolean;
  120751. /**
  120752. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  120753. */
  120754. keysRotationOffsetModifierCtrl: boolean;
  120755. /**
  120756. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  120757. */
  120758. keysRotationOffsetModifierShift: boolean;
  120759. /**
  120760. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  120761. */
  120762. keysRadiusIncr: number[];
  120763. /**
  120764. * Defines the list of key codes associated with the zoom-out action (increase radius)
  120765. */
  120766. keysRadiusDecr: number[];
  120767. /**
  120768. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  120769. */
  120770. keysRadiusModifierAlt: boolean;
  120771. /**
  120772. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  120773. */
  120774. keysRadiusModifierCtrl: boolean;
  120775. /**
  120776. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  120777. */
  120778. keysRadiusModifierShift: boolean;
  120779. /**
  120780. * Defines the rate of change of heightOffset.
  120781. */
  120782. heightSensibility: number;
  120783. /**
  120784. * Defines the rate of change of rotationOffset.
  120785. */
  120786. rotationSensibility: number;
  120787. /**
  120788. * Defines the rate of change of radius.
  120789. */
  120790. radiusSensibility: number;
  120791. private _keys;
  120792. private _ctrlPressed;
  120793. private _altPressed;
  120794. private _shiftPressed;
  120795. private _onCanvasBlurObserver;
  120796. private _onKeyboardObserver;
  120797. private _engine;
  120798. private _scene;
  120799. /**
  120800. * Attach the input controls to a specific dom element to get the input from.
  120801. * @param element Defines the element the controls should be listened from
  120802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120803. */
  120804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120805. /**
  120806. * Detach the current controls from the specified dom element.
  120807. * @param element Defines the element to stop listening the inputs from
  120808. */
  120809. detachControl(element: Nullable<HTMLElement>): void;
  120810. /**
  120811. * Update the current camera state depending on the inputs that have been used this frame.
  120812. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120813. */
  120814. checkInputs(): void;
  120815. /**
  120816. * Gets the class name of the current input.
  120817. * @returns the class name
  120818. */
  120819. getClassName(): string;
  120820. /**
  120821. * Get the friendly name associated with the input class.
  120822. * @returns the input friendly name
  120823. */
  120824. getSimpleName(): string;
  120825. /**
  120826. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120827. * allow modification of the heightOffset value.
  120828. */
  120829. private _modifierHeightOffset;
  120830. /**
  120831. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120832. * allow modification of the rotationOffset value.
  120833. */
  120834. private _modifierRotationOffset;
  120835. /**
  120836. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120837. * allow modification of the radius value.
  120838. */
  120839. private _modifierRadius;
  120840. }
  120841. }
  120842. declare module BABYLON {
  120843. interface FreeCameraInputsManager {
  120844. /**
  120845. * @hidden
  120846. */
  120847. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  120848. /**
  120849. * Add orientation input support to the input manager.
  120850. * @returns the current input manager
  120851. */
  120852. addDeviceOrientation(): FreeCameraInputsManager;
  120853. }
  120854. /**
  120855. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  120856. * Screen rotation is taken into account.
  120857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120858. */
  120859. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  120860. private _camera;
  120861. private _screenOrientationAngle;
  120862. private _constantTranform;
  120863. private _screenQuaternion;
  120864. private _alpha;
  120865. private _beta;
  120866. private _gamma;
  120867. /**
  120868. * Can be used to detect if a device orientation sensor is available on a device
  120869. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  120870. * @returns a promise that will resolve on orientation change
  120871. */
  120872. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  120873. /**
  120874. * @hidden
  120875. */
  120876. _onDeviceOrientationChangedObservable: Observable<void>;
  120877. /**
  120878. * Instantiates a new input
  120879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120880. */
  120881. constructor();
  120882. /**
  120883. * Define the camera controlled by the input.
  120884. */
  120885. get camera(): FreeCamera;
  120886. set camera(camera: FreeCamera);
  120887. /**
  120888. * Attach the input controls to a specific dom element to get the input from.
  120889. * @param element Defines the element the controls should be listened from
  120890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120891. */
  120892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120893. private _orientationChanged;
  120894. private _deviceOrientation;
  120895. /**
  120896. * Detach the current controls from the specified dom element.
  120897. * @param element Defines the element to stop listening the inputs from
  120898. */
  120899. detachControl(element: Nullable<HTMLElement>): void;
  120900. /**
  120901. * Update the current camera state depending on the inputs that have been used this frame.
  120902. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120903. */
  120904. checkInputs(): void;
  120905. /**
  120906. * Gets the class name of the current intput.
  120907. * @returns the class name
  120908. */
  120909. getClassName(): string;
  120910. /**
  120911. * Get the friendly name associated with the input class.
  120912. * @returns the input friendly name
  120913. */
  120914. getSimpleName(): string;
  120915. }
  120916. }
  120917. declare module BABYLON {
  120918. /**
  120919. * Manage the gamepad inputs to control a free camera.
  120920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120921. */
  120922. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  120923. /**
  120924. * Define the camera the input is attached to.
  120925. */
  120926. camera: FreeCamera;
  120927. /**
  120928. * Define the Gamepad controlling the input
  120929. */
  120930. gamepad: Nullable<Gamepad>;
  120931. /**
  120932. * Defines the gamepad rotation sensiblity.
  120933. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120934. */
  120935. gamepadAngularSensibility: number;
  120936. /**
  120937. * Defines the gamepad move sensiblity.
  120938. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120939. */
  120940. gamepadMoveSensibility: number;
  120941. private _yAxisScale;
  120942. /**
  120943. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120944. */
  120945. get invertYAxis(): boolean;
  120946. set invertYAxis(value: boolean);
  120947. private _onGamepadConnectedObserver;
  120948. private _onGamepadDisconnectedObserver;
  120949. private _cameraTransform;
  120950. private _deltaTransform;
  120951. private _vector3;
  120952. private _vector2;
  120953. /**
  120954. * Attach the input controls to a specific dom element to get the input from.
  120955. * @param element Defines the element the controls should be listened from
  120956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120957. */
  120958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120959. /**
  120960. * Detach the current controls from the specified dom element.
  120961. * @param element Defines the element to stop listening the inputs from
  120962. */
  120963. detachControl(element: Nullable<HTMLElement>): void;
  120964. /**
  120965. * Update the current camera state depending on the inputs that have been used this frame.
  120966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120967. */
  120968. checkInputs(): void;
  120969. /**
  120970. * Gets the class name of the current intput.
  120971. * @returns the class name
  120972. */
  120973. getClassName(): string;
  120974. /**
  120975. * Get the friendly name associated with the input class.
  120976. * @returns the input friendly name
  120977. */
  120978. getSimpleName(): string;
  120979. }
  120980. }
  120981. declare module BABYLON {
  120982. /**
  120983. * Defines the potential axis of a Joystick
  120984. */
  120985. export enum JoystickAxis {
  120986. /** X axis */
  120987. X = 0,
  120988. /** Y axis */
  120989. Y = 1,
  120990. /** Z axis */
  120991. Z = 2
  120992. }
  120993. /**
  120994. * Class used to define virtual joystick (used in touch mode)
  120995. */
  120996. export class VirtualJoystick {
  120997. /**
  120998. * Gets or sets a boolean indicating that left and right values must be inverted
  120999. */
  121000. reverseLeftRight: boolean;
  121001. /**
  121002. * Gets or sets a boolean indicating that up and down values must be inverted
  121003. */
  121004. reverseUpDown: boolean;
  121005. /**
  121006. * Gets the offset value for the position (ie. the change of the position value)
  121007. */
  121008. deltaPosition: Vector3;
  121009. /**
  121010. * Gets a boolean indicating if the virtual joystick was pressed
  121011. */
  121012. pressed: boolean;
  121013. /**
  121014. * Canvas the virtual joystick will render onto, default z-index of this is 5
  121015. */
  121016. static Canvas: Nullable<HTMLCanvasElement>;
  121017. private static _globalJoystickIndex;
  121018. private static vjCanvasContext;
  121019. private static vjCanvasWidth;
  121020. private static vjCanvasHeight;
  121021. private static halfWidth;
  121022. private _action;
  121023. private _axisTargetedByLeftAndRight;
  121024. private _axisTargetedByUpAndDown;
  121025. private _joystickSensibility;
  121026. private _inversedSensibility;
  121027. private _joystickPointerID;
  121028. private _joystickColor;
  121029. private _joystickPointerPos;
  121030. private _joystickPreviousPointerPos;
  121031. private _joystickPointerStartPos;
  121032. private _deltaJoystickVector;
  121033. private _leftJoystick;
  121034. private _touches;
  121035. private _onPointerDownHandlerRef;
  121036. private _onPointerMoveHandlerRef;
  121037. private _onPointerUpHandlerRef;
  121038. private _onResize;
  121039. /**
  121040. * Creates a new virtual joystick
  121041. * @param leftJoystick defines that the joystick is for left hand (false by default)
  121042. */
  121043. constructor(leftJoystick?: boolean);
  121044. /**
  121045. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  121046. * @param newJoystickSensibility defines the new sensibility
  121047. */
  121048. setJoystickSensibility(newJoystickSensibility: number): void;
  121049. private _onPointerDown;
  121050. private _onPointerMove;
  121051. private _onPointerUp;
  121052. /**
  121053. * Change the color of the virtual joystick
  121054. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  121055. */
  121056. setJoystickColor(newColor: string): void;
  121057. /**
  121058. * Defines a callback to call when the joystick is touched
  121059. * @param action defines the callback
  121060. */
  121061. setActionOnTouch(action: () => any): void;
  121062. /**
  121063. * Defines which axis you'd like to control for left & right
  121064. * @param axis defines the axis to use
  121065. */
  121066. setAxisForLeftRight(axis: JoystickAxis): void;
  121067. /**
  121068. * Defines which axis you'd like to control for up & down
  121069. * @param axis defines the axis to use
  121070. */
  121071. setAxisForUpDown(axis: JoystickAxis): void;
  121072. private _drawVirtualJoystick;
  121073. /**
  121074. * Release internal HTML canvas
  121075. */
  121076. releaseCanvas(): void;
  121077. }
  121078. }
  121079. declare module BABYLON {
  121080. interface FreeCameraInputsManager {
  121081. /**
  121082. * Add virtual joystick input support to the input manager.
  121083. * @returns the current input manager
  121084. */
  121085. addVirtualJoystick(): FreeCameraInputsManager;
  121086. }
  121087. /**
  121088. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  121089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121090. */
  121091. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  121092. /**
  121093. * Defines the camera the input is attached to.
  121094. */
  121095. camera: FreeCamera;
  121096. private _leftjoystick;
  121097. private _rightjoystick;
  121098. /**
  121099. * Gets the left stick of the virtual joystick.
  121100. * @returns The virtual Joystick
  121101. */
  121102. getLeftJoystick(): VirtualJoystick;
  121103. /**
  121104. * Gets the right stick of the virtual joystick.
  121105. * @returns The virtual Joystick
  121106. */
  121107. getRightJoystick(): VirtualJoystick;
  121108. /**
  121109. * Update the current camera state depending on the inputs that have been used this frame.
  121110. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121111. */
  121112. checkInputs(): void;
  121113. /**
  121114. * Attach the input controls to a specific dom element to get the input from.
  121115. * @param element Defines the element the controls should be listened from
  121116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121117. */
  121118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121119. /**
  121120. * Detach the current controls from the specified dom element.
  121121. * @param element Defines the element to stop listening the inputs from
  121122. */
  121123. detachControl(element: Nullable<HTMLElement>): void;
  121124. /**
  121125. * Gets the class name of the current intput.
  121126. * @returns the class name
  121127. */
  121128. getClassName(): string;
  121129. /**
  121130. * Get the friendly name associated with the input class.
  121131. * @returns the input friendly name
  121132. */
  121133. getSimpleName(): string;
  121134. }
  121135. }
  121136. declare module BABYLON {
  121137. /**
  121138. * This represents a FPS type of camera controlled by touch.
  121139. * This is like a universal camera minus the Gamepad controls.
  121140. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121141. */
  121142. export class TouchCamera extends FreeCamera {
  121143. /**
  121144. * Defines the touch sensibility for rotation.
  121145. * The higher the faster.
  121146. */
  121147. get touchAngularSensibility(): number;
  121148. set touchAngularSensibility(value: number);
  121149. /**
  121150. * Defines the touch sensibility for move.
  121151. * The higher the faster.
  121152. */
  121153. get touchMoveSensibility(): number;
  121154. set touchMoveSensibility(value: number);
  121155. /**
  121156. * Instantiates a new touch camera.
  121157. * This represents a FPS type of camera controlled by touch.
  121158. * This is like a universal camera minus the Gamepad controls.
  121159. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121160. * @param name Define the name of the camera in the scene
  121161. * @param position Define the start position of the camera in the scene
  121162. * @param scene Define the scene the camera belongs to
  121163. */
  121164. constructor(name: string, position: Vector3, scene: Scene);
  121165. /**
  121166. * Gets the current object class name.
  121167. * @return the class name
  121168. */
  121169. getClassName(): string;
  121170. /** @hidden */
  121171. _setupInputs(): void;
  121172. }
  121173. }
  121174. declare module BABYLON {
  121175. /**
  121176. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  121177. * being tilted forward or back and left or right.
  121178. */
  121179. export class DeviceOrientationCamera extends FreeCamera {
  121180. private _initialQuaternion;
  121181. private _quaternionCache;
  121182. private _tmpDragQuaternion;
  121183. private _disablePointerInputWhenUsingDeviceOrientation;
  121184. /**
  121185. * Creates a new device orientation camera
  121186. * @param name The name of the camera
  121187. * @param position The start position camera
  121188. * @param scene The scene the camera belongs to
  121189. */
  121190. constructor(name: string, position: Vector3, scene: Scene);
  121191. /**
  121192. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  121193. */
  121194. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  121195. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  121196. private _dragFactor;
  121197. /**
  121198. * Enabled turning on the y axis when the orientation sensor is active
  121199. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  121200. */
  121201. enableHorizontalDragging(dragFactor?: number): void;
  121202. /**
  121203. * Gets the current instance class name ("DeviceOrientationCamera").
  121204. * This helps avoiding instanceof at run time.
  121205. * @returns the class name
  121206. */
  121207. getClassName(): string;
  121208. /**
  121209. * @hidden
  121210. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  121211. */
  121212. _checkInputs(): void;
  121213. /**
  121214. * Reset the camera to its default orientation on the specified axis only.
  121215. * @param axis The axis to reset
  121216. */
  121217. resetToCurrentRotation(axis?: Axis): void;
  121218. }
  121219. }
  121220. declare module BABYLON {
  121221. /**
  121222. * Defines supported buttons for XBox360 compatible gamepads
  121223. */
  121224. export enum Xbox360Button {
  121225. /** A */
  121226. A = 0,
  121227. /** B */
  121228. B = 1,
  121229. /** X */
  121230. X = 2,
  121231. /** Y */
  121232. Y = 3,
  121233. /** Left button */
  121234. LB = 4,
  121235. /** Right button */
  121236. RB = 5,
  121237. /** Back */
  121238. Back = 8,
  121239. /** Start */
  121240. Start = 9,
  121241. /** Left stick */
  121242. LeftStick = 10,
  121243. /** Right stick */
  121244. RightStick = 11
  121245. }
  121246. /** Defines values for XBox360 DPad */
  121247. export enum Xbox360Dpad {
  121248. /** Up */
  121249. Up = 12,
  121250. /** Down */
  121251. Down = 13,
  121252. /** Left */
  121253. Left = 14,
  121254. /** Right */
  121255. Right = 15
  121256. }
  121257. /**
  121258. * Defines a XBox360 gamepad
  121259. */
  121260. export class Xbox360Pad extends Gamepad {
  121261. private _leftTrigger;
  121262. private _rightTrigger;
  121263. private _onlefttriggerchanged;
  121264. private _onrighttriggerchanged;
  121265. private _onbuttondown;
  121266. private _onbuttonup;
  121267. private _ondpaddown;
  121268. private _ondpadup;
  121269. /** Observable raised when a button is pressed */
  121270. onButtonDownObservable: Observable<Xbox360Button>;
  121271. /** Observable raised when a button is released */
  121272. onButtonUpObservable: Observable<Xbox360Button>;
  121273. /** Observable raised when a pad is pressed */
  121274. onPadDownObservable: Observable<Xbox360Dpad>;
  121275. /** Observable raised when a pad is released */
  121276. onPadUpObservable: Observable<Xbox360Dpad>;
  121277. private _buttonA;
  121278. private _buttonB;
  121279. private _buttonX;
  121280. private _buttonY;
  121281. private _buttonBack;
  121282. private _buttonStart;
  121283. private _buttonLB;
  121284. private _buttonRB;
  121285. private _buttonLeftStick;
  121286. private _buttonRightStick;
  121287. private _dPadUp;
  121288. private _dPadDown;
  121289. private _dPadLeft;
  121290. private _dPadRight;
  121291. private _isXboxOnePad;
  121292. /**
  121293. * Creates a new XBox360 gamepad object
  121294. * @param id defines the id of this gamepad
  121295. * @param index defines its index
  121296. * @param gamepad defines the internal HTML gamepad object
  121297. * @param xboxOne defines if it is a XBox One gamepad
  121298. */
  121299. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  121300. /**
  121301. * Defines the callback to call when left trigger is pressed
  121302. * @param callback defines the callback to use
  121303. */
  121304. onlefttriggerchanged(callback: (value: number) => void): void;
  121305. /**
  121306. * Defines the callback to call when right trigger is pressed
  121307. * @param callback defines the callback to use
  121308. */
  121309. onrighttriggerchanged(callback: (value: number) => void): void;
  121310. /**
  121311. * Gets the left trigger value
  121312. */
  121313. get leftTrigger(): number;
  121314. /**
  121315. * Sets the left trigger value
  121316. */
  121317. set leftTrigger(newValue: number);
  121318. /**
  121319. * Gets the right trigger value
  121320. */
  121321. get rightTrigger(): number;
  121322. /**
  121323. * Sets the right trigger value
  121324. */
  121325. set rightTrigger(newValue: number);
  121326. /**
  121327. * Defines the callback to call when a button is pressed
  121328. * @param callback defines the callback to use
  121329. */
  121330. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  121331. /**
  121332. * Defines the callback to call when a button is released
  121333. * @param callback defines the callback to use
  121334. */
  121335. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  121336. /**
  121337. * Defines the callback to call when a pad is pressed
  121338. * @param callback defines the callback to use
  121339. */
  121340. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  121341. /**
  121342. * Defines the callback to call when a pad is released
  121343. * @param callback defines the callback to use
  121344. */
  121345. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  121346. private _setButtonValue;
  121347. private _setDPadValue;
  121348. /**
  121349. * Gets the value of the `A` button
  121350. */
  121351. get buttonA(): number;
  121352. /**
  121353. * Sets the value of the `A` button
  121354. */
  121355. set buttonA(value: number);
  121356. /**
  121357. * Gets the value of the `B` button
  121358. */
  121359. get buttonB(): number;
  121360. /**
  121361. * Sets the value of the `B` button
  121362. */
  121363. set buttonB(value: number);
  121364. /**
  121365. * Gets the value of the `X` button
  121366. */
  121367. get buttonX(): number;
  121368. /**
  121369. * Sets the value of the `X` button
  121370. */
  121371. set buttonX(value: number);
  121372. /**
  121373. * Gets the value of the `Y` button
  121374. */
  121375. get buttonY(): number;
  121376. /**
  121377. * Sets the value of the `Y` button
  121378. */
  121379. set buttonY(value: number);
  121380. /**
  121381. * Gets the value of the `Start` button
  121382. */
  121383. get buttonStart(): number;
  121384. /**
  121385. * Sets the value of the `Start` button
  121386. */
  121387. set buttonStart(value: number);
  121388. /**
  121389. * Gets the value of the `Back` button
  121390. */
  121391. get buttonBack(): number;
  121392. /**
  121393. * Sets the value of the `Back` button
  121394. */
  121395. set buttonBack(value: number);
  121396. /**
  121397. * Gets the value of the `Left` button
  121398. */
  121399. get buttonLB(): number;
  121400. /**
  121401. * Sets the value of the `Left` button
  121402. */
  121403. set buttonLB(value: number);
  121404. /**
  121405. * Gets the value of the `Right` button
  121406. */
  121407. get buttonRB(): number;
  121408. /**
  121409. * Sets the value of the `Right` button
  121410. */
  121411. set buttonRB(value: number);
  121412. /**
  121413. * Gets the value of the Left joystick
  121414. */
  121415. get buttonLeftStick(): number;
  121416. /**
  121417. * Sets the value of the Left joystick
  121418. */
  121419. set buttonLeftStick(value: number);
  121420. /**
  121421. * Gets the value of the Right joystick
  121422. */
  121423. get buttonRightStick(): number;
  121424. /**
  121425. * Sets the value of the Right joystick
  121426. */
  121427. set buttonRightStick(value: number);
  121428. /**
  121429. * Gets the value of D-pad up
  121430. */
  121431. get dPadUp(): number;
  121432. /**
  121433. * Sets the value of D-pad up
  121434. */
  121435. set dPadUp(value: number);
  121436. /**
  121437. * Gets the value of D-pad down
  121438. */
  121439. get dPadDown(): number;
  121440. /**
  121441. * Sets the value of D-pad down
  121442. */
  121443. set dPadDown(value: number);
  121444. /**
  121445. * Gets the value of D-pad left
  121446. */
  121447. get dPadLeft(): number;
  121448. /**
  121449. * Sets the value of D-pad left
  121450. */
  121451. set dPadLeft(value: number);
  121452. /**
  121453. * Gets the value of D-pad right
  121454. */
  121455. get dPadRight(): number;
  121456. /**
  121457. * Sets the value of D-pad right
  121458. */
  121459. set dPadRight(value: number);
  121460. /**
  121461. * Force the gamepad to synchronize with device values
  121462. */
  121463. update(): void;
  121464. /**
  121465. * Disposes the gamepad
  121466. */
  121467. dispose(): void;
  121468. }
  121469. }
  121470. declare module BABYLON {
  121471. /**
  121472. * Defines supported buttons for DualShock compatible gamepads
  121473. */
  121474. export enum DualShockButton {
  121475. /** Cross */
  121476. Cross = 0,
  121477. /** Circle */
  121478. Circle = 1,
  121479. /** Square */
  121480. Square = 2,
  121481. /** Triangle */
  121482. Triangle = 3,
  121483. /** L1 */
  121484. L1 = 4,
  121485. /** R1 */
  121486. R1 = 5,
  121487. /** Share */
  121488. Share = 8,
  121489. /** Options */
  121490. Options = 9,
  121491. /** Left stick */
  121492. LeftStick = 10,
  121493. /** Right stick */
  121494. RightStick = 11
  121495. }
  121496. /** Defines values for DualShock DPad */
  121497. export enum DualShockDpad {
  121498. /** Up */
  121499. Up = 12,
  121500. /** Down */
  121501. Down = 13,
  121502. /** Left */
  121503. Left = 14,
  121504. /** Right */
  121505. Right = 15
  121506. }
  121507. /**
  121508. * Defines a DualShock gamepad
  121509. */
  121510. export class DualShockPad extends Gamepad {
  121511. private _leftTrigger;
  121512. private _rightTrigger;
  121513. private _onlefttriggerchanged;
  121514. private _onrighttriggerchanged;
  121515. private _onbuttondown;
  121516. private _onbuttonup;
  121517. private _ondpaddown;
  121518. private _ondpadup;
  121519. /** Observable raised when a button is pressed */
  121520. onButtonDownObservable: Observable<DualShockButton>;
  121521. /** Observable raised when a button is released */
  121522. onButtonUpObservable: Observable<DualShockButton>;
  121523. /** Observable raised when a pad is pressed */
  121524. onPadDownObservable: Observable<DualShockDpad>;
  121525. /** Observable raised when a pad is released */
  121526. onPadUpObservable: Observable<DualShockDpad>;
  121527. private _buttonCross;
  121528. private _buttonCircle;
  121529. private _buttonSquare;
  121530. private _buttonTriangle;
  121531. private _buttonShare;
  121532. private _buttonOptions;
  121533. private _buttonL1;
  121534. private _buttonR1;
  121535. private _buttonLeftStick;
  121536. private _buttonRightStick;
  121537. private _dPadUp;
  121538. private _dPadDown;
  121539. private _dPadLeft;
  121540. private _dPadRight;
  121541. /**
  121542. * Creates a new DualShock gamepad object
  121543. * @param id defines the id of this gamepad
  121544. * @param index defines its index
  121545. * @param gamepad defines the internal HTML gamepad object
  121546. */
  121547. constructor(id: string, index: number, gamepad: any);
  121548. /**
  121549. * Defines the callback to call when left trigger is pressed
  121550. * @param callback defines the callback to use
  121551. */
  121552. onlefttriggerchanged(callback: (value: number) => void): void;
  121553. /**
  121554. * Defines the callback to call when right trigger is pressed
  121555. * @param callback defines the callback to use
  121556. */
  121557. onrighttriggerchanged(callback: (value: number) => void): void;
  121558. /**
  121559. * Gets the left trigger value
  121560. */
  121561. get leftTrigger(): number;
  121562. /**
  121563. * Sets the left trigger value
  121564. */
  121565. set leftTrigger(newValue: number);
  121566. /**
  121567. * Gets the right trigger value
  121568. */
  121569. get rightTrigger(): number;
  121570. /**
  121571. * Sets the right trigger value
  121572. */
  121573. set rightTrigger(newValue: number);
  121574. /**
  121575. * Defines the callback to call when a button is pressed
  121576. * @param callback defines the callback to use
  121577. */
  121578. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  121579. /**
  121580. * Defines the callback to call when a button is released
  121581. * @param callback defines the callback to use
  121582. */
  121583. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  121584. /**
  121585. * Defines the callback to call when a pad is pressed
  121586. * @param callback defines the callback to use
  121587. */
  121588. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  121589. /**
  121590. * Defines the callback to call when a pad is released
  121591. * @param callback defines the callback to use
  121592. */
  121593. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  121594. private _setButtonValue;
  121595. private _setDPadValue;
  121596. /**
  121597. * Gets the value of the `Cross` button
  121598. */
  121599. get buttonCross(): number;
  121600. /**
  121601. * Sets the value of the `Cross` button
  121602. */
  121603. set buttonCross(value: number);
  121604. /**
  121605. * Gets the value of the `Circle` button
  121606. */
  121607. get buttonCircle(): number;
  121608. /**
  121609. * Sets the value of the `Circle` button
  121610. */
  121611. set buttonCircle(value: number);
  121612. /**
  121613. * Gets the value of the `Square` button
  121614. */
  121615. get buttonSquare(): number;
  121616. /**
  121617. * Sets the value of the `Square` button
  121618. */
  121619. set buttonSquare(value: number);
  121620. /**
  121621. * Gets the value of the `Triangle` button
  121622. */
  121623. get buttonTriangle(): number;
  121624. /**
  121625. * Sets the value of the `Triangle` button
  121626. */
  121627. set buttonTriangle(value: number);
  121628. /**
  121629. * Gets the value of the `Options` button
  121630. */
  121631. get buttonOptions(): number;
  121632. /**
  121633. * Sets the value of the `Options` button
  121634. */
  121635. set buttonOptions(value: number);
  121636. /**
  121637. * Gets the value of the `Share` button
  121638. */
  121639. get buttonShare(): number;
  121640. /**
  121641. * Sets the value of the `Share` button
  121642. */
  121643. set buttonShare(value: number);
  121644. /**
  121645. * Gets the value of the `L1` button
  121646. */
  121647. get buttonL1(): number;
  121648. /**
  121649. * Sets the value of the `L1` button
  121650. */
  121651. set buttonL1(value: number);
  121652. /**
  121653. * Gets the value of the `R1` button
  121654. */
  121655. get buttonR1(): number;
  121656. /**
  121657. * Sets the value of the `R1` button
  121658. */
  121659. set buttonR1(value: number);
  121660. /**
  121661. * Gets the value of the Left joystick
  121662. */
  121663. get buttonLeftStick(): number;
  121664. /**
  121665. * Sets the value of the Left joystick
  121666. */
  121667. set buttonLeftStick(value: number);
  121668. /**
  121669. * Gets the value of the Right joystick
  121670. */
  121671. get buttonRightStick(): number;
  121672. /**
  121673. * Sets the value of the Right joystick
  121674. */
  121675. set buttonRightStick(value: number);
  121676. /**
  121677. * Gets the value of D-pad up
  121678. */
  121679. get dPadUp(): number;
  121680. /**
  121681. * Sets the value of D-pad up
  121682. */
  121683. set dPadUp(value: number);
  121684. /**
  121685. * Gets the value of D-pad down
  121686. */
  121687. get dPadDown(): number;
  121688. /**
  121689. * Sets the value of D-pad down
  121690. */
  121691. set dPadDown(value: number);
  121692. /**
  121693. * Gets the value of D-pad left
  121694. */
  121695. get dPadLeft(): number;
  121696. /**
  121697. * Sets the value of D-pad left
  121698. */
  121699. set dPadLeft(value: number);
  121700. /**
  121701. * Gets the value of D-pad right
  121702. */
  121703. get dPadRight(): number;
  121704. /**
  121705. * Sets the value of D-pad right
  121706. */
  121707. set dPadRight(value: number);
  121708. /**
  121709. * Force the gamepad to synchronize with device values
  121710. */
  121711. update(): void;
  121712. /**
  121713. * Disposes the gamepad
  121714. */
  121715. dispose(): void;
  121716. }
  121717. }
  121718. declare module BABYLON {
  121719. /**
  121720. * Manager for handling gamepads
  121721. */
  121722. export class GamepadManager {
  121723. private _scene?;
  121724. private _babylonGamepads;
  121725. private _oneGamepadConnected;
  121726. /** @hidden */
  121727. _isMonitoring: boolean;
  121728. private _gamepadEventSupported;
  121729. private _gamepadSupport?;
  121730. /**
  121731. * observable to be triggered when the gamepad controller has been connected
  121732. */
  121733. onGamepadConnectedObservable: Observable<Gamepad>;
  121734. /**
  121735. * observable to be triggered when the gamepad controller has been disconnected
  121736. */
  121737. onGamepadDisconnectedObservable: Observable<Gamepad>;
  121738. private _onGamepadConnectedEvent;
  121739. private _onGamepadDisconnectedEvent;
  121740. /**
  121741. * Initializes the gamepad manager
  121742. * @param _scene BabylonJS scene
  121743. */
  121744. constructor(_scene?: Scene | undefined);
  121745. /**
  121746. * The gamepads in the game pad manager
  121747. */
  121748. get gamepads(): Gamepad[];
  121749. /**
  121750. * Get the gamepad controllers based on type
  121751. * @param type The type of gamepad controller
  121752. * @returns Nullable gamepad
  121753. */
  121754. getGamepadByType(type?: number): Nullable<Gamepad>;
  121755. /**
  121756. * Disposes the gamepad manager
  121757. */
  121758. dispose(): void;
  121759. private _addNewGamepad;
  121760. private _startMonitoringGamepads;
  121761. private _stopMonitoringGamepads;
  121762. /** @hidden */
  121763. _checkGamepadsStatus(): void;
  121764. private _updateGamepadObjects;
  121765. }
  121766. }
  121767. declare module BABYLON {
  121768. interface Scene {
  121769. /** @hidden */
  121770. _gamepadManager: Nullable<GamepadManager>;
  121771. /**
  121772. * Gets the gamepad manager associated with the scene
  121773. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  121774. */
  121775. gamepadManager: GamepadManager;
  121776. }
  121777. /**
  121778. * Interface representing a free camera inputs manager
  121779. */
  121780. interface FreeCameraInputsManager {
  121781. /**
  121782. * Adds gamepad input support to the FreeCameraInputsManager.
  121783. * @returns the FreeCameraInputsManager
  121784. */
  121785. addGamepad(): FreeCameraInputsManager;
  121786. }
  121787. /**
  121788. * Interface representing an arc rotate camera inputs manager
  121789. */
  121790. interface ArcRotateCameraInputsManager {
  121791. /**
  121792. * Adds gamepad input support to the ArcRotateCamera InputManager.
  121793. * @returns the camera inputs manager
  121794. */
  121795. addGamepad(): ArcRotateCameraInputsManager;
  121796. }
  121797. /**
  121798. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  121799. */
  121800. export class GamepadSystemSceneComponent implements ISceneComponent {
  121801. /**
  121802. * The component name helpfull to identify the component in the list of scene components.
  121803. */
  121804. readonly name: string;
  121805. /**
  121806. * The scene the component belongs to.
  121807. */
  121808. scene: Scene;
  121809. /**
  121810. * Creates a new instance of the component for the given scene
  121811. * @param scene Defines the scene to register the component in
  121812. */
  121813. constructor(scene: Scene);
  121814. /**
  121815. * Registers the component in a given scene
  121816. */
  121817. register(): void;
  121818. /**
  121819. * Rebuilds the elements related to this component in case of
  121820. * context lost for instance.
  121821. */
  121822. rebuild(): void;
  121823. /**
  121824. * Disposes the component and the associated ressources
  121825. */
  121826. dispose(): void;
  121827. private _beforeCameraUpdate;
  121828. }
  121829. }
  121830. declare module BABYLON {
  121831. /**
  121832. * 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,
  121833. * which still works and will still be found in many Playgrounds.
  121834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121835. */
  121836. export class UniversalCamera extends TouchCamera {
  121837. /**
  121838. * Defines the gamepad rotation sensiblity.
  121839. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121840. */
  121841. get gamepadAngularSensibility(): number;
  121842. set gamepadAngularSensibility(value: number);
  121843. /**
  121844. * Defines the gamepad move sensiblity.
  121845. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121846. */
  121847. get gamepadMoveSensibility(): number;
  121848. set gamepadMoveSensibility(value: number);
  121849. /**
  121850. * 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,
  121851. * which still works and will still be found in many Playgrounds.
  121852. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121853. * @param name Define the name of the camera in the scene
  121854. * @param position Define the start position of the camera in the scene
  121855. * @param scene Define the scene the camera belongs to
  121856. */
  121857. constructor(name: string, position: Vector3, scene: Scene);
  121858. /**
  121859. * Gets the current object class name.
  121860. * @return the class name
  121861. */
  121862. getClassName(): string;
  121863. }
  121864. }
  121865. declare module BABYLON {
  121866. /**
  121867. * This represents a FPS type of camera. This is only here for back compat purpose.
  121868. * Please use the UniversalCamera instead as both are identical.
  121869. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121870. */
  121871. export class GamepadCamera extends UniversalCamera {
  121872. /**
  121873. * Instantiates a new Gamepad Camera
  121874. * This represents a FPS type of camera. This is only here for back compat purpose.
  121875. * Please use the UniversalCamera instead as both are identical.
  121876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121877. * @param name Define the name of the camera in the scene
  121878. * @param position Define the start position of the camera in the scene
  121879. * @param scene Define the scene the camera belongs to
  121880. */
  121881. constructor(name: string, position: Vector3, scene: Scene);
  121882. /**
  121883. * Gets the current object class name.
  121884. * @return the class name
  121885. */
  121886. getClassName(): string;
  121887. }
  121888. }
  121889. declare module BABYLON {
  121890. /** @hidden */
  121891. export var passPixelShader: {
  121892. name: string;
  121893. shader: string;
  121894. };
  121895. }
  121896. declare module BABYLON {
  121897. /** @hidden */
  121898. export var passCubePixelShader: {
  121899. name: string;
  121900. shader: string;
  121901. };
  121902. }
  121903. declare module BABYLON {
  121904. /**
  121905. * PassPostProcess which produces an output the same as it's input
  121906. */
  121907. export class PassPostProcess extends PostProcess {
  121908. /**
  121909. * Creates the PassPostProcess
  121910. * @param name The name of the effect.
  121911. * @param options The required width/height ratio to downsize to before computing the render pass.
  121912. * @param camera The camera to apply the render pass to.
  121913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121914. * @param engine The engine which the post process will be applied. (default: current engine)
  121915. * @param reusable If the post process can be reused on the same frame. (default: false)
  121916. * @param textureType The type of texture to be used when performing the post processing.
  121917. * @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)
  121918. */
  121919. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121920. }
  121921. /**
  121922. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  121923. */
  121924. export class PassCubePostProcess extends PostProcess {
  121925. private _face;
  121926. /**
  121927. * Gets or sets the cube face to display.
  121928. * * 0 is +X
  121929. * * 1 is -X
  121930. * * 2 is +Y
  121931. * * 3 is -Y
  121932. * * 4 is +Z
  121933. * * 5 is -Z
  121934. */
  121935. get face(): number;
  121936. set face(value: number);
  121937. /**
  121938. * Creates the PassCubePostProcess
  121939. * @param name The name of the effect.
  121940. * @param options The required width/height ratio to downsize to before computing the render pass.
  121941. * @param camera The camera to apply the render pass to.
  121942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121943. * @param engine The engine which the post process will be applied. (default: current engine)
  121944. * @param reusable If the post process can be reused on the same frame. (default: false)
  121945. * @param textureType The type of texture to be used when performing the post processing.
  121946. * @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)
  121947. */
  121948. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121949. }
  121950. }
  121951. declare module BABYLON {
  121952. /** @hidden */
  121953. export var anaglyphPixelShader: {
  121954. name: string;
  121955. shader: string;
  121956. };
  121957. }
  121958. declare module BABYLON {
  121959. /**
  121960. * Postprocess used to generate anaglyphic rendering
  121961. */
  121962. export class AnaglyphPostProcess extends PostProcess {
  121963. private _passedProcess;
  121964. /**
  121965. * Creates a new AnaglyphPostProcess
  121966. * @param name defines postprocess name
  121967. * @param options defines creation options or target ratio scale
  121968. * @param rigCameras defines cameras using this postprocess
  121969. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  121970. * @param engine defines hosting engine
  121971. * @param reusable defines if the postprocess will be reused multiple times per frame
  121972. */
  121973. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  121974. }
  121975. }
  121976. declare module BABYLON {
  121977. /**
  121978. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  121979. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  121980. */
  121981. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  121982. /**
  121983. * Creates a new AnaglyphArcRotateCamera
  121984. * @param name defines camera name
  121985. * @param alpha defines alpha angle (in radians)
  121986. * @param beta defines beta angle (in radians)
  121987. * @param radius defines radius
  121988. * @param target defines camera target
  121989. * @param interaxialDistance defines distance between each color axis
  121990. * @param scene defines the hosting scene
  121991. */
  121992. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  121993. /**
  121994. * Gets camera class name
  121995. * @returns AnaglyphArcRotateCamera
  121996. */
  121997. getClassName(): string;
  121998. }
  121999. }
  122000. declare module BABYLON {
  122001. /**
  122002. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  122003. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122004. */
  122005. export class AnaglyphFreeCamera extends FreeCamera {
  122006. /**
  122007. * Creates a new AnaglyphFreeCamera
  122008. * @param name defines camera name
  122009. * @param position defines initial position
  122010. * @param interaxialDistance defines distance between each color axis
  122011. * @param scene defines the hosting scene
  122012. */
  122013. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122014. /**
  122015. * Gets camera class name
  122016. * @returns AnaglyphFreeCamera
  122017. */
  122018. getClassName(): string;
  122019. }
  122020. }
  122021. declare module BABYLON {
  122022. /**
  122023. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  122024. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122025. */
  122026. export class AnaglyphGamepadCamera extends GamepadCamera {
  122027. /**
  122028. * Creates a new AnaglyphGamepadCamera
  122029. * @param name defines camera name
  122030. * @param position defines initial position
  122031. * @param interaxialDistance defines distance between each color axis
  122032. * @param scene defines the hosting scene
  122033. */
  122034. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122035. /**
  122036. * Gets camera class name
  122037. * @returns AnaglyphGamepadCamera
  122038. */
  122039. getClassName(): string;
  122040. }
  122041. }
  122042. declare module BABYLON {
  122043. /**
  122044. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  122045. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122046. */
  122047. export class AnaglyphUniversalCamera extends UniversalCamera {
  122048. /**
  122049. * Creates a new AnaglyphUniversalCamera
  122050. * @param name defines camera name
  122051. * @param position defines initial position
  122052. * @param interaxialDistance defines distance between each color axis
  122053. * @param scene defines the hosting scene
  122054. */
  122055. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122056. /**
  122057. * Gets camera class name
  122058. * @returns AnaglyphUniversalCamera
  122059. */
  122060. getClassName(): string;
  122061. }
  122062. }
  122063. declare module BABYLON {
  122064. /**
  122065. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  122066. * @see http://doc.babylonjs.com/features/cameras
  122067. */
  122068. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  122069. /**
  122070. * Creates a new StereoscopicArcRotateCamera
  122071. * @param name defines camera name
  122072. * @param alpha defines alpha angle (in radians)
  122073. * @param beta defines beta angle (in radians)
  122074. * @param radius defines radius
  122075. * @param target defines camera target
  122076. * @param interaxialDistance defines distance between each color axis
  122077. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122078. * @param scene defines the hosting scene
  122079. */
  122080. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122081. /**
  122082. * Gets camera class name
  122083. * @returns StereoscopicArcRotateCamera
  122084. */
  122085. getClassName(): string;
  122086. }
  122087. }
  122088. declare module BABYLON {
  122089. /**
  122090. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  122091. * @see http://doc.babylonjs.com/features/cameras
  122092. */
  122093. export class StereoscopicFreeCamera extends FreeCamera {
  122094. /**
  122095. * Creates a new StereoscopicFreeCamera
  122096. * @param name defines camera name
  122097. * @param position defines initial position
  122098. * @param interaxialDistance defines distance between each color axis
  122099. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122100. * @param scene defines the hosting scene
  122101. */
  122102. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122103. /**
  122104. * Gets camera class name
  122105. * @returns StereoscopicFreeCamera
  122106. */
  122107. getClassName(): string;
  122108. }
  122109. }
  122110. declare module BABYLON {
  122111. /**
  122112. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  122113. * @see http://doc.babylonjs.com/features/cameras
  122114. */
  122115. export class StereoscopicGamepadCamera extends GamepadCamera {
  122116. /**
  122117. * Creates a new StereoscopicGamepadCamera
  122118. * @param name defines camera name
  122119. * @param position defines initial position
  122120. * @param interaxialDistance defines distance between each color axis
  122121. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122122. * @param scene defines the hosting scene
  122123. */
  122124. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122125. /**
  122126. * Gets camera class name
  122127. * @returns StereoscopicGamepadCamera
  122128. */
  122129. getClassName(): string;
  122130. }
  122131. }
  122132. declare module BABYLON {
  122133. /**
  122134. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  122135. * @see http://doc.babylonjs.com/features/cameras
  122136. */
  122137. export class StereoscopicUniversalCamera extends UniversalCamera {
  122138. /**
  122139. * Creates a new StereoscopicUniversalCamera
  122140. * @param name defines camera name
  122141. * @param position defines initial position
  122142. * @param interaxialDistance defines distance between each color axis
  122143. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122144. * @param scene defines the hosting scene
  122145. */
  122146. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122147. /**
  122148. * Gets camera class name
  122149. * @returns StereoscopicUniversalCamera
  122150. */
  122151. getClassName(): string;
  122152. }
  122153. }
  122154. declare module BABYLON {
  122155. /**
  122156. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  122157. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122158. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122159. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122160. */
  122161. export class VirtualJoysticksCamera extends FreeCamera {
  122162. /**
  122163. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  122164. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122165. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122166. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122167. * @param name Define the name of the camera in the scene
  122168. * @param position Define the start position of the camera in the scene
  122169. * @param scene Define the scene the camera belongs to
  122170. */
  122171. constructor(name: string, position: Vector3, scene: Scene);
  122172. /**
  122173. * Gets the current object class name.
  122174. * @return the class name
  122175. */
  122176. getClassName(): string;
  122177. }
  122178. }
  122179. declare module BABYLON {
  122180. /**
  122181. * This represents all the required metrics to create a VR camera.
  122182. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  122183. */
  122184. export class VRCameraMetrics {
  122185. /**
  122186. * Define the horizontal resolution off the screen.
  122187. */
  122188. hResolution: number;
  122189. /**
  122190. * Define the vertical resolution off the screen.
  122191. */
  122192. vResolution: number;
  122193. /**
  122194. * Define the horizontal screen size.
  122195. */
  122196. hScreenSize: number;
  122197. /**
  122198. * Define the vertical screen size.
  122199. */
  122200. vScreenSize: number;
  122201. /**
  122202. * Define the vertical screen center position.
  122203. */
  122204. vScreenCenter: number;
  122205. /**
  122206. * Define the distance of the eyes to the screen.
  122207. */
  122208. eyeToScreenDistance: number;
  122209. /**
  122210. * Define the distance between both lenses
  122211. */
  122212. lensSeparationDistance: number;
  122213. /**
  122214. * Define the distance between both viewer's eyes.
  122215. */
  122216. interpupillaryDistance: number;
  122217. /**
  122218. * Define the distortion factor of the VR postprocess.
  122219. * Please, touch with care.
  122220. */
  122221. distortionK: number[];
  122222. /**
  122223. * Define the chromatic aberration correction factors for the VR post process.
  122224. */
  122225. chromaAbCorrection: number[];
  122226. /**
  122227. * Define the scale factor of the post process.
  122228. * The smaller the better but the slower.
  122229. */
  122230. postProcessScaleFactor: number;
  122231. /**
  122232. * Define an offset for the lens center.
  122233. */
  122234. lensCenterOffset: number;
  122235. /**
  122236. * Define if the current vr camera should compensate the distortion of the lense or not.
  122237. */
  122238. compensateDistortion: boolean;
  122239. /**
  122240. * Defines if multiview should be enabled when rendering (Default: false)
  122241. */
  122242. multiviewEnabled: boolean;
  122243. /**
  122244. * Gets the rendering aspect ratio based on the provided resolutions.
  122245. */
  122246. get aspectRatio(): number;
  122247. /**
  122248. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  122249. */
  122250. get aspectRatioFov(): number;
  122251. /**
  122252. * @hidden
  122253. */
  122254. get leftHMatrix(): Matrix;
  122255. /**
  122256. * @hidden
  122257. */
  122258. get rightHMatrix(): Matrix;
  122259. /**
  122260. * @hidden
  122261. */
  122262. get leftPreViewMatrix(): Matrix;
  122263. /**
  122264. * @hidden
  122265. */
  122266. get rightPreViewMatrix(): Matrix;
  122267. /**
  122268. * Get the default VRMetrics based on the most generic setup.
  122269. * @returns the default vr metrics
  122270. */
  122271. static GetDefault(): VRCameraMetrics;
  122272. }
  122273. }
  122274. declare module BABYLON {
  122275. /** @hidden */
  122276. export var vrDistortionCorrectionPixelShader: {
  122277. name: string;
  122278. shader: string;
  122279. };
  122280. }
  122281. declare module BABYLON {
  122282. /**
  122283. * VRDistortionCorrectionPostProcess used for mobile VR
  122284. */
  122285. export class VRDistortionCorrectionPostProcess extends PostProcess {
  122286. private _isRightEye;
  122287. private _distortionFactors;
  122288. private _postProcessScaleFactor;
  122289. private _lensCenterOffset;
  122290. private _scaleIn;
  122291. private _scaleFactor;
  122292. private _lensCenter;
  122293. /**
  122294. * Initializes the VRDistortionCorrectionPostProcess
  122295. * @param name The name of the effect.
  122296. * @param camera The camera to apply the render pass to.
  122297. * @param isRightEye If this is for the right eye distortion
  122298. * @param vrMetrics All the required metrics for the VR camera
  122299. */
  122300. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  122301. }
  122302. }
  122303. declare module BABYLON {
  122304. /**
  122305. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  122306. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122307. */
  122308. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  122309. /**
  122310. * Creates a new VRDeviceOrientationArcRotateCamera
  122311. * @param name defines camera name
  122312. * @param alpha defines the camera rotation along the logitudinal axis
  122313. * @param beta defines the camera rotation along the latitudinal axis
  122314. * @param radius defines the camera distance from its target
  122315. * @param target defines the camera target
  122316. * @param scene defines the scene the camera belongs to
  122317. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122318. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122319. */
  122320. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122321. /**
  122322. * Gets camera class name
  122323. * @returns VRDeviceOrientationArcRotateCamera
  122324. */
  122325. getClassName(): string;
  122326. }
  122327. }
  122328. declare module BABYLON {
  122329. /**
  122330. * Camera used to simulate VR rendering (based on FreeCamera)
  122331. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122332. */
  122333. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  122334. /**
  122335. * Creates a new VRDeviceOrientationFreeCamera
  122336. * @param name defines camera name
  122337. * @param position defines the start position of the camera
  122338. * @param scene defines the scene the camera belongs to
  122339. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122340. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122341. */
  122342. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122343. /**
  122344. * Gets camera class name
  122345. * @returns VRDeviceOrientationFreeCamera
  122346. */
  122347. getClassName(): string;
  122348. }
  122349. }
  122350. declare module BABYLON {
  122351. /**
  122352. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  122353. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122354. */
  122355. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  122356. /**
  122357. * Creates a new VRDeviceOrientationGamepadCamera
  122358. * @param name defines camera name
  122359. * @param position defines the start position of the camera
  122360. * @param scene defines the scene the camera belongs to
  122361. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122362. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122363. */
  122364. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122365. /**
  122366. * Gets camera class name
  122367. * @returns VRDeviceOrientationGamepadCamera
  122368. */
  122369. getClassName(): string;
  122370. }
  122371. }
  122372. declare module BABYLON {
  122373. /** @hidden */
  122374. export var imageProcessingPixelShader: {
  122375. name: string;
  122376. shader: string;
  122377. };
  122378. }
  122379. declare module BABYLON {
  122380. /**
  122381. * ImageProcessingPostProcess
  122382. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  122383. */
  122384. export class ImageProcessingPostProcess extends PostProcess {
  122385. /**
  122386. * Default configuration related to image processing available in the PBR Material.
  122387. */
  122388. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122389. /**
  122390. * Gets the image processing configuration used either in this material.
  122391. */
  122392. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  122393. /**
  122394. * Sets the Default image processing configuration used either in the this material.
  122395. *
  122396. * If sets to null, the scene one is in use.
  122397. */
  122398. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  122399. /**
  122400. * Keep track of the image processing observer to allow dispose and replace.
  122401. */
  122402. private _imageProcessingObserver;
  122403. /**
  122404. * Attaches a new image processing configuration to the PBR Material.
  122405. * @param configuration
  122406. */
  122407. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  122408. /**
  122409. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122410. */
  122411. get colorCurves(): Nullable<ColorCurves>;
  122412. /**
  122413. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122414. */
  122415. set colorCurves(value: Nullable<ColorCurves>);
  122416. /**
  122417. * Gets wether the color curves effect is enabled.
  122418. */
  122419. get colorCurvesEnabled(): boolean;
  122420. /**
  122421. * Sets wether the color curves effect is enabled.
  122422. */
  122423. set colorCurvesEnabled(value: boolean);
  122424. /**
  122425. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122426. */
  122427. get colorGradingTexture(): Nullable<BaseTexture>;
  122428. /**
  122429. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122430. */
  122431. set colorGradingTexture(value: Nullable<BaseTexture>);
  122432. /**
  122433. * Gets wether the color grading effect is enabled.
  122434. */
  122435. get colorGradingEnabled(): boolean;
  122436. /**
  122437. * Gets wether the color grading effect is enabled.
  122438. */
  122439. set colorGradingEnabled(value: boolean);
  122440. /**
  122441. * Gets exposure used in the effect.
  122442. */
  122443. get exposure(): number;
  122444. /**
  122445. * Sets exposure used in the effect.
  122446. */
  122447. set exposure(value: number);
  122448. /**
  122449. * Gets wether tonemapping is enabled or not.
  122450. */
  122451. get toneMappingEnabled(): boolean;
  122452. /**
  122453. * Sets wether tonemapping is enabled or not
  122454. */
  122455. set toneMappingEnabled(value: boolean);
  122456. /**
  122457. * Gets the type of tone mapping effect.
  122458. */
  122459. get toneMappingType(): number;
  122460. /**
  122461. * Sets the type of tone mapping effect.
  122462. */
  122463. set toneMappingType(value: number);
  122464. /**
  122465. * Gets contrast used in the effect.
  122466. */
  122467. get contrast(): number;
  122468. /**
  122469. * Sets contrast used in the effect.
  122470. */
  122471. set contrast(value: number);
  122472. /**
  122473. * Gets Vignette stretch size.
  122474. */
  122475. get vignetteStretch(): number;
  122476. /**
  122477. * Sets Vignette stretch size.
  122478. */
  122479. set vignetteStretch(value: number);
  122480. /**
  122481. * Gets Vignette centre X Offset.
  122482. */
  122483. get vignetteCentreX(): number;
  122484. /**
  122485. * Sets Vignette centre X Offset.
  122486. */
  122487. set vignetteCentreX(value: number);
  122488. /**
  122489. * Gets Vignette centre Y Offset.
  122490. */
  122491. get vignetteCentreY(): number;
  122492. /**
  122493. * Sets Vignette centre Y Offset.
  122494. */
  122495. set vignetteCentreY(value: number);
  122496. /**
  122497. * Gets Vignette weight or intensity of the vignette effect.
  122498. */
  122499. get vignetteWeight(): number;
  122500. /**
  122501. * Sets Vignette weight or intensity of the vignette effect.
  122502. */
  122503. set vignetteWeight(value: number);
  122504. /**
  122505. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122506. * if vignetteEnabled is set to true.
  122507. */
  122508. get vignetteColor(): Color4;
  122509. /**
  122510. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122511. * if vignetteEnabled is set to true.
  122512. */
  122513. set vignetteColor(value: Color4);
  122514. /**
  122515. * Gets Camera field of view used by the Vignette effect.
  122516. */
  122517. get vignetteCameraFov(): number;
  122518. /**
  122519. * Sets Camera field of view used by the Vignette effect.
  122520. */
  122521. set vignetteCameraFov(value: number);
  122522. /**
  122523. * Gets the vignette blend mode allowing different kind of effect.
  122524. */
  122525. get vignetteBlendMode(): number;
  122526. /**
  122527. * Sets the vignette blend mode allowing different kind of effect.
  122528. */
  122529. set vignetteBlendMode(value: number);
  122530. /**
  122531. * Gets wether the vignette effect is enabled.
  122532. */
  122533. get vignetteEnabled(): boolean;
  122534. /**
  122535. * Sets wether the vignette effect is enabled.
  122536. */
  122537. set vignetteEnabled(value: boolean);
  122538. private _fromLinearSpace;
  122539. /**
  122540. * Gets wether the input of the processing is in Gamma or Linear Space.
  122541. */
  122542. get fromLinearSpace(): boolean;
  122543. /**
  122544. * Sets wether the input of the processing is in Gamma or Linear Space.
  122545. */
  122546. set fromLinearSpace(value: boolean);
  122547. /**
  122548. * Defines cache preventing GC.
  122549. */
  122550. private _defines;
  122551. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  122552. /**
  122553. * "ImageProcessingPostProcess"
  122554. * @returns "ImageProcessingPostProcess"
  122555. */
  122556. getClassName(): string;
  122557. protected _updateParameters(): void;
  122558. dispose(camera?: Camera): void;
  122559. }
  122560. }
  122561. declare module BABYLON {
  122562. /**
  122563. * Class containing static functions to help procedurally build meshes
  122564. */
  122565. export class GroundBuilder {
  122566. /**
  122567. * Creates a ground mesh
  122568. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  122569. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  122570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122571. * @param name defines the name of the mesh
  122572. * @param options defines the options used to create the mesh
  122573. * @param scene defines the hosting scene
  122574. * @returns the ground mesh
  122575. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  122576. */
  122577. static CreateGround(name: string, options: {
  122578. width?: number;
  122579. height?: number;
  122580. subdivisions?: number;
  122581. subdivisionsX?: number;
  122582. subdivisionsY?: number;
  122583. updatable?: boolean;
  122584. }, scene: any): Mesh;
  122585. /**
  122586. * Creates a tiled ground mesh
  122587. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  122588. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  122589. * * 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
  122590. * * 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
  122591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122592. * @param name defines the name of the mesh
  122593. * @param options defines the options used to create the mesh
  122594. * @param scene defines the hosting scene
  122595. * @returns the tiled ground mesh
  122596. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  122597. */
  122598. static CreateTiledGround(name: string, options: {
  122599. xmin: number;
  122600. zmin: number;
  122601. xmax: number;
  122602. zmax: number;
  122603. subdivisions?: {
  122604. w: number;
  122605. h: number;
  122606. };
  122607. precision?: {
  122608. w: number;
  122609. h: number;
  122610. };
  122611. updatable?: boolean;
  122612. }, scene?: Nullable<Scene>): Mesh;
  122613. /**
  122614. * Creates a ground mesh from a height map
  122615. * * The parameter `url` sets the URL of the height map image resource.
  122616. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  122617. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  122618. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  122619. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  122620. * * 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.
  122621. * * 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).
  122622. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  122623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122624. * @param name defines the name of the mesh
  122625. * @param url defines the url to the height map
  122626. * @param options defines the options used to create the mesh
  122627. * @param scene defines the hosting scene
  122628. * @returns the ground mesh
  122629. * @see https://doc.babylonjs.com/babylon101/height_map
  122630. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  122631. */
  122632. static CreateGroundFromHeightMap(name: string, url: string, options: {
  122633. width?: number;
  122634. height?: number;
  122635. subdivisions?: number;
  122636. minHeight?: number;
  122637. maxHeight?: number;
  122638. colorFilter?: Color3;
  122639. alphaFilter?: number;
  122640. updatable?: boolean;
  122641. onReady?: (mesh: GroundMesh) => void;
  122642. }, scene?: Nullable<Scene>): GroundMesh;
  122643. }
  122644. }
  122645. declare module BABYLON {
  122646. /**
  122647. * Class containing static functions to help procedurally build meshes
  122648. */
  122649. export class TorusBuilder {
  122650. /**
  122651. * Creates a torus mesh
  122652. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  122653. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  122654. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  122655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122658. * @param name defines the name of the mesh
  122659. * @param options defines the options used to create the mesh
  122660. * @param scene defines the hosting scene
  122661. * @returns the torus mesh
  122662. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  122663. */
  122664. static CreateTorus(name: string, options: {
  122665. diameter?: number;
  122666. thickness?: number;
  122667. tessellation?: number;
  122668. updatable?: boolean;
  122669. sideOrientation?: number;
  122670. frontUVs?: Vector4;
  122671. backUVs?: Vector4;
  122672. }, scene: any): Mesh;
  122673. }
  122674. }
  122675. declare module BABYLON {
  122676. /**
  122677. * Class containing static functions to help procedurally build meshes
  122678. */
  122679. export class CylinderBuilder {
  122680. /**
  122681. * Creates a cylinder or a cone mesh
  122682. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  122683. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  122684. * * 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.
  122685. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  122686. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  122687. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  122688. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  122689. * * 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).
  122690. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  122691. * * 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).
  122692. * * 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
  122693. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  122694. * * 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
  122695. * * 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.
  122696. * * If `enclose` is false, a ring surface is one element.
  122697. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  122698. * * 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
  122699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122702. * @param name defines the name of the mesh
  122703. * @param options defines the options used to create the mesh
  122704. * @param scene defines the hosting scene
  122705. * @returns the cylinder mesh
  122706. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  122707. */
  122708. static CreateCylinder(name: string, options: {
  122709. height?: number;
  122710. diameterTop?: number;
  122711. diameterBottom?: number;
  122712. diameter?: number;
  122713. tessellation?: number;
  122714. subdivisions?: number;
  122715. arc?: number;
  122716. faceColors?: Color4[];
  122717. faceUV?: Vector4[];
  122718. updatable?: boolean;
  122719. hasRings?: boolean;
  122720. enclose?: boolean;
  122721. cap?: number;
  122722. sideOrientation?: number;
  122723. frontUVs?: Vector4;
  122724. backUVs?: Vector4;
  122725. }, scene: any): Mesh;
  122726. }
  122727. }
  122728. declare module BABYLON {
  122729. /**
  122730. * States of the webXR experience
  122731. */
  122732. export enum WebXRState {
  122733. /**
  122734. * Transitioning to being in XR mode
  122735. */
  122736. ENTERING_XR = 0,
  122737. /**
  122738. * Transitioning to non XR mode
  122739. */
  122740. EXITING_XR = 1,
  122741. /**
  122742. * In XR mode and presenting
  122743. */
  122744. IN_XR = 2,
  122745. /**
  122746. * Not entered XR mode
  122747. */
  122748. NOT_IN_XR = 3
  122749. }
  122750. /**
  122751. * Abstraction of the XR render target
  122752. */
  122753. export interface WebXRRenderTarget extends IDisposable {
  122754. /**
  122755. * xrpresent context of the canvas which can be used to display/mirror xr content
  122756. */
  122757. canvasContext: WebGLRenderingContext;
  122758. /**
  122759. * xr layer for the canvas
  122760. */
  122761. xrLayer: Nullable<XRWebGLLayer>;
  122762. /**
  122763. * Initializes the xr layer for the session
  122764. * @param xrSession xr session
  122765. * @returns a promise that will resolve once the XR Layer has been created
  122766. */
  122767. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122768. }
  122769. }
  122770. declare module BABYLON {
  122771. /**
  122772. * COnfiguration object for WebXR output canvas
  122773. */
  122774. export class WebXRManagedOutputCanvasOptions {
  122775. /**
  122776. * An optional canvas in case you wish to create it yourself and provide it here.
  122777. * If not provided, a new canvas will be created
  122778. */
  122779. canvasElement?: HTMLCanvasElement;
  122780. /**
  122781. * Options for this XR Layer output
  122782. */
  122783. canvasOptions?: XRWebGLLayerOptions;
  122784. /**
  122785. * CSS styling for a newly created canvas (if not provided)
  122786. */
  122787. newCanvasCssStyle?: string;
  122788. /**
  122789. * Get the default values of the configuration object
  122790. * @returns default values of this configuration object
  122791. */
  122792. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  122793. }
  122794. /**
  122795. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  122796. */
  122797. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  122798. private _options;
  122799. private _canvas;
  122800. private _engine;
  122801. /**
  122802. * Rendering context of the canvas which can be used to display/mirror xr content
  122803. */
  122804. canvasContext: WebGLRenderingContext;
  122805. /**
  122806. * xr layer for the canvas
  122807. */
  122808. xrLayer: Nullable<XRWebGLLayer>;
  122809. /**
  122810. * Initializes the canvas to be added/removed upon entering/exiting xr
  122811. * @param _xrSessionManager The XR Session manager
  122812. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  122813. */
  122814. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  122815. /**
  122816. * Disposes of the object
  122817. */
  122818. dispose(): void;
  122819. /**
  122820. * Initializes the xr layer for the session
  122821. * @param xrSession xr session
  122822. * @returns a promise that will resolve once the XR Layer has been created
  122823. */
  122824. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122825. private _addCanvas;
  122826. private _removeCanvas;
  122827. private _setManagedOutputCanvas;
  122828. }
  122829. }
  122830. declare module BABYLON {
  122831. /**
  122832. * Manages an XRSession to work with Babylon's engine
  122833. * @see https://doc.babylonjs.com/how_to/webxr
  122834. */
  122835. export class WebXRSessionManager implements IDisposable {
  122836. /** The scene which the session should be created for */
  122837. scene: Scene;
  122838. private _referenceSpace;
  122839. private _rttProvider;
  122840. private _sessionEnded;
  122841. private _xrNavigator;
  122842. private baseLayer;
  122843. /**
  122844. * The base reference space from which the session started. good if you want to reset your
  122845. * reference space
  122846. */
  122847. baseReferenceSpace: XRReferenceSpace;
  122848. /**
  122849. * Current XR frame
  122850. */
  122851. currentFrame: Nullable<XRFrame>;
  122852. /** WebXR timestamp updated every frame */
  122853. currentTimestamp: number;
  122854. /**
  122855. * Used just in case of a failure to initialize an immersive session.
  122856. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  122857. */
  122858. defaultHeightCompensation: number;
  122859. /**
  122860. * Fires every time a new xrFrame arrives which can be used to update the camera
  122861. */
  122862. onXRFrameObservable: Observable<XRFrame>;
  122863. /**
  122864. * Fires when the reference space changed
  122865. */
  122866. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  122867. /**
  122868. * Fires when the xr session is ended either by the device or manually done
  122869. */
  122870. onXRSessionEnded: Observable<any>;
  122871. /**
  122872. * Fires when the xr session is ended either by the device or manually done
  122873. */
  122874. onXRSessionInit: Observable<XRSession>;
  122875. /**
  122876. * Underlying xr session
  122877. */
  122878. session: XRSession;
  122879. /**
  122880. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  122881. * or get the offset the player is currently at.
  122882. */
  122883. viewerReferenceSpace: XRReferenceSpace;
  122884. /**
  122885. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  122886. * @param scene The scene which the session should be created for
  122887. */
  122888. constructor(
  122889. /** The scene which the session should be created for */
  122890. scene: Scene);
  122891. /**
  122892. * The current reference space used in this session. This reference space can constantly change!
  122893. * It is mainly used to offset the camera's position.
  122894. */
  122895. get referenceSpace(): XRReferenceSpace;
  122896. /**
  122897. * Set a new reference space and triggers the observable
  122898. */
  122899. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  122900. /**
  122901. * Disposes of the session manager
  122902. */
  122903. dispose(): void;
  122904. /**
  122905. * Stops the xrSession and restores the render loop
  122906. * @returns Promise which resolves after it exits XR
  122907. */
  122908. exitXRAsync(): Promise<void>;
  122909. /**
  122910. * Gets the correct render target texture to be rendered this frame for this eye
  122911. * @param eye the eye for which to get the render target
  122912. * @returns the render target for the specified eye
  122913. */
  122914. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  122915. /**
  122916. * Creates a WebXRRenderTarget object for the XR session
  122917. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  122918. * @param options optional options to provide when creating a new render target
  122919. * @returns a WebXR render target to which the session can render
  122920. */
  122921. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  122922. /**
  122923. * Initializes the manager
  122924. * After initialization enterXR can be called to start an XR session
  122925. * @returns Promise which resolves after it is initialized
  122926. */
  122927. initializeAsync(): Promise<void>;
  122928. /**
  122929. * Initializes an xr session
  122930. * @param xrSessionMode mode to initialize
  122931. * @param xrSessionInit defines optional and required values to pass to the session builder
  122932. * @returns a promise which will resolve once the session has been initialized
  122933. */
  122934. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  122935. /**
  122936. * Checks if a session would be supported for the creation options specified
  122937. * @param sessionMode session mode to check if supported eg. immersive-vr
  122938. * @returns A Promise that resolves to true if supported and false if not
  122939. */
  122940. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  122941. /**
  122942. * Resets the reference space to the one started the session
  122943. */
  122944. resetReferenceSpace(): void;
  122945. /**
  122946. * Starts rendering to the xr layer
  122947. */
  122948. runXRRenderLoop(): void;
  122949. /**
  122950. * Sets the reference space on the xr session
  122951. * @param referenceSpaceType space to set
  122952. * @returns a promise that will resolve once the reference space has been set
  122953. */
  122954. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  122955. /**
  122956. * Updates the render state of the session
  122957. * @param state state to set
  122958. * @returns a promise that resolves once the render state has been updated
  122959. */
  122960. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  122961. /**
  122962. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  122963. * @param sessionMode defines the session to test
  122964. * @returns a promise with boolean as final value
  122965. */
  122966. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  122967. private _createRenderTargetTexture;
  122968. }
  122969. }
  122970. declare module BABYLON {
  122971. /**
  122972. * WebXR Camera which holds the views for the xrSession
  122973. * @see https://doc.babylonjs.com/how_to/webxr_camera
  122974. */
  122975. export class WebXRCamera extends FreeCamera {
  122976. private _xrSessionManager;
  122977. private _firstFrame;
  122978. private _referenceQuaternion;
  122979. private _referencedPosition;
  122980. private _xrInvPositionCache;
  122981. private _xrInvQuaternionCache;
  122982. /**
  122983. * Should position compensation execute on first frame.
  122984. * This is used when copying the position from a native (non XR) camera
  122985. */
  122986. compensateOnFirstFrame: boolean;
  122987. /**
  122988. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  122989. * @param name the name of the camera
  122990. * @param scene the scene to add the camera to
  122991. * @param _xrSessionManager a constructed xr session manager
  122992. */
  122993. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  122994. /**
  122995. * Return the user's height, unrelated to the current ground.
  122996. * This will be the y position of this camera, when ground level is 0.
  122997. */
  122998. get realWorldHeight(): number;
  122999. /** @hidden */
  123000. _updateForDualEyeDebugging(): void;
  123001. /**
  123002. * Sets this camera's transformation based on a non-vr camera
  123003. * @param otherCamera the non-vr camera to copy the transformation from
  123004. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  123005. */
  123006. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  123007. /**
  123008. * Gets the current instance class name ("WebXRCamera").
  123009. * @returns the class name
  123010. */
  123011. getClassName(): string;
  123012. /**
  123013. * Overriding the _getViewMatrix function, as it is computed by WebXR
  123014. */
  123015. _getViewMatrix(): Matrix;
  123016. private _updateFromXRSession;
  123017. private _updateNumberOfRigCameras;
  123018. private _updateReferenceSpace;
  123019. private _updateReferenceSpaceOffset;
  123020. }
  123021. }
  123022. declare module BABYLON {
  123023. /**
  123024. * Defining the interface required for a (webxr) feature
  123025. */
  123026. export interface IWebXRFeature extends IDisposable {
  123027. /**
  123028. * Is this feature attached
  123029. */
  123030. attached: boolean;
  123031. /**
  123032. * Should auto-attach be disabled?
  123033. */
  123034. disableAutoAttach: boolean;
  123035. /**
  123036. * Attach the feature to the session
  123037. * Will usually be called by the features manager
  123038. *
  123039. * @param force should attachment be forced (even when already attached)
  123040. * @returns true if successful.
  123041. */
  123042. attach(force?: boolean): boolean;
  123043. /**
  123044. * Detach the feature from the session
  123045. * Will usually be called by the features manager
  123046. *
  123047. * @returns true if successful.
  123048. */
  123049. detach(): boolean;
  123050. }
  123051. /**
  123052. * A list of the currently available features without referencing them
  123053. */
  123054. export class WebXRFeatureName {
  123055. /**
  123056. * The name of the anchor system feature
  123057. */
  123058. static ANCHOR_SYSTEM: string;
  123059. /**
  123060. * The name of the background remover feature
  123061. */
  123062. static BACKGROUND_REMOVER: string;
  123063. /**
  123064. * The name of the hit test feature
  123065. */
  123066. static HIT_TEST: string;
  123067. /**
  123068. * physics impostors for xr controllers feature
  123069. */
  123070. static PHYSICS_CONTROLLERS: string;
  123071. /**
  123072. * The name of the plane detection feature
  123073. */
  123074. static PLANE_DETECTION: string;
  123075. /**
  123076. * The name of the pointer selection feature
  123077. */
  123078. static POINTER_SELECTION: string;
  123079. /**
  123080. * The name of the teleportation feature
  123081. */
  123082. static TELEPORTATION: string;
  123083. }
  123084. /**
  123085. * Defining the constructor of a feature. Used to register the modules.
  123086. */
  123087. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  123088. /**
  123089. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  123090. * It is mainly used in AR sessions.
  123091. *
  123092. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  123093. */
  123094. export class WebXRFeaturesManager implements IDisposable {
  123095. private _xrSessionManager;
  123096. private static readonly _AvailableFeatures;
  123097. private _features;
  123098. /**
  123099. * constructs a new features manages.
  123100. *
  123101. * @param _xrSessionManager an instance of WebXRSessionManager
  123102. */
  123103. constructor(_xrSessionManager: WebXRSessionManager);
  123104. /**
  123105. * Used to register a module. After calling this function a developer can use this feature in the scene.
  123106. * Mainly used internally.
  123107. *
  123108. * @param featureName the name of the feature to register
  123109. * @param constructorFunction the function used to construct the module
  123110. * @param version the (babylon) version of the module
  123111. * @param stable is that a stable version of this module
  123112. */
  123113. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  123114. /**
  123115. * Returns a constructor of a specific feature.
  123116. *
  123117. * @param featureName the name of the feature to construct
  123118. * @param version the version of the feature to load
  123119. * @param xrSessionManager the xrSessionManager. Used to construct the module
  123120. * @param options optional options provided to the module.
  123121. * @returns a function that, when called, will return a new instance of this feature
  123122. */
  123123. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  123124. /**
  123125. * Can be used to return the list of features currently registered
  123126. *
  123127. * @returns an Array of available features
  123128. */
  123129. static GetAvailableFeatures(): string[];
  123130. /**
  123131. * Gets the versions available for a specific feature
  123132. * @param featureName the name of the feature
  123133. * @returns an array with the available versions
  123134. */
  123135. static GetAvailableVersions(featureName: string): string[];
  123136. /**
  123137. * Return the latest unstable version of this feature
  123138. * @param featureName the name of the feature to search
  123139. * @returns the version number. if not found will return -1
  123140. */
  123141. static GetLatestVersionOfFeature(featureName: string): number;
  123142. /**
  123143. * Return the latest stable version of this feature
  123144. * @param featureName the name of the feature to search
  123145. * @returns the version number. if not found will return -1
  123146. */
  123147. static GetStableVersionOfFeature(featureName: string): number;
  123148. /**
  123149. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  123150. * Can be used during a session to start a feature
  123151. * @param featureName the name of feature to attach
  123152. */
  123153. attachFeature(featureName: string): void;
  123154. /**
  123155. * Can be used inside a session or when the session ends to detach a specific feature
  123156. * @param featureName the name of the feature to detach
  123157. */
  123158. detachFeature(featureName: string): void;
  123159. /**
  123160. * Used to disable an already-enabled feature
  123161. * The feature will be disposed and will be recreated once enabled.
  123162. * @param featureName the feature to disable
  123163. * @returns true if disable was successful
  123164. */
  123165. disableFeature(featureName: string | {
  123166. Name: string;
  123167. }): boolean;
  123168. /**
  123169. * dispose this features manager
  123170. */
  123171. dispose(): void;
  123172. /**
  123173. * 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.
  123174. * 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.
  123175. *
  123176. * @param featureName the name of the feature to load or the class of the feature
  123177. * @param version optional version to load. if not provided the latest version will be enabled
  123178. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  123179. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  123180. * @returns a new constructed feature or throws an error if feature not found.
  123181. */
  123182. enableFeature(featureName: string | {
  123183. Name: string;
  123184. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  123185. /**
  123186. * get the implementation of an enabled feature.
  123187. * @param featureName the name of the feature to load
  123188. * @returns the feature class, if found
  123189. */
  123190. getEnabledFeature(featureName: string): IWebXRFeature;
  123191. /**
  123192. * Get the list of enabled features
  123193. * @returns an array of enabled features
  123194. */
  123195. getEnabledFeatures(): string[];
  123196. }
  123197. }
  123198. declare module BABYLON {
  123199. /**
  123200. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  123201. * @see https://doc.babylonjs.com/how_to/webxr
  123202. */
  123203. export class WebXRExperienceHelper implements IDisposable {
  123204. private scene;
  123205. private _nonVRCamera;
  123206. private _originalSceneAutoClear;
  123207. private _supported;
  123208. /**
  123209. * Camera used to render xr content
  123210. */
  123211. camera: WebXRCamera;
  123212. /** A features manager for this xr session */
  123213. featuresManager: WebXRFeaturesManager;
  123214. /**
  123215. * Observers registered here will be triggered after the camera's initial transformation is set
  123216. * This can be used to set a different ground level or an extra rotation.
  123217. *
  123218. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  123219. * to the position set after this observable is done executing.
  123220. */
  123221. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  123222. /**
  123223. * Fires when the state of the experience helper has changed
  123224. */
  123225. onStateChangedObservable: Observable<WebXRState>;
  123226. /** Session manager used to keep track of xr session */
  123227. sessionManager: WebXRSessionManager;
  123228. /**
  123229. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  123230. */
  123231. state: WebXRState;
  123232. /**
  123233. * Creates a WebXRExperienceHelper
  123234. * @param scene The scene the helper should be created in
  123235. */
  123236. private constructor();
  123237. /**
  123238. * Creates the experience helper
  123239. * @param scene the scene to attach the experience helper to
  123240. * @returns a promise for the experience helper
  123241. */
  123242. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  123243. /**
  123244. * Disposes of the experience helper
  123245. */
  123246. dispose(): void;
  123247. /**
  123248. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  123249. * @param sessionMode options for the XR session
  123250. * @param referenceSpaceType frame of reference of the XR session
  123251. * @param renderTarget the output canvas that will be used to enter XR mode
  123252. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  123253. * @returns promise that resolves after xr mode has entered
  123254. */
  123255. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  123256. /**
  123257. * Exits XR mode and returns the scene to its original state
  123258. * @returns promise that resolves after xr mode has exited
  123259. */
  123260. exitXRAsync(): Promise<void>;
  123261. private _nonXRToXRCamera;
  123262. private _setState;
  123263. }
  123264. }
  123265. declare module BABYLON {
  123266. /**
  123267. * X-Y values for axes in WebXR
  123268. */
  123269. export interface IWebXRMotionControllerAxesValue {
  123270. /**
  123271. * The value of the x axis
  123272. */
  123273. x: number;
  123274. /**
  123275. * The value of the y-axis
  123276. */
  123277. y: number;
  123278. }
  123279. /**
  123280. * changed / previous values for the values of this component
  123281. */
  123282. export interface IWebXRMotionControllerComponentChangesValues<T> {
  123283. /**
  123284. * current (this frame) value
  123285. */
  123286. current: T;
  123287. /**
  123288. * previous (last change) value
  123289. */
  123290. previous: T;
  123291. }
  123292. /**
  123293. * Represents changes in the component between current frame and last values recorded
  123294. */
  123295. export interface IWebXRMotionControllerComponentChanges {
  123296. /**
  123297. * will be populated with previous and current values if axes changed
  123298. */
  123299. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  123300. /**
  123301. * will be populated with previous and current values if pressed changed
  123302. */
  123303. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123304. /**
  123305. * will be populated with previous and current values if touched changed
  123306. */
  123307. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123308. /**
  123309. * will be populated with previous and current values if value changed
  123310. */
  123311. value?: IWebXRMotionControllerComponentChangesValues<number>;
  123312. }
  123313. /**
  123314. * This class represents a single component (for example button or thumbstick) of a motion controller
  123315. */
  123316. export class WebXRControllerComponent implements IDisposable {
  123317. /**
  123318. * the id of this component
  123319. */
  123320. id: string;
  123321. /**
  123322. * the type of the component
  123323. */
  123324. type: MotionControllerComponentType;
  123325. private _buttonIndex;
  123326. private _axesIndices;
  123327. private _axes;
  123328. private _changes;
  123329. private _currentValue;
  123330. private _hasChanges;
  123331. private _pressed;
  123332. private _touched;
  123333. /**
  123334. * button component type
  123335. */
  123336. static BUTTON_TYPE: MotionControllerComponentType;
  123337. /**
  123338. * squeeze component type
  123339. */
  123340. static SQUEEZE_TYPE: MotionControllerComponentType;
  123341. /**
  123342. * Thumbstick component type
  123343. */
  123344. static THUMBSTICK_TYPE: MotionControllerComponentType;
  123345. /**
  123346. * Touchpad component type
  123347. */
  123348. static TOUCHPAD_TYPE: MotionControllerComponentType;
  123349. /**
  123350. * trigger component type
  123351. */
  123352. static TRIGGER_TYPE: MotionControllerComponentType;
  123353. /**
  123354. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  123355. * the axes data changes
  123356. */
  123357. onAxisValueChangedObservable: Observable<{
  123358. x: number;
  123359. y: number;
  123360. }>;
  123361. /**
  123362. * Observers registered here will be triggered when the state of a button changes
  123363. * State change is either pressed / touched / value
  123364. */
  123365. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  123366. /**
  123367. * Creates a new component for a motion controller.
  123368. * It is created by the motion controller itself
  123369. *
  123370. * @param id the id of this component
  123371. * @param type the type of the component
  123372. * @param _buttonIndex index in the buttons array of the gamepad
  123373. * @param _axesIndices indices of the values in the axes array of the gamepad
  123374. */
  123375. constructor(
  123376. /**
  123377. * the id of this component
  123378. */
  123379. id: string,
  123380. /**
  123381. * the type of the component
  123382. */
  123383. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  123384. /**
  123385. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  123386. */
  123387. get axes(): IWebXRMotionControllerAxesValue;
  123388. /**
  123389. * Get the changes. Elements will be populated only if they changed with their previous and current value
  123390. */
  123391. get changes(): IWebXRMotionControllerComponentChanges;
  123392. /**
  123393. * Return whether or not the component changed the last frame
  123394. */
  123395. get hasChanges(): boolean;
  123396. /**
  123397. * is the button currently pressed
  123398. */
  123399. get pressed(): boolean;
  123400. /**
  123401. * is the button currently touched
  123402. */
  123403. get touched(): boolean;
  123404. /**
  123405. * Get the current value of this component
  123406. */
  123407. get value(): number;
  123408. /**
  123409. * Dispose this component
  123410. */
  123411. dispose(): void;
  123412. /**
  123413. * Are there axes correlating to this component
  123414. * @return true is axes data is available
  123415. */
  123416. isAxes(): boolean;
  123417. /**
  123418. * Is this component a button (hence - pressable)
  123419. * @returns true if can be pressed
  123420. */
  123421. isButton(): boolean;
  123422. /**
  123423. * update this component using the gamepad object it is in. Called on every frame
  123424. * @param nativeController the native gamepad controller object
  123425. */
  123426. update(nativeController: IMinimalMotionControllerObject): void;
  123427. }
  123428. }
  123429. declare module BABYLON {
  123430. /**
  123431. * Class used to represent data loading progression
  123432. */
  123433. export class SceneLoaderProgressEvent {
  123434. /** defines if data length to load can be evaluated */
  123435. readonly lengthComputable: boolean;
  123436. /** defines the loaded data length */
  123437. readonly loaded: number;
  123438. /** defines the data length to load */
  123439. readonly total: number;
  123440. /**
  123441. * Create a new progress event
  123442. * @param lengthComputable defines if data length to load can be evaluated
  123443. * @param loaded defines the loaded data length
  123444. * @param total defines the data length to load
  123445. */
  123446. constructor(
  123447. /** defines if data length to load can be evaluated */
  123448. lengthComputable: boolean,
  123449. /** defines the loaded data length */
  123450. loaded: number,
  123451. /** defines the data length to load */
  123452. total: number);
  123453. /**
  123454. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  123455. * @param event defines the source event
  123456. * @returns a new SceneLoaderProgressEvent
  123457. */
  123458. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  123459. }
  123460. /**
  123461. * Interface used by SceneLoader plugins to define supported file extensions
  123462. */
  123463. export interface ISceneLoaderPluginExtensions {
  123464. /**
  123465. * Defines the list of supported extensions
  123466. */
  123467. [extension: string]: {
  123468. isBinary: boolean;
  123469. };
  123470. }
  123471. /**
  123472. * Interface used by SceneLoader plugin factory
  123473. */
  123474. export interface ISceneLoaderPluginFactory {
  123475. /**
  123476. * Defines the name of the factory
  123477. */
  123478. name: string;
  123479. /**
  123480. * Function called to create a new plugin
  123481. * @return the new plugin
  123482. */
  123483. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  123484. /**
  123485. * The callback that returns true if the data can be directly loaded.
  123486. * @param data string containing the file data
  123487. * @returns if the data can be loaded directly
  123488. */
  123489. canDirectLoad?(data: string): boolean;
  123490. }
  123491. /**
  123492. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  123493. */
  123494. export interface ISceneLoaderPluginBase {
  123495. /**
  123496. * The friendly name of this plugin.
  123497. */
  123498. name: string;
  123499. /**
  123500. * The file extensions supported by this plugin.
  123501. */
  123502. extensions: string | ISceneLoaderPluginExtensions;
  123503. /**
  123504. * The callback called when loading from a url.
  123505. * @param scene scene loading this url
  123506. * @param url url to load
  123507. * @param onSuccess callback called when the file successfully loads
  123508. * @param onProgress callback called while file is loading (if the server supports this mode)
  123509. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123510. * @param onError callback called when the file fails to load
  123511. * @returns a file request object
  123512. */
  123513. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123514. /**
  123515. * The callback called when loading from a file object.
  123516. * @param scene scene loading this file
  123517. * @param file defines the file to load
  123518. * @param onSuccess defines the callback to call when data is loaded
  123519. * @param onProgress defines the callback to call during loading process
  123520. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123521. * @param onError defines the callback to call when an error occurs
  123522. * @returns a file request object
  123523. */
  123524. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123525. /**
  123526. * The callback that returns true if the data can be directly loaded.
  123527. * @param data string containing the file data
  123528. * @returns if the data can be loaded directly
  123529. */
  123530. canDirectLoad?(data: string): boolean;
  123531. /**
  123532. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  123533. * @param scene scene loading this data
  123534. * @param data string containing the data
  123535. * @returns data to pass to the plugin
  123536. */
  123537. directLoad?(scene: Scene, data: string): any;
  123538. /**
  123539. * The callback that allows custom handling of the root url based on the response url.
  123540. * @param rootUrl the original root url
  123541. * @param responseURL the response url if available
  123542. * @returns the new root url
  123543. */
  123544. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  123545. }
  123546. /**
  123547. * Interface used to define a SceneLoader plugin
  123548. */
  123549. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  123550. /**
  123551. * Import meshes into a scene.
  123552. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123553. * @param scene The scene to import into
  123554. * @param data The data to import
  123555. * @param rootUrl The root url for scene and resources
  123556. * @param meshes The meshes array to import into
  123557. * @param particleSystems The particle systems array to import into
  123558. * @param skeletons The skeletons array to import into
  123559. * @param onError The callback when import fails
  123560. * @returns True if successful or false otherwise
  123561. */
  123562. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  123563. /**
  123564. * Load into a scene.
  123565. * @param scene The scene to load into
  123566. * @param data The data to import
  123567. * @param rootUrl The root url for scene and resources
  123568. * @param onError The callback when import fails
  123569. * @returns True if successful or false otherwise
  123570. */
  123571. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  123572. /**
  123573. * Load into an asset container.
  123574. * @param scene The scene to load into
  123575. * @param data The data to import
  123576. * @param rootUrl The root url for scene and resources
  123577. * @param onError The callback when import fails
  123578. * @returns The loaded asset container
  123579. */
  123580. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  123581. }
  123582. /**
  123583. * Interface used to define an async SceneLoader plugin
  123584. */
  123585. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  123586. /**
  123587. * Import meshes into a scene.
  123588. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123589. * @param scene The scene to import into
  123590. * @param data The data to import
  123591. * @param rootUrl The root url for scene and resources
  123592. * @param onProgress The callback when the load progresses
  123593. * @param fileName Defines the name of the file to load
  123594. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  123595. */
  123596. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  123597. meshes: AbstractMesh[];
  123598. particleSystems: IParticleSystem[];
  123599. skeletons: Skeleton[];
  123600. animationGroups: AnimationGroup[];
  123601. }>;
  123602. /**
  123603. * Load into a scene.
  123604. * @param scene The scene to load into
  123605. * @param data The data to import
  123606. * @param rootUrl The root url for scene and resources
  123607. * @param onProgress The callback when the load progresses
  123608. * @param fileName Defines the name of the file to load
  123609. * @returns Nothing
  123610. */
  123611. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  123612. /**
  123613. * Load into an asset container.
  123614. * @param scene The scene to load into
  123615. * @param data The data to import
  123616. * @param rootUrl The root url for scene and resources
  123617. * @param onProgress The callback when the load progresses
  123618. * @param fileName Defines the name of the file to load
  123619. * @returns The loaded asset container
  123620. */
  123621. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  123622. }
  123623. /**
  123624. * Mode that determines how to handle old animation groups before loading new ones.
  123625. */
  123626. export enum SceneLoaderAnimationGroupLoadingMode {
  123627. /**
  123628. * Reset all old animations to initial state then dispose them.
  123629. */
  123630. Clean = 0,
  123631. /**
  123632. * Stop all old animations.
  123633. */
  123634. Stop = 1,
  123635. /**
  123636. * Restart old animations from first frame.
  123637. */
  123638. Sync = 2,
  123639. /**
  123640. * Old animations remains untouched.
  123641. */
  123642. NoSync = 3
  123643. }
  123644. /**
  123645. * Class used to load scene from various file formats using registered plugins
  123646. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  123647. */
  123648. export class SceneLoader {
  123649. /**
  123650. * No logging while loading
  123651. */
  123652. static readonly NO_LOGGING: number;
  123653. /**
  123654. * Minimal logging while loading
  123655. */
  123656. static readonly MINIMAL_LOGGING: number;
  123657. /**
  123658. * Summary logging while loading
  123659. */
  123660. static readonly SUMMARY_LOGGING: number;
  123661. /**
  123662. * Detailled logging while loading
  123663. */
  123664. static readonly DETAILED_LOGGING: number;
  123665. /**
  123666. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  123667. */
  123668. static get ForceFullSceneLoadingForIncremental(): boolean;
  123669. static set ForceFullSceneLoadingForIncremental(value: boolean);
  123670. /**
  123671. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  123672. */
  123673. static get ShowLoadingScreen(): boolean;
  123674. static set ShowLoadingScreen(value: boolean);
  123675. /**
  123676. * Defines the current logging level (while loading the scene)
  123677. * @ignorenaming
  123678. */
  123679. static get loggingLevel(): number;
  123680. static set loggingLevel(value: number);
  123681. /**
  123682. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  123683. */
  123684. static get CleanBoneMatrixWeights(): boolean;
  123685. static set CleanBoneMatrixWeights(value: boolean);
  123686. /**
  123687. * Event raised when a plugin is used to load a scene
  123688. */
  123689. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123690. private static _registeredPlugins;
  123691. private static _getDefaultPlugin;
  123692. private static _getPluginForExtension;
  123693. private static _getPluginForDirectLoad;
  123694. private static _getPluginForFilename;
  123695. private static _getDirectLoad;
  123696. private static _loadData;
  123697. private static _getFileInfo;
  123698. /**
  123699. * Gets a plugin that can load the given extension
  123700. * @param extension defines the extension to load
  123701. * @returns a plugin or null if none works
  123702. */
  123703. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  123704. /**
  123705. * Gets a boolean indicating that the given extension can be loaded
  123706. * @param extension defines the extension to load
  123707. * @returns true if the extension is supported
  123708. */
  123709. static IsPluginForExtensionAvailable(extension: string): boolean;
  123710. /**
  123711. * Adds a new plugin to the list of registered plugins
  123712. * @param plugin defines the plugin to add
  123713. */
  123714. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  123715. /**
  123716. * Import meshes into a scene
  123717. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123718. * @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)
  123719. * @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)
  123720. * @param scene the instance of BABYLON.Scene to append to
  123721. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  123722. * @param onProgress a callback with a progress event for each file being loaded
  123723. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123724. * @param pluginExtension the extension used to determine the plugin
  123725. * @returns The loaded plugin
  123726. */
  123727. 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>;
  123728. /**
  123729. * Import meshes into a scene
  123730. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123731. * @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)
  123732. * @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)
  123733. * @param scene the instance of BABYLON.Scene to append to
  123734. * @param onProgress a callback with a progress event for each file being loaded
  123735. * @param pluginExtension the extension used to determine the plugin
  123736. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  123737. */
  123738. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  123739. meshes: AbstractMesh[];
  123740. particleSystems: IParticleSystem[];
  123741. skeletons: Skeleton[];
  123742. animationGroups: AnimationGroup[];
  123743. }>;
  123744. /**
  123745. * Load a scene
  123746. * @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)
  123747. * @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)
  123748. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123749. * @param onSuccess a callback with the scene when import succeeds
  123750. * @param onProgress a callback with a progress event for each file being loaded
  123751. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123752. * @param pluginExtension the extension used to determine the plugin
  123753. * @returns The loaded plugin
  123754. */
  123755. 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>;
  123756. /**
  123757. * Load a scene
  123758. * @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)
  123759. * @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)
  123760. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123761. * @param onProgress a callback with a progress event for each file being loaded
  123762. * @param pluginExtension the extension used to determine the plugin
  123763. * @returns The loaded scene
  123764. */
  123765. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123766. /**
  123767. * Append a scene
  123768. * @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)
  123769. * @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)
  123770. * @param scene is the instance of BABYLON.Scene to append to
  123771. * @param onSuccess a callback with the scene when import succeeds
  123772. * @param onProgress a callback with a progress event for each file being loaded
  123773. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123774. * @param pluginExtension the extension used to determine the plugin
  123775. * @returns The loaded plugin
  123776. */
  123777. 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>;
  123778. /**
  123779. * Append a scene
  123780. * @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)
  123781. * @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)
  123782. * @param scene is the instance of BABYLON.Scene to append to
  123783. * @param onProgress a callback with a progress event for each file being loaded
  123784. * @param pluginExtension the extension used to determine the plugin
  123785. * @returns The given scene
  123786. */
  123787. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123788. /**
  123789. * Load a scene into an asset container
  123790. * @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)
  123791. * @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)
  123792. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123793. * @param onSuccess a callback with the scene when import succeeds
  123794. * @param onProgress a callback with a progress event for each file being loaded
  123795. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123796. * @param pluginExtension the extension used to determine the plugin
  123797. * @returns The loaded plugin
  123798. */
  123799. 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>;
  123800. /**
  123801. * Load a scene into an asset container
  123802. * @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)
  123803. * @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)
  123804. * @param scene is the instance of Scene to append to
  123805. * @param onProgress a callback with a progress event for each file being loaded
  123806. * @param pluginExtension the extension used to determine the plugin
  123807. * @returns The loaded asset container
  123808. */
  123809. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  123810. /**
  123811. * Import animations from a file into a scene
  123812. * @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)
  123813. * @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)
  123814. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123815. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123816. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123817. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123818. * @param onSuccess a callback with the scene when import succeeds
  123819. * @param onProgress a callback with a progress event for each file being loaded
  123820. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123821. */
  123822. 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;
  123823. /**
  123824. * Import animations from a file into a scene
  123825. * @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)
  123826. * @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)
  123827. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123828. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123829. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123830. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123831. * @param onSuccess a callback with the scene when import succeeds
  123832. * @param onProgress a callback with a progress event for each file being loaded
  123833. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123834. * @returns the updated scene with imported animations
  123835. */
  123836. 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>;
  123837. }
  123838. }
  123839. declare module BABYLON {
  123840. /**
  123841. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  123842. */
  123843. export type MotionControllerHandedness = "none" | "left" | "right";
  123844. /**
  123845. * The type of components available in motion controllers.
  123846. * This is not the name of the component.
  123847. */
  123848. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  123849. /**
  123850. * The state of a controller component
  123851. */
  123852. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  123853. /**
  123854. * The schema of motion controller layout.
  123855. * No object will be initialized using this interface
  123856. * This is used just to define the profile.
  123857. */
  123858. export interface IMotionControllerLayout {
  123859. /**
  123860. * Path to load the assets. Usually relative to the base path
  123861. */
  123862. assetPath: string;
  123863. /**
  123864. * Available components (unsorted)
  123865. */
  123866. components: {
  123867. /**
  123868. * A map of component Ids
  123869. */
  123870. [componentId: string]: {
  123871. /**
  123872. * The type of input the component outputs
  123873. */
  123874. type: MotionControllerComponentType;
  123875. /**
  123876. * The indices of this component in the gamepad object
  123877. */
  123878. gamepadIndices: {
  123879. /**
  123880. * Index of button
  123881. */
  123882. button?: number;
  123883. /**
  123884. * If available, index of x-axis
  123885. */
  123886. xAxis?: number;
  123887. /**
  123888. * If available, index of y-axis
  123889. */
  123890. yAxis?: number;
  123891. };
  123892. /**
  123893. * The mesh's root node name
  123894. */
  123895. rootNodeName: string;
  123896. /**
  123897. * Animation definitions for this model
  123898. */
  123899. visualResponses: {
  123900. [stateKey: string]: {
  123901. /**
  123902. * What property will be animated
  123903. */
  123904. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  123905. /**
  123906. * What states influence this visual response
  123907. */
  123908. states: MotionControllerComponentStateType[];
  123909. /**
  123910. * Type of animation - movement or visibility
  123911. */
  123912. valueNodeProperty: "transform" | "visibility";
  123913. /**
  123914. * Base node name to move. Its position will be calculated according to the min and max nodes
  123915. */
  123916. valueNodeName?: string;
  123917. /**
  123918. * Minimum movement node
  123919. */
  123920. minNodeName?: string;
  123921. /**
  123922. * Max movement node
  123923. */
  123924. maxNodeName?: string;
  123925. };
  123926. };
  123927. /**
  123928. * If touch enabled, what is the name of node to display user feedback
  123929. */
  123930. touchPointNodeName?: string;
  123931. };
  123932. };
  123933. /**
  123934. * Is it xr standard mapping or not
  123935. */
  123936. gamepadMapping: "" | "xr-standard";
  123937. /**
  123938. * Base root node of this entire model
  123939. */
  123940. rootNodeName: string;
  123941. /**
  123942. * Defines the main button component id
  123943. */
  123944. selectComponentId: string;
  123945. }
  123946. /**
  123947. * A definition for the layout map in the input profile
  123948. */
  123949. export interface IMotionControllerLayoutMap {
  123950. /**
  123951. * Layouts with handedness type as a key
  123952. */
  123953. [handedness: string]: IMotionControllerLayout;
  123954. }
  123955. /**
  123956. * The XR Input profile schema
  123957. * Profiles can be found here:
  123958. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  123959. */
  123960. export interface IMotionControllerProfile {
  123961. /**
  123962. * fallback profiles for this profileId
  123963. */
  123964. fallbackProfileIds: string[];
  123965. /**
  123966. * The layout map, with handedness as key
  123967. */
  123968. layouts: IMotionControllerLayoutMap;
  123969. /**
  123970. * The id of this profile
  123971. * correlates to the profile(s) in the xrInput.profiles array
  123972. */
  123973. profileId: string;
  123974. }
  123975. /**
  123976. * A helper-interface for the 3 meshes needed for controller button animation
  123977. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  123978. */
  123979. export interface IMotionControllerButtonMeshMap {
  123980. /**
  123981. * the mesh that defines the pressed value mesh position.
  123982. * This is used to find the max-position of this button
  123983. */
  123984. pressedMesh: AbstractMesh;
  123985. /**
  123986. * the mesh that defines the unpressed value mesh position.
  123987. * This is used to find the min (or initial) position of this button
  123988. */
  123989. unpressedMesh: AbstractMesh;
  123990. /**
  123991. * The mesh that will be changed when value changes
  123992. */
  123993. valueMesh: AbstractMesh;
  123994. }
  123995. /**
  123996. * A helper-interface for the 3 meshes needed for controller axis animation.
  123997. * This will be expanded when touchpad animations are fully supported
  123998. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  123999. */
  124000. export interface IMotionControllerMeshMap {
  124001. /**
  124002. * the mesh that defines the maximum value mesh position.
  124003. */
  124004. maxMesh?: AbstractMesh;
  124005. /**
  124006. * the mesh that defines the minimum value mesh position.
  124007. */
  124008. minMesh?: AbstractMesh;
  124009. /**
  124010. * The mesh that will be changed when axis value changes
  124011. */
  124012. valueMesh: AbstractMesh;
  124013. }
  124014. /**
  124015. * The elements needed for change-detection of the gamepad objects in motion controllers
  124016. */
  124017. export interface IMinimalMotionControllerObject {
  124018. /**
  124019. * Available axes of this controller
  124020. */
  124021. axes: number[];
  124022. /**
  124023. * An array of available buttons
  124024. */
  124025. buttons: Array<{
  124026. /**
  124027. * Value of the button/trigger
  124028. */
  124029. value: number;
  124030. /**
  124031. * If the button/trigger is currently touched
  124032. */
  124033. touched: boolean;
  124034. /**
  124035. * If the button/trigger is currently pressed
  124036. */
  124037. pressed: boolean;
  124038. }>;
  124039. /**
  124040. * EXPERIMENTAL haptic support.
  124041. */
  124042. hapticActuators?: Array<{
  124043. pulse: (value: number, duration: number) => Promise<boolean>;
  124044. }>;
  124045. }
  124046. /**
  124047. * An Abstract Motion controller
  124048. * This class receives an xrInput and a profile layout and uses those to initialize the components
  124049. * Each component has an observable to check for changes in value and state
  124050. */
  124051. export abstract class WebXRAbstractMotionController implements IDisposable {
  124052. protected scene: Scene;
  124053. protected layout: IMotionControllerLayout;
  124054. /**
  124055. * The gamepad object correlating to this controller
  124056. */
  124057. gamepadObject: IMinimalMotionControllerObject;
  124058. /**
  124059. * handedness (left/right/none) of this controller
  124060. */
  124061. handedness: MotionControllerHandedness;
  124062. private _initComponent;
  124063. private _modelReady;
  124064. /**
  124065. * A map of components (WebXRControllerComponent) in this motion controller
  124066. * Components have a ComponentType and can also have both button and axis definitions
  124067. */
  124068. readonly components: {
  124069. [id: string]: WebXRControllerComponent;
  124070. };
  124071. /**
  124072. * Disable the model's animation. Can be set at any time.
  124073. */
  124074. disableAnimation: boolean;
  124075. /**
  124076. * Observers registered here will be triggered when the model of this controller is done loading
  124077. */
  124078. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  124079. /**
  124080. * The profile id of this motion controller
  124081. */
  124082. abstract profileId: string;
  124083. /**
  124084. * The root mesh of the model. It is null if the model was not yet initialized
  124085. */
  124086. rootMesh: Nullable<AbstractMesh>;
  124087. /**
  124088. * constructs a new abstract motion controller
  124089. * @param scene the scene to which the model of the controller will be added
  124090. * @param layout The profile layout to load
  124091. * @param gamepadObject The gamepad object correlating to this controller
  124092. * @param handedness handedness (left/right/none) of this controller
  124093. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  124094. */
  124095. constructor(scene: Scene, layout: IMotionControllerLayout,
  124096. /**
  124097. * The gamepad object correlating to this controller
  124098. */
  124099. gamepadObject: IMinimalMotionControllerObject,
  124100. /**
  124101. * handedness (left/right/none) of this controller
  124102. */
  124103. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  124104. /**
  124105. * Dispose this controller, the model mesh and all its components
  124106. */
  124107. dispose(): void;
  124108. /**
  124109. * Returns all components of specific type
  124110. * @param type the type to search for
  124111. * @return an array of components with this type
  124112. */
  124113. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  124114. /**
  124115. * get a component based an its component id as defined in layout.components
  124116. * @param id the id of the component
  124117. * @returns the component correlates to the id or undefined if not found
  124118. */
  124119. getComponent(id: string): WebXRControllerComponent;
  124120. /**
  124121. * Get the list of components available in this motion controller
  124122. * @returns an array of strings correlating to available components
  124123. */
  124124. getComponentIds(): string[];
  124125. /**
  124126. * Get the first component of specific type
  124127. * @param type type of component to find
  124128. * @return a controller component or null if not found
  124129. */
  124130. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  124131. /**
  124132. * Get the main (Select) component of this controller as defined in the layout
  124133. * @returns the main component of this controller
  124134. */
  124135. getMainComponent(): WebXRControllerComponent;
  124136. /**
  124137. * Loads the model correlating to this controller
  124138. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  124139. * @returns A promise fulfilled with the result of the model loading
  124140. */
  124141. loadModel(): Promise<boolean>;
  124142. /**
  124143. * Update this model using the current XRFrame
  124144. * @param xrFrame the current xr frame to use and update the model
  124145. */
  124146. updateFromXRFrame(xrFrame: XRFrame): void;
  124147. /**
  124148. * Backwards compatibility due to a deeply-integrated typo
  124149. */
  124150. get handness(): XREye;
  124151. /**
  124152. * Pulse (vibrate) this controller
  124153. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  124154. * Consecutive calls to this function will cancel the last pulse call
  124155. *
  124156. * @param value the strength of the pulse in 0.0...1.0 range
  124157. * @param duration Duration of the pulse in milliseconds
  124158. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  124159. * @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
  124160. */
  124161. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  124162. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124163. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124164. /**
  124165. * Moves the axis on the controller mesh based on its current state
  124166. * @param axis the index of the axis
  124167. * @param axisValue the value of the axis which determines the meshes new position
  124168. * @hidden
  124169. */
  124170. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  124171. /**
  124172. * Update the model itself with the current frame data
  124173. * @param xrFrame the frame to use for updating the model mesh
  124174. */
  124175. protected updateModel(xrFrame: XRFrame): void;
  124176. /**
  124177. * Get the filename and path for this controller's model
  124178. * @returns a map of filename and path
  124179. */
  124180. protected abstract _getFilenameAndPath(): {
  124181. filename: string;
  124182. path: string;
  124183. };
  124184. /**
  124185. * This function is called before the mesh is loaded. It checks for loading constraints.
  124186. * For example, this function can check if the GLB loader is available
  124187. * If this function returns false, the generic controller will be loaded instead
  124188. * @returns Is the client ready to load the mesh
  124189. */
  124190. protected abstract _getModelLoadingConstraints(): boolean;
  124191. /**
  124192. * This function will be called after the model was successfully loaded and can be used
  124193. * for mesh transformations before it is available for the user
  124194. * @param meshes the loaded meshes
  124195. */
  124196. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  124197. /**
  124198. * Set the root mesh for this controller. Important for the WebXR controller class
  124199. * @param meshes the loaded meshes
  124200. */
  124201. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  124202. /**
  124203. * A function executed each frame that updates the mesh (if needed)
  124204. * @param xrFrame the current xrFrame
  124205. */
  124206. protected abstract _updateModel(xrFrame: XRFrame): void;
  124207. private _getGenericFilenameAndPath;
  124208. private _getGenericParentMesh;
  124209. }
  124210. }
  124211. declare module BABYLON {
  124212. /**
  124213. * A generic trigger-only motion controller for WebXR
  124214. */
  124215. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  124216. /**
  124217. * Static version of the profile id of this controller
  124218. */
  124219. static ProfileId: string;
  124220. profileId: string;
  124221. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  124222. protected _getFilenameAndPath(): {
  124223. filename: string;
  124224. path: string;
  124225. };
  124226. protected _getModelLoadingConstraints(): boolean;
  124227. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  124228. protected _setRootMesh(meshes: AbstractMesh[]): void;
  124229. protected _updateModel(): void;
  124230. }
  124231. }
  124232. declare module BABYLON {
  124233. /**
  124234. * Class containing static functions to help procedurally build meshes
  124235. */
  124236. export class SphereBuilder {
  124237. /**
  124238. * Creates a sphere mesh
  124239. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124240. * * 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`)
  124241. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124242. * * 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
  124243. * * 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)
  124244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124247. * @param name defines the name of the mesh
  124248. * @param options defines the options used to create the mesh
  124249. * @param scene defines the hosting scene
  124250. * @returns the sphere mesh
  124251. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124252. */
  124253. static CreateSphere(name: string, options: {
  124254. segments?: number;
  124255. diameter?: number;
  124256. diameterX?: number;
  124257. diameterY?: number;
  124258. diameterZ?: number;
  124259. arc?: number;
  124260. slice?: number;
  124261. sideOrientation?: number;
  124262. frontUVs?: Vector4;
  124263. backUVs?: Vector4;
  124264. updatable?: boolean;
  124265. }, scene?: Nullable<Scene>): Mesh;
  124266. }
  124267. }
  124268. declare module BABYLON {
  124269. /**
  124270. * A profiled motion controller has its profile loaded from an online repository.
  124271. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  124272. */
  124273. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  124274. private _repositoryUrl;
  124275. private _buttonMeshMapping;
  124276. private _touchDots;
  124277. /**
  124278. * The profile ID of this controller. Will be populated when the controller initializes.
  124279. */
  124280. profileId: string;
  124281. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  124282. dispose(): void;
  124283. protected _getFilenameAndPath(): {
  124284. filename: string;
  124285. path: string;
  124286. };
  124287. protected _getModelLoadingConstraints(): boolean;
  124288. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  124289. protected _setRootMesh(meshes: AbstractMesh[]): void;
  124290. protected _updateModel(_xrFrame: XRFrame): void;
  124291. }
  124292. }
  124293. declare module BABYLON {
  124294. /**
  124295. * A construction function type to create a new controller based on an xrInput object
  124296. */
  124297. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  124298. /**
  124299. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  124300. *
  124301. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  124302. * it should be replaced with auto-loaded controllers.
  124303. *
  124304. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  124305. */
  124306. export class WebXRMotionControllerManager {
  124307. private static _AvailableControllers;
  124308. private static _Fallbacks;
  124309. private static _ProfileLoadingPromises;
  124310. private static _ProfilesList;
  124311. /**
  124312. * The base URL of the online controller repository. Can be changed at any time.
  124313. */
  124314. static BaseRepositoryUrl: string;
  124315. /**
  124316. * Which repository gets priority - local or online
  124317. */
  124318. static PrioritizeOnlineRepository: boolean;
  124319. /**
  124320. * Use the online repository, or use only locally-defined controllers
  124321. */
  124322. static UseOnlineRepository: boolean;
  124323. /**
  124324. * Clear the cache used for profile loading and reload when requested again
  124325. */
  124326. static ClearProfilesCache(): void;
  124327. /**
  124328. * Register the default fallbacks.
  124329. * This function is called automatically when this file is imported.
  124330. */
  124331. static DefaultFallbacks(): void;
  124332. /**
  124333. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  124334. * @param profileId the profile to which a fallback needs to be found
  124335. * @return an array with corresponding fallback profiles
  124336. */
  124337. static FindFallbackWithProfileId(profileId: string): string[];
  124338. /**
  124339. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  124340. * The order of search:
  124341. *
  124342. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  124343. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  124344. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  124345. * 4) return the generic trigger controller if none were found
  124346. *
  124347. * @param xrInput the xrInput to which a new controller is initialized
  124348. * @param scene the scene to which the model will be added
  124349. * @param forceProfile force a certain profile for this controller
  124350. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  124351. */
  124352. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  124353. /**
  124354. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  124355. *
  124356. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  124357. *
  124358. * @param type the profile type to register
  124359. * @param constructFunction the function to be called when loading this profile
  124360. */
  124361. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  124362. /**
  124363. * Register a fallback to a specific profile.
  124364. * @param profileId the profileId that will receive the fallbacks
  124365. * @param fallbacks A list of fallback profiles
  124366. */
  124367. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  124368. /**
  124369. * Will update the list of profiles available in the repository
  124370. * @return a promise that resolves to a map of profiles available online
  124371. */
  124372. static UpdateProfilesList(): Promise<{
  124373. [profile: string]: string;
  124374. }>;
  124375. private static _LoadProfileFromRepository;
  124376. private static _LoadProfilesFromAvailableControllers;
  124377. }
  124378. }
  124379. declare module BABYLON {
  124380. /**
  124381. * Configuration options for the WebXR controller creation
  124382. */
  124383. export interface IWebXRControllerOptions {
  124384. /**
  124385. * Should the controller mesh be animated when a user interacts with it
  124386. * The pressed buttons / thumbstick and touchpad animations will be disabled
  124387. */
  124388. disableMotionControllerAnimation?: boolean;
  124389. /**
  124390. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  124391. */
  124392. doNotLoadControllerMesh?: boolean;
  124393. /**
  124394. * Force a specific controller type for this controller.
  124395. * This can be used when creating your own profile or when testing different controllers
  124396. */
  124397. forceControllerProfile?: string;
  124398. /**
  124399. * Defines a rendering group ID for meshes that will be loaded.
  124400. * This is for the default controllers only.
  124401. */
  124402. renderingGroupId?: number;
  124403. }
  124404. /**
  124405. * Represents an XR controller
  124406. */
  124407. export class WebXRInputSource {
  124408. private _scene;
  124409. /** The underlying input source for the controller */
  124410. inputSource: XRInputSource;
  124411. private _options;
  124412. private _tmpVector;
  124413. private _uniqueId;
  124414. /**
  124415. * 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
  124416. */
  124417. grip?: AbstractMesh;
  124418. /**
  124419. * If available, this is the gamepad object related to this controller.
  124420. * Using this object it is possible to get click events and trackpad changes of the
  124421. * webxr controller that is currently being used.
  124422. */
  124423. motionController?: WebXRAbstractMotionController;
  124424. /**
  124425. * Event that fires when the controller is removed/disposed.
  124426. * The object provided as event data is this controller, after associated assets were disposed.
  124427. * uniqueId is still available.
  124428. */
  124429. onDisposeObservable: Observable<WebXRInputSource>;
  124430. /**
  124431. * Will be triggered when the mesh associated with the motion controller is done loading.
  124432. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  124433. * A shortened version of controller -> motion controller -> on mesh loaded.
  124434. */
  124435. onMeshLoadedObservable: Observable<AbstractMesh>;
  124436. /**
  124437. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  124438. */
  124439. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  124440. /**
  124441. * Pointer which can be used to select objects or attach a visible laser to
  124442. */
  124443. pointer: AbstractMesh;
  124444. /**
  124445. * Creates the controller
  124446. * @see https://doc.babylonjs.com/how_to/webxr
  124447. * @param _scene the scene which the controller should be associated to
  124448. * @param inputSource the underlying input source for the controller
  124449. * @param _options options for this controller creation
  124450. */
  124451. constructor(_scene: Scene,
  124452. /** The underlying input source for the controller */
  124453. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  124454. /**
  124455. * Get this controllers unique id
  124456. */
  124457. get uniqueId(): string;
  124458. /**
  124459. * Disposes of the object
  124460. */
  124461. dispose(): void;
  124462. /**
  124463. * Gets a world space ray coming from the pointer or grip
  124464. * @param result the resulting ray
  124465. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  124466. */
  124467. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  124468. /**
  124469. * Updates the controller pose based on the given XRFrame
  124470. * @param xrFrame xr frame to update the pose with
  124471. * @param referenceSpace reference space to use
  124472. */
  124473. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  124474. }
  124475. }
  124476. declare module BABYLON {
  124477. /**
  124478. * The schema for initialization options of the XR Input class
  124479. */
  124480. export interface IWebXRInputOptions {
  124481. /**
  124482. * If set to true no model will be automatically loaded
  124483. */
  124484. doNotLoadControllerMeshes?: boolean;
  124485. /**
  124486. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  124487. * If not found, the xr input profile data will be used.
  124488. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  124489. */
  124490. forceInputProfile?: string;
  124491. /**
  124492. * Do not send a request to the controller repository to load the profile.
  124493. *
  124494. * Instead, use the controllers available in babylon itself.
  124495. */
  124496. disableOnlineControllerRepository?: boolean;
  124497. /**
  124498. * A custom URL for the controllers repository
  124499. */
  124500. customControllersRepositoryURL?: string;
  124501. /**
  124502. * Should the controller model's components not move according to the user input
  124503. */
  124504. disableControllerAnimation?: boolean;
  124505. /**
  124506. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  124507. */
  124508. controllerOptions?: IWebXRControllerOptions;
  124509. }
  124510. /**
  124511. * XR input used to track XR inputs such as controllers/rays
  124512. */
  124513. export class WebXRInput implements IDisposable {
  124514. /**
  124515. * the xr session manager for this session
  124516. */
  124517. xrSessionManager: WebXRSessionManager;
  124518. /**
  124519. * the WebXR camera for this session. Mainly used for teleportation
  124520. */
  124521. xrCamera: WebXRCamera;
  124522. private readonly options;
  124523. /**
  124524. * XR controllers being tracked
  124525. */
  124526. controllers: Array<WebXRInputSource>;
  124527. private _frameObserver;
  124528. private _sessionEndedObserver;
  124529. private _sessionInitObserver;
  124530. /**
  124531. * Event when a controller has been connected/added
  124532. */
  124533. onControllerAddedObservable: Observable<WebXRInputSource>;
  124534. /**
  124535. * Event when a controller has been removed/disconnected
  124536. */
  124537. onControllerRemovedObservable: Observable<WebXRInputSource>;
  124538. /**
  124539. * Initializes the WebXRInput
  124540. * @param xrSessionManager the xr session manager for this session
  124541. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  124542. * @param options = initialization options for this xr input
  124543. */
  124544. constructor(
  124545. /**
  124546. * the xr session manager for this session
  124547. */
  124548. xrSessionManager: WebXRSessionManager,
  124549. /**
  124550. * the WebXR camera for this session. Mainly used for teleportation
  124551. */
  124552. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  124553. private _onInputSourcesChange;
  124554. private _addAndRemoveControllers;
  124555. /**
  124556. * Disposes of the object
  124557. */
  124558. dispose(): void;
  124559. }
  124560. }
  124561. declare module BABYLON {
  124562. /**
  124563. * This is the base class for all WebXR features.
  124564. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  124565. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  124566. */
  124567. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  124568. protected _xrSessionManager: WebXRSessionManager;
  124569. private _attached;
  124570. private _removeOnDetach;
  124571. /**
  124572. * Should auto-attach be disabled?
  124573. */
  124574. disableAutoAttach: boolean;
  124575. /**
  124576. * Construct a new (abstract) WebXR feature
  124577. * @param _xrSessionManager the xr session manager for this feature
  124578. */
  124579. constructor(_xrSessionManager: WebXRSessionManager);
  124580. /**
  124581. * Is this feature attached
  124582. */
  124583. get attached(): boolean;
  124584. /**
  124585. * attach this feature
  124586. *
  124587. * @param force should attachment be forced (even when already attached)
  124588. * @returns true if successful, false is failed or already attached
  124589. */
  124590. attach(force?: boolean): boolean;
  124591. /**
  124592. * detach this feature.
  124593. *
  124594. * @returns true if successful, false if failed or already detached
  124595. */
  124596. detach(): boolean;
  124597. /**
  124598. * Dispose this feature and all of the resources attached
  124599. */
  124600. dispose(): void;
  124601. /**
  124602. * This is used to register callbacks that will automatically be removed when detach is called.
  124603. * @param observable the observable to which the observer will be attached
  124604. * @param callback the callback to register
  124605. */
  124606. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  124607. /**
  124608. * Code in this function will be executed on each xrFrame received from the browser.
  124609. * This function will not execute after the feature is detached.
  124610. * @param _xrFrame the current frame
  124611. */
  124612. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  124613. }
  124614. }
  124615. declare module BABYLON {
  124616. /**
  124617. * Renders a layer on top of an existing scene
  124618. */
  124619. export class UtilityLayerRenderer implements IDisposable {
  124620. /** the original scene that will be rendered on top of */
  124621. originalScene: Scene;
  124622. private _pointerCaptures;
  124623. private _lastPointerEvents;
  124624. private static _DefaultUtilityLayer;
  124625. private static _DefaultKeepDepthUtilityLayer;
  124626. private _sharedGizmoLight;
  124627. private _renderCamera;
  124628. /**
  124629. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  124630. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  124631. * @returns the camera that is used when rendering the utility layer
  124632. */
  124633. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  124634. /**
  124635. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  124636. * @param cam the camera that should be used when rendering the utility layer
  124637. */
  124638. setRenderCamera(cam: Nullable<Camera>): void;
  124639. /**
  124640. * @hidden
  124641. * Light which used by gizmos to get light shading
  124642. */
  124643. _getSharedGizmoLight(): HemisphericLight;
  124644. /**
  124645. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  124646. */
  124647. pickUtilitySceneFirst: boolean;
  124648. /**
  124649. * 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)
  124650. */
  124651. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  124652. /**
  124653. * 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)
  124654. */
  124655. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  124656. /**
  124657. * The scene that is rendered on top of the original scene
  124658. */
  124659. utilityLayerScene: Scene;
  124660. /**
  124661. * If the utility layer should automatically be rendered on top of existing scene
  124662. */
  124663. shouldRender: boolean;
  124664. /**
  124665. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  124666. */
  124667. onlyCheckPointerDownEvents: boolean;
  124668. /**
  124669. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  124670. */
  124671. processAllEvents: boolean;
  124672. /**
  124673. * Observable raised when the pointer move from the utility layer scene to the main scene
  124674. */
  124675. onPointerOutObservable: Observable<number>;
  124676. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  124677. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  124678. private _afterRenderObserver;
  124679. private _sceneDisposeObserver;
  124680. private _originalPointerObserver;
  124681. /**
  124682. * Instantiates a UtilityLayerRenderer
  124683. * @param originalScene the original scene that will be rendered on top of
  124684. * @param handleEvents boolean indicating if the utility layer should handle events
  124685. */
  124686. constructor(
  124687. /** the original scene that will be rendered on top of */
  124688. originalScene: Scene, handleEvents?: boolean);
  124689. private _notifyObservers;
  124690. /**
  124691. * Renders the utility layers scene on top of the original scene
  124692. */
  124693. render(): void;
  124694. /**
  124695. * Disposes of the renderer
  124696. */
  124697. dispose(): void;
  124698. private _updateCamera;
  124699. }
  124700. }
  124701. declare module BABYLON {
  124702. /**
  124703. * Options interface for the pointer selection module
  124704. */
  124705. export interface IWebXRControllerPointerSelectionOptions {
  124706. /**
  124707. * if provided, this scene will be used to render meshes.
  124708. */
  124709. customUtilityLayerScene?: Scene;
  124710. /**
  124711. * 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)
  124712. * If not disabled, the last picked point will be used to execute a pointer up event
  124713. * If disabled, pointer up event will be triggered right after the pointer down event.
  124714. * Used in screen and gaze target ray mode only
  124715. */
  124716. disablePointerUpOnTouchOut: boolean;
  124717. /**
  124718. * For gaze mode (time to select instead of press)
  124719. */
  124720. forceGazeMode: boolean;
  124721. /**
  124722. * 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
  124723. * to start a new countdown to the pointer down event.
  124724. * Defaults to 1.
  124725. */
  124726. gazeModePointerMovedFactor?: number;
  124727. /**
  124728. * Different button type to use instead of the main component
  124729. */
  124730. overrideButtonId?: string;
  124731. /**
  124732. * use this rendering group id for the meshes (optional)
  124733. */
  124734. renderingGroupId?: number;
  124735. /**
  124736. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  124737. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  124738. * 3000 means 3 seconds between pointing at something and selecting it
  124739. */
  124740. timeToSelect?: number;
  124741. /**
  124742. * Should meshes created here be added to a utility layer or the main scene
  124743. */
  124744. useUtilityLayer?: boolean;
  124745. /**
  124746. * the xr input to use with this pointer selection
  124747. */
  124748. xrInput: WebXRInput;
  124749. }
  124750. /**
  124751. * A module that will enable pointer selection for motion controllers of XR Input Sources
  124752. */
  124753. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  124754. private readonly _options;
  124755. private static _idCounter;
  124756. private _attachController;
  124757. private _controllers;
  124758. private _scene;
  124759. private _tmpVectorForPickCompare;
  124760. /**
  124761. * The module's name
  124762. */
  124763. static readonly Name: string;
  124764. /**
  124765. * The (Babylon) version of this module.
  124766. * This is an integer representing the implementation version.
  124767. * This number does not correspond to the WebXR specs version
  124768. */
  124769. static readonly Version: number;
  124770. /**
  124771. * Disable lighting on the laser pointer (so it will always be visible)
  124772. */
  124773. disablePointerLighting: boolean;
  124774. /**
  124775. * Disable lighting on the selection mesh (so it will always be visible)
  124776. */
  124777. disableSelectionMeshLighting: boolean;
  124778. /**
  124779. * Should the laser pointer be displayed
  124780. */
  124781. displayLaserPointer: boolean;
  124782. /**
  124783. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  124784. */
  124785. displaySelectionMesh: boolean;
  124786. /**
  124787. * This color will be set to the laser pointer when selection is triggered
  124788. */
  124789. laserPointerPickedColor: Color3;
  124790. /**
  124791. * Default color of the laser pointer
  124792. */
  124793. lasterPointerDefaultColor: Color3;
  124794. /**
  124795. * default color of the selection ring
  124796. */
  124797. selectionMeshDefaultColor: Color3;
  124798. /**
  124799. * This color will be applied to the selection ring when selection is triggered
  124800. */
  124801. selectionMeshPickedColor: Color3;
  124802. /**
  124803. * Optional filter to be used for ray selection. This predicate shares behavior with
  124804. * scene.pointerMovePredicate which takes priority if it is also assigned.
  124805. */
  124806. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  124807. /**
  124808. * constructs a new background remover module
  124809. * @param _xrSessionManager the session manager for this module
  124810. * @param _options read-only options to be used in this module
  124811. */
  124812. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  124813. /**
  124814. * attach this feature
  124815. * Will usually be called by the features manager
  124816. *
  124817. * @returns true if successful.
  124818. */
  124819. attach(): boolean;
  124820. /**
  124821. * detach this feature.
  124822. * Will usually be called by the features manager
  124823. *
  124824. * @returns true if successful.
  124825. */
  124826. detach(): boolean;
  124827. /**
  124828. * Will get the mesh under a specific pointer.
  124829. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  124830. * @param controllerId the controllerId to check
  124831. * @returns The mesh under pointer or null if no mesh is under the pointer
  124832. */
  124833. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  124834. /**
  124835. * Get the xr controller that correlates to the pointer id in the pointer event
  124836. *
  124837. * @param id the pointer id to search for
  124838. * @returns the controller that correlates to this id or null if not found
  124839. */
  124840. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  124841. protected _onXRFrame(_xrFrame: XRFrame): void;
  124842. private _attachGazeMode;
  124843. private _attachScreenRayMode;
  124844. private _attachTrackedPointerRayMode;
  124845. private _convertNormalToDirectionOfRay;
  124846. private _detachController;
  124847. private _generateNewMeshPair;
  124848. private _pickingMoved;
  124849. private _updatePointerDistance;
  124850. }
  124851. }
  124852. declare module BABYLON {
  124853. /**
  124854. * Button which can be used to enter a different mode of XR
  124855. */
  124856. export class WebXREnterExitUIButton {
  124857. /** button element */
  124858. element: HTMLElement;
  124859. /** XR initialization options for the button */
  124860. sessionMode: XRSessionMode;
  124861. /** Reference space type */
  124862. referenceSpaceType: XRReferenceSpaceType;
  124863. /**
  124864. * Creates a WebXREnterExitUIButton
  124865. * @param element button element
  124866. * @param sessionMode XR initialization session mode
  124867. * @param referenceSpaceType the type of reference space to be used
  124868. */
  124869. constructor(
  124870. /** button element */
  124871. element: HTMLElement,
  124872. /** XR initialization options for the button */
  124873. sessionMode: XRSessionMode,
  124874. /** Reference space type */
  124875. referenceSpaceType: XRReferenceSpaceType);
  124876. /**
  124877. * Extendable function which can be used to update the button's visuals when the state changes
  124878. * @param activeButton the current active button in the UI
  124879. */
  124880. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  124881. }
  124882. /**
  124883. * Options to create the webXR UI
  124884. */
  124885. export class WebXREnterExitUIOptions {
  124886. /**
  124887. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  124888. */
  124889. customButtons?: Array<WebXREnterExitUIButton>;
  124890. /**
  124891. * A reference space type to use when creating the default button.
  124892. * Default is local-floor
  124893. */
  124894. referenceSpaceType?: XRReferenceSpaceType;
  124895. /**
  124896. * Context to enter xr with
  124897. */
  124898. renderTarget?: Nullable<WebXRRenderTarget>;
  124899. /**
  124900. * A session mode to use when creating the default button.
  124901. * Default is immersive-vr
  124902. */
  124903. sessionMode?: XRSessionMode;
  124904. /**
  124905. * A list of optional features to init the session with
  124906. */
  124907. optionalFeatures?: string[];
  124908. }
  124909. /**
  124910. * UI to allow the user to enter/exit XR mode
  124911. */
  124912. export class WebXREnterExitUI implements IDisposable {
  124913. private scene;
  124914. /** version of the options passed to this UI */
  124915. options: WebXREnterExitUIOptions;
  124916. private _activeButton;
  124917. private _buttons;
  124918. private _overlay;
  124919. /**
  124920. * Fired every time the active button is changed.
  124921. *
  124922. * When xr is entered via a button that launches xr that button will be the callback parameter
  124923. *
  124924. * When exiting xr the callback parameter will be null)
  124925. */
  124926. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  124927. /**
  124928. *
  124929. * @param scene babylon scene object to use
  124930. * @param options (read-only) version of the options passed to this UI
  124931. */
  124932. private constructor();
  124933. /**
  124934. * Creates UI to allow the user to enter/exit XR mode
  124935. * @param scene the scene to add the ui to
  124936. * @param helper the xr experience helper to enter/exit xr with
  124937. * @param options options to configure the UI
  124938. * @returns the created ui
  124939. */
  124940. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  124941. /**
  124942. * Disposes of the XR UI component
  124943. */
  124944. dispose(): void;
  124945. private _updateButtons;
  124946. }
  124947. }
  124948. declare module BABYLON {
  124949. /**
  124950. * Class containing static functions to help procedurally build meshes
  124951. */
  124952. export class LinesBuilder {
  124953. /**
  124954. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124955. * * 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
  124956. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124957. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124958. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124959. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124960. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124961. * * 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
  124962. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124965. * @param name defines the name of the new line system
  124966. * @param options defines the options used to create the line system
  124967. * @param scene defines the hosting scene
  124968. * @returns a new line system mesh
  124969. */
  124970. static CreateLineSystem(name: string, options: {
  124971. lines: Vector3[][];
  124972. updatable?: boolean;
  124973. instance?: Nullable<LinesMesh>;
  124974. colors?: Nullable<Color4[][]>;
  124975. useVertexAlpha?: boolean;
  124976. }, scene: Nullable<Scene>): LinesMesh;
  124977. /**
  124978. * Creates a line mesh
  124979. * 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
  124980. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124981. * * The parameter `points` is an array successive Vector3
  124982. * * 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
  124983. * * The optional parameter `colors` is an array of successive Color4, one per line point
  124984. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  124985. * * When updating an instance, remember that only point positions can change, not the number of points
  124986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124987. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  124988. * @param name defines the name of the new line system
  124989. * @param options defines the options used to create the line system
  124990. * @param scene defines the hosting scene
  124991. * @returns a new line mesh
  124992. */
  124993. static CreateLines(name: string, options: {
  124994. points: Vector3[];
  124995. updatable?: boolean;
  124996. instance?: Nullable<LinesMesh>;
  124997. colors?: Color4[];
  124998. useVertexAlpha?: boolean;
  124999. }, scene?: Nullable<Scene>): LinesMesh;
  125000. /**
  125001. * Creates a dashed line mesh
  125002. * * 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
  125003. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125004. * * The parameter `points` is an array successive Vector3
  125005. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125006. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125007. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125008. * * 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
  125009. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125010. * * When updating an instance, remember that only point positions can change, not the number of points
  125011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125012. * @param name defines the name of the mesh
  125013. * @param options defines the options used to create the mesh
  125014. * @param scene defines the hosting scene
  125015. * @returns the dashed line mesh
  125016. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125017. */
  125018. static CreateDashedLines(name: string, options: {
  125019. points: Vector3[];
  125020. dashSize?: number;
  125021. gapSize?: number;
  125022. dashNb?: number;
  125023. updatable?: boolean;
  125024. instance?: LinesMesh;
  125025. useVertexAlpha?: boolean;
  125026. }, scene?: Nullable<Scene>): LinesMesh;
  125027. }
  125028. }
  125029. declare module BABYLON {
  125030. /**
  125031. * The options container for the teleportation module
  125032. */
  125033. export interface IWebXRTeleportationOptions {
  125034. /**
  125035. * if provided, this scene will be used to render meshes.
  125036. */
  125037. customUtilityLayerScene?: Scene;
  125038. /**
  125039. * Values to configure the default target mesh
  125040. */
  125041. defaultTargetMeshOptions?: {
  125042. /**
  125043. * Fill color of the teleportation area
  125044. */
  125045. teleportationFillColor?: string;
  125046. /**
  125047. * Border color for the teleportation area
  125048. */
  125049. teleportationBorderColor?: string;
  125050. /**
  125051. * Disable the mesh's animation sequence
  125052. */
  125053. disableAnimation?: boolean;
  125054. /**
  125055. * Disable lighting on the material or the ring and arrow
  125056. */
  125057. disableLighting?: boolean;
  125058. /**
  125059. * Override the default material of the torus and arrow
  125060. */
  125061. torusArrowMaterial?: Material;
  125062. };
  125063. /**
  125064. * A list of meshes to use as floor meshes.
  125065. * Meshes can be added and removed after initializing the feature using the
  125066. * addFloorMesh and removeFloorMesh functions
  125067. * If empty, rotation will still work
  125068. */
  125069. floorMeshes?: AbstractMesh[];
  125070. /**
  125071. * use this rendering group id for the meshes (optional)
  125072. */
  125073. renderingGroupId?: number;
  125074. /**
  125075. * Should teleportation move only to snap points
  125076. */
  125077. snapPointsOnly?: boolean;
  125078. /**
  125079. * An array of points to which the teleportation will snap to.
  125080. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  125081. */
  125082. snapPositions?: Vector3[];
  125083. /**
  125084. * How close should the teleportation ray be in order to snap to position.
  125085. * Default to 0.8 units (meters)
  125086. */
  125087. snapToPositionRadius?: number;
  125088. /**
  125089. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  125090. * If you want to support rotation, make sure your mesh has a direction indicator.
  125091. *
  125092. * When left untouched, the default mesh will be initialized.
  125093. */
  125094. teleportationTargetMesh?: AbstractMesh;
  125095. /**
  125096. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  125097. */
  125098. timeToTeleport?: number;
  125099. /**
  125100. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  125101. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  125102. */
  125103. useMainComponentOnly?: boolean;
  125104. /**
  125105. * Should meshes created here be added to a utility layer or the main scene
  125106. */
  125107. useUtilityLayer?: boolean;
  125108. /**
  125109. * Babylon XR Input class for controller
  125110. */
  125111. xrInput: WebXRInput;
  125112. }
  125113. /**
  125114. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  125115. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  125116. * the input of the attached controllers.
  125117. */
  125118. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  125119. private _options;
  125120. private _controllers;
  125121. private _currentTeleportationControllerId;
  125122. private _floorMeshes;
  125123. private _quadraticBezierCurve;
  125124. private _selectionFeature;
  125125. private _snapToPositions;
  125126. private _snappedToPoint;
  125127. private _teleportationRingMaterial?;
  125128. private _tmpRay;
  125129. private _tmpVector;
  125130. /**
  125131. * The module's name
  125132. */
  125133. static readonly Name: string;
  125134. /**
  125135. * The (Babylon) version of this module.
  125136. * This is an integer representing the implementation version.
  125137. * This number does not correspond to the webxr specs version
  125138. */
  125139. static readonly Version: number;
  125140. /**
  125141. * Is movement backwards enabled
  125142. */
  125143. backwardsMovementEnabled: boolean;
  125144. /**
  125145. * Distance to travel when moving backwards
  125146. */
  125147. backwardsTeleportationDistance: number;
  125148. /**
  125149. * The distance from the user to the inspection point in the direction of the controller
  125150. * A higher number will allow the user to move further
  125151. * defaults to 5 (meters, in xr units)
  125152. */
  125153. parabolicCheckRadius: number;
  125154. /**
  125155. * Should the module support parabolic ray on top of direct ray
  125156. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  125157. * Very helpful when moving between floors / different heights
  125158. */
  125159. parabolicRayEnabled: boolean;
  125160. /**
  125161. * How much rotation should be applied when rotating right and left
  125162. */
  125163. rotationAngle: number;
  125164. /**
  125165. * Is rotation enabled when moving forward?
  125166. * Disabling this feature will prevent the user from deciding the direction when teleporting
  125167. */
  125168. rotationEnabled: boolean;
  125169. /**
  125170. * constructs a new anchor system
  125171. * @param _xrSessionManager an instance of WebXRSessionManager
  125172. * @param _options configuration object for this feature
  125173. */
  125174. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  125175. /**
  125176. * Get the snapPointsOnly flag
  125177. */
  125178. get snapPointsOnly(): boolean;
  125179. /**
  125180. * Sets the snapPointsOnly flag
  125181. * @param snapToPoints should teleportation be exclusively to snap points
  125182. */
  125183. set snapPointsOnly(snapToPoints: boolean);
  125184. /**
  125185. * Add a new mesh to the floor meshes array
  125186. * @param mesh the mesh to use as floor mesh
  125187. */
  125188. addFloorMesh(mesh: AbstractMesh): void;
  125189. /**
  125190. * Add a new snap-to point to fix teleportation to this position
  125191. * @param newSnapPoint The new Snap-To point
  125192. */
  125193. addSnapPoint(newSnapPoint: Vector3): void;
  125194. attach(): boolean;
  125195. detach(): boolean;
  125196. dispose(): void;
  125197. /**
  125198. * Remove a mesh from the floor meshes array
  125199. * @param mesh the mesh to remove
  125200. */
  125201. removeFloorMesh(mesh: AbstractMesh): void;
  125202. /**
  125203. * Remove a mesh from the floor meshes array using its name
  125204. * @param name the mesh name to remove
  125205. */
  125206. removeFloorMeshByName(name: string): void;
  125207. /**
  125208. * 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
  125209. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  125210. * @returns was the point found and removed or not
  125211. */
  125212. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  125213. /**
  125214. * This function sets a selection feature that will be disabled when
  125215. * the forward ray is shown and will be reattached when hidden.
  125216. * This is used to remove the selection rays when moving.
  125217. * @param selectionFeature the feature to disable when forward movement is enabled
  125218. */
  125219. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  125220. protected _onXRFrame(_xrFrame: XRFrame): void;
  125221. private _attachController;
  125222. private _createDefaultTargetMesh;
  125223. private _detachController;
  125224. private _findClosestSnapPointWithRadius;
  125225. private _setTargetMeshPosition;
  125226. private _setTargetMeshVisibility;
  125227. private _showParabolicPath;
  125228. private _teleportForward;
  125229. }
  125230. }
  125231. declare module BABYLON {
  125232. /**
  125233. * Options for the default xr helper
  125234. */
  125235. export class WebXRDefaultExperienceOptions {
  125236. /**
  125237. * Enable or disable default UI to enter XR
  125238. */
  125239. disableDefaultUI?: boolean;
  125240. /**
  125241. * Should teleportation not initialize. defaults to false.
  125242. */
  125243. disableTeleportation?: boolean;
  125244. /**
  125245. * Floor meshes that will be used for teleport
  125246. */
  125247. floorMeshes?: Array<AbstractMesh>;
  125248. /**
  125249. * If set to true, the first frame will not be used to reset position
  125250. * The first frame is mainly used when copying transformation from the old camera
  125251. * Mainly used in AR
  125252. */
  125253. ignoreNativeCameraTransformation?: boolean;
  125254. /**
  125255. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  125256. */
  125257. inputOptions?: IWebXRInputOptions;
  125258. /**
  125259. * optional configuration for the output canvas
  125260. */
  125261. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  125262. /**
  125263. * optional UI options. This can be used among other to change session mode and reference space type
  125264. */
  125265. uiOptions?: WebXREnterExitUIOptions;
  125266. /**
  125267. * When loading teleportation and pointer select, use stable versions instead of latest.
  125268. */
  125269. useStablePlugins?: boolean;
  125270. /**
  125271. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  125272. */
  125273. renderingGroupId?: number;
  125274. /**
  125275. * A list of optional features to init the session with
  125276. * If set to true, all features we support will be added
  125277. */
  125278. optionalFeatures?: boolean | string[];
  125279. }
  125280. /**
  125281. * Default experience which provides a similar setup to the previous webVRExperience
  125282. */
  125283. export class WebXRDefaultExperience {
  125284. /**
  125285. * Base experience
  125286. */
  125287. baseExperience: WebXRExperienceHelper;
  125288. /**
  125289. * Enables ui for entering/exiting xr
  125290. */
  125291. enterExitUI: WebXREnterExitUI;
  125292. /**
  125293. * Input experience extension
  125294. */
  125295. input: WebXRInput;
  125296. /**
  125297. * Enables laser pointer and selection
  125298. */
  125299. pointerSelection: WebXRControllerPointerSelection;
  125300. /**
  125301. * Default target xr should render to
  125302. */
  125303. renderTarget: WebXRRenderTarget;
  125304. /**
  125305. * Enables teleportation
  125306. */
  125307. teleportation: WebXRMotionControllerTeleportation;
  125308. private constructor();
  125309. /**
  125310. * Creates the default xr experience
  125311. * @param scene scene
  125312. * @param options options for basic configuration
  125313. * @returns resulting WebXRDefaultExperience
  125314. */
  125315. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125316. /**
  125317. * DIsposes of the experience helper
  125318. */
  125319. dispose(): void;
  125320. }
  125321. }
  125322. declare module BABYLON {
  125323. /**
  125324. * Options to modify the vr teleportation behavior.
  125325. */
  125326. export interface VRTeleportationOptions {
  125327. /**
  125328. * The name of the mesh which should be used as the teleportation floor. (default: null)
  125329. */
  125330. floorMeshName?: string;
  125331. /**
  125332. * A list of meshes to be used as the teleportation floor. (default: empty)
  125333. */
  125334. floorMeshes?: Mesh[];
  125335. /**
  125336. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  125337. */
  125338. teleportationMode?: number;
  125339. /**
  125340. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  125341. */
  125342. teleportationTime?: number;
  125343. /**
  125344. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  125345. */
  125346. teleportationSpeed?: number;
  125347. /**
  125348. * The easing function used in the animation or null for Linear. (default CircleEase)
  125349. */
  125350. easingFunction?: EasingFunction;
  125351. }
  125352. /**
  125353. * Options to modify the vr experience helper's behavior.
  125354. */
  125355. export interface VRExperienceHelperOptions extends WebVROptions {
  125356. /**
  125357. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  125358. */
  125359. createDeviceOrientationCamera?: boolean;
  125360. /**
  125361. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  125362. */
  125363. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  125364. /**
  125365. * Uses the main button on the controller to toggle the laser casted. (default: true)
  125366. */
  125367. laserToggle?: boolean;
  125368. /**
  125369. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  125370. */
  125371. floorMeshes?: Mesh[];
  125372. /**
  125373. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  125374. */
  125375. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  125376. /**
  125377. * Defines if WebXR should be used instead of WebVR (if available)
  125378. */
  125379. useXR?: boolean;
  125380. }
  125381. /**
  125382. * Event containing information after VR has been entered
  125383. */
  125384. export class OnAfterEnteringVRObservableEvent {
  125385. /**
  125386. * If entering vr was successful
  125387. */
  125388. success: boolean;
  125389. }
  125390. /**
  125391. * Helps to quickly add VR support to an existing scene.
  125392. * See http://doc.babylonjs.com/how_to/webvr_helper
  125393. */
  125394. export class VRExperienceHelper {
  125395. /** Options to modify the vr experience helper's behavior. */
  125396. webVROptions: VRExperienceHelperOptions;
  125397. private _scene;
  125398. private _position;
  125399. private _btnVR;
  125400. private _btnVRDisplayed;
  125401. private _webVRsupported;
  125402. private _webVRready;
  125403. private _webVRrequesting;
  125404. private _webVRpresenting;
  125405. private _hasEnteredVR;
  125406. private _fullscreenVRpresenting;
  125407. private _inputElement;
  125408. private _webVRCamera;
  125409. private _vrDeviceOrientationCamera;
  125410. private _deviceOrientationCamera;
  125411. private _existingCamera;
  125412. private _onKeyDown;
  125413. private _onVrDisplayPresentChange;
  125414. private _onVRDisplayChanged;
  125415. private _onVRRequestPresentStart;
  125416. private _onVRRequestPresentComplete;
  125417. /**
  125418. * 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)
  125419. */
  125420. enableGazeEvenWhenNoPointerLock: boolean;
  125421. /**
  125422. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  125423. */
  125424. exitVROnDoubleTap: boolean;
  125425. /**
  125426. * Observable raised right before entering VR.
  125427. */
  125428. onEnteringVRObservable: Observable<VRExperienceHelper>;
  125429. /**
  125430. * Observable raised when entering VR has completed.
  125431. */
  125432. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  125433. /**
  125434. * Observable raised when exiting VR.
  125435. */
  125436. onExitingVRObservable: Observable<VRExperienceHelper>;
  125437. /**
  125438. * Observable raised when controller mesh is loaded.
  125439. */
  125440. onControllerMeshLoadedObservable: Observable<WebVRController>;
  125441. /** Return this.onEnteringVRObservable
  125442. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  125443. */
  125444. get onEnteringVR(): Observable<VRExperienceHelper>;
  125445. /** Return this.onExitingVRObservable
  125446. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  125447. */
  125448. get onExitingVR(): Observable<VRExperienceHelper>;
  125449. /** Return this.onControllerMeshLoadedObservable
  125450. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  125451. */
  125452. get onControllerMeshLoaded(): Observable<WebVRController>;
  125453. private _rayLength;
  125454. private _useCustomVRButton;
  125455. private _teleportationRequested;
  125456. private _teleportActive;
  125457. private _floorMeshName;
  125458. private _floorMeshesCollection;
  125459. private _teleportationMode;
  125460. private _teleportationTime;
  125461. private _teleportationSpeed;
  125462. private _teleportationEasing;
  125463. private _rotationAllowed;
  125464. private _teleportBackwardsVector;
  125465. private _teleportationTarget;
  125466. private _isDefaultTeleportationTarget;
  125467. private _postProcessMove;
  125468. private _teleportationFillColor;
  125469. private _teleportationBorderColor;
  125470. private _rotationAngle;
  125471. private _haloCenter;
  125472. private _cameraGazer;
  125473. private _padSensibilityUp;
  125474. private _padSensibilityDown;
  125475. private _leftController;
  125476. private _rightController;
  125477. private _gazeColor;
  125478. private _laserColor;
  125479. private _pickedLaserColor;
  125480. private _pickedGazeColor;
  125481. /**
  125482. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  125483. */
  125484. onNewMeshSelected: Observable<AbstractMesh>;
  125485. /**
  125486. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  125487. * This observable will provide the mesh and the controller used to select the mesh
  125488. */
  125489. onMeshSelectedWithController: Observable<{
  125490. mesh: AbstractMesh;
  125491. controller: WebVRController;
  125492. }>;
  125493. /**
  125494. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  125495. */
  125496. onNewMeshPicked: Observable<PickingInfo>;
  125497. private _circleEase;
  125498. /**
  125499. * Observable raised before camera teleportation
  125500. */
  125501. onBeforeCameraTeleport: Observable<Vector3>;
  125502. /**
  125503. * Observable raised after camera teleportation
  125504. */
  125505. onAfterCameraTeleport: Observable<Vector3>;
  125506. /**
  125507. * Observable raised when current selected mesh gets unselected
  125508. */
  125509. onSelectedMeshUnselected: Observable<AbstractMesh>;
  125510. private _raySelectionPredicate;
  125511. /**
  125512. * To be optionaly changed by user to define custom ray selection
  125513. */
  125514. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125515. /**
  125516. * To be optionaly changed by user to define custom selection logic (after ray selection)
  125517. */
  125518. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  125519. /**
  125520. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  125521. */
  125522. teleportationEnabled: boolean;
  125523. private _defaultHeight;
  125524. private _teleportationInitialized;
  125525. private _interactionsEnabled;
  125526. private _interactionsRequested;
  125527. private _displayGaze;
  125528. private _displayLaserPointer;
  125529. /**
  125530. * The mesh used to display where the user is going to teleport.
  125531. */
  125532. get teleportationTarget(): Mesh;
  125533. /**
  125534. * Sets the mesh to be used to display where the user is going to teleport.
  125535. */
  125536. set teleportationTarget(value: Mesh);
  125537. /**
  125538. * 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
  125539. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  125540. * See http://doc.babylonjs.com/resources/baking_transformations
  125541. */
  125542. get gazeTrackerMesh(): Mesh;
  125543. set gazeTrackerMesh(value: Mesh);
  125544. /**
  125545. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  125546. */
  125547. updateGazeTrackerScale: boolean;
  125548. /**
  125549. * If the gaze trackers color should be updated when selecting meshes
  125550. */
  125551. updateGazeTrackerColor: boolean;
  125552. /**
  125553. * If the controller laser color should be updated when selecting meshes
  125554. */
  125555. updateControllerLaserColor: boolean;
  125556. /**
  125557. * The gaze tracking mesh corresponding to the left controller
  125558. */
  125559. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  125560. /**
  125561. * The gaze tracking mesh corresponding to the right controller
  125562. */
  125563. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  125564. /**
  125565. * If the ray of the gaze should be displayed.
  125566. */
  125567. get displayGaze(): boolean;
  125568. /**
  125569. * Sets if the ray of the gaze should be displayed.
  125570. */
  125571. set displayGaze(value: boolean);
  125572. /**
  125573. * If the ray of the LaserPointer should be displayed.
  125574. */
  125575. get displayLaserPointer(): boolean;
  125576. /**
  125577. * Sets if the ray of the LaserPointer should be displayed.
  125578. */
  125579. set displayLaserPointer(value: boolean);
  125580. /**
  125581. * The deviceOrientationCamera used as the camera when not in VR.
  125582. */
  125583. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  125584. /**
  125585. * Based on the current WebVR support, returns the current VR camera used.
  125586. */
  125587. get currentVRCamera(): Nullable<Camera>;
  125588. /**
  125589. * The webVRCamera which is used when in VR.
  125590. */
  125591. get webVRCamera(): WebVRFreeCamera;
  125592. /**
  125593. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  125594. */
  125595. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  125596. /**
  125597. * The html button that is used to trigger entering into VR.
  125598. */
  125599. get vrButton(): Nullable<HTMLButtonElement>;
  125600. private get _teleportationRequestInitiated();
  125601. /**
  125602. * Defines whether or not Pointer lock should be requested when switching to
  125603. * full screen.
  125604. */
  125605. requestPointerLockOnFullScreen: boolean;
  125606. /**
  125607. * If asking to force XR, this will be populated with the default xr experience
  125608. */
  125609. xr: WebXRDefaultExperience;
  125610. /**
  125611. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  125612. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  125613. */
  125614. xrTestDone: boolean;
  125615. /**
  125616. * Instantiates a VRExperienceHelper.
  125617. * Helps to quickly add VR support to an existing scene.
  125618. * @param scene The scene the VRExperienceHelper belongs to.
  125619. * @param webVROptions Options to modify the vr experience helper's behavior.
  125620. */
  125621. constructor(scene: Scene,
  125622. /** Options to modify the vr experience helper's behavior. */
  125623. webVROptions?: VRExperienceHelperOptions);
  125624. private completeVRInit;
  125625. private _onDefaultMeshLoaded;
  125626. private _onResize;
  125627. private _onFullscreenChange;
  125628. /**
  125629. * Gets a value indicating if we are currently in VR mode.
  125630. */
  125631. get isInVRMode(): boolean;
  125632. private onVrDisplayPresentChange;
  125633. private onVRDisplayChanged;
  125634. private moveButtonToBottomRight;
  125635. private displayVRButton;
  125636. private updateButtonVisibility;
  125637. private _cachedAngularSensibility;
  125638. /**
  125639. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  125640. * Otherwise, will use the fullscreen API.
  125641. */
  125642. enterVR(): void;
  125643. /**
  125644. * Attempt to exit VR, or fullscreen.
  125645. */
  125646. exitVR(): void;
  125647. /**
  125648. * The position of the vr experience helper.
  125649. */
  125650. get position(): Vector3;
  125651. /**
  125652. * Sets the position of the vr experience helper.
  125653. */
  125654. set position(value: Vector3);
  125655. /**
  125656. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  125657. */
  125658. enableInteractions(): void;
  125659. private get _noControllerIsActive();
  125660. private beforeRender;
  125661. private _isTeleportationFloor;
  125662. /**
  125663. * Adds a floor mesh to be used for teleportation.
  125664. * @param floorMesh the mesh to be used for teleportation.
  125665. */
  125666. addFloorMesh(floorMesh: Mesh): void;
  125667. /**
  125668. * Removes a floor mesh from being used for teleportation.
  125669. * @param floorMesh the mesh to be removed.
  125670. */
  125671. removeFloorMesh(floorMesh: Mesh): void;
  125672. /**
  125673. * Enables interactions and teleportation using the VR controllers and gaze.
  125674. * @param vrTeleportationOptions options to modify teleportation behavior.
  125675. */
  125676. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  125677. private _onNewGamepadConnected;
  125678. private _tryEnableInteractionOnController;
  125679. private _onNewGamepadDisconnected;
  125680. private _enableInteractionOnController;
  125681. private _checkTeleportWithRay;
  125682. private _checkRotate;
  125683. private _checkTeleportBackwards;
  125684. private _enableTeleportationOnController;
  125685. private _createTeleportationCircles;
  125686. private _displayTeleportationTarget;
  125687. private _hideTeleportationTarget;
  125688. private _rotateCamera;
  125689. private _moveTeleportationSelectorTo;
  125690. private _workingVector;
  125691. private _workingQuaternion;
  125692. private _workingMatrix;
  125693. /**
  125694. * Time Constant Teleportation Mode
  125695. */
  125696. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  125697. /**
  125698. * Speed Constant Teleportation Mode
  125699. */
  125700. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  125701. /**
  125702. * Teleports the users feet to the desired location
  125703. * @param location The location where the user's feet should be placed
  125704. */
  125705. teleportCamera(location: Vector3): void;
  125706. private _convertNormalToDirectionOfRay;
  125707. private _castRayAndSelectObject;
  125708. private _notifySelectedMeshUnselected;
  125709. /**
  125710. * Permanently set new colors for the laser pointer
  125711. * @param color the new laser color
  125712. * @param pickedColor the new laser color when picked mesh detected
  125713. */
  125714. setLaserColor(color: Color3, pickedColor?: Color3): void;
  125715. /**
  125716. * Set lighting enabled / disabled on the laser pointer of both controllers
  125717. * @param enabled should the lighting be enabled on the laser pointer
  125718. */
  125719. setLaserLightingState(enabled?: boolean): void;
  125720. /**
  125721. * Permanently set new colors for the gaze pointer
  125722. * @param color the new gaze color
  125723. * @param pickedColor the new gaze color when picked mesh detected
  125724. */
  125725. setGazeColor(color: Color3, pickedColor?: Color3): void;
  125726. /**
  125727. * Sets the color of the laser ray from the vr controllers.
  125728. * @param color new color for the ray.
  125729. */
  125730. changeLaserColor(color: Color3): void;
  125731. /**
  125732. * Sets the color of the ray from the vr headsets gaze.
  125733. * @param color new color for the ray.
  125734. */
  125735. changeGazeColor(color: Color3): void;
  125736. /**
  125737. * Exits VR and disposes of the vr experience helper
  125738. */
  125739. dispose(): void;
  125740. /**
  125741. * Gets the name of the VRExperienceHelper class
  125742. * @returns "VRExperienceHelper"
  125743. */
  125744. getClassName(): string;
  125745. }
  125746. }
  125747. declare module BABYLON {
  125748. /**
  125749. * Contains an array of blocks representing the octree
  125750. */
  125751. export interface IOctreeContainer<T> {
  125752. /**
  125753. * Blocks within the octree
  125754. */
  125755. blocks: Array<OctreeBlock<T>>;
  125756. }
  125757. /**
  125758. * Class used to store a cell in an octree
  125759. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125760. */
  125761. export class OctreeBlock<T> {
  125762. /**
  125763. * Gets the content of the current block
  125764. */
  125765. entries: T[];
  125766. /**
  125767. * Gets the list of block children
  125768. */
  125769. blocks: Array<OctreeBlock<T>>;
  125770. private _depth;
  125771. private _maxDepth;
  125772. private _capacity;
  125773. private _minPoint;
  125774. private _maxPoint;
  125775. private _boundingVectors;
  125776. private _creationFunc;
  125777. /**
  125778. * Creates a new block
  125779. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  125780. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  125781. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125782. * @param depth defines the current depth of this block in the octree
  125783. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  125784. * @param creationFunc defines a callback to call when an element is added to the block
  125785. */
  125786. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  125787. /**
  125788. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125789. */
  125790. get capacity(): number;
  125791. /**
  125792. * Gets the minimum vector (in world space) of the block's bounding box
  125793. */
  125794. get minPoint(): Vector3;
  125795. /**
  125796. * Gets the maximum vector (in world space) of the block's bounding box
  125797. */
  125798. get maxPoint(): Vector3;
  125799. /**
  125800. * Add a new element to this block
  125801. * @param entry defines the element to add
  125802. */
  125803. addEntry(entry: T): void;
  125804. /**
  125805. * Remove an element from this block
  125806. * @param entry defines the element to remove
  125807. */
  125808. removeEntry(entry: T): void;
  125809. /**
  125810. * Add an array of elements to this block
  125811. * @param entries defines the array of elements to add
  125812. */
  125813. addEntries(entries: T[]): void;
  125814. /**
  125815. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  125816. * @param frustumPlanes defines the frustum planes to test
  125817. * @param selection defines the array to store current content if selection is positive
  125818. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125819. */
  125820. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125821. /**
  125822. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  125823. * @param sphereCenter defines the bounding sphere center
  125824. * @param sphereRadius defines the bounding sphere radius
  125825. * @param selection defines the array to store current content if selection is positive
  125826. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125827. */
  125828. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125829. /**
  125830. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  125831. * @param ray defines the ray to test with
  125832. * @param selection defines the array to store current content if selection is positive
  125833. */
  125834. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  125835. /**
  125836. * Subdivide the content into child blocks (this block will then be empty)
  125837. */
  125838. createInnerBlocks(): void;
  125839. /**
  125840. * @hidden
  125841. */
  125842. 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;
  125843. }
  125844. }
  125845. declare module BABYLON {
  125846. /**
  125847. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  125848. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125849. */
  125850. export class Octree<T> {
  125851. /** 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.) */
  125852. maxDepth: number;
  125853. /**
  125854. * Blocks within the octree containing objects
  125855. */
  125856. blocks: Array<OctreeBlock<T>>;
  125857. /**
  125858. * Content stored in the octree
  125859. */
  125860. dynamicContent: T[];
  125861. private _maxBlockCapacity;
  125862. private _selectionContent;
  125863. private _creationFunc;
  125864. /**
  125865. * Creates a octree
  125866. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125867. * @param creationFunc function to be used to instatiate the octree
  125868. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  125869. * @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.)
  125870. */
  125871. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  125872. /** 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.) */
  125873. maxDepth?: number);
  125874. /**
  125875. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  125876. * @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);
  125877. * @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);
  125878. * @param entries meshes to be added to the octree blocks
  125879. */
  125880. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  125881. /**
  125882. * Adds a mesh to the octree
  125883. * @param entry Mesh to add to the octree
  125884. */
  125885. addMesh(entry: T): void;
  125886. /**
  125887. * Remove an element from the octree
  125888. * @param entry defines the element to remove
  125889. */
  125890. removeMesh(entry: T): void;
  125891. /**
  125892. * Selects an array of meshes within the frustum
  125893. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  125894. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  125895. * @returns array of meshes within the frustum
  125896. */
  125897. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  125898. /**
  125899. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  125900. * @param sphereCenter defines the bounding sphere center
  125901. * @param sphereRadius defines the bounding sphere radius
  125902. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125903. * @returns an array of objects that intersect the sphere
  125904. */
  125905. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  125906. /**
  125907. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  125908. * @param ray defines the ray to test with
  125909. * @returns array of intersected objects
  125910. */
  125911. intersectsRay(ray: Ray): SmartArray<T>;
  125912. /**
  125913. * Adds a mesh into the octree block if it intersects the block
  125914. */
  125915. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  125916. /**
  125917. * Adds a submesh into the octree block if it intersects the block
  125918. */
  125919. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  125920. }
  125921. }
  125922. declare module BABYLON {
  125923. interface Scene {
  125924. /**
  125925. * @hidden
  125926. * Backing Filed
  125927. */
  125928. _selectionOctree: Octree<AbstractMesh>;
  125929. /**
  125930. * Gets the octree used to boost mesh selection (picking)
  125931. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125932. */
  125933. selectionOctree: Octree<AbstractMesh>;
  125934. /**
  125935. * Creates or updates the octree used to boost selection (picking)
  125936. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125937. * @param maxCapacity defines the maximum capacity per leaf
  125938. * @param maxDepth defines the maximum depth of the octree
  125939. * @returns an octree of AbstractMesh
  125940. */
  125941. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  125942. }
  125943. interface AbstractMesh {
  125944. /**
  125945. * @hidden
  125946. * Backing Field
  125947. */
  125948. _submeshesOctree: Octree<SubMesh>;
  125949. /**
  125950. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  125951. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  125952. * @param maxCapacity defines the maximum size of each block (64 by default)
  125953. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  125954. * @returns the new octree
  125955. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  125956. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125957. */
  125958. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  125959. }
  125960. /**
  125961. * Defines the octree scene component responsible to manage any octrees
  125962. * in a given scene.
  125963. */
  125964. export class OctreeSceneComponent {
  125965. /**
  125966. * The component name help to identify the component in the list of scene components.
  125967. */
  125968. readonly name: string;
  125969. /**
  125970. * The scene the component belongs to.
  125971. */
  125972. scene: Scene;
  125973. /**
  125974. * Indicates if the meshes have been checked to make sure they are isEnabled()
  125975. */
  125976. readonly checksIsEnabled: boolean;
  125977. /**
  125978. * Creates a new instance of the component for the given scene
  125979. * @param scene Defines the scene to register the component in
  125980. */
  125981. constructor(scene: Scene);
  125982. /**
  125983. * Registers the component in a given scene
  125984. */
  125985. register(): void;
  125986. /**
  125987. * Return the list of active meshes
  125988. * @returns the list of active meshes
  125989. */
  125990. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  125991. /**
  125992. * Return the list of active sub meshes
  125993. * @param mesh The mesh to get the candidates sub meshes from
  125994. * @returns the list of active sub meshes
  125995. */
  125996. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  125997. private _tempRay;
  125998. /**
  125999. * Return the list of sub meshes intersecting with a given local ray
  126000. * @param mesh defines the mesh to find the submesh for
  126001. * @param localRay defines the ray in local space
  126002. * @returns the list of intersecting sub meshes
  126003. */
  126004. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  126005. /**
  126006. * Return the list of sub meshes colliding with a collider
  126007. * @param mesh defines the mesh to find the submesh for
  126008. * @param collider defines the collider to evaluate the collision against
  126009. * @returns the list of colliding sub meshes
  126010. */
  126011. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  126012. /**
  126013. * Rebuilds the elements related to this component in case of
  126014. * context lost for instance.
  126015. */
  126016. rebuild(): void;
  126017. /**
  126018. * Disposes the component and the associated ressources.
  126019. */
  126020. dispose(): void;
  126021. }
  126022. }
  126023. declare module BABYLON {
  126024. /**
  126025. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  126026. */
  126027. export class Gizmo implements IDisposable {
  126028. /** The utility layer the gizmo will be added to */
  126029. gizmoLayer: UtilityLayerRenderer;
  126030. /**
  126031. * The root mesh of the gizmo
  126032. */
  126033. _rootMesh: Mesh;
  126034. private _attachedMesh;
  126035. /**
  126036. * Ratio for the scale of the gizmo (Default: 1)
  126037. */
  126038. scaleRatio: number;
  126039. /**
  126040. * If a custom mesh has been set (Default: false)
  126041. */
  126042. protected _customMeshSet: boolean;
  126043. /**
  126044. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  126045. * * When set, interactions will be enabled
  126046. */
  126047. get attachedMesh(): Nullable<AbstractMesh>;
  126048. set attachedMesh(value: Nullable<AbstractMesh>);
  126049. /**
  126050. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  126051. * @param mesh The mesh to replace the default mesh of the gizmo
  126052. */
  126053. setCustomMesh(mesh: Mesh): void;
  126054. /**
  126055. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  126056. */
  126057. updateGizmoRotationToMatchAttachedMesh: boolean;
  126058. /**
  126059. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  126060. */
  126061. updateGizmoPositionToMatchAttachedMesh: boolean;
  126062. /**
  126063. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  126064. */
  126065. updateScale: boolean;
  126066. protected _interactionsEnabled: boolean;
  126067. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126068. private _beforeRenderObserver;
  126069. private _tempVector;
  126070. /**
  126071. * Creates a gizmo
  126072. * @param gizmoLayer The utility layer the gizmo will be added to
  126073. */
  126074. constructor(
  126075. /** The utility layer the gizmo will be added to */
  126076. gizmoLayer?: UtilityLayerRenderer);
  126077. /**
  126078. * Updates the gizmo to match the attached mesh's position/rotation
  126079. */
  126080. protected _update(): void;
  126081. /**
  126082. * Disposes of the gizmo
  126083. */
  126084. dispose(): void;
  126085. }
  126086. }
  126087. declare module BABYLON {
  126088. /**
  126089. * Single plane drag gizmo
  126090. */
  126091. export class PlaneDragGizmo extends Gizmo {
  126092. /**
  126093. * Drag behavior responsible for the gizmos dragging interactions
  126094. */
  126095. dragBehavior: PointerDragBehavior;
  126096. private _pointerObserver;
  126097. /**
  126098. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126099. */
  126100. snapDistance: number;
  126101. /**
  126102. * Event that fires each time the gizmo snaps to a new location.
  126103. * * snapDistance is the the change in distance
  126104. */
  126105. onSnapObservable: Observable<{
  126106. snapDistance: number;
  126107. }>;
  126108. private _plane;
  126109. private _coloredMaterial;
  126110. private _hoverMaterial;
  126111. private _isEnabled;
  126112. private _parent;
  126113. /** @hidden */
  126114. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  126115. /** @hidden */
  126116. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  126117. /**
  126118. * Creates a PlaneDragGizmo
  126119. * @param gizmoLayer The utility layer the gizmo will be added to
  126120. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  126121. * @param color The color of the gizmo
  126122. */
  126123. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  126124. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126125. /**
  126126. * If the gizmo is enabled
  126127. */
  126128. set isEnabled(value: boolean);
  126129. get isEnabled(): boolean;
  126130. /**
  126131. * Disposes of the gizmo
  126132. */
  126133. dispose(): void;
  126134. }
  126135. }
  126136. declare module BABYLON {
  126137. /**
  126138. * Gizmo that enables dragging a mesh along 3 axis
  126139. */
  126140. export class PositionGizmo extends Gizmo {
  126141. /**
  126142. * Internal gizmo used for interactions on the x axis
  126143. */
  126144. xGizmo: AxisDragGizmo;
  126145. /**
  126146. * Internal gizmo used for interactions on the y axis
  126147. */
  126148. yGizmo: AxisDragGizmo;
  126149. /**
  126150. * Internal gizmo used for interactions on the z axis
  126151. */
  126152. zGizmo: AxisDragGizmo;
  126153. /**
  126154. * Internal gizmo used for interactions on the yz plane
  126155. */
  126156. xPlaneGizmo: PlaneDragGizmo;
  126157. /**
  126158. * Internal gizmo used for interactions on the xz plane
  126159. */
  126160. yPlaneGizmo: PlaneDragGizmo;
  126161. /**
  126162. * Internal gizmo used for interactions on the xy plane
  126163. */
  126164. zPlaneGizmo: PlaneDragGizmo;
  126165. /**
  126166. * private variables
  126167. */
  126168. private _meshAttached;
  126169. private _updateGizmoRotationToMatchAttachedMesh;
  126170. private _snapDistance;
  126171. private _scaleRatio;
  126172. /** Fires an event when any of it's sub gizmos are dragged */
  126173. onDragStartObservable: Observable<unknown>;
  126174. /** Fires an event when any of it's sub gizmos are released from dragging */
  126175. onDragEndObservable: Observable<unknown>;
  126176. /**
  126177. * If set to true, planar drag is enabled
  126178. */
  126179. private _planarGizmoEnabled;
  126180. get attachedMesh(): Nullable<AbstractMesh>;
  126181. set attachedMesh(mesh: Nullable<AbstractMesh>);
  126182. /**
  126183. * Creates a PositionGizmo
  126184. * @param gizmoLayer The utility layer the gizmo will be added to
  126185. */
  126186. constructor(gizmoLayer?: UtilityLayerRenderer);
  126187. /**
  126188. * If the planar drag gizmo is enabled
  126189. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  126190. */
  126191. set planarGizmoEnabled(value: boolean);
  126192. get planarGizmoEnabled(): boolean;
  126193. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  126194. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  126195. /**
  126196. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126197. */
  126198. set snapDistance(value: number);
  126199. get snapDistance(): number;
  126200. /**
  126201. * Ratio for the scale of the gizmo (Default: 1)
  126202. */
  126203. set scaleRatio(value: number);
  126204. get scaleRatio(): number;
  126205. /**
  126206. * Disposes of the gizmo
  126207. */
  126208. dispose(): void;
  126209. /**
  126210. * CustomMeshes are not supported by this gizmo
  126211. * @param mesh The mesh to replace the default mesh of the gizmo
  126212. */
  126213. setCustomMesh(mesh: Mesh): void;
  126214. }
  126215. }
  126216. declare module BABYLON {
  126217. /**
  126218. * Single axis drag gizmo
  126219. */
  126220. export class AxisDragGizmo extends Gizmo {
  126221. /**
  126222. * Drag behavior responsible for the gizmos dragging interactions
  126223. */
  126224. dragBehavior: PointerDragBehavior;
  126225. private _pointerObserver;
  126226. /**
  126227. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126228. */
  126229. snapDistance: number;
  126230. /**
  126231. * Event that fires each time the gizmo snaps to a new location.
  126232. * * snapDistance is the the change in distance
  126233. */
  126234. onSnapObservable: Observable<{
  126235. snapDistance: number;
  126236. }>;
  126237. private _isEnabled;
  126238. private _parent;
  126239. private _arrow;
  126240. private _coloredMaterial;
  126241. private _hoverMaterial;
  126242. /** @hidden */
  126243. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  126244. /** @hidden */
  126245. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  126246. /**
  126247. * Creates an AxisDragGizmo
  126248. * @param gizmoLayer The utility layer the gizmo will be added to
  126249. * @param dragAxis The axis which the gizmo will be able to drag on
  126250. * @param color The color of the gizmo
  126251. */
  126252. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  126253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126254. /**
  126255. * If the gizmo is enabled
  126256. */
  126257. set isEnabled(value: boolean);
  126258. get isEnabled(): boolean;
  126259. /**
  126260. * Disposes of the gizmo
  126261. */
  126262. dispose(): void;
  126263. }
  126264. }
  126265. declare module BABYLON.Debug {
  126266. /**
  126267. * The Axes viewer will show 3 axes in a specific point in space
  126268. */
  126269. export class AxesViewer {
  126270. private _xAxis;
  126271. private _yAxis;
  126272. private _zAxis;
  126273. private _scaleLinesFactor;
  126274. private _instanced;
  126275. /**
  126276. * Gets the hosting scene
  126277. */
  126278. scene: Scene;
  126279. /**
  126280. * Gets or sets a number used to scale line length
  126281. */
  126282. scaleLines: number;
  126283. /** Gets the node hierarchy used to render x-axis */
  126284. get xAxis(): TransformNode;
  126285. /** Gets the node hierarchy used to render y-axis */
  126286. get yAxis(): TransformNode;
  126287. /** Gets the node hierarchy used to render z-axis */
  126288. get zAxis(): TransformNode;
  126289. /**
  126290. * Creates a new AxesViewer
  126291. * @param scene defines the hosting scene
  126292. * @param scaleLines defines a number used to scale line length (1 by default)
  126293. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  126294. * @param xAxis defines the node hierarchy used to render the x-axis
  126295. * @param yAxis defines the node hierarchy used to render the y-axis
  126296. * @param zAxis defines the node hierarchy used to render the z-axis
  126297. */
  126298. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  126299. /**
  126300. * Force the viewer to update
  126301. * @param position defines the position of the viewer
  126302. * @param xaxis defines the x axis of the viewer
  126303. * @param yaxis defines the y axis of the viewer
  126304. * @param zaxis defines the z axis of the viewer
  126305. */
  126306. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  126307. /**
  126308. * Creates an instance of this axes viewer.
  126309. * @returns a new axes viewer with instanced meshes
  126310. */
  126311. createInstance(): AxesViewer;
  126312. /** Releases resources */
  126313. dispose(): void;
  126314. private static _SetRenderingGroupId;
  126315. }
  126316. }
  126317. declare module BABYLON.Debug {
  126318. /**
  126319. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  126320. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  126321. */
  126322. export class BoneAxesViewer extends AxesViewer {
  126323. /**
  126324. * Gets or sets the target mesh where to display the axes viewer
  126325. */
  126326. mesh: Nullable<Mesh>;
  126327. /**
  126328. * Gets or sets the target bone where to display the axes viewer
  126329. */
  126330. bone: Nullable<Bone>;
  126331. /** Gets current position */
  126332. pos: Vector3;
  126333. /** Gets direction of X axis */
  126334. xaxis: Vector3;
  126335. /** Gets direction of Y axis */
  126336. yaxis: Vector3;
  126337. /** Gets direction of Z axis */
  126338. zaxis: Vector3;
  126339. /**
  126340. * Creates a new BoneAxesViewer
  126341. * @param scene defines the hosting scene
  126342. * @param bone defines the target bone
  126343. * @param mesh defines the target mesh
  126344. * @param scaleLines defines a scaling factor for line length (1 by default)
  126345. */
  126346. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  126347. /**
  126348. * Force the viewer to update
  126349. */
  126350. update(): void;
  126351. /** Releases resources */
  126352. dispose(): void;
  126353. }
  126354. }
  126355. declare module BABYLON {
  126356. /**
  126357. * Interface used to define scene explorer extensibility option
  126358. */
  126359. export interface IExplorerExtensibilityOption {
  126360. /**
  126361. * Define the option label
  126362. */
  126363. label: string;
  126364. /**
  126365. * Defines the action to execute on click
  126366. */
  126367. action: (entity: any) => void;
  126368. }
  126369. /**
  126370. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  126371. */
  126372. export interface IExplorerExtensibilityGroup {
  126373. /**
  126374. * Defines a predicate to test if a given type mut be extended
  126375. */
  126376. predicate: (entity: any) => boolean;
  126377. /**
  126378. * Gets the list of options added to a type
  126379. */
  126380. entries: IExplorerExtensibilityOption[];
  126381. }
  126382. /**
  126383. * Interface used to define the options to use to create the Inspector
  126384. */
  126385. export interface IInspectorOptions {
  126386. /**
  126387. * Display in overlay mode (default: false)
  126388. */
  126389. overlay?: boolean;
  126390. /**
  126391. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  126392. */
  126393. globalRoot?: HTMLElement;
  126394. /**
  126395. * Display the Scene explorer
  126396. */
  126397. showExplorer?: boolean;
  126398. /**
  126399. * Display the property inspector
  126400. */
  126401. showInspector?: boolean;
  126402. /**
  126403. * Display in embed mode (both panes on the right)
  126404. */
  126405. embedMode?: boolean;
  126406. /**
  126407. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  126408. */
  126409. handleResize?: boolean;
  126410. /**
  126411. * Allow the panes to popup (default: true)
  126412. */
  126413. enablePopup?: boolean;
  126414. /**
  126415. * Allow the panes to be closed by users (default: true)
  126416. */
  126417. enableClose?: boolean;
  126418. /**
  126419. * Optional list of extensibility entries
  126420. */
  126421. explorerExtensibility?: IExplorerExtensibilityGroup[];
  126422. /**
  126423. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  126424. */
  126425. inspectorURL?: string;
  126426. /**
  126427. * Optional initial tab (default to DebugLayerTab.Properties)
  126428. */
  126429. initialTab?: DebugLayerTab;
  126430. }
  126431. interface Scene {
  126432. /**
  126433. * @hidden
  126434. * Backing field
  126435. */
  126436. _debugLayer: DebugLayer;
  126437. /**
  126438. * Gets the debug layer (aka Inspector) associated with the scene
  126439. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126440. */
  126441. debugLayer: DebugLayer;
  126442. }
  126443. /**
  126444. * Enum of inspector action tab
  126445. */
  126446. export enum DebugLayerTab {
  126447. /**
  126448. * Properties tag (default)
  126449. */
  126450. Properties = 0,
  126451. /**
  126452. * Debug tab
  126453. */
  126454. Debug = 1,
  126455. /**
  126456. * Statistics tab
  126457. */
  126458. Statistics = 2,
  126459. /**
  126460. * Tools tab
  126461. */
  126462. Tools = 3,
  126463. /**
  126464. * Settings tab
  126465. */
  126466. Settings = 4
  126467. }
  126468. /**
  126469. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126470. * what is happening in your scene
  126471. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126472. */
  126473. export class DebugLayer {
  126474. /**
  126475. * Define the url to get the inspector script from.
  126476. * By default it uses the babylonjs CDN.
  126477. * @ignoreNaming
  126478. */
  126479. static InspectorURL: string;
  126480. private _scene;
  126481. private BJSINSPECTOR;
  126482. private _onPropertyChangedObservable?;
  126483. /**
  126484. * Observable triggered when a property is changed through the inspector.
  126485. */
  126486. get onPropertyChangedObservable(): any;
  126487. /**
  126488. * Instantiates a new debug layer.
  126489. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126490. * what is happening in your scene
  126491. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126492. * @param scene Defines the scene to inspect
  126493. */
  126494. constructor(scene: Scene);
  126495. /** Creates the inspector window. */
  126496. private _createInspector;
  126497. /**
  126498. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  126499. * @param entity defines the entity to select
  126500. * @param lineContainerTitle defines the specific block to highlight
  126501. */
  126502. select(entity: any, lineContainerTitle?: string): void;
  126503. /** Get the inspector from bundle or global */
  126504. private _getGlobalInspector;
  126505. /**
  126506. * Get if the inspector is visible or not.
  126507. * @returns true if visible otherwise, false
  126508. */
  126509. isVisible(): boolean;
  126510. /**
  126511. * Hide the inspector and close its window.
  126512. */
  126513. hide(): void;
  126514. /**
  126515. * Update the scene in the inspector
  126516. */
  126517. setAsActiveScene(): void;
  126518. /**
  126519. * Launch the debugLayer.
  126520. * @param config Define the configuration of the inspector
  126521. * @return a promise fulfilled when the debug layer is visible
  126522. */
  126523. show(config?: IInspectorOptions): Promise<DebugLayer>;
  126524. }
  126525. }
  126526. declare module BABYLON {
  126527. /**
  126528. * Class containing static functions to help procedurally build meshes
  126529. */
  126530. export class BoxBuilder {
  126531. /**
  126532. * Creates a box mesh
  126533. * * The parameter `size` sets the size (float) of each box side (default 1)
  126534. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126535. * * 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)
  126536. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126540. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126541. * @param name defines the name of the mesh
  126542. * @param options defines the options used to create the mesh
  126543. * @param scene defines the hosting scene
  126544. * @returns the box mesh
  126545. */
  126546. static CreateBox(name: string, options: {
  126547. size?: number;
  126548. width?: number;
  126549. height?: number;
  126550. depth?: number;
  126551. faceUV?: Vector4[];
  126552. faceColors?: Color4[];
  126553. sideOrientation?: number;
  126554. frontUVs?: Vector4;
  126555. backUVs?: Vector4;
  126556. wrap?: boolean;
  126557. topBaseAt?: number;
  126558. bottomBaseAt?: number;
  126559. updatable?: boolean;
  126560. }, scene?: Nullable<Scene>): Mesh;
  126561. }
  126562. }
  126563. declare module BABYLON.Debug {
  126564. /**
  126565. * Used to show the physics impostor around the specific mesh
  126566. */
  126567. export class PhysicsViewer {
  126568. /** @hidden */
  126569. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  126570. /** @hidden */
  126571. protected _meshes: Array<Nullable<AbstractMesh>>;
  126572. /** @hidden */
  126573. protected _scene: Nullable<Scene>;
  126574. /** @hidden */
  126575. protected _numMeshes: number;
  126576. /** @hidden */
  126577. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  126578. private _renderFunction;
  126579. private _utilityLayer;
  126580. private _debugBoxMesh;
  126581. private _debugSphereMesh;
  126582. private _debugCylinderMesh;
  126583. private _debugMaterial;
  126584. private _debugMeshMeshes;
  126585. /**
  126586. * Creates a new PhysicsViewer
  126587. * @param scene defines the hosting scene
  126588. */
  126589. constructor(scene: Scene);
  126590. /** @hidden */
  126591. protected _updateDebugMeshes(): void;
  126592. /**
  126593. * Renders a specified physic impostor
  126594. * @param impostor defines the impostor to render
  126595. * @param targetMesh defines the mesh represented by the impostor
  126596. * @returns the new debug mesh used to render the impostor
  126597. */
  126598. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  126599. /**
  126600. * Hides a specified physic impostor
  126601. * @param impostor defines the impostor to hide
  126602. */
  126603. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  126604. private _getDebugMaterial;
  126605. private _getDebugBoxMesh;
  126606. private _getDebugSphereMesh;
  126607. private _getDebugCylinderMesh;
  126608. private _getDebugMeshMesh;
  126609. private _getDebugMesh;
  126610. /** Releases all resources */
  126611. dispose(): void;
  126612. }
  126613. }
  126614. declare module BABYLON {
  126615. /**
  126616. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126617. * in order to better appreciate the issue one might have.
  126618. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126619. */
  126620. export class RayHelper {
  126621. /**
  126622. * Defines the ray we are currently tryin to visualize.
  126623. */
  126624. ray: Nullable<Ray>;
  126625. private _renderPoints;
  126626. private _renderLine;
  126627. private _renderFunction;
  126628. private _scene;
  126629. private _updateToMeshFunction;
  126630. private _attachedToMesh;
  126631. private _meshSpaceDirection;
  126632. private _meshSpaceOrigin;
  126633. /**
  126634. * Helper function to create a colored helper in a scene in one line.
  126635. * @param ray Defines the ray we are currently tryin to visualize
  126636. * @param scene Defines the scene the ray is used in
  126637. * @param color Defines the color we want to see the ray in
  126638. * @returns The newly created ray helper.
  126639. */
  126640. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  126641. /**
  126642. * Instantiate a new ray helper.
  126643. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126644. * in order to better appreciate the issue one might have.
  126645. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126646. * @param ray Defines the ray we are currently tryin to visualize
  126647. */
  126648. constructor(ray: Ray);
  126649. /**
  126650. * Shows the ray we are willing to debug.
  126651. * @param scene Defines the scene the ray needs to be rendered in
  126652. * @param color Defines the color the ray needs to be rendered in
  126653. */
  126654. show(scene: Scene, color?: Color3): void;
  126655. /**
  126656. * Hides the ray we are debugging.
  126657. */
  126658. hide(): void;
  126659. private _render;
  126660. /**
  126661. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  126662. * @param mesh Defines the mesh we want the helper attached to
  126663. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  126664. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  126665. * @param length Defines the length of the ray
  126666. */
  126667. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  126668. /**
  126669. * Detach the ray helper from the mesh it has previously been attached to.
  126670. */
  126671. detachFromMesh(): void;
  126672. private _updateToMesh;
  126673. /**
  126674. * Dispose the helper and release its associated resources.
  126675. */
  126676. dispose(): void;
  126677. }
  126678. }
  126679. declare module BABYLON.Debug {
  126680. /**
  126681. * Class used to render a debug view of a given skeleton
  126682. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  126683. */
  126684. export class SkeletonViewer {
  126685. /** defines the skeleton to render */
  126686. skeleton: Skeleton;
  126687. /** defines the mesh attached to the skeleton */
  126688. mesh: AbstractMesh;
  126689. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126690. autoUpdateBonesMatrices: boolean;
  126691. /** defines the rendering group id to use with the viewer */
  126692. renderingGroupId: number;
  126693. /** Gets or sets the color used to render the skeleton */
  126694. color: Color3;
  126695. private _scene;
  126696. private _debugLines;
  126697. private _debugMesh;
  126698. private _isEnabled;
  126699. private _renderFunction;
  126700. private _utilityLayer;
  126701. /**
  126702. * Returns the mesh used to render the bones
  126703. */
  126704. get debugMesh(): Nullable<LinesMesh>;
  126705. /**
  126706. * Creates a new SkeletonViewer
  126707. * @param skeleton defines the skeleton to render
  126708. * @param mesh defines the mesh attached to the skeleton
  126709. * @param scene defines the hosting scene
  126710. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  126711. * @param renderingGroupId defines the rendering group id to use with the viewer
  126712. */
  126713. constructor(
  126714. /** defines the skeleton to render */
  126715. skeleton: Skeleton,
  126716. /** defines the mesh attached to the skeleton */
  126717. mesh: AbstractMesh, scene: Scene,
  126718. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126719. autoUpdateBonesMatrices?: boolean,
  126720. /** defines the rendering group id to use with the viewer */
  126721. renderingGroupId?: number);
  126722. /** Gets or sets a boolean indicating if the viewer is enabled */
  126723. set isEnabled(value: boolean);
  126724. get isEnabled(): boolean;
  126725. private _getBonePosition;
  126726. private _getLinesForBonesWithLength;
  126727. private _getLinesForBonesNoLength;
  126728. /** Update the viewer to sync with current skeleton state */
  126729. update(): void;
  126730. /** Release associated resources */
  126731. dispose(): void;
  126732. }
  126733. }
  126734. declare module BABYLON {
  126735. /**
  126736. * Enum for Device Types
  126737. */
  126738. export enum DeviceType {
  126739. /** Generic */
  126740. Generic = 0,
  126741. /** Keyboard */
  126742. Keyboard = 1,
  126743. /** Mouse */
  126744. Mouse = 2,
  126745. /** Touch Pointers */
  126746. Touch = 3,
  126747. /** PS4 Dual Shock */
  126748. DualShock = 4,
  126749. /** Xbox */
  126750. Xbox = 5,
  126751. /** Switch Controller */
  126752. Switch = 6
  126753. }
  126754. /**
  126755. * Enum for All Pointers (Touch/Mouse)
  126756. */
  126757. export enum PointerInput {
  126758. /** Horizontal Axis */
  126759. Horizontal = 0,
  126760. /** Vertical Axis */
  126761. Vertical = 1,
  126762. /** Left Click or Touch */
  126763. LeftClick = 2,
  126764. /** Middle Click */
  126765. MiddleClick = 3,
  126766. /** Right Click */
  126767. RightClick = 4,
  126768. /** Browser Back */
  126769. BrowserBack = 5,
  126770. /** Browser Forward */
  126771. BrowserForward = 6
  126772. }
  126773. /**
  126774. * Enum for Dual Shock Gamepad
  126775. */
  126776. export enum DualShockInput {
  126777. /** Cross */
  126778. Cross = 0,
  126779. /** Circle */
  126780. Circle = 1,
  126781. /** Square */
  126782. Square = 2,
  126783. /** Triangle */
  126784. Triangle = 3,
  126785. /** L1 */
  126786. L1 = 4,
  126787. /** R1 */
  126788. R1 = 5,
  126789. /** L2 */
  126790. L2 = 6,
  126791. /** R2 */
  126792. R2 = 7,
  126793. /** Share */
  126794. Share = 8,
  126795. /** Options */
  126796. Options = 9,
  126797. /** L3 */
  126798. L3 = 10,
  126799. /** R3 */
  126800. R3 = 11,
  126801. /** DPadUp */
  126802. DPadUp = 12,
  126803. /** DPadDown */
  126804. DPadDown = 13,
  126805. /** DPadLeft */
  126806. DPadLeft = 14,
  126807. /** DRight */
  126808. DPadRight = 15,
  126809. /** Home */
  126810. Home = 16,
  126811. /** TouchPad */
  126812. TouchPad = 17,
  126813. /** LStickXAxis */
  126814. LStickXAxis = 18,
  126815. /** LStickYAxis */
  126816. LStickYAxis = 19,
  126817. /** RStickXAxis */
  126818. RStickXAxis = 20,
  126819. /** RStickYAxis */
  126820. RStickYAxis = 21
  126821. }
  126822. /**
  126823. * Enum for Xbox Gamepad
  126824. */
  126825. export enum XboxInput {
  126826. /** A */
  126827. A = 0,
  126828. /** B */
  126829. B = 1,
  126830. /** X */
  126831. X = 2,
  126832. /** Y */
  126833. Y = 3,
  126834. /** LB */
  126835. LB = 4,
  126836. /** RB */
  126837. RB = 5,
  126838. /** LT */
  126839. LT = 6,
  126840. /** RT */
  126841. RT = 7,
  126842. /** Back */
  126843. Back = 8,
  126844. /** Start */
  126845. Start = 9,
  126846. /** LS */
  126847. LS = 10,
  126848. /** RS */
  126849. RS = 11,
  126850. /** DPadUp */
  126851. DPadUp = 12,
  126852. /** DPadDown */
  126853. DPadDown = 13,
  126854. /** DPadLeft */
  126855. DPadLeft = 14,
  126856. /** DRight */
  126857. DPadRight = 15,
  126858. /** Home */
  126859. Home = 16,
  126860. /** LStickXAxis */
  126861. LStickXAxis = 17,
  126862. /** LStickYAxis */
  126863. LStickYAxis = 18,
  126864. /** RStickXAxis */
  126865. RStickXAxis = 19,
  126866. /** RStickYAxis */
  126867. RStickYAxis = 20
  126868. }
  126869. /**
  126870. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  126871. */
  126872. export enum SwitchInput {
  126873. /** B */
  126874. B = 0,
  126875. /** A */
  126876. A = 1,
  126877. /** Y */
  126878. Y = 2,
  126879. /** X */
  126880. X = 3,
  126881. /** L */
  126882. L = 4,
  126883. /** R */
  126884. R = 5,
  126885. /** ZL */
  126886. ZL = 6,
  126887. /** ZR */
  126888. ZR = 7,
  126889. /** Minus */
  126890. Minus = 8,
  126891. /** Plus */
  126892. Plus = 9,
  126893. /** LS */
  126894. LS = 10,
  126895. /** RS */
  126896. RS = 11,
  126897. /** DPadUp */
  126898. DPadUp = 12,
  126899. /** DPadDown */
  126900. DPadDown = 13,
  126901. /** DPadLeft */
  126902. DPadLeft = 14,
  126903. /** DRight */
  126904. DPadRight = 15,
  126905. /** Home */
  126906. Home = 16,
  126907. /** Capture */
  126908. Capture = 17,
  126909. /** LStickXAxis */
  126910. LStickXAxis = 18,
  126911. /** LStickYAxis */
  126912. LStickYAxis = 19,
  126913. /** RStickXAxis */
  126914. RStickXAxis = 20,
  126915. /** RStickYAxis */
  126916. RStickYAxis = 21
  126917. }
  126918. }
  126919. declare module BABYLON {
  126920. /**
  126921. * This class will take all inputs from Keyboard, Pointer, and
  126922. * any Gamepads and provide a polling system that all devices
  126923. * will use. This class assumes that there will only be one
  126924. * pointer device and one keyboard.
  126925. */
  126926. export class DeviceInputSystem implements IDisposable {
  126927. /**
  126928. * Callback to be triggered when a device is connected
  126929. */
  126930. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  126931. /**
  126932. * Callback to be triggered when a device is disconnected
  126933. */
  126934. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  126935. /**
  126936. * Callback to be triggered when event driven input is updated
  126937. */
  126938. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  126939. private _inputs;
  126940. private _gamepads;
  126941. private _keyboardActive;
  126942. private _pointerActive;
  126943. private _elementToAttachTo;
  126944. private _keyboardDownEvent;
  126945. private _keyboardUpEvent;
  126946. private _pointerMoveEvent;
  126947. private _pointerDownEvent;
  126948. private _pointerUpEvent;
  126949. private _gamepadConnectedEvent;
  126950. private _gamepadDisconnectedEvent;
  126951. private static _MAX_KEYCODES;
  126952. private static _MAX_POINTER_INPUTS;
  126953. /**
  126954. * Default Constructor
  126955. * @param engine - engine to pull input element from
  126956. */
  126957. constructor(engine: Engine);
  126958. /**
  126959. * Checks for current device input value, given an id and input index
  126960. * @param deviceName Id of connected device
  126961. * @param inputIndex Index of device input
  126962. * @returns Current value of input
  126963. */
  126964. /**
  126965. * Checks for current device input value, given an id and input index
  126966. * @param deviceType Enum specifiying device type
  126967. * @param deviceSlot "Slot" or index that device is referenced in
  126968. * @param inputIndex Id of input to be checked
  126969. * @returns Current value of input
  126970. */
  126971. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  126972. /**
  126973. * Dispose of all the eventlisteners
  126974. */
  126975. dispose(): void;
  126976. /**
  126977. * Add device and inputs to device array
  126978. * @param deviceType Enum specifiying device type
  126979. * @param deviceSlot "Slot" or index that device is referenced in
  126980. * @param numberOfInputs Number of input entries to create for given device
  126981. */
  126982. private _registerDevice;
  126983. /**
  126984. * Given a specific device name, remove that device from the device map
  126985. * @param deviceType Enum specifiying device type
  126986. * @param deviceSlot "Slot" or index that device is referenced in
  126987. */
  126988. private _unregisterDevice;
  126989. /**
  126990. * Handle all actions that come from keyboard interaction
  126991. */
  126992. private _handleKeyActions;
  126993. /**
  126994. * Handle all actions that come from pointer interaction
  126995. */
  126996. private _handlePointerActions;
  126997. /**
  126998. * Handle all actions that come from gamepad interaction
  126999. */
  127000. private _handleGamepadActions;
  127001. /**
  127002. * Update all non-event based devices with each frame
  127003. * @param deviceType Enum specifiying device type
  127004. * @param deviceSlot "Slot" or index that device is referenced in
  127005. * @param inputIndex Id of input to be checked
  127006. */
  127007. private _updateDevice;
  127008. /**
  127009. * Gets DeviceType from the device name
  127010. * @param deviceName Name of Device from DeviceInputSystem
  127011. * @returns DeviceType enum value
  127012. */
  127013. private _getGamepadDeviceType;
  127014. }
  127015. }
  127016. declare module BABYLON {
  127017. /**
  127018. * Type to handle enforcement of inputs
  127019. */
  127020. 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;
  127021. }
  127022. declare module BABYLON {
  127023. /**
  127024. * Class that handles all input for a specific device
  127025. */
  127026. export class DeviceSource<T extends DeviceType> {
  127027. /** Type of device */
  127028. readonly deviceType: DeviceType;
  127029. /** "Slot" or index that device is referenced in */
  127030. readonly deviceSlot: number;
  127031. /**
  127032. * Observable to handle device input changes per device
  127033. */
  127034. readonly onInputChangedObservable: Observable<{
  127035. inputIndex: DeviceInput<T>;
  127036. previousState: Nullable<number>;
  127037. currentState: Nullable<number>;
  127038. }>;
  127039. private readonly _deviceInputSystem;
  127040. /**
  127041. * Default Constructor
  127042. * @param deviceInputSystem Reference to DeviceInputSystem
  127043. * @param deviceType Type of device
  127044. * @param deviceSlot "Slot" or index that device is referenced in
  127045. */
  127046. constructor(deviceInputSystem: DeviceInputSystem,
  127047. /** Type of device */
  127048. deviceType: DeviceType,
  127049. /** "Slot" or index that device is referenced in */
  127050. deviceSlot?: number);
  127051. /**
  127052. * Get input for specific input
  127053. * @param inputIndex index of specific input on device
  127054. * @returns Input value from DeviceInputSystem
  127055. */
  127056. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  127057. }
  127058. /**
  127059. * Class to keep track of devices
  127060. */
  127061. export class DeviceSourceManager implements IDisposable {
  127062. /**
  127063. * Observable to be triggered when before a device is connected
  127064. */
  127065. readonly onBeforeDeviceConnectedObservable: Observable<{
  127066. deviceType: DeviceType;
  127067. deviceSlot: number;
  127068. }>;
  127069. /**
  127070. * Observable to be triggered when before a device is disconnected
  127071. */
  127072. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  127073. deviceType: DeviceType;
  127074. deviceSlot: number;
  127075. }>;
  127076. /**
  127077. * Observable to be triggered when after a device is connected
  127078. */
  127079. readonly onAfterDeviceConnectedObservable: Observable<{
  127080. deviceType: DeviceType;
  127081. deviceSlot: number;
  127082. }>;
  127083. /**
  127084. * Observable to be triggered when after a device is disconnected
  127085. */
  127086. readonly onAfterDeviceDisconnectedObservable: Observable<{
  127087. deviceType: DeviceType;
  127088. deviceSlot: number;
  127089. }>;
  127090. private readonly _devices;
  127091. private readonly _firstDevice;
  127092. private readonly _deviceInputSystem;
  127093. /**
  127094. * Default Constructor
  127095. * @param engine engine to pull input element from
  127096. */
  127097. constructor(engine: Engine);
  127098. /**
  127099. * Gets a DeviceSource, given a type and slot
  127100. * @param deviceType Enum specifying device type
  127101. * @param deviceSlot "Slot" or index that device is referenced in
  127102. * @returns DeviceSource object
  127103. */
  127104. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  127105. /**
  127106. * Gets an array of DeviceSource objects for a given device type
  127107. * @param deviceType Enum specifying device type
  127108. * @returns Array of DeviceSource objects
  127109. */
  127110. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  127111. /**
  127112. * Dispose of DeviceInputSystem and other parts
  127113. */
  127114. dispose(): void;
  127115. /**
  127116. * Function to add device name to device list
  127117. * @param deviceType Enum specifying device type
  127118. * @param deviceSlot "Slot" or index that device is referenced in
  127119. */
  127120. private _addDevice;
  127121. /**
  127122. * Function to remove device name to device list
  127123. * @param deviceType Enum specifying device type
  127124. * @param deviceSlot "Slot" or index that device is referenced in
  127125. */
  127126. private _removeDevice;
  127127. /**
  127128. * Updates array storing first connected device of each type
  127129. * @param type Type of Device
  127130. */
  127131. private _updateFirstDevices;
  127132. }
  127133. }
  127134. declare module BABYLON {
  127135. /**
  127136. * Options to create the null engine
  127137. */
  127138. export class NullEngineOptions {
  127139. /**
  127140. * Render width (Default: 512)
  127141. */
  127142. renderWidth: number;
  127143. /**
  127144. * Render height (Default: 256)
  127145. */
  127146. renderHeight: number;
  127147. /**
  127148. * Texture size (Default: 512)
  127149. */
  127150. textureSize: number;
  127151. /**
  127152. * If delta time between frames should be constant
  127153. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127154. */
  127155. deterministicLockstep: boolean;
  127156. /**
  127157. * Maximum about of steps between frames (Default: 4)
  127158. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127159. */
  127160. lockstepMaxSteps: number;
  127161. }
  127162. /**
  127163. * The null engine class provides support for headless version of babylon.js.
  127164. * This can be used in server side scenario or for testing purposes
  127165. */
  127166. export class NullEngine extends Engine {
  127167. private _options;
  127168. /**
  127169. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  127170. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127171. * @returns true if engine is in deterministic lock step mode
  127172. */
  127173. isDeterministicLockStep(): boolean;
  127174. /**
  127175. * Gets the max steps when engine is running in deterministic lock step
  127176. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127177. * @returns the max steps
  127178. */
  127179. getLockstepMaxSteps(): number;
  127180. /**
  127181. * Gets the current hardware scaling level.
  127182. * By default the hardware scaling level is computed from the window device ratio.
  127183. * 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.
  127184. * @returns a number indicating the current hardware scaling level
  127185. */
  127186. getHardwareScalingLevel(): number;
  127187. constructor(options?: NullEngineOptions);
  127188. /**
  127189. * Creates a vertex buffer
  127190. * @param vertices the data for the vertex buffer
  127191. * @returns the new WebGL static buffer
  127192. */
  127193. createVertexBuffer(vertices: FloatArray): DataBuffer;
  127194. /**
  127195. * Creates a new index buffer
  127196. * @param indices defines the content of the index buffer
  127197. * @param updatable defines if the index buffer must be updatable
  127198. * @returns a new webGL buffer
  127199. */
  127200. createIndexBuffer(indices: IndicesArray): DataBuffer;
  127201. /**
  127202. * Clear the current render buffer or the current render target (if any is set up)
  127203. * @param color defines the color to use
  127204. * @param backBuffer defines if the back buffer must be cleared
  127205. * @param depth defines if the depth buffer must be cleared
  127206. * @param stencil defines if the stencil buffer must be cleared
  127207. */
  127208. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  127209. /**
  127210. * Gets the current render width
  127211. * @param useScreen defines if screen size must be used (or the current render target if any)
  127212. * @returns a number defining the current render width
  127213. */
  127214. getRenderWidth(useScreen?: boolean): number;
  127215. /**
  127216. * Gets the current render height
  127217. * @param useScreen defines if screen size must be used (or the current render target if any)
  127218. * @returns a number defining the current render height
  127219. */
  127220. getRenderHeight(useScreen?: boolean): number;
  127221. /**
  127222. * Set the WebGL's viewport
  127223. * @param viewport defines the viewport element to be used
  127224. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  127225. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  127226. */
  127227. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  127228. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  127229. /**
  127230. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  127231. * @param pipelineContext defines the pipeline context to use
  127232. * @param uniformsNames defines the list of uniform names
  127233. * @returns an array of webGL uniform locations
  127234. */
  127235. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  127236. /**
  127237. * Gets the lsit of active attributes for a given webGL program
  127238. * @param pipelineContext defines the pipeline context to use
  127239. * @param attributesNames defines the list of attribute names to get
  127240. * @returns an array of indices indicating the offset of each attribute
  127241. */
  127242. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  127243. /**
  127244. * Binds an effect to the webGL context
  127245. * @param effect defines the effect to bind
  127246. */
  127247. bindSamplers(effect: Effect): void;
  127248. /**
  127249. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  127250. * @param effect defines the effect to activate
  127251. */
  127252. enableEffect(effect: Effect): void;
  127253. /**
  127254. * Set various states to the webGL context
  127255. * @param culling defines backface culling state
  127256. * @param zOffset defines the value to apply to zOffset (0 by default)
  127257. * @param force defines if states must be applied even if cache is up to date
  127258. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  127259. */
  127260. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  127261. /**
  127262. * Set the value of an uniform to an array of int32
  127263. * @param uniform defines the webGL uniform location where to store the value
  127264. * @param array defines the array of int32 to store
  127265. */
  127266. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  127267. /**
  127268. * Set the value of an uniform to an array of int32 (stored as vec2)
  127269. * @param uniform defines the webGL uniform location where to store the value
  127270. * @param array defines the array of int32 to store
  127271. */
  127272. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  127273. /**
  127274. * Set the value of an uniform to an array of int32 (stored as vec3)
  127275. * @param uniform defines the webGL uniform location where to store the value
  127276. * @param array defines the array of int32 to store
  127277. */
  127278. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  127279. /**
  127280. * Set the value of an uniform to an array of int32 (stored as vec4)
  127281. * @param uniform defines the webGL uniform location where to store the value
  127282. * @param array defines the array of int32 to store
  127283. */
  127284. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  127285. /**
  127286. * Set the value of an uniform to an array of float32
  127287. * @param uniform defines the webGL uniform location where to store the value
  127288. * @param array defines the array of float32 to store
  127289. */
  127290. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  127291. /**
  127292. * Set the value of an uniform to an array of float32 (stored as vec2)
  127293. * @param uniform defines the webGL uniform location where to store the value
  127294. * @param array defines the array of float32 to store
  127295. */
  127296. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  127297. /**
  127298. * Set the value of an uniform to an array of float32 (stored as vec3)
  127299. * @param uniform defines the webGL uniform location where to store the value
  127300. * @param array defines the array of float32 to store
  127301. */
  127302. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  127303. /**
  127304. * Set the value of an uniform to an array of float32 (stored as vec4)
  127305. * @param uniform defines the webGL uniform location where to store the value
  127306. * @param array defines the array of float32 to store
  127307. */
  127308. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  127309. /**
  127310. * Set the value of an uniform to an array of number
  127311. * @param uniform defines the webGL uniform location where to store the value
  127312. * @param array defines the array of number to store
  127313. */
  127314. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  127315. /**
  127316. * Set the value of an uniform to an array of number (stored as vec2)
  127317. * @param uniform defines the webGL uniform location where to store the value
  127318. * @param array defines the array of number to store
  127319. */
  127320. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  127321. /**
  127322. * Set the value of an uniform to an array of number (stored as vec3)
  127323. * @param uniform defines the webGL uniform location where to store the value
  127324. * @param array defines the array of number to store
  127325. */
  127326. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  127327. /**
  127328. * Set the value of an uniform to an array of number (stored as vec4)
  127329. * @param uniform defines the webGL uniform location where to store the value
  127330. * @param array defines the array of number to store
  127331. */
  127332. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  127333. /**
  127334. * Set the value of an uniform to an array of float32 (stored as matrices)
  127335. * @param uniform defines the webGL uniform location where to store the value
  127336. * @param matrices defines the array of float32 to store
  127337. */
  127338. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  127339. /**
  127340. * Set the value of an uniform to a matrix (3x3)
  127341. * @param uniform defines the webGL uniform location where to store the value
  127342. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  127343. */
  127344. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127345. /**
  127346. * Set the value of an uniform to a matrix (2x2)
  127347. * @param uniform defines the webGL uniform location where to store the value
  127348. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  127349. */
  127350. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127351. /**
  127352. * Set the value of an uniform to a number (float)
  127353. * @param uniform defines the webGL uniform location where to store the value
  127354. * @param value defines the float number to store
  127355. */
  127356. setFloat(uniform: WebGLUniformLocation, value: number): void;
  127357. /**
  127358. * Set the value of an uniform to a vec2
  127359. * @param uniform defines the webGL uniform location where to store the value
  127360. * @param x defines the 1st component of the value
  127361. * @param y defines the 2nd component of the value
  127362. */
  127363. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  127364. /**
  127365. * Set the value of an uniform to a vec3
  127366. * @param uniform defines the webGL uniform location where to store the value
  127367. * @param x defines the 1st component of the value
  127368. * @param y defines the 2nd component of the value
  127369. * @param z defines the 3rd component of the value
  127370. */
  127371. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  127372. /**
  127373. * Set the value of an uniform to a boolean
  127374. * @param uniform defines the webGL uniform location where to store the value
  127375. * @param bool defines the boolean to store
  127376. */
  127377. setBool(uniform: WebGLUniformLocation, bool: number): void;
  127378. /**
  127379. * Set the value of an uniform to a vec4
  127380. * @param uniform defines the webGL uniform location where to store the value
  127381. * @param x defines the 1st component of the value
  127382. * @param y defines the 2nd component of the value
  127383. * @param z defines the 3rd component of the value
  127384. * @param w defines the 4th component of the value
  127385. */
  127386. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  127387. /**
  127388. * Sets the current alpha mode
  127389. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  127390. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  127391. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  127392. */
  127393. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  127394. /**
  127395. * Bind webGl buffers directly to the webGL context
  127396. * @param vertexBuffers defines the vertex buffer to bind
  127397. * @param indexBuffer defines the index buffer to bind
  127398. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  127399. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  127400. * @param effect defines the effect associated with the vertex buffer
  127401. */
  127402. bindBuffers(vertexBuffers: {
  127403. [key: string]: VertexBuffer;
  127404. }, indexBuffer: DataBuffer, effect: Effect): void;
  127405. /**
  127406. * Force the entire cache to be cleared
  127407. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  127408. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  127409. */
  127410. wipeCaches(bruteForce?: boolean): void;
  127411. /**
  127412. * Send a draw order
  127413. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  127414. * @param indexStart defines the starting index
  127415. * @param indexCount defines the number of index to draw
  127416. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127417. */
  127418. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  127419. /**
  127420. * Draw a list of indexed primitives
  127421. * @param fillMode defines the primitive to use
  127422. * @param indexStart defines the starting index
  127423. * @param indexCount defines the number of index to draw
  127424. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127425. */
  127426. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  127427. /**
  127428. * Draw a list of unindexed primitives
  127429. * @param fillMode defines the primitive to use
  127430. * @param verticesStart defines the index of first vertex to draw
  127431. * @param verticesCount defines the count of vertices to draw
  127432. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127433. */
  127434. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  127435. /** @hidden */
  127436. _createTexture(): WebGLTexture;
  127437. /** @hidden */
  127438. _releaseTexture(texture: InternalTexture): void;
  127439. /**
  127440. * Usually called from Texture.ts.
  127441. * Passed information to create a WebGLTexture
  127442. * @param urlArg defines a value which contains one of the following:
  127443. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  127444. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  127445. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  127446. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  127447. * @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)
  127448. * @param scene needed for loading to the correct scene
  127449. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  127450. * @param onLoad optional callback to be called upon successful completion
  127451. * @param onError optional callback to be called upon failure
  127452. * @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
  127453. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  127454. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  127455. * @param forcedExtension defines the extension to use to pick the right loader
  127456. * @param mimeType defines an optional mime type
  127457. * @returns a InternalTexture for assignment back into BABYLON.Texture
  127458. */
  127459. 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;
  127460. /**
  127461. * Creates a new render target texture
  127462. * @param size defines the size of the texture
  127463. * @param options defines the options used to create the texture
  127464. * @returns a new render target texture stored in an InternalTexture
  127465. */
  127466. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  127467. /**
  127468. * Update the sampling mode of a given texture
  127469. * @param samplingMode defines the required sampling mode
  127470. * @param texture defines the texture to update
  127471. */
  127472. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  127473. /**
  127474. * Binds the frame buffer to the specified texture.
  127475. * @param texture The texture to render to or null for the default canvas
  127476. * @param faceIndex The face of the texture to render to in case of cube texture
  127477. * @param requiredWidth The width of the target to render to
  127478. * @param requiredHeight The height of the target to render to
  127479. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  127480. * @param lodLevel defines le lod level to bind to the frame buffer
  127481. */
  127482. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  127483. /**
  127484. * Unbind the current render target texture from the webGL context
  127485. * @param texture defines the render target texture to unbind
  127486. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  127487. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  127488. */
  127489. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  127490. /**
  127491. * Creates a dynamic vertex buffer
  127492. * @param vertices the data for the dynamic vertex buffer
  127493. * @returns the new WebGL dynamic buffer
  127494. */
  127495. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  127496. /**
  127497. * Update the content of a dynamic texture
  127498. * @param texture defines the texture to update
  127499. * @param canvas defines the canvas containing the source
  127500. * @param invertY defines if data must be stored with Y axis inverted
  127501. * @param premulAlpha defines if alpha is stored as premultiplied
  127502. * @param format defines the format of the data
  127503. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  127504. */
  127505. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  127506. /**
  127507. * Gets a boolean indicating if all created effects are ready
  127508. * @returns true if all effects are ready
  127509. */
  127510. areAllEffectsReady(): boolean;
  127511. /**
  127512. * @hidden
  127513. * Get the current error code of the webGL context
  127514. * @returns the error code
  127515. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  127516. */
  127517. getError(): number;
  127518. /** @hidden */
  127519. _getUnpackAlignement(): number;
  127520. /** @hidden */
  127521. _unpackFlipY(value: boolean): void;
  127522. /**
  127523. * Update a dynamic index buffer
  127524. * @param indexBuffer defines the target index buffer
  127525. * @param indices defines the data to update
  127526. * @param offset defines the offset in the target index buffer where update should start
  127527. */
  127528. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  127529. /**
  127530. * Updates a dynamic vertex buffer.
  127531. * @param vertexBuffer the vertex buffer to update
  127532. * @param vertices the data used to update the vertex buffer
  127533. * @param byteOffset the byte offset of the data (optional)
  127534. * @param byteLength the byte length of the data (optional)
  127535. */
  127536. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  127537. /** @hidden */
  127538. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  127539. /** @hidden */
  127540. _bindTexture(channel: number, texture: InternalTexture): void;
  127541. protected _deleteBuffer(buffer: WebGLBuffer): void;
  127542. /**
  127543. * 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
  127544. */
  127545. releaseEffects(): void;
  127546. displayLoadingUI(): void;
  127547. hideLoadingUI(): void;
  127548. /** @hidden */
  127549. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127550. /** @hidden */
  127551. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127552. /** @hidden */
  127553. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127554. /** @hidden */
  127555. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  127556. }
  127557. }
  127558. declare module BABYLON {
  127559. /**
  127560. * @hidden
  127561. **/
  127562. export class _TimeToken {
  127563. _startTimeQuery: Nullable<WebGLQuery>;
  127564. _endTimeQuery: Nullable<WebGLQuery>;
  127565. _timeElapsedQuery: Nullable<WebGLQuery>;
  127566. _timeElapsedQueryEnded: boolean;
  127567. }
  127568. }
  127569. declare module BABYLON {
  127570. /** @hidden */
  127571. export class _OcclusionDataStorage {
  127572. /** @hidden */
  127573. occlusionInternalRetryCounter: number;
  127574. /** @hidden */
  127575. isOcclusionQueryInProgress: boolean;
  127576. /** @hidden */
  127577. isOccluded: boolean;
  127578. /** @hidden */
  127579. occlusionRetryCount: number;
  127580. /** @hidden */
  127581. occlusionType: number;
  127582. /** @hidden */
  127583. occlusionQueryAlgorithmType: number;
  127584. }
  127585. interface Engine {
  127586. /**
  127587. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  127588. * @return the new query
  127589. */
  127590. createQuery(): WebGLQuery;
  127591. /**
  127592. * Delete and release a webGL query
  127593. * @param query defines the query to delete
  127594. * @return the current engine
  127595. */
  127596. deleteQuery(query: WebGLQuery): Engine;
  127597. /**
  127598. * Check if a given query has resolved and got its value
  127599. * @param query defines the query to check
  127600. * @returns true if the query got its value
  127601. */
  127602. isQueryResultAvailable(query: WebGLQuery): boolean;
  127603. /**
  127604. * Gets the value of a given query
  127605. * @param query defines the query to check
  127606. * @returns the value of the query
  127607. */
  127608. getQueryResult(query: WebGLQuery): number;
  127609. /**
  127610. * Initiates an occlusion query
  127611. * @param algorithmType defines the algorithm to use
  127612. * @param query defines the query to use
  127613. * @returns the current engine
  127614. * @see http://doc.babylonjs.com/features/occlusionquery
  127615. */
  127616. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  127617. /**
  127618. * Ends an occlusion query
  127619. * @see http://doc.babylonjs.com/features/occlusionquery
  127620. * @param algorithmType defines the algorithm to use
  127621. * @returns the current engine
  127622. */
  127623. endOcclusionQuery(algorithmType: number): Engine;
  127624. /**
  127625. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  127626. * Please note that only one query can be issued at a time
  127627. * @returns a time token used to track the time span
  127628. */
  127629. startTimeQuery(): Nullable<_TimeToken>;
  127630. /**
  127631. * Ends a time query
  127632. * @param token defines the token used to measure the time span
  127633. * @returns the time spent (in ns)
  127634. */
  127635. endTimeQuery(token: _TimeToken): int;
  127636. /** @hidden */
  127637. _currentNonTimestampToken: Nullable<_TimeToken>;
  127638. /** @hidden */
  127639. _createTimeQuery(): WebGLQuery;
  127640. /** @hidden */
  127641. _deleteTimeQuery(query: WebGLQuery): void;
  127642. /** @hidden */
  127643. _getGlAlgorithmType(algorithmType: number): number;
  127644. /** @hidden */
  127645. _getTimeQueryResult(query: WebGLQuery): any;
  127646. /** @hidden */
  127647. _getTimeQueryAvailability(query: WebGLQuery): any;
  127648. }
  127649. interface AbstractMesh {
  127650. /**
  127651. * Backing filed
  127652. * @hidden
  127653. */
  127654. __occlusionDataStorage: _OcclusionDataStorage;
  127655. /**
  127656. * Access property
  127657. * @hidden
  127658. */
  127659. _occlusionDataStorage: _OcclusionDataStorage;
  127660. /**
  127661. * 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.
  127662. * The default value is -1 which means don't break the query and wait till the result
  127663. * @see http://doc.babylonjs.com/features/occlusionquery
  127664. */
  127665. occlusionRetryCount: number;
  127666. /**
  127667. * 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:
  127668. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  127669. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  127670. * * 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.
  127671. * @see http://doc.babylonjs.com/features/occlusionquery
  127672. */
  127673. occlusionType: number;
  127674. /**
  127675. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  127676. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  127677. * * 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.
  127678. * @see http://doc.babylonjs.com/features/occlusionquery
  127679. */
  127680. occlusionQueryAlgorithmType: number;
  127681. /**
  127682. * 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
  127683. * @see http://doc.babylonjs.com/features/occlusionquery
  127684. */
  127685. isOccluded: boolean;
  127686. /**
  127687. * Flag to check the progress status of the query
  127688. * @see http://doc.babylonjs.com/features/occlusionquery
  127689. */
  127690. isOcclusionQueryInProgress: boolean;
  127691. }
  127692. }
  127693. declare module BABYLON {
  127694. /** @hidden */
  127695. export var _forceTransformFeedbackToBundle: boolean;
  127696. interface Engine {
  127697. /**
  127698. * Creates a webGL transform feedback object
  127699. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  127700. * @returns the webGL transform feedback object
  127701. */
  127702. createTransformFeedback(): WebGLTransformFeedback;
  127703. /**
  127704. * Delete a webGL transform feedback object
  127705. * @param value defines the webGL transform feedback object to delete
  127706. */
  127707. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  127708. /**
  127709. * Bind a webGL transform feedback object to the webgl context
  127710. * @param value defines the webGL transform feedback object to bind
  127711. */
  127712. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  127713. /**
  127714. * Begins a transform feedback operation
  127715. * @param usePoints defines if points or triangles must be used
  127716. */
  127717. beginTransformFeedback(usePoints: boolean): void;
  127718. /**
  127719. * Ends a transform feedback operation
  127720. */
  127721. endTransformFeedback(): void;
  127722. /**
  127723. * Specify the varyings to use with transform feedback
  127724. * @param program defines the associated webGL program
  127725. * @param value defines the list of strings representing the varying names
  127726. */
  127727. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  127728. /**
  127729. * Bind a webGL buffer for a transform feedback operation
  127730. * @param value defines the webGL buffer to bind
  127731. */
  127732. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  127733. }
  127734. }
  127735. declare module BABYLON {
  127736. /**
  127737. * Creation options of the multi render target texture.
  127738. */
  127739. export interface IMultiRenderTargetOptions {
  127740. /**
  127741. * Define if the texture needs to create mip maps after render.
  127742. */
  127743. generateMipMaps?: boolean;
  127744. /**
  127745. * Define the types of all the draw buffers we want to create
  127746. */
  127747. types?: number[];
  127748. /**
  127749. * Define the sampling modes of all the draw buffers we want to create
  127750. */
  127751. samplingModes?: number[];
  127752. /**
  127753. * Define if a depth buffer is required
  127754. */
  127755. generateDepthBuffer?: boolean;
  127756. /**
  127757. * Define if a stencil buffer is required
  127758. */
  127759. generateStencilBuffer?: boolean;
  127760. /**
  127761. * Define if a depth texture is required instead of a depth buffer
  127762. */
  127763. generateDepthTexture?: boolean;
  127764. /**
  127765. * Define the number of desired draw buffers
  127766. */
  127767. textureCount?: number;
  127768. /**
  127769. * Define if aspect ratio should be adapted to the texture or stay the scene one
  127770. */
  127771. doNotChangeAspectRatio?: boolean;
  127772. /**
  127773. * Define the default type of the buffers we are creating
  127774. */
  127775. defaultType?: number;
  127776. }
  127777. /**
  127778. * A multi render target, like a render target provides the ability to render to a texture.
  127779. * Unlike the render target, it can render to several draw buffers in one draw.
  127780. * This is specially interesting in deferred rendering or for any effects requiring more than
  127781. * just one color from a single pass.
  127782. */
  127783. export class MultiRenderTarget extends RenderTargetTexture {
  127784. private _internalTextures;
  127785. private _textures;
  127786. private _multiRenderTargetOptions;
  127787. /**
  127788. * Get if draw buffers are currently supported by the used hardware and browser.
  127789. */
  127790. get isSupported(): boolean;
  127791. /**
  127792. * Get the list of textures generated by the multi render target.
  127793. */
  127794. get textures(): Texture[];
  127795. /**
  127796. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  127797. */
  127798. get depthTexture(): Texture;
  127799. /**
  127800. * Set the wrapping mode on U of all the textures we are rendering to.
  127801. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127802. */
  127803. set wrapU(wrap: number);
  127804. /**
  127805. * Set the wrapping mode on V of all the textures we are rendering to.
  127806. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127807. */
  127808. set wrapV(wrap: number);
  127809. /**
  127810. * Instantiate a new multi render target texture.
  127811. * A multi render target, like a render target provides the ability to render to a texture.
  127812. * Unlike the render target, it can render to several draw buffers in one draw.
  127813. * This is specially interesting in deferred rendering or for any effects requiring more than
  127814. * just one color from a single pass.
  127815. * @param name Define the name of the texture
  127816. * @param size Define the size of the buffers to render to
  127817. * @param count Define the number of target we are rendering into
  127818. * @param scene Define the scene the texture belongs to
  127819. * @param options Define the options used to create the multi render target
  127820. */
  127821. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  127822. /** @hidden */
  127823. _rebuild(): void;
  127824. private _createInternalTextures;
  127825. private _createTextures;
  127826. /**
  127827. * Define the number of samples used if MSAA is enabled.
  127828. */
  127829. get samples(): number;
  127830. set samples(value: number);
  127831. /**
  127832. * Resize all the textures in the multi render target.
  127833. * Be carrefull as it will recreate all the data in the new texture.
  127834. * @param size Define the new size
  127835. */
  127836. resize(size: any): void;
  127837. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  127838. /**
  127839. * Dispose the render targets and their associated resources
  127840. */
  127841. dispose(): void;
  127842. /**
  127843. * Release all the underlying texture used as draw buffers.
  127844. */
  127845. releaseInternalTextures(): void;
  127846. }
  127847. }
  127848. declare module BABYLON {
  127849. interface ThinEngine {
  127850. /**
  127851. * Unbind a list of render target textures from the webGL context
  127852. * This is used only when drawBuffer extension or webGL2 are active
  127853. * @param textures defines the render target textures to unbind
  127854. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  127855. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  127856. */
  127857. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  127858. /**
  127859. * Create a multi render target texture
  127860. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  127861. * @param size defines the size of the texture
  127862. * @param options defines the creation options
  127863. * @returns the cube texture as an InternalTexture
  127864. */
  127865. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  127866. /**
  127867. * Update the sample count for a given multiple render target texture
  127868. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  127869. * @param textures defines the textures to update
  127870. * @param samples defines the sample count to set
  127871. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  127872. */
  127873. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  127874. }
  127875. }
  127876. declare module BABYLON {
  127877. /**
  127878. * Class used to define an additional view for the engine
  127879. * @see https://doc.babylonjs.com/how_to/multi_canvases
  127880. */
  127881. export class EngineView {
  127882. /** Defines the canvas where to render the view */
  127883. target: HTMLCanvasElement;
  127884. /** Defines an optional camera used to render the view (will use active camera else) */
  127885. camera?: Camera;
  127886. }
  127887. interface Engine {
  127888. /**
  127889. * Gets or sets the HTML element to use for attaching events
  127890. */
  127891. inputElement: Nullable<HTMLElement>;
  127892. /**
  127893. * Gets the current engine view
  127894. * @see https://doc.babylonjs.com/how_to/multi_canvases
  127895. */
  127896. activeView: Nullable<EngineView>;
  127897. /** Gets or sets the list of views */
  127898. views: EngineView[];
  127899. /**
  127900. * Register a new child canvas
  127901. * @param canvas defines the canvas to register
  127902. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  127903. * @returns the associated view
  127904. */
  127905. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  127906. /**
  127907. * Remove a registered child canvas
  127908. * @param canvas defines the canvas to remove
  127909. * @returns the current engine
  127910. */
  127911. unRegisterView(canvas: HTMLCanvasElement): Engine;
  127912. }
  127913. }
  127914. declare module BABYLON {
  127915. interface Engine {
  127916. /** @hidden */
  127917. _excludedCompressedTextures: string[];
  127918. /** @hidden */
  127919. _textureFormatInUse: string;
  127920. /**
  127921. * Gets the list of texture formats supported
  127922. */
  127923. readonly texturesSupported: Array<string>;
  127924. /**
  127925. * Gets the texture format in use
  127926. */
  127927. readonly textureFormatInUse: Nullable<string>;
  127928. /**
  127929. * Set the compressed texture extensions or file names to skip.
  127930. *
  127931. * @param skippedFiles defines the list of those texture files you want to skip
  127932. * Example: [".dds", ".env", "myfile.png"]
  127933. */
  127934. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  127935. /**
  127936. * Set the compressed texture format to use, based on the formats you have, and the formats
  127937. * supported by the hardware / browser.
  127938. *
  127939. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  127940. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  127941. * to API arguments needed to compressed textures. This puts the burden on the container
  127942. * generator to house the arcane code for determining these for current & future formats.
  127943. *
  127944. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  127945. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  127946. *
  127947. * Note: The result of this call is not taken into account when a texture is base64.
  127948. *
  127949. * @param formatsAvailable defines the list of those format families you have created
  127950. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  127951. *
  127952. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  127953. * @returns The extension selected.
  127954. */
  127955. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  127956. }
  127957. }
  127958. declare module BABYLON {
  127959. /**
  127960. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  127961. */
  127962. export interface CubeMapInfo {
  127963. /**
  127964. * The pixel array for the front face.
  127965. * This is stored in format, left to right, up to down format.
  127966. */
  127967. front: Nullable<ArrayBufferView>;
  127968. /**
  127969. * The pixel array for the back face.
  127970. * This is stored in format, left to right, up to down format.
  127971. */
  127972. back: Nullable<ArrayBufferView>;
  127973. /**
  127974. * The pixel array for the left face.
  127975. * This is stored in format, left to right, up to down format.
  127976. */
  127977. left: Nullable<ArrayBufferView>;
  127978. /**
  127979. * The pixel array for the right face.
  127980. * This is stored in format, left to right, up to down format.
  127981. */
  127982. right: Nullable<ArrayBufferView>;
  127983. /**
  127984. * The pixel array for the up face.
  127985. * This is stored in format, left to right, up to down format.
  127986. */
  127987. up: Nullable<ArrayBufferView>;
  127988. /**
  127989. * The pixel array for the down face.
  127990. * This is stored in format, left to right, up to down format.
  127991. */
  127992. down: Nullable<ArrayBufferView>;
  127993. /**
  127994. * The size of the cubemap stored.
  127995. *
  127996. * Each faces will be size * size pixels.
  127997. */
  127998. size: number;
  127999. /**
  128000. * The format of the texture.
  128001. *
  128002. * RGBA, RGB.
  128003. */
  128004. format: number;
  128005. /**
  128006. * The type of the texture data.
  128007. *
  128008. * UNSIGNED_INT, FLOAT.
  128009. */
  128010. type: number;
  128011. /**
  128012. * Specifies whether the texture is in gamma space.
  128013. */
  128014. gammaSpace: boolean;
  128015. }
  128016. /**
  128017. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  128018. */
  128019. export class PanoramaToCubeMapTools {
  128020. private static FACE_LEFT;
  128021. private static FACE_RIGHT;
  128022. private static FACE_FRONT;
  128023. private static FACE_BACK;
  128024. private static FACE_DOWN;
  128025. private static FACE_UP;
  128026. /**
  128027. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  128028. *
  128029. * @param float32Array The source data.
  128030. * @param inputWidth The width of the input panorama.
  128031. * @param inputHeight The height of the input panorama.
  128032. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  128033. * @return The cubemap data
  128034. */
  128035. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  128036. private static CreateCubemapTexture;
  128037. private static CalcProjectionSpherical;
  128038. }
  128039. }
  128040. declare module BABYLON {
  128041. /**
  128042. * Helper class dealing with the extraction of spherical polynomial dataArray
  128043. * from a cube map.
  128044. */
  128045. export class CubeMapToSphericalPolynomialTools {
  128046. private static FileFaces;
  128047. /**
  128048. * Converts a texture to the according Spherical Polynomial data.
  128049. * This extracts the first 3 orders only as they are the only one used in the lighting.
  128050. *
  128051. * @param texture The texture to extract the information from.
  128052. * @return The Spherical Polynomial data.
  128053. */
  128054. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  128055. /**
  128056. * Converts a cubemap to the according Spherical Polynomial data.
  128057. * This extracts the first 3 orders only as they are the only one used in the lighting.
  128058. *
  128059. * @param cubeInfo The Cube map to extract the information from.
  128060. * @return The Spherical Polynomial data.
  128061. */
  128062. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  128063. }
  128064. }
  128065. declare module BABYLON {
  128066. interface BaseTexture {
  128067. /**
  128068. * Get the polynomial representation of the texture data.
  128069. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  128070. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  128071. */
  128072. sphericalPolynomial: Nullable<SphericalPolynomial>;
  128073. }
  128074. }
  128075. declare module BABYLON {
  128076. /** @hidden */
  128077. export var rgbdEncodePixelShader: {
  128078. name: string;
  128079. shader: string;
  128080. };
  128081. }
  128082. declare module BABYLON {
  128083. /** @hidden */
  128084. export var rgbdDecodePixelShader: {
  128085. name: string;
  128086. shader: string;
  128087. };
  128088. }
  128089. declare module BABYLON {
  128090. /**
  128091. * Raw texture data and descriptor sufficient for WebGL texture upload
  128092. */
  128093. export interface EnvironmentTextureInfo {
  128094. /**
  128095. * Version of the environment map
  128096. */
  128097. version: number;
  128098. /**
  128099. * Width of image
  128100. */
  128101. width: number;
  128102. /**
  128103. * Irradiance information stored in the file.
  128104. */
  128105. irradiance: any;
  128106. /**
  128107. * Specular information stored in the file.
  128108. */
  128109. specular: any;
  128110. }
  128111. /**
  128112. * Defines One Image in the file. It requires only the position in the file
  128113. * as well as the length.
  128114. */
  128115. interface BufferImageData {
  128116. /**
  128117. * Length of the image data.
  128118. */
  128119. length: number;
  128120. /**
  128121. * Position of the data from the null terminator delimiting the end of the JSON.
  128122. */
  128123. position: number;
  128124. }
  128125. /**
  128126. * Defines the specular data enclosed in the file.
  128127. * This corresponds to the version 1 of the data.
  128128. */
  128129. export interface EnvironmentTextureSpecularInfoV1 {
  128130. /**
  128131. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  128132. */
  128133. specularDataPosition?: number;
  128134. /**
  128135. * This contains all the images data needed to reconstruct the cubemap.
  128136. */
  128137. mipmaps: Array<BufferImageData>;
  128138. /**
  128139. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  128140. */
  128141. lodGenerationScale: number;
  128142. }
  128143. /**
  128144. * Sets of helpers addressing the serialization and deserialization of environment texture
  128145. * stored in a BabylonJS env file.
  128146. * Those files are usually stored as .env files.
  128147. */
  128148. export class EnvironmentTextureTools {
  128149. /**
  128150. * Magic number identifying the env file.
  128151. */
  128152. private static _MagicBytes;
  128153. /**
  128154. * Gets the environment info from an env file.
  128155. * @param data The array buffer containing the .env bytes.
  128156. * @returns the environment file info (the json header) if successfully parsed.
  128157. */
  128158. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  128159. /**
  128160. * Creates an environment texture from a loaded cube texture.
  128161. * @param texture defines the cube texture to convert in env file
  128162. * @return a promise containing the environment data if succesfull.
  128163. */
  128164. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  128165. /**
  128166. * Creates a JSON representation of the spherical data.
  128167. * @param texture defines the texture containing the polynomials
  128168. * @return the JSON representation of the spherical info
  128169. */
  128170. private static _CreateEnvTextureIrradiance;
  128171. /**
  128172. * Creates the ArrayBufferViews used for initializing environment texture image data.
  128173. * @param data the image data
  128174. * @param info parameters that determine what views will be created for accessing the underlying buffer
  128175. * @return the views described by info providing access to the underlying buffer
  128176. */
  128177. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  128178. /**
  128179. * Uploads the texture info contained in the env file to the GPU.
  128180. * @param texture defines the internal texture to upload to
  128181. * @param data defines the data to load
  128182. * @param info defines the texture info retrieved through the GetEnvInfo method
  128183. * @returns a promise
  128184. */
  128185. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  128186. private static _OnImageReadyAsync;
  128187. /**
  128188. * Uploads the levels of image data to the GPU.
  128189. * @param texture defines the internal texture to upload to
  128190. * @param imageData defines the array buffer views of image data [mipmap][face]
  128191. * @returns a promise
  128192. */
  128193. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  128194. /**
  128195. * Uploads spherical polynomials information to the texture.
  128196. * @param texture defines the texture we are trying to upload the information to
  128197. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  128198. */
  128199. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  128200. /** @hidden */
  128201. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  128202. }
  128203. }
  128204. declare module BABYLON {
  128205. /** @hidden */
  128206. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  128207. private _genericAttributeLocation;
  128208. private _varyingLocationCount;
  128209. private _varyingLocationMap;
  128210. private _replacements;
  128211. private _textureCount;
  128212. private _uniforms;
  128213. lineProcessor(line: string): string;
  128214. attributeProcessor(attribute: string): string;
  128215. varyingProcessor(varying: string, isFragment: boolean): string;
  128216. uniformProcessor(uniform: string): string;
  128217. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  128218. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  128219. }
  128220. }
  128221. declare module BABYLON {
  128222. /**
  128223. * Class used to inline functions in shader code
  128224. */
  128225. export class ShaderCodeInliner {
  128226. private static readonly _RegexpFindFunctionNameAndType;
  128227. private _sourceCode;
  128228. private _functionDescr;
  128229. private _numMaxIterations;
  128230. /** Gets or sets the token used to mark the functions to inline */
  128231. inlineToken: string;
  128232. /** Gets or sets the debug mode */
  128233. debug: boolean;
  128234. /** Gets the code after the inlining process */
  128235. get code(): string;
  128236. /**
  128237. * Initializes the inliner
  128238. * @param sourceCode shader code source to inline
  128239. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  128240. */
  128241. constructor(sourceCode: string, numMaxIterations?: number);
  128242. /**
  128243. * Start the processing of the shader code
  128244. */
  128245. processCode(): void;
  128246. private _collectFunctions;
  128247. private _processInlining;
  128248. private _extractBetweenMarkers;
  128249. private _skipWhitespaces;
  128250. private _removeComments;
  128251. private _replaceFunctionCallsByCode;
  128252. private _findBackward;
  128253. private _escapeRegExp;
  128254. private _replaceNames;
  128255. }
  128256. }
  128257. declare module BABYLON {
  128258. /**
  128259. * Container for accessors for natively-stored mesh data buffers.
  128260. */
  128261. class NativeDataBuffer extends DataBuffer {
  128262. /**
  128263. * Accessor value used to identify/retrieve a natively-stored index buffer.
  128264. */
  128265. nativeIndexBuffer?: any;
  128266. /**
  128267. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  128268. */
  128269. nativeVertexBuffer?: any;
  128270. }
  128271. /** @hidden */
  128272. class NativeTexture extends InternalTexture {
  128273. getInternalTexture(): InternalTexture;
  128274. getViewCount(): number;
  128275. }
  128276. /** @hidden */
  128277. export class NativeEngine extends Engine {
  128278. private readonly _native;
  128279. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  128280. private readonly INVALID_HANDLE;
  128281. getHardwareScalingLevel(): number;
  128282. constructor();
  128283. dispose(): void;
  128284. /**
  128285. * Can be used to override the current requestAnimationFrame requester.
  128286. * @hidden
  128287. */
  128288. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  128289. /**
  128290. * Override default engine behavior.
  128291. * @param color
  128292. * @param backBuffer
  128293. * @param depth
  128294. * @param stencil
  128295. */
  128296. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  128297. /**
  128298. * Gets host document
  128299. * @returns the host document object
  128300. */
  128301. getHostDocument(): Nullable<Document>;
  128302. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128303. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  128304. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  128305. recordVertexArrayObject(vertexBuffers: {
  128306. [key: string]: VertexBuffer;
  128307. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  128308. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128309. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128310. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128311. /**
  128312. * Draw a list of indexed primitives
  128313. * @param fillMode defines the primitive to use
  128314. * @param indexStart defines the starting index
  128315. * @param indexCount defines the number of index to draw
  128316. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128317. */
  128318. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128319. /**
  128320. * Draw a list of unindexed primitives
  128321. * @param fillMode defines the primitive to use
  128322. * @param verticesStart defines the index of first vertex to draw
  128323. * @param verticesCount defines the count of vertices to draw
  128324. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128325. */
  128326. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128327. createPipelineContext(): IPipelineContext;
  128328. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  128329. /** @hidden */
  128330. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  128331. /** @hidden */
  128332. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  128333. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128334. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128335. protected _setProgram(program: WebGLProgram): void;
  128336. _releaseEffect(effect: Effect): void;
  128337. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  128338. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  128339. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  128340. bindSamplers(effect: Effect): void;
  128341. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  128342. getRenderWidth(useScreen?: boolean): number;
  128343. getRenderHeight(useScreen?: boolean): number;
  128344. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  128345. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128346. /**
  128347. * Set the z offset to apply to current rendering
  128348. * @param value defines the offset to apply
  128349. */
  128350. setZOffset(value: number): void;
  128351. /**
  128352. * Gets the current value of the zOffset
  128353. * @returns the current zOffset state
  128354. */
  128355. getZOffset(): number;
  128356. /**
  128357. * Enable or disable depth buffering
  128358. * @param enable defines the state to set
  128359. */
  128360. setDepthBuffer(enable: boolean): void;
  128361. /**
  128362. * Gets a boolean indicating if depth writing is enabled
  128363. * @returns the current depth writing state
  128364. */
  128365. getDepthWrite(): boolean;
  128366. /**
  128367. * Enable or disable depth writing
  128368. * @param enable defines the state to set
  128369. */
  128370. setDepthWrite(enable: boolean): void;
  128371. /**
  128372. * Enable or disable color writing
  128373. * @param enable defines the state to set
  128374. */
  128375. setColorWrite(enable: boolean): void;
  128376. /**
  128377. * Gets a boolean indicating if color writing is enabled
  128378. * @returns the current color writing state
  128379. */
  128380. getColorWrite(): boolean;
  128381. /**
  128382. * Sets alpha constants used by some alpha blending modes
  128383. * @param r defines the red component
  128384. * @param g defines the green component
  128385. * @param b defines the blue component
  128386. * @param a defines the alpha component
  128387. */
  128388. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  128389. /**
  128390. * Sets the current alpha mode
  128391. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  128392. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128393. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128394. */
  128395. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128396. /**
  128397. * Gets the current alpha mode
  128398. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128399. * @returns the current alpha mode
  128400. */
  128401. getAlphaMode(): number;
  128402. setInt(uniform: WebGLUniformLocation, int: number): void;
  128403. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128404. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128405. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128406. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128407. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128408. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128409. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128410. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128411. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128412. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128413. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128414. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128415. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128416. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128417. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128418. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128419. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128420. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128421. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128422. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  128423. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  128424. wipeCaches(bruteForce?: boolean): void;
  128425. _createTexture(): WebGLTexture;
  128426. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  128427. /**
  128428. * Usually called from Texture.ts.
  128429. * Passed information to create a WebGLTexture
  128430. * @param url defines a value which contains one of the following:
  128431. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128432. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128433. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128434. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128435. * @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)
  128436. * @param scene needed for loading to the correct scene
  128437. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128438. * @param onLoad optional callback to be called upon successful completion
  128439. * @param onError optional callback to be called upon failure
  128440. * @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
  128441. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128442. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128443. * @param forcedExtension defines the extension to use to pick the right loader
  128444. * @param mimeType defines an optional mime type
  128445. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128446. */
  128447. 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;
  128448. /**
  128449. * Creates a cube texture
  128450. * @param rootUrl defines the url where the files to load is located
  128451. * @param scene defines the current scene
  128452. * @param files defines the list of files to load (1 per face)
  128453. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  128454. * @param onLoad defines an optional callback raised when the texture is loaded
  128455. * @param onError defines an optional callback raised if there is an issue to load the texture
  128456. * @param format defines the format of the data
  128457. * @param forcedExtension defines the extension to use to pick the right loader
  128458. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  128459. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  128460. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  128461. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  128462. * @returns the cube texture as an InternalTexture
  128463. */
  128464. 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;
  128465. private _getSamplingFilter;
  128466. private static _GetNativeTextureFormat;
  128467. createRenderTargetTexture(size: number | {
  128468. width: number;
  128469. height: number;
  128470. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  128471. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128472. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128473. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128474. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  128475. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  128476. /**
  128477. * Updates a dynamic vertex buffer.
  128478. * @param vertexBuffer the vertex buffer to update
  128479. * @param data the data used to update the vertex buffer
  128480. * @param byteOffset the byte offset of the data (optional)
  128481. * @param byteLength the byte length of the data (optional)
  128482. */
  128483. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  128484. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  128485. private _updateAnisotropicLevel;
  128486. private _getAddressMode;
  128487. /** @hidden */
  128488. _bindTexture(channel: number, texture: InternalTexture): void;
  128489. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  128490. releaseEffects(): void;
  128491. /** @hidden */
  128492. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128493. /** @hidden */
  128494. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128495. /** @hidden */
  128496. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128497. /** @hidden */
  128498. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128499. }
  128500. }
  128501. declare module BABYLON {
  128502. /**
  128503. * Gather the list of clipboard event types as constants.
  128504. */
  128505. export class ClipboardEventTypes {
  128506. /**
  128507. * The clipboard event is fired when a copy command is active (pressed).
  128508. */
  128509. static readonly COPY: number;
  128510. /**
  128511. * The clipboard event is fired when a cut command is active (pressed).
  128512. */
  128513. static readonly CUT: number;
  128514. /**
  128515. * The clipboard event is fired when a paste command is active (pressed).
  128516. */
  128517. static readonly PASTE: number;
  128518. }
  128519. /**
  128520. * This class is used to store clipboard related info for the onClipboardObservable event.
  128521. */
  128522. export class ClipboardInfo {
  128523. /**
  128524. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128525. */
  128526. type: number;
  128527. /**
  128528. * Defines the related dom event
  128529. */
  128530. event: ClipboardEvent;
  128531. /**
  128532. *Creates an instance of ClipboardInfo.
  128533. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  128534. * @param event Defines the related dom event
  128535. */
  128536. constructor(
  128537. /**
  128538. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128539. */
  128540. type: number,
  128541. /**
  128542. * Defines the related dom event
  128543. */
  128544. event: ClipboardEvent);
  128545. /**
  128546. * Get the clipboard event's type from the keycode.
  128547. * @param keyCode Defines the keyCode for the current keyboard event.
  128548. * @return {number}
  128549. */
  128550. static GetTypeFromCharacter(keyCode: number): number;
  128551. }
  128552. }
  128553. declare module BABYLON {
  128554. /**
  128555. * Google Daydream controller
  128556. */
  128557. export class DaydreamController extends WebVRController {
  128558. /**
  128559. * Base Url for the controller model.
  128560. */
  128561. static MODEL_BASE_URL: string;
  128562. /**
  128563. * File name for the controller model.
  128564. */
  128565. static MODEL_FILENAME: string;
  128566. /**
  128567. * Gamepad Id prefix used to identify Daydream Controller.
  128568. */
  128569. static readonly GAMEPAD_ID_PREFIX: string;
  128570. /**
  128571. * Creates a new DaydreamController from a gamepad
  128572. * @param vrGamepad the gamepad that the controller should be created from
  128573. */
  128574. constructor(vrGamepad: any);
  128575. /**
  128576. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128577. * @param scene scene in which to add meshes
  128578. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128579. */
  128580. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128581. /**
  128582. * Called once for each button that changed state since the last frame
  128583. * @param buttonIdx Which button index changed
  128584. * @param state New state of the button
  128585. * @param changes Which properties on the state changed since last frame
  128586. */
  128587. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128588. }
  128589. }
  128590. declare module BABYLON {
  128591. /**
  128592. * Gear VR Controller
  128593. */
  128594. export class GearVRController extends WebVRController {
  128595. /**
  128596. * Base Url for the controller model.
  128597. */
  128598. static MODEL_BASE_URL: string;
  128599. /**
  128600. * File name for the controller model.
  128601. */
  128602. static MODEL_FILENAME: string;
  128603. /**
  128604. * Gamepad Id prefix used to identify this controller.
  128605. */
  128606. static readonly GAMEPAD_ID_PREFIX: string;
  128607. private readonly _buttonIndexToObservableNameMap;
  128608. /**
  128609. * Creates a new GearVRController from a gamepad
  128610. * @param vrGamepad the gamepad that the controller should be created from
  128611. */
  128612. constructor(vrGamepad: any);
  128613. /**
  128614. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128615. * @param scene scene in which to add meshes
  128616. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128617. */
  128618. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128619. /**
  128620. * Called once for each button that changed state since the last frame
  128621. * @param buttonIdx Which button index changed
  128622. * @param state New state of the button
  128623. * @param changes Which properties on the state changed since last frame
  128624. */
  128625. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128626. }
  128627. }
  128628. declare module BABYLON {
  128629. /**
  128630. * Generic Controller
  128631. */
  128632. export class GenericController extends WebVRController {
  128633. /**
  128634. * Base Url for the controller model.
  128635. */
  128636. static readonly MODEL_BASE_URL: string;
  128637. /**
  128638. * File name for the controller model.
  128639. */
  128640. static readonly MODEL_FILENAME: string;
  128641. /**
  128642. * Creates a new GenericController from a gamepad
  128643. * @param vrGamepad the gamepad that the controller should be created from
  128644. */
  128645. constructor(vrGamepad: any);
  128646. /**
  128647. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128648. * @param scene scene in which to add meshes
  128649. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128650. */
  128651. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128652. /**
  128653. * Called once for each button that changed state since the last frame
  128654. * @param buttonIdx Which button index changed
  128655. * @param state New state of the button
  128656. * @param changes Which properties on the state changed since last frame
  128657. */
  128658. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128659. }
  128660. }
  128661. declare module BABYLON {
  128662. /**
  128663. * Oculus Touch Controller
  128664. */
  128665. export class OculusTouchController extends WebVRController {
  128666. /**
  128667. * Base Url for the controller model.
  128668. */
  128669. static MODEL_BASE_URL: string;
  128670. /**
  128671. * File name for the left controller model.
  128672. */
  128673. static MODEL_LEFT_FILENAME: string;
  128674. /**
  128675. * File name for the right controller model.
  128676. */
  128677. static MODEL_RIGHT_FILENAME: string;
  128678. /**
  128679. * Base Url for the Quest controller model.
  128680. */
  128681. static QUEST_MODEL_BASE_URL: string;
  128682. /**
  128683. * @hidden
  128684. * If the controllers are running on a device that needs the updated Quest controller models
  128685. */
  128686. static _IsQuest: boolean;
  128687. /**
  128688. * Fired when the secondary trigger on this controller is modified
  128689. */
  128690. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  128691. /**
  128692. * Fired when the thumb rest on this controller is modified
  128693. */
  128694. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  128695. /**
  128696. * Creates a new OculusTouchController from a gamepad
  128697. * @param vrGamepad the gamepad that the controller should be created from
  128698. */
  128699. constructor(vrGamepad: any);
  128700. /**
  128701. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128702. * @param scene scene in which to add meshes
  128703. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128704. */
  128705. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128706. /**
  128707. * Fired when the A button on this controller is modified
  128708. */
  128709. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128710. /**
  128711. * Fired when the B button on this controller is modified
  128712. */
  128713. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128714. /**
  128715. * Fired when the X button on this controller is modified
  128716. */
  128717. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128718. /**
  128719. * Fired when the Y button on this controller is modified
  128720. */
  128721. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128722. /**
  128723. * Called once for each button that changed state since the last frame
  128724. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  128725. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  128726. * 2) secondary trigger (same)
  128727. * 3) A (right) X (left), touch, pressed = value
  128728. * 4) B / Y
  128729. * 5) thumb rest
  128730. * @param buttonIdx Which button index changed
  128731. * @param state New state of the button
  128732. * @param changes Which properties on the state changed since last frame
  128733. */
  128734. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128735. }
  128736. }
  128737. declare module BABYLON {
  128738. /**
  128739. * Vive Controller
  128740. */
  128741. export class ViveController extends WebVRController {
  128742. /**
  128743. * Base Url for the controller model.
  128744. */
  128745. static MODEL_BASE_URL: string;
  128746. /**
  128747. * File name for the controller model.
  128748. */
  128749. static MODEL_FILENAME: string;
  128750. /**
  128751. * Creates a new ViveController from a gamepad
  128752. * @param vrGamepad the gamepad that the controller should be created from
  128753. */
  128754. constructor(vrGamepad: any);
  128755. /**
  128756. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128757. * @param scene scene in which to add meshes
  128758. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128759. */
  128760. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128761. /**
  128762. * Fired when the left button on this controller is modified
  128763. */
  128764. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128765. /**
  128766. * Fired when the right button on this controller is modified
  128767. */
  128768. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128769. /**
  128770. * Fired when the menu button on this controller is modified
  128771. */
  128772. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128773. /**
  128774. * Called once for each button that changed state since the last frame
  128775. * Vive mapping:
  128776. * 0: touchpad
  128777. * 1: trigger
  128778. * 2: left AND right buttons
  128779. * 3: menu button
  128780. * @param buttonIdx Which button index changed
  128781. * @param state New state of the button
  128782. * @param changes Which properties on the state changed since last frame
  128783. */
  128784. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128785. }
  128786. }
  128787. declare module BABYLON {
  128788. /**
  128789. * Defines the WindowsMotionController object that the state of the windows motion controller
  128790. */
  128791. export class WindowsMotionController extends WebVRController {
  128792. /**
  128793. * The base url used to load the left and right controller models
  128794. */
  128795. static MODEL_BASE_URL: string;
  128796. /**
  128797. * The name of the left controller model file
  128798. */
  128799. static MODEL_LEFT_FILENAME: string;
  128800. /**
  128801. * The name of the right controller model file
  128802. */
  128803. static MODEL_RIGHT_FILENAME: string;
  128804. /**
  128805. * The controller name prefix for this controller type
  128806. */
  128807. static readonly GAMEPAD_ID_PREFIX: string;
  128808. /**
  128809. * The controller id pattern for this controller type
  128810. */
  128811. private static readonly GAMEPAD_ID_PATTERN;
  128812. private _loadedMeshInfo;
  128813. protected readonly _mapping: {
  128814. buttons: string[];
  128815. buttonMeshNames: {
  128816. trigger: string;
  128817. menu: string;
  128818. grip: string;
  128819. thumbstick: string;
  128820. trackpad: string;
  128821. };
  128822. buttonObservableNames: {
  128823. trigger: string;
  128824. menu: string;
  128825. grip: string;
  128826. thumbstick: string;
  128827. trackpad: string;
  128828. };
  128829. axisMeshNames: string[];
  128830. pointingPoseMeshName: string;
  128831. };
  128832. /**
  128833. * Fired when the trackpad on this controller is clicked
  128834. */
  128835. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  128836. /**
  128837. * Fired when the trackpad on this controller is modified
  128838. */
  128839. onTrackpadValuesChangedObservable: Observable<StickValues>;
  128840. /**
  128841. * The current x and y values of this controller's trackpad
  128842. */
  128843. trackpad: StickValues;
  128844. /**
  128845. * Creates a new WindowsMotionController from a gamepad
  128846. * @param vrGamepad the gamepad that the controller should be created from
  128847. */
  128848. constructor(vrGamepad: any);
  128849. /**
  128850. * Fired when the trigger on this controller is modified
  128851. */
  128852. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128853. /**
  128854. * Fired when the menu button on this controller is modified
  128855. */
  128856. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128857. /**
  128858. * Fired when the grip button on this controller is modified
  128859. */
  128860. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128861. /**
  128862. * Fired when the thumbstick button on this controller is modified
  128863. */
  128864. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128865. /**
  128866. * Fired when the touchpad button on this controller is modified
  128867. */
  128868. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128869. /**
  128870. * Fired when the touchpad values on this controller are modified
  128871. */
  128872. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  128873. protected _updateTrackpad(): void;
  128874. /**
  128875. * Called once per frame by the engine.
  128876. */
  128877. update(): void;
  128878. /**
  128879. * Called once for each button that changed state since the last frame
  128880. * @param buttonIdx Which button index changed
  128881. * @param state New state of the button
  128882. * @param changes Which properties on the state changed since last frame
  128883. */
  128884. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128885. /**
  128886. * Moves the buttons on the controller mesh based on their current state
  128887. * @param buttonName the name of the button to move
  128888. * @param buttonValue the value of the button which determines the buttons new position
  128889. */
  128890. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  128891. /**
  128892. * Moves the axis on the controller mesh based on its current state
  128893. * @param axis the index of the axis
  128894. * @param axisValue the value of the axis which determines the meshes new position
  128895. * @hidden
  128896. */
  128897. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  128898. /**
  128899. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128900. * @param scene scene in which to add meshes
  128901. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128902. */
  128903. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  128904. /**
  128905. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  128906. * can be transformed by button presses and axes values, based on this._mapping.
  128907. *
  128908. * @param scene scene in which the meshes exist
  128909. * @param meshes list of meshes that make up the controller model to process
  128910. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  128911. */
  128912. private processModel;
  128913. private createMeshInfo;
  128914. /**
  128915. * Gets the ray of the controller in the direction the controller is pointing
  128916. * @param length the length the resulting ray should be
  128917. * @returns a ray in the direction the controller is pointing
  128918. */
  128919. getForwardRay(length?: number): Ray;
  128920. /**
  128921. * Disposes of the controller
  128922. */
  128923. dispose(): void;
  128924. }
  128925. /**
  128926. * This class represents a new windows motion controller in XR.
  128927. */
  128928. export class XRWindowsMotionController extends WindowsMotionController {
  128929. /**
  128930. * Changing the original WIndowsMotionController mapping to fir the new mapping
  128931. */
  128932. protected readonly _mapping: {
  128933. buttons: string[];
  128934. buttonMeshNames: {
  128935. trigger: string;
  128936. menu: string;
  128937. grip: string;
  128938. thumbstick: string;
  128939. trackpad: string;
  128940. };
  128941. buttonObservableNames: {
  128942. trigger: string;
  128943. menu: string;
  128944. grip: string;
  128945. thumbstick: string;
  128946. trackpad: string;
  128947. };
  128948. axisMeshNames: string[];
  128949. pointingPoseMeshName: string;
  128950. };
  128951. /**
  128952. * Construct a new XR-Based windows motion controller
  128953. *
  128954. * @param gamepadInfo the gamepad object from the browser
  128955. */
  128956. constructor(gamepadInfo: any);
  128957. /**
  128958. * holds the thumbstick values (X,Y)
  128959. */
  128960. thumbstickValues: StickValues;
  128961. /**
  128962. * Fired when the thumbstick on this controller is clicked
  128963. */
  128964. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  128965. /**
  128966. * Fired when the thumbstick on this controller is modified
  128967. */
  128968. onThumbstickValuesChangedObservable: Observable<StickValues>;
  128969. /**
  128970. * Fired when the touchpad button on this controller is modified
  128971. */
  128972. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  128973. /**
  128974. * Fired when the touchpad values on this controller are modified
  128975. */
  128976. onTrackpadValuesChangedObservable: Observable<StickValues>;
  128977. /**
  128978. * Fired when the thumbstick button on this controller is modified
  128979. * here to prevent breaking changes
  128980. */
  128981. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128982. /**
  128983. * updating the thumbstick(!) and not the trackpad.
  128984. * This is named this way due to the difference between WebVR and XR and to avoid
  128985. * changing the parent class.
  128986. */
  128987. protected _updateTrackpad(): void;
  128988. /**
  128989. * Disposes the class with joy
  128990. */
  128991. dispose(): void;
  128992. }
  128993. }
  128994. declare module BABYLON {
  128995. /**
  128996. * Class containing static functions to help procedurally build meshes
  128997. */
  128998. export class PolyhedronBuilder {
  128999. /**
  129000. * Creates a polyhedron mesh
  129001. * * 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
  129002. * * The parameter `size` (positive float, default 1) sets the polygon size
  129003. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  129004. * * 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`
  129005. * * 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
  129006. * * 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)`)
  129007. * * 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
  129008. * * 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
  129009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129012. * @param name defines the name of the mesh
  129013. * @param options defines the options used to create the mesh
  129014. * @param scene defines the hosting scene
  129015. * @returns the polyhedron mesh
  129016. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  129017. */
  129018. static CreatePolyhedron(name: string, options: {
  129019. type?: number;
  129020. size?: number;
  129021. sizeX?: number;
  129022. sizeY?: number;
  129023. sizeZ?: number;
  129024. custom?: any;
  129025. faceUV?: Vector4[];
  129026. faceColors?: Color4[];
  129027. flat?: boolean;
  129028. updatable?: boolean;
  129029. sideOrientation?: number;
  129030. frontUVs?: Vector4;
  129031. backUVs?: Vector4;
  129032. }, scene?: Nullable<Scene>): Mesh;
  129033. }
  129034. }
  129035. declare module BABYLON {
  129036. /**
  129037. * Gizmo that enables scaling a mesh along 3 axis
  129038. */
  129039. export class ScaleGizmo extends Gizmo {
  129040. /**
  129041. * Internal gizmo used for interactions on the x axis
  129042. */
  129043. xGizmo: AxisScaleGizmo;
  129044. /**
  129045. * Internal gizmo used for interactions on the y axis
  129046. */
  129047. yGizmo: AxisScaleGizmo;
  129048. /**
  129049. * Internal gizmo used for interactions on the z axis
  129050. */
  129051. zGizmo: AxisScaleGizmo;
  129052. /**
  129053. * Internal gizmo used to scale all axis equally
  129054. */
  129055. uniformScaleGizmo: AxisScaleGizmo;
  129056. private _meshAttached;
  129057. private _updateGizmoRotationToMatchAttachedMesh;
  129058. private _snapDistance;
  129059. private _scaleRatio;
  129060. private _uniformScalingMesh;
  129061. private _octahedron;
  129062. private _sensitivity;
  129063. /** Fires an event when any of it's sub gizmos are dragged */
  129064. onDragStartObservable: Observable<unknown>;
  129065. /** Fires an event when any of it's sub gizmos are released from dragging */
  129066. onDragEndObservable: Observable<unknown>;
  129067. get attachedMesh(): Nullable<AbstractMesh>;
  129068. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129069. /**
  129070. * Creates a ScaleGizmo
  129071. * @param gizmoLayer The utility layer the gizmo will be added to
  129072. */
  129073. constructor(gizmoLayer?: UtilityLayerRenderer);
  129074. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129075. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129076. /**
  129077. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129078. */
  129079. set snapDistance(value: number);
  129080. get snapDistance(): number;
  129081. /**
  129082. * Ratio for the scale of the gizmo (Default: 1)
  129083. */
  129084. set scaleRatio(value: number);
  129085. get scaleRatio(): number;
  129086. /**
  129087. * Sensitivity factor for dragging (Default: 1)
  129088. */
  129089. set sensitivity(value: number);
  129090. get sensitivity(): number;
  129091. /**
  129092. * Disposes of the gizmo
  129093. */
  129094. dispose(): void;
  129095. }
  129096. }
  129097. declare module BABYLON {
  129098. /**
  129099. * Single axis scale gizmo
  129100. */
  129101. export class AxisScaleGizmo extends Gizmo {
  129102. /**
  129103. * Drag behavior responsible for the gizmos dragging interactions
  129104. */
  129105. dragBehavior: PointerDragBehavior;
  129106. private _pointerObserver;
  129107. /**
  129108. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129109. */
  129110. snapDistance: number;
  129111. /**
  129112. * Event that fires each time the gizmo snaps to a new location.
  129113. * * snapDistance is the the change in distance
  129114. */
  129115. onSnapObservable: Observable<{
  129116. snapDistance: number;
  129117. }>;
  129118. /**
  129119. * If the scaling operation should be done on all axis (default: false)
  129120. */
  129121. uniformScaling: boolean;
  129122. /**
  129123. * Custom sensitivity value for the drag strength
  129124. */
  129125. sensitivity: number;
  129126. private _isEnabled;
  129127. private _parent;
  129128. private _arrow;
  129129. private _coloredMaterial;
  129130. private _hoverMaterial;
  129131. /**
  129132. * Creates an AxisScaleGizmo
  129133. * @param gizmoLayer The utility layer the gizmo will be added to
  129134. * @param dragAxis The axis which the gizmo will be able to scale on
  129135. * @param color The color of the gizmo
  129136. */
  129137. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  129138. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129139. /**
  129140. * If the gizmo is enabled
  129141. */
  129142. set isEnabled(value: boolean);
  129143. get isEnabled(): boolean;
  129144. /**
  129145. * Disposes of the gizmo
  129146. */
  129147. dispose(): void;
  129148. /**
  129149. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  129150. * @param mesh The mesh to replace the default mesh of the gizmo
  129151. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  129152. */
  129153. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  129154. }
  129155. }
  129156. declare module BABYLON {
  129157. /**
  129158. * Bounding box gizmo
  129159. */
  129160. export class BoundingBoxGizmo extends Gizmo {
  129161. private _lineBoundingBox;
  129162. private _rotateSpheresParent;
  129163. private _scaleBoxesParent;
  129164. private _boundingDimensions;
  129165. private _renderObserver;
  129166. private _pointerObserver;
  129167. private _scaleDragSpeed;
  129168. private _tmpQuaternion;
  129169. private _tmpVector;
  129170. private _tmpRotationMatrix;
  129171. /**
  129172. * 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)
  129173. */
  129174. ignoreChildren: boolean;
  129175. /**
  129176. * 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)
  129177. */
  129178. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  129179. /**
  129180. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  129181. */
  129182. rotationSphereSize: number;
  129183. /**
  129184. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  129185. */
  129186. scaleBoxSize: number;
  129187. /**
  129188. * 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)
  129189. */
  129190. fixedDragMeshScreenSize: boolean;
  129191. /**
  129192. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  129193. */
  129194. fixedDragMeshScreenSizeDistanceFactor: number;
  129195. /**
  129196. * Fired when a rotation sphere or scale box is dragged
  129197. */
  129198. onDragStartObservable: Observable<{}>;
  129199. /**
  129200. * Fired when a scale box is dragged
  129201. */
  129202. onScaleBoxDragObservable: Observable<{}>;
  129203. /**
  129204. * Fired when a scale box drag is ended
  129205. */
  129206. onScaleBoxDragEndObservable: Observable<{}>;
  129207. /**
  129208. * Fired when a rotation sphere is dragged
  129209. */
  129210. onRotationSphereDragObservable: Observable<{}>;
  129211. /**
  129212. * Fired when a rotation sphere drag is ended
  129213. */
  129214. onRotationSphereDragEndObservable: Observable<{}>;
  129215. /**
  129216. * 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)
  129217. */
  129218. scalePivot: Nullable<Vector3>;
  129219. /**
  129220. * Mesh used as a pivot to rotate the attached mesh
  129221. */
  129222. private _anchorMesh;
  129223. private _existingMeshScale;
  129224. private _dragMesh;
  129225. private pointerDragBehavior;
  129226. private coloredMaterial;
  129227. private hoverColoredMaterial;
  129228. /**
  129229. * Sets the color of the bounding box gizmo
  129230. * @param color the color to set
  129231. */
  129232. setColor(color: Color3): void;
  129233. /**
  129234. * Creates an BoundingBoxGizmo
  129235. * @param gizmoLayer The utility layer the gizmo will be added to
  129236. * @param color The color of the gizmo
  129237. */
  129238. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  129239. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129240. private _selectNode;
  129241. /**
  129242. * Updates the bounding box information for the Gizmo
  129243. */
  129244. updateBoundingBox(): void;
  129245. private _updateRotationSpheres;
  129246. private _updateScaleBoxes;
  129247. /**
  129248. * Enables rotation on the specified axis and disables rotation on the others
  129249. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  129250. */
  129251. setEnabledRotationAxis(axis: string): void;
  129252. /**
  129253. * Enables/disables scaling
  129254. * @param enable if scaling should be enabled
  129255. * @param homogeneousScaling defines if scaling should only be homogeneous
  129256. */
  129257. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  129258. private _updateDummy;
  129259. /**
  129260. * Enables a pointer drag behavior on the bounding box of the gizmo
  129261. */
  129262. enableDragBehavior(): void;
  129263. /**
  129264. * Disposes of the gizmo
  129265. */
  129266. dispose(): void;
  129267. /**
  129268. * 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)
  129269. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  129270. * @returns the bounding box mesh with the passed in mesh as a child
  129271. */
  129272. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  129273. /**
  129274. * CustomMeshes are not supported by this gizmo
  129275. * @param mesh The mesh to replace the default mesh of the gizmo
  129276. */
  129277. setCustomMesh(mesh: Mesh): void;
  129278. }
  129279. }
  129280. declare module BABYLON {
  129281. /**
  129282. * Single plane rotation gizmo
  129283. */
  129284. export class PlaneRotationGizmo extends Gizmo {
  129285. /**
  129286. * Drag behavior responsible for the gizmos dragging interactions
  129287. */
  129288. dragBehavior: PointerDragBehavior;
  129289. private _pointerObserver;
  129290. /**
  129291. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  129292. */
  129293. snapDistance: number;
  129294. /**
  129295. * Event that fires each time the gizmo snaps to a new location.
  129296. * * snapDistance is the the change in distance
  129297. */
  129298. onSnapObservable: Observable<{
  129299. snapDistance: number;
  129300. }>;
  129301. private _isEnabled;
  129302. private _parent;
  129303. /**
  129304. * Creates a PlaneRotationGizmo
  129305. * @param gizmoLayer The utility layer the gizmo will be added to
  129306. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  129307. * @param color The color of the gizmo
  129308. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129309. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129310. */
  129311. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  129312. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129313. /**
  129314. * If the gizmo is enabled
  129315. */
  129316. set isEnabled(value: boolean);
  129317. get isEnabled(): boolean;
  129318. /**
  129319. * Disposes of the gizmo
  129320. */
  129321. dispose(): void;
  129322. }
  129323. }
  129324. declare module BABYLON {
  129325. /**
  129326. * Gizmo that enables rotating a mesh along 3 axis
  129327. */
  129328. export class RotationGizmo extends Gizmo {
  129329. /**
  129330. * Internal gizmo used for interactions on the x axis
  129331. */
  129332. xGizmo: PlaneRotationGizmo;
  129333. /**
  129334. * Internal gizmo used for interactions on the y axis
  129335. */
  129336. yGizmo: PlaneRotationGizmo;
  129337. /**
  129338. * Internal gizmo used for interactions on the z axis
  129339. */
  129340. zGizmo: PlaneRotationGizmo;
  129341. /** Fires an event when any of it's sub gizmos are dragged */
  129342. onDragStartObservable: Observable<unknown>;
  129343. /** Fires an event when any of it's sub gizmos are released from dragging */
  129344. onDragEndObservable: Observable<unknown>;
  129345. private _meshAttached;
  129346. get attachedMesh(): Nullable<AbstractMesh>;
  129347. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129348. /**
  129349. * Creates a RotationGizmo
  129350. * @param gizmoLayer The utility layer the gizmo will be added to
  129351. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129352. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129353. */
  129354. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  129355. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129356. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129357. /**
  129358. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129359. */
  129360. set snapDistance(value: number);
  129361. get snapDistance(): number;
  129362. /**
  129363. * Ratio for the scale of the gizmo (Default: 1)
  129364. */
  129365. set scaleRatio(value: number);
  129366. get scaleRatio(): number;
  129367. /**
  129368. * Disposes of the gizmo
  129369. */
  129370. dispose(): void;
  129371. /**
  129372. * CustomMeshes are not supported by this gizmo
  129373. * @param mesh The mesh to replace the default mesh of the gizmo
  129374. */
  129375. setCustomMesh(mesh: Mesh): void;
  129376. }
  129377. }
  129378. declare module BABYLON {
  129379. /**
  129380. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  129381. */
  129382. export class GizmoManager implements IDisposable {
  129383. private scene;
  129384. /**
  129385. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  129386. */
  129387. gizmos: {
  129388. positionGizmo: Nullable<PositionGizmo>;
  129389. rotationGizmo: Nullable<RotationGizmo>;
  129390. scaleGizmo: Nullable<ScaleGizmo>;
  129391. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  129392. };
  129393. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  129394. clearGizmoOnEmptyPointerEvent: boolean;
  129395. /** Fires an event when the manager is attached to a mesh */
  129396. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  129397. private _gizmosEnabled;
  129398. private _pointerObserver;
  129399. private _attachedMesh;
  129400. private _boundingBoxColor;
  129401. private _defaultUtilityLayer;
  129402. private _defaultKeepDepthUtilityLayer;
  129403. /**
  129404. * When bounding box gizmo is enabled, this can be used to track drag/end events
  129405. */
  129406. boundingBoxDragBehavior: SixDofDragBehavior;
  129407. /**
  129408. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  129409. */
  129410. attachableMeshes: Nullable<Array<AbstractMesh>>;
  129411. /**
  129412. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  129413. */
  129414. usePointerToAttachGizmos: boolean;
  129415. /**
  129416. * Utility layer that the bounding box gizmo belongs to
  129417. */
  129418. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  129419. /**
  129420. * Utility layer that all gizmos besides bounding box belong to
  129421. */
  129422. get utilityLayer(): UtilityLayerRenderer;
  129423. /**
  129424. * Instatiates a gizmo manager
  129425. * @param scene the scene to overlay the gizmos on top of
  129426. */
  129427. constructor(scene: Scene);
  129428. /**
  129429. * Attaches a set of gizmos to the specified mesh
  129430. * @param mesh The mesh the gizmo's should be attached to
  129431. */
  129432. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  129433. /**
  129434. * If the position gizmo is enabled
  129435. */
  129436. set positionGizmoEnabled(value: boolean);
  129437. get positionGizmoEnabled(): boolean;
  129438. /**
  129439. * If the rotation gizmo is enabled
  129440. */
  129441. set rotationGizmoEnabled(value: boolean);
  129442. get rotationGizmoEnabled(): boolean;
  129443. /**
  129444. * If the scale gizmo is enabled
  129445. */
  129446. set scaleGizmoEnabled(value: boolean);
  129447. get scaleGizmoEnabled(): boolean;
  129448. /**
  129449. * If the boundingBox gizmo is enabled
  129450. */
  129451. set boundingBoxGizmoEnabled(value: boolean);
  129452. get boundingBoxGizmoEnabled(): boolean;
  129453. /**
  129454. * Disposes of the gizmo manager
  129455. */
  129456. dispose(): void;
  129457. }
  129458. }
  129459. declare module BABYLON {
  129460. /**
  129461. * A directional light is defined by a direction (what a surprise!).
  129462. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  129463. * 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.
  129464. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129465. */
  129466. export class DirectionalLight extends ShadowLight {
  129467. private _shadowFrustumSize;
  129468. /**
  129469. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  129470. */
  129471. get shadowFrustumSize(): number;
  129472. /**
  129473. * Specifies a fix frustum size for the shadow generation.
  129474. */
  129475. set shadowFrustumSize(value: number);
  129476. private _shadowOrthoScale;
  129477. /**
  129478. * Gets the shadow projection scale against the optimal computed one.
  129479. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129480. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129481. */
  129482. get shadowOrthoScale(): number;
  129483. /**
  129484. * Sets the shadow projection scale against the optimal computed one.
  129485. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129486. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129487. */
  129488. set shadowOrthoScale(value: number);
  129489. /**
  129490. * Automatically compute the projection matrix to best fit (including all the casters)
  129491. * on each frame.
  129492. */
  129493. autoUpdateExtends: boolean;
  129494. /**
  129495. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  129496. * on each frame. autoUpdateExtends must be set to true for this to work
  129497. */
  129498. autoCalcShadowZBounds: boolean;
  129499. private _orthoLeft;
  129500. private _orthoRight;
  129501. private _orthoTop;
  129502. private _orthoBottom;
  129503. /**
  129504. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  129505. * The directional light is emitted from everywhere in the given direction.
  129506. * It can cast shadows.
  129507. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129508. * @param name The friendly name of the light
  129509. * @param direction The direction of the light
  129510. * @param scene The scene the light belongs to
  129511. */
  129512. constructor(name: string, direction: Vector3, scene: Scene);
  129513. /**
  129514. * Returns the string "DirectionalLight".
  129515. * @return The class name
  129516. */
  129517. getClassName(): string;
  129518. /**
  129519. * Returns the integer 1.
  129520. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129521. */
  129522. getTypeID(): number;
  129523. /**
  129524. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  129525. * Returns the DirectionalLight Shadow projection matrix.
  129526. */
  129527. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129528. /**
  129529. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  129530. * Returns the DirectionalLight Shadow projection matrix.
  129531. */
  129532. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  129533. /**
  129534. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  129535. * Returns the DirectionalLight Shadow projection matrix.
  129536. */
  129537. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129538. protected _buildUniformLayout(): void;
  129539. /**
  129540. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  129541. * @param effect The effect to update
  129542. * @param lightIndex The index of the light in the effect to update
  129543. * @returns The directional light
  129544. */
  129545. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  129546. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  129547. /**
  129548. * Gets the minZ used for shadow according to both the scene and the light.
  129549. *
  129550. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129551. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129552. * @param activeCamera The camera we are returning the min for
  129553. * @returns the depth min z
  129554. */
  129555. getDepthMinZ(activeCamera: Camera): number;
  129556. /**
  129557. * Gets the maxZ used for shadow according to both the scene and the light.
  129558. *
  129559. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129560. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129561. * @param activeCamera The camera we are returning the max for
  129562. * @returns the depth max z
  129563. */
  129564. getDepthMaxZ(activeCamera: Camera): number;
  129565. /**
  129566. * Prepares the list of defines specific to the light type.
  129567. * @param defines the list of defines
  129568. * @param lightIndex defines the index of the light for the effect
  129569. */
  129570. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129571. }
  129572. }
  129573. declare module BABYLON {
  129574. /**
  129575. * Class containing static functions to help procedurally build meshes
  129576. */
  129577. export class HemisphereBuilder {
  129578. /**
  129579. * Creates a hemisphere mesh
  129580. * @param name defines the name of the mesh
  129581. * @param options defines the options used to create the mesh
  129582. * @param scene defines the hosting scene
  129583. * @returns the hemisphere mesh
  129584. */
  129585. static CreateHemisphere(name: string, options: {
  129586. segments?: number;
  129587. diameter?: number;
  129588. sideOrientation?: number;
  129589. }, scene: any): Mesh;
  129590. }
  129591. }
  129592. declare module BABYLON {
  129593. /**
  129594. * A spot light is defined by a position, a direction, an angle, and an exponent.
  129595. * These values define a cone of light starting from the position, emitting toward the direction.
  129596. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  129597. * and the exponent defines the speed of the decay of the light with distance (reach).
  129598. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129599. */
  129600. export class SpotLight extends ShadowLight {
  129601. private _angle;
  129602. private _innerAngle;
  129603. private _cosHalfAngle;
  129604. private _lightAngleScale;
  129605. private _lightAngleOffset;
  129606. /**
  129607. * Gets the cone angle of the spot light in Radians.
  129608. */
  129609. get angle(): number;
  129610. /**
  129611. * Sets the cone angle of the spot light in Radians.
  129612. */
  129613. set angle(value: number);
  129614. /**
  129615. * Only used in gltf falloff mode, this defines the angle where
  129616. * the directional falloff will start before cutting at angle which could be seen
  129617. * as outer angle.
  129618. */
  129619. get innerAngle(): number;
  129620. /**
  129621. * Only used in gltf falloff mode, this defines the angle where
  129622. * the directional falloff will start before cutting at angle which could be seen
  129623. * as outer angle.
  129624. */
  129625. set innerAngle(value: number);
  129626. private _shadowAngleScale;
  129627. /**
  129628. * Allows scaling the angle of the light for shadow generation only.
  129629. */
  129630. get shadowAngleScale(): number;
  129631. /**
  129632. * Allows scaling the angle of the light for shadow generation only.
  129633. */
  129634. set shadowAngleScale(value: number);
  129635. /**
  129636. * The light decay speed with the distance from the emission spot.
  129637. */
  129638. exponent: number;
  129639. private _projectionTextureMatrix;
  129640. /**
  129641. * Allows reading the projecton texture
  129642. */
  129643. get projectionTextureMatrix(): Matrix;
  129644. protected _projectionTextureLightNear: number;
  129645. /**
  129646. * Gets the near clip of the Spotlight for texture projection.
  129647. */
  129648. get projectionTextureLightNear(): number;
  129649. /**
  129650. * Sets the near clip of the Spotlight for texture projection.
  129651. */
  129652. set projectionTextureLightNear(value: number);
  129653. protected _projectionTextureLightFar: number;
  129654. /**
  129655. * Gets the far clip of the Spotlight for texture projection.
  129656. */
  129657. get projectionTextureLightFar(): number;
  129658. /**
  129659. * Sets the far clip of the Spotlight for texture projection.
  129660. */
  129661. set projectionTextureLightFar(value: number);
  129662. protected _projectionTextureUpDirection: Vector3;
  129663. /**
  129664. * Gets the Up vector of the Spotlight for texture projection.
  129665. */
  129666. get projectionTextureUpDirection(): Vector3;
  129667. /**
  129668. * Sets the Up vector of the Spotlight for texture projection.
  129669. */
  129670. set projectionTextureUpDirection(value: Vector3);
  129671. private _projectionTexture;
  129672. /**
  129673. * Gets the projection texture of the light.
  129674. */
  129675. get projectionTexture(): Nullable<BaseTexture>;
  129676. /**
  129677. * Sets the projection texture of the light.
  129678. */
  129679. set projectionTexture(value: Nullable<BaseTexture>);
  129680. private _projectionTextureViewLightDirty;
  129681. private _projectionTextureProjectionLightDirty;
  129682. private _projectionTextureDirty;
  129683. private _projectionTextureViewTargetVector;
  129684. private _projectionTextureViewLightMatrix;
  129685. private _projectionTextureProjectionLightMatrix;
  129686. private _projectionTextureScalingMatrix;
  129687. /**
  129688. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  129689. * It can cast shadows.
  129690. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129691. * @param name The light friendly name
  129692. * @param position The position of the spot light in the scene
  129693. * @param direction The direction of the light in the scene
  129694. * @param angle The cone angle of the light in Radians
  129695. * @param exponent The light decay speed with the distance from the emission spot
  129696. * @param scene The scene the lights belongs to
  129697. */
  129698. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  129699. /**
  129700. * Returns the string "SpotLight".
  129701. * @returns the class name
  129702. */
  129703. getClassName(): string;
  129704. /**
  129705. * Returns the integer 2.
  129706. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129707. */
  129708. getTypeID(): number;
  129709. /**
  129710. * Overrides the direction setter to recompute the projection texture view light Matrix.
  129711. */
  129712. protected _setDirection(value: Vector3): void;
  129713. /**
  129714. * Overrides the position setter to recompute the projection texture view light Matrix.
  129715. */
  129716. protected _setPosition(value: Vector3): void;
  129717. /**
  129718. * 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.
  129719. * Returns the SpotLight.
  129720. */
  129721. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129722. protected _computeProjectionTextureViewLightMatrix(): void;
  129723. protected _computeProjectionTextureProjectionLightMatrix(): void;
  129724. /**
  129725. * Main function for light texture projection matrix computing.
  129726. */
  129727. protected _computeProjectionTextureMatrix(): void;
  129728. protected _buildUniformLayout(): void;
  129729. private _computeAngleValues;
  129730. /**
  129731. * Sets the passed Effect "effect" with the Light textures.
  129732. * @param effect The effect to update
  129733. * @param lightIndex The index of the light in the effect to update
  129734. * @returns The light
  129735. */
  129736. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  129737. /**
  129738. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  129739. * @param effect The effect to update
  129740. * @param lightIndex The index of the light in the effect to update
  129741. * @returns The spot light
  129742. */
  129743. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  129744. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129745. /**
  129746. * Disposes the light and the associated resources.
  129747. */
  129748. dispose(): void;
  129749. /**
  129750. * Prepares the list of defines specific to the light type.
  129751. * @param defines the list of defines
  129752. * @param lightIndex defines the index of the light for the effect
  129753. */
  129754. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129755. }
  129756. }
  129757. declare module BABYLON {
  129758. /**
  129759. * Gizmo that enables viewing a light
  129760. */
  129761. export class LightGizmo extends Gizmo {
  129762. private _lightMesh;
  129763. private _material;
  129764. private _cachedPosition;
  129765. private _cachedForward;
  129766. private _attachedMeshParent;
  129767. /**
  129768. * Creates a LightGizmo
  129769. * @param gizmoLayer The utility layer the gizmo will be added to
  129770. */
  129771. constructor(gizmoLayer?: UtilityLayerRenderer);
  129772. private _light;
  129773. /**
  129774. * The light that the gizmo is attached to
  129775. */
  129776. set light(light: Nullable<Light>);
  129777. get light(): Nullable<Light>;
  129778. /**
  129779. * Gets the material used to render the light gizmo
  129780. */
  129781. get material(): StandardMaterial;
  129782. /**
  129783. * @hidden
  129784. * Updates the gizmo to match the attached mesh's position/rotation
  129785. */
  129786. protected _update(): void;
  129787. private static _Scale;
  129788. /**
  129789. * Creates the lines for a light mesh
  129790. */
  129791. private static _CreateLightLines;
  129792. /**
  129793. * Disposes of the light gizmo
  129794. */
  129795. dispose(): void;
  129796. private static _CreateHemisphericLightMesh;
  129797. private static _CreatePointLightMesh;
  129798. private static _CreateSpotLightMesh;
  129799. private static _CreateDirectionalLightMesh;
  129800. }
  129801. }
  129802. declare module BABYLON {
  129803. /** @hidden */
  129804. export var backgroundFragmentDeclaration: {
  129805. name: string;
  129806. shader: string;
  129807. };
  129808. }
  129809. declare module BABYLON {
  129810. /** @hidden */
  129811. export var backgroundUboDeclaration: {
  129812. name: string;
  129813. shader: string;
  129814. };
  129815. }
  129816. declare module BABYLON {
  129817. /** @hidden */
  129818. export var backgroundPixelShader: {
  129819. name: string;
  129820. shader: string;
  129821. };
  129822. }
  129823. declare module BABYLON {
  129824. /** @hidden */
  129825. export var backgroundVertexDeclaration: {
  129826. name: string;
  129827. shader: string;
  129828. };
  129829. }
  129830. declare module BABYLON {
  129831. /** @hidden */
  129832. export var backgroundVertexShader: {
  129833. name: string;
  129834. shader: string;
  129835. };
  129836. }
  129837. declare module BABYLON {
  129838. /**
  129839. * Background material used to create an efficient environement around your scene.
  129840. */
  129841. export class BackgroundMaterial extends PushMaterial {
  129842. /**
  129843. * Standard reflectance value at parallel view angle.
  129844. */
  129845. static StandardReflectance0: number;
  129846. /**
  129847. * Standard reflectance value at grazing angle.
  129848. */
  129849. static StandardReflectance90: number;
  129850. protected _primaryColor: Color3;
  129851. /**
  129852. * Key light Color (multiply against the environement texture)
  129853. */
  129854. primaryColor: Color3;
  129855. protected __perceptualColor: Nullable<Color3>;
  129856. /**
  129857. * Experimental Internal Use Only.
  129858. *
  129859. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  129860. * This acts as a helper to set the primary color to a more "human friendly" value.
  129861. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  129862. * output color as close as possible from the chosen value.
  129863. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  129864. * part of lighting setup.)
  129865. */
  129866. get _perceptualColor(): Nullable<Color3>;
  129867. set _perceptualColor(value: Nullable<Color3>);
  129868. protected _primaryColorShadowLevel: float;
  129869. /**
  129870. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  129871. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  129872. */
  129873. get primaryColorShadowLevel(): float;
  129874. set primaryColorShadowLevel(value: float);
  129875. protected _primaryColorHighlightLevel: float;
  129876. /**
  129877. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  129878. * The primary color is used at the level chosen to define what the white area would look.
  129879. */
  129880. get primaryColorHighlightLevel(): float;
  129881. set primaryColorHighlightLevel(value: float);
  129882. protected _reflectionTexture: Nullable<BaseTexture>;
  129883. /**
  129884. * Reflection Texture used in the material.
  129885. * Should be author in a specific way for the best result (refer to the documentation).
  129886. */
  129887. reflectionTexture: Nullable<BaseTexture>;
  129888. protected _reflectionBlur: float;
  129889. /**
  129890. * Reflection Texture level of blur.
  129891. *
  129892. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  129893. * texture twice.
  129894. */
  129895. reflectionBlur: float;
  129896. protected _diffuseTexture: Nullable<BaseTexture>;
  129897. /**
  129898. * Diffuse Texture used in the material.
  129899. * Should be author in a specific way for the best result (refer to the documentation).
  129900. */
  129901. diffuseTexture: Nullable<BaseTexture>;
  129902. protected _shadowLights: Nullable<IShadowLight[]>;
  129903. /**
  129904. * Specify the list of lights casting shadow on the material.
  129905. * All scene shadow lights will be included if null.
  129906. */
  129907. shadowLights: Nullable<IShadowLight[]>;
  129908. protected _shadowLevel: float;
  129909. /**
  129910. * Helps adjusting the shadow to a softer level if required.
  129911. * 0 means black shadows and 1 means no shadows.
  129912. */
  129913. shadowLevel: float;
  129914. protected _sceneCenter: Vector3;
  129915. /**
  129916. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  129917. * It is usually zero but might be interesting to modify according to your setup.
  129918. */
  129919. sceneCenter: Vector3;
  129920. protected _opacityFresnel: boolean;
  129921. /**
  129922. * This helps specifying that the material is falling off to the sky box at grazing angle.
  129923. * This helps ensuring a nice transition when the camera goes under the ground.
  129924. */
  129925. opacityFresnel: boolean;
  129926. protected _reflectionFresnel: boolean;
  129927. /**
  129928. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  129929. * This helps adding a mirror texture on the ground.
  129930. */
  129931. reflectionFresnel: boolean;
  129932. protected _reflectionFalloffDistance: number;
  129933. /**
  129934. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  129935. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  129936. */
  129937. reflectionFalloffDistance: number;
  129938. protected _reflectionAmount: number;
  129939. /**
  129940. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  129941. */
  129942. reflectionAmount: number;
  129943. protected _reflectionReflectance0: number;
  129944. /**
  129945. * This specifies the weight of the reflection at grazing angle.
  129946. */
  129947. reflectionReflectance0: number;
  129948. protected _reflectionReflectance90: number;
  129949. /**
  129950. * This specifies the weight of the reflection at a perpendicular point of view.
  129951. */
  129952. reflectionReflectance90: number;
  129953. /**
  129954. * Sets the reflection reflectance fresnel values according to the default standard
  129955. * empirically know to work well :-)
  129956. */
  129957. set reflectionStandardFresnelWeight(value: number);
  129958. protected _useRGBColor: boolean;
  129959. /**
  129960. * Helps to directly use the maps channels instead of their level.
  129961. */
  129962. useRGBColor: boolean;
  129963. protected _enableNoise: boolean;
  129964. /**
  129965. * This helps reducing the banding effect that could occur on the background.
  129966. */
  129967. enableNoise: boolean;
  129968. /**
  129969. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  129970. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  129971. * Recommended to be keep at 1.0 except for special cases.
  129972. */
  129973. get fovMultiplier(): number;
  129974. set fovMultiplier(value: number);
  129975. private _fovMultiplier;
  129976. /**
  129977. * Enable the FOV adjustment feature controlled by fovMultiplier.
  129978. */
  129979. useEquirectangularFOV: boolean;
  129980. private _maxSimultaneousLights;
  129981. /**
  129982. * Number of Simultaneous lights allowed on the material.
  129983. */
  129984. maxSimultaneousLights: int;
  129985. /**
  129986. * Default configuration related to image processing available in the Background Material.
  129987. */
  129988. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  129989. /**
  129990. * Keep track of the image processing observer to allow dispose and replace.
  129991. */
  129992. private _imageProcessingObserver;
  129993. /**
  129994. * Attaches a new image processing configuration to the PBR Material.
  129995. * @param configuration (if null the scene configuration will be use)
  129996. */
  129997. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  129998. /**
  129999. * Gets the image processing configuration used either in this material.
  130000. */
  130001. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  130002. /**
  130003. * Sets the Default image processing configuration used either in the this material.
  130004. *
  130005. * If sets to null, the scene one is in use.
  130006. */
  130007. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  130008. /**
  130009. * Gets wether the color curves effect is enabled.
  130010. */
  130011. get cameraColorCurvesEnabled(): boolean;
  130012. /**
  130013. * Sets wether the color curves effect is enabled.
  130014. */
  130015. set cameraColorCurvesEnabled(value: boolean);
  130016. /**
  130017. * Gets wether the color grading effect is enabled.
  130018. */
  130019. get cameraColorGradingEnabled(): boolean;
  130020. /**
  130021. * Gets wether the color grading effect is enabled.
  130022. */
  130023. set cameraColorGradingEnabled(value: boolean);
  130024. /**
  130025. * Gets wether tonemapping is enabled or not.
  130026. */
  130027. get cameraToneMappingEnabled(): boolean;
  130028. /**
  130029. * Sets wether tonemapping is enabled or not
  130030. */
  130031. set cameraToneMappingEnabled(value: boolean);
  130032. /**
  130033. * The camera exposure used on this material.
  130034. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130035. * This corresponds to a photographic exposure.
  130036. */
  130037. get cameraExposure(): float;
  130038. /**
  130039. * The camera exposure used on this material.
  130040. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130041. * This corresponds to a photographic exposure.
  130042. */
  130043. set cameraExposure(value: float);
  130044. /**
  130045. * Gets The camera contrast used on this material.
  130046. */
  130047. get cameraContrast(): float;
  130048. /**
  130049. * Sets The camera contrast used on this material.
  130050. */
  130051. set cameraContrast(value: float);
  130052. /**
  130053. * Gets the Color Grading 2D Lookup Texture.
  130054. */
  130055. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  130056. /**
  130057. * Sets the Color Grading 2D Lookup Texture.
  130058. */
  130059. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  130060. /**
  130061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  130062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  130063. * 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;
  130064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  130065. */
  130066. get cameraColorCurves(): Nullable<ColorCurves>;
  130067. /**
  130068. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  130069. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  130070. * 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;
  130071. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  130072. */
  130073. set cameraColorCurves(value: Nullable<ColorCurves>);
  130074. /**
  130075. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  130076. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  130077. */
  130078. switchToBGR: boolean;
  130079. private _renderTargets;
  130080. private _reflectionControls;
  130081. private _white;
  130082. private _primaryShadowColor;
  130083. private _primaryHighlightColor;
  130084. /**
  130085. * Instantiates a Background Material in the given scene
  130086. * @param name The friendly name of the material
  130087. * @param scene The scene to add the material to
  130088. */
  130089. constructor(name: string, scene: Scene);
  130090. /**
  130091. * Gets a boolean indicating that current material needs to register RTT
  130092. */
  130093. get hasRenderTargetTextures(): boolean;
  130094. /**
  130095. * The entire material has been created in order to prevent overdraw.
  130096. * @returns false
  130097. */
  130098. needAlphaTesting(): boolean;
  130099. /**
  130100. * The entire material has been created in order to prevent overdraw.
  130101. * @returns true if blending is enable
  130102. */
  130103. needAlphaBlending(): boolean;
  130104. /**
  130105. * Checks wether the material is ready to be rendered for a given mesh.
  130106. * @param mesh The mesh to render
  130107. * @param subMesh The submesh to check against
  130108. * @param useInstances Specify wether or not the material is used with instances
  130109. * @returns true if all the dependencies are ready (Textures, Effects...)
  130110. */
  130111. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130112. /**
  130113. * Compute the primary color according to the chosen perceptual color.
  130114. */
  130115. private _computePrimaryColorFromPerceptualColor;
  130116. /**
  130117. * Compute the highlights and shadow colors according to their chosen levels.
  130118. */
  130119. private _computePrimaryColors;
  130120. /**
  130121. * Build the uniform buffer used in the material.
  130122. */
  130123. buildUniformLayout(): void;
  130124. /**
  130125. * Unbind the material.
  130126. */
  130127. unbind(): void;
  130128. /**
  130129. * Bind only the world matrix to the material.
  130130. * @param world The world matrix to bind.
  130131. */
  130132. bindOnlyWorldMatrix(world: Matrix): void;
  130133. /**
  130134. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  130135. * @param world The world matrix to bind.
  130136. * @param subMesh The submesh to bind for.
  130137. */
  130138. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130139. /**
  130140. * Checks to see if a texture is used in the material.
  130141. * @param texture - Base texture to use.
  130142. * @returns - Boolean specifying if a texture is used in the material.
  130143. */
  130144. hasTexture(texture: BaseTexture): boolean;
  130145. /**
  130146. * Dispose the material.
  130147. * @param forceDisposeEffect Force disposal of the associated effect.
  130148. * @param forceDisposeTextures Force disposal of the associated textures.
  130149. */
  130150. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  130151. /**
  130152. * Clones the material.
  130153. * @param name The cloned name.
  130154. * @returns The cloned material.
  130155. */
  130156. clone(name: string): BackgroundMaterial;
  130157. /**
  130158. * Serializes the current material to its JSON representation.
  130159. * @returns The JSON representation.
  130160. */
  130161. serialize(): any;
  130162. /**
  130163. * Gets the class name of the material
  130164. * @returns "BackgroundMaterial"
  130165. */
  130166. getClassName(): string;
  130167. /**
  130168. * Parse a JSON input to create back a background material.
  130169. * @param source The JSON data to parse
  130170. * @param scene The scene to create the parsed material in
  130171. * @param rootUrl The root url of the assets the material depends upon
  130172. * @returns the instantiated BackgroundMaterial.
  130173. */
  130174. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  130175. }
  130176. }
  130177. declare module BABYLON {
  130178. /**
  130179. * Represents the different options available during the creation of
  130180. * a Environment helper.
  130181. *
  130182. * This can control the default ground, skybox and image processing setup of your scene.
  130183. */
  130184. export interface IEnvironmentHelperOptions {
  130185. /**
  130186. * Specifies whether or not to create a ground.
  130187. * True by default.
  130188. */
  130189. createGround: boolean;
  130190. /**
  130191. * Specifies the ground size.
  130192. * 15 by default.
  130193. */
  130194. groundSize: number;
  130195. /**
  130196. * The texture used on the ground for the main color.
  130197. * Comes from the BabylonJS CDN by default.
  130198. *
  130199. * Remarks: Can be either a texture or a url.
  130200. */
  130201. groundTexture: string | BaseTexture;
  130202. /**
  130203. * The color mixed in the ground texture by default.
  130204. * BabylonJS clearColor by default.
  130205. */
  130206. groundColor: Color3;
  130207. /**
  130208. * Specifies the ground opacity.
  130209. * 1 by default.
  130210. */
  130211. groundOpacity: number;
  130212. /**
  130213. * Enables the ground to receive shadows.
  130214. * True by default.
  130215. */
  130216. enableGroundShadow: boolean;
  130217. /**
  130218. * Helps preventing the shadow to be fully black on the ground.
  130219. * 0.5 by default.
  130220. */
  130221. groundShadowLevel: number;
  130222. /**
  130223. * Creates a mirror texture attach to the ground.
  130224. * false by default.
  130225. */
  130226. enableGroundMirror: boolean;
  130227. /**
  130228. * Specifies the ground mirror size ratio.
  130229. * 0.3 by default as the default kernel is 64.
  130230. */
  130231. groundMirrorSizeRatio: number;
  130232. /**
  130233. * Specifies the ground mirror blur kernel size.
  130234. * 64 by default.
  130235. */
  130236. groundMirrorBlurKernel: number;
  130237. /**
  130238. * Specifies the ground mirror visibility amount.
  130239. * 1 by default
  130240. */
  130241. groundMirrorAmount: number;
  130242. /**
  130243. * Specifies the ground mirror reflectance weight.
  130244. * This uses the standard weight of the background material to setup the fresnel effect
  130245. * of the mirror.
  130246. * 1 by default.
  130247. */
  130248. groundMirrorFresnelWeight: number;
  130249. /**
  130250. * Specifies the ground mirror Falloff distance.
  130251. * This can helps reducing the size of the reflection.
  130252. * 0 by Default.
  130253. */
  130254. groundMirrorFallOffDistance: number;
  130255. /**
  130256. * Specifies the ground mirror texture type.
  130257. * Unsigned Int by Default.
  130258. */
  130259. groundMirrorTextureType: number;
  130260. /**
  130261. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  130262. * the shown objects.
  130263. */
  130264. groundYBias: number;
  130265. /**
  130266. * Specifies whether or not to create a skybox.
  130267. * True by default.
  130268. */
  130269. createSkybox: boolean;
  130270. /**
  130271. * Specifies the skybox size.
  130272. * 20 by default.
  130273. */
  130274. skyboxSize: number;
  130275. /**
  130276. * The texture used on the skybox for the main color.
  130277. * Comes from the BabylonJS CDN by default.
  130278. *
  130279. * Remarks: Can be either a texture or a url.
  130280. */
  130281. skyboxTexture: string | BaseTexture;
  130282. /**
  130283. * The color mixed in the skybox texture by default.
  130284. * BabylonJS clearColor by default.
  130285. */
  130286. skyboxColor: Color3;
  130287. /**
  130288. * The background rotation around the Y axis of the scene.
  130289. * This helps aligning the key lights of your scene with the background.
  130290. * 0 by default.
  130291. */
  130292. backgroundYRotation: number;
  130293. /**
  130294. * Compute automatically the size of the elements to best fit with the scene.
  130295. */
  130296. sizeAuto: boolean;
  130297. /**
  130298. * Default position of the rootMesh if autoSize is not true.
  130299. */
  130300. rootPosition: Vector3;
  130301. /**
  130302. * Sets up the image processing in the scene.
  130303. * true by default.
  130304. */
  130305. setupImageProcessing: boolean;
  130306. /**
  130307. * The texture used as your environment texture in the scene.
  130308. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  130309. *
  130310. * Remarks: Can be either a texture or a url.
  130311. */
  130312. environmentTexture: string | BaseTexture;
  130313. /**
  130314. * The value of the exposure to apply to the scene.
  130315. * 0.6 by default if setupImageProcessing is true.
  130316. */
  130317. cameraExposure: number;
  130318. /**
  130319. * The value of the contrast to apply to the scene.
  130320. * 1.6 by default if setupImageProcessing is true.
  130321. */
  130322. cameraContrast: number;
  130323. /**
  130324. * Specifies whether or not tonemapping should be enabled in the scene.
  130325. * true by default if setupImageProcessing is true.
  130326. */
  130327. toneMappingEnabled: boolean;
  130328. }
  130329. /**
  130330. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  130331. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  130332. * It also helps with the default setup of your imageProcessing configuration.
  130333. */
  130334. export class EnvironmentHelper {
  130335. /**
  130336. * Default ground texture URL.
  130337. */
  130338. private static _groundTextureCDNUrl;
  130339. /**
  130340. * Default skybox texture URL.
  130341. */
  130342. private static _skyboxTextureCDNUrl;
  130343. /**
  130344. * Default environment texture URL.
  130345. */
  130346. private static _environmentTextureCDNUrl;
  130347. /**
  130348. * Creates the default options for the helper.
  130349. */
  130350. private static _getDefaultOptions;
  130351. private _rootMesh;
  130352. /**
  130353. * Gets the root mesh created by the helper.
  130354. */
  130355. get rootMesh(): Mesh;
  130356. private _skybox;
  130357. /**
  130358. * Gets the skybox created by the helper.
  130359. */
  130360. get skybox(): Nullable<Mesh>;
  130361. private _skyboxTexture;
  130362. /**
  130363. * Gets the skybox texture created by the helper.
  130364. */
  130365. get skyboxTexture(): Nullable<BaseTexture>;
  130366. private _skyboxMaterial;
  130367. /**
  130368. * Gets the skybox material created by the helper.
  130369. */
  130370. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  130371. private _ground;
  130372. /**
  130373. * Gets the ground mesh created by the helper.
  130374. */
  130375. get ground(): Nullable<Mesh>;
  130376. private _groundTexture;
  130377. /**
  130378. * Gets the ground texture created by the helper.
  130379. */
  130380. get groundTexture(): Nullable<BaseTexture>;
  130381. private _groundMirror;
  130382. /**
  130383. * Gets the ground mirror created by the helper.
  130384. */
  130385. get groundMirror(): Nullable<MirrorTexture>;
  130386. /**
  130387. * Gets the ground mirror render list to helps pushing the meshes
  130388. * you wish in the ground reflection.
  130389. */
  130390. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  130391. private _groundMaterial;
  130392. /**
  130393. * Gets the ground material created by the helper.
  130394. */
  130395. get groundMaterial(): Nullable<BackgroundMaterial>;
  130396. /**
  130397. * Stores the creation options.
  130398. */
  130399. private readonly _scene;
  130400. private _options;
  130401. /**
  130402. * This observable will be notified with any error during the creation of the environment,
  130403. * mainly texture creation errors.
  130404. */
  130405. onErrorObservable: Observable<{
  130406. message?: string;
  130407. exception?: any;
  130408. }>;
  130409. /**
  130410. * constructor
  130411. * @param options Defines the options we want to customize the helper
  130412. * @param scene The scene to add the material to
  130413. */
  130414. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  130415. /**
  130416. * Updates the background according to the new options
  130417. * @param options
  130418. */
  130419. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  130420. /**
  130421. * Sets the primary color of all the available elements.
  130422. * @param color the main color to affect to the ground and the background
  130423. */
  130424. setMainColor(color: Color3): void;
  130425. /**
  130426. * Setup the image processing according to the specified options.
  130427. */
  130428. private _setupImageProcessing;
  130429. /**
  130430. * Setup the environment texture according to the specified options.
  130431. */
  130432. private _setupEnvironmentTexture;
  130433. /**
  130434. * Setup the background according to the specified options.
  130435. */
  130436. private _setupBackground;
  130437. /**
  130438. * Get the scene sizes according to the setup.
  130439. */
  130440. private _getSceneSize;
  130441. /**
  130442. * Setup the ground according to the specified options.
  130443. */
  130444. private _setupGround;
  130445. /**
  130446. * Setup the ground material according to the specified options.
  130447. */
  130448. private _setupGroundMaterial;
  130449. /**
  130450. * Setup the ground diffuse texture according to the specified options.
  130451. */
  130452. private _setupGroundDiffuseTexture;
  130453. /**
  130454. * Setup the ground mirror texture according to the specified options.
  130455. */
  130456. private _setupGroundMirrorTexture;
  130457. /**
  130458. * Setup the ground to receive the mirror texture.
  130459. */
  130460. private _setupMirrorInGroundMaterial;
  130461. /**
  130462. * Setup the skybox according to the specified options.
  130463. */
  130464. private _setupSkybox;
  130465. /**
  130466. * Setup the skybox material according to the specified options.
  130467. */
  130468. private _setupSkyboxMaterial;
  130469. /**
  130470. * Setup the skybox reflection texture according to the specified options.
  130471. */
  130472. private _setupSkyboxReflectionTexture;
  130473. private _errorHandler;
  130474. /**
  130475. * Dispose all the elements created by the Helper.
  130476. */
  130477. dispose(): void;
  130478. }
  130479. }
  130480. declare module BABYLON {
  130481. /**
  130482. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  130483. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  130484. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  130485. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  130486. */
  130487. export class PhotoDome extends TransformNode {
  130488. /**
  130489. * Define the image as a Monoscopic panoramic 360 image.
  130490. */
  130491. static readonly MODE_MONOSCOPIC: number;
  130492. /**
  130493. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130494. */
  130495. static readonly MODE_TOPBOTTOM: number;
  130496. /**
  130497. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130498. */
  130499. static readonly MODE_SIDEBYSIDE: number;
  130500. private _useDirectMapping;
  130501. /**
  130502. * The texture being displayed on the sphere
  130503. */
  130504. protected _photoTexture: Texture;
  130505. /**
  130506. * Gets or sets the texture being displayed on the sphere
  130507. */
  130508. get photoTexture(): Texture;
  130509. set photoTexture(value: Texture);
  130510. /**
  130511. * Observable raised when an error occured while loading the 360 image
  130512. */
  130513. onLoadErrorObservable: Observable<string>;
  130514. /**
  130515. * The skybox material
  130516. */
  130517. protected _material: BackgroundMaterial;
  130518. /**
  130519. * The surface used for the skybox
  130520. */
  130521. protected _mesh: Mesh;
  130522. /**
  130523. * Gets the mesh used for the skybox.
  130524. */
  130525. get mesh(): Mesh;
  130526. /**
  130527. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130528. * Also see the options.resolution property.
  130529. */
  130530. get fovMultiplier(): number;
  130531. set fovMultiplier(value: number);
  130532. private _imageMode;
  130533. /**
  130534. * Gets or set the current video mode for the video. It can be:
  130535. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  130536. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130537. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130538. */
  130539. get imageMode(): number;
  130540. set imageMode(value: number);
  130541. /**
  130542. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  130543. * @param name Element's name, child elements will append suffixes for their own names.
  130544. * @param urlsOfPhoto defines the url of the photo to display
  130545. * @param options defines an object containing optional or exposed sub element properties
  130546. * @param onError defines a callback called when an error occured while loading the texture
  130547. */
  130548. constructor(name: string, urlOfPhoto: string, options: {
  130549. resolution?: number;
  130550. size?: number;
  130551. useDirectMapping?: boolean;
  130552. faceForward?: boolean;
  130553. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  130554. private _onBeforeCameraRenderObserver;
  130555. private _changeImageMode;
  130556. /**
  130557. * Releases resources associated with this node.
  130558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  130559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  130560. */
  130561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  130562. }
  130563. }
  130564. declare module BABYLON {
  130565. /**
  130566. * Class used to host RGBD texture specific utilities
  130567. */
  130568. export class RGBDTextureTools {
  130569. /**
  130570. * Expand the RGBD Texture from RGBD to Half Float if possible.
  130571. * @param texture the texture to expand.
  130572. */
  130573. static ExpandRGBDTexture(texture: Texture): void;
  130574. }
  130575. }
  130576. declare module BABYLON {
  130577. /**
  130578. * Class used to host texture specific utilities
  130579. */
  130580. export class BRDFTextureTools {
  130581. /**
  130582. * Prevents texture cache collision
  130583. */
  130584. private static _instanceNumber;
  130585. /**
  130586. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  130587. * @param scene defines the hosting scene
  130588. * @returns the environment BRDF texture
  130589. */
  130590. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  130591. private static _environmentBRDFBase64Texture;
  130592. }
  130593. }
  130594. declare module BABYLON {
  130595. /**
  130596. * @hidden
  130597. */
  130598. export interface IMaterialClearCoatDefines {
  130599. CLEARCOAT: boolean;
  130600. CLEARCOAT_DEFAULTIOR: boolean;
  130601. CLEARCOAT_TEXTURE: boolean;
  130602. CLEARCOAT_TEXTUREDIRECTUV: number;
  130603. CLEARCOAT_BUMP: boolean;
  130604. CLEARCOAT_BUMPDIRECTUV: number;
  130605. CLEARCOAT_TINT: boolean;
  130606. CLEARCOAT_TINT_TEXTURE: boolean;
  130607. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  130608. /** @hidden */
  130609. _areTexturesDirty: boolean;
  130610. }
  130611. /**
  130612. * Define the code related to the clear coat parameters of the pbr material.
  130613. */
  130614. export class PBRClearCoatConfiguration {
  130615. /**
  130616. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130617. * The default fits with a polyurethane material.
  130618. */
  130619. private static readonly _DefaultIndexOfRefraction;
  130620. private _isEnabled;
  130621. /**
  130622. * Defines if the clear coat is enabled in the material.
  130623. */
  130624. isEnabled: boolean;
  130625. /**
  130626. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  130627. */
  130628. intensity: number;
  130629. /**
  130630. * Defines the clear coat layer roughness.
  130631. */
  130632. roughness: number;
  130633. private _indexOfRefraction;
  130634. /**
  130635. * Defines the index of refraction of the clear coat.
  130636. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130637. * The default fits with a polyurethane material.
  130638. * Changing the default value is more performance intensive.
  130639. */
  130640. indexOfRefraction: number;
  130641. private _texture;
  130642. /**
  130643. * Stores the clear coat values in a texture.
  130644. */
  130645. texture: Nullable<BaseTexture>;
  130646. private _bumpTexture;
  130647. /**
  130648. * Define the clear coat specific bump texture.
  130649. */
  130650. bumpTexture: Nullable<BaseTexture>;
  130651. private _isTintEnabled;
  130652. /**
  130653. * Defines if the clear coat tint is enabled in the material.
  130654. */
  130655. isTintEnabled: boolean;
  130656. /**
  130657. * Defines the clear coat tint of the material.
  130658. * This is only use if tint is enabled
  130659. */
  130660. tintColor: Color3;
  130661. /**
  130662. * Defines the distance at which the tint color should be found in the
  130663. * clear coat media.
  130664. * This is only use if tint is enabled
  130665. */
  130666. tintColorAtDistance: number;
  130667. /**
  130668. * Defines the clear coat layer thickness.
  130669. * This is only use if tint is enabled
  130670. */
  130671. tintThickness: number;
  130672. private _tintTexture;
  130673. /**
  130674. * Stores the clear tint values in a texture.
  130675. * rgb is tint
  130676. * a is a thickness factor
  130677. */
  130678. tintTexture: Nullable<BaseTexture>;
  130679. /** @hidden */
  130680. private _internalMarkAllSubMeshesAsTexturesDirty;
  130681. /** @hidden */
  130682. _markAllSubMeshesAsTexturesDirty(): void;
  130683. /**
  130684. * Instantiate a new istance of clear coat configuration.
  130685. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130686. */
  130687. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130688. /**
  130689. * Gets wehter the submesh is ready to be used or not.
  130690. * @param defines the list of "defines" to update.
  130691. * @param scene defines the scene the material belongs to.
  130692. * @param engine defines the engine the material belongs to.
  130693. * @param disableBumpMap defines wether the material disables bump or not.
  130694. * @returns - boolean indicating that the submesh is ready or not.
  130695. */
  130696. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  130697. /**
  130698. * Checks to see if a texture is used in the material.
  130699. * @param defines the list of "defines" to update.
  130700. * @param scene defines the scene to the material belongs to.
  130701. */
  130702. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  130703. /**
  130704. * Binds the material data.
  130705. * @param uniformBuffer defines the Uniform buffer to fill in.
  130706. * @param scene defines the scene the material belongs to.
  130707. * @param engine defines the engine the material belongs to.
  130708. * @param disableBumpMap defines wether the material disables bump or not.
  130709. * @param isFrozen defines wether the material is frozen or not.
  130710. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  130711. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  130712. */
  130713. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  130714. /**
  130715. * Checks to see if a texture is used in the material.
  130716. * @param texture - Base texture to use.
  130717. * @returns - Boolean specifying if a texture is used in the material.
  130718. */
  130719. hasTexture(texture: BaseTexture): boolean;
  130720. /**
  130721. * Returns an array of the actively used textures.
  130722. * @param activeTextures Array of BaseTextures
  130723. */
  130724. getActiveTextures(activeTextures: BaseTexture[]): void;
  130725. /**
  130726. * Returns the animatable textures.
  130727. * @param animatables Array of animatable textures.
  130728. */
  130729. getAnimatables(animatables: IAnimatable[]): void;
  130730. /**
  130731. * Disposes the resources of the material.
  130732. * @param forceDisposeTextures - Forces the disposal of all textures.
  130733. */
  130734. dispose(forceDisposeTextures?: boolean): void;
  130735. /**
  130736. * Get the current class name of the texture useful for serialization or dynamic coding.
  130737. * @returns "PBRClearCoatConfiguration"
  130738. */
  130739. getClassName(): string;
  130740. /**
  130741. * Add fallbacks to the effect fallbacks list.
  130742. * @param defines defines the Base texture to use.
  130743. * @param fallbacks defines the current fallback list.
  130744. * @param currentRank defines the current fallback rank.
  130745. * @returns the new fallback rank.
  130746. */
  130747. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130748. /**
  130749. * Add the required uniforms to the current list.
  130750. * @param uniforms defines the current uniform list.
  130751. */
  130752. static AddUniforms(uniforms: string[]): void;
  130753. /**
  130754. * Add the required samplers to the current list.
  130755. * @param samplers defines the current sampler list.
  130756. */
  130757. static AddSamplers(samplers: string[]): void;
  130758. /**
  130759. * Add the required uniforms to the current buffer.
  130760. * @param uniformBuffer defines the current uniform buffer.
  130761. */
  130762. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130763. /**
  130764. * Makes a duplicate of the current configuration into another one.
  130765. * @param clearCoatConfiguration define the config where to copy the info
  130766. */
  130767. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  130768. /**
  130769. * Serializes this clear coat configuration.
  130770. * @returns - An object with the serialized config.
  130771. */
  130772. serialize(): any;
  130773. /**
  130774. * Parses a anisotropy Configuration from a serialized object.
  130775. * @param source - Serialized object.
  130776. * @param scene Defines the scene we are parsing for
  130777. * @param rootUrl Defines the rootUrl to load from
  130778. */
  130779. parse(source: any, scene: Scene, rootUrl: string): void;
  130780. }
  130781. }
  130782. declare module BABYLON {
  130783. /**
  130784. * @hidden
  130785. */
  130786. export interface IMaterialAnisotropicDefines {
  130787. ANISOTROPIC: boolean;
  130788. ANISOTROPIC_TEXTURE: boolean;
  130789. ANISOTROPIC_TEXTUREDIRECTUV: number;
  130790. MAINUV1: boolean;
  130791. _areTexturesDirty: boolean;
  130792. _needUVs: boolean;
  130793. }
  130794. /**
  130795. * Define the code related to the anisotropic parameters of the pbr material.
  130796. */
  130797. export class PBRAnisotropicConfiguration {
  130798. private _isEnabled;
  130799. /**
  130800. * Defines if the anisotropy is enabled in the material.
  130801. */
  130802. isEnabled: boolean;
  130803. /**
  130804. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  130805. */
  130806. intensity: number;
  130807. /**
  130808. * Defines if the effect is along the tangents, bitangents or in between.
  130809. * By default, the effect is "strectching" the highlights along the tangents.
  130810. */
  130811. direction: Vector2;
  130812. private _texture;
  130813. /**
  130814. * Stores the anisotropy values in a texture.
  130815. * rg is direction (like normal from -1 to 1)
  130816. * b is a intensity
  130817. */
  130818. texture: Nullable<BaseTexture>;
  130819. /** @hidden */
  130820. private _internalMarkAllSubMeshesAsTexturesDirty;
  130821. /** @hidden */
  130822. _markAllSubMeshesAsTexturesDirty(): void;
  130823. /**
  130824. * Instantiate a new istance of anisotropy configuration.
  130825. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130826. */
  130827. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130828. /**
  130829. * Specifies that the submesh is ready to be used.
  130830. * @param defines the list of "defines" to update.
  130831. * @param scene defines the scene the material belongs to.
  130832. * @returns - boolean indicating that the submesh is ready or not.
  130833. */
  130834. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  130835. /**
  130836. * Checks to see if a texture is used in the material.
  130837. * @param defines the list of "defines" to update.
  130838. * @param mesh the mesh we are preparing the defines for.
  130839. * @param scene defines the scene the material belongs to.
  130840. */
  130841. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  130842. /**
  130843. * Binds the material data.
  130844. * @param uniformBuffer defines the Uniform buffer to fill in.
  130845. * @param scene defines the scene the material belongs to.
  130846. * @param isFrozen defines wether the material is frozen or not.
  130847. */
  130848. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  130849. /**
  130850. * Checks to see if a texture is used in the material.
  130851. * @param texture - Base texture to use.
  130852. * @returns - Boolean specifying if a texture is used in the material.
  130853. */
  130854. hasTexture(texture: BaseTexture): boolean;
  130855. /**
  130856. * Returns an array of the actively used textures.
  130857. * @param activeTextures Array of BaseTextures
  130858. */
  130859. getActiveTextures(activeTextures: BaseTexture[]): void;
  130860. /**
  130861. * Returns the animatable textures.
  130862. * @param animatables Array of animatable textures.
  130863. */
  130864. getAnimatables(animatables: IAnimatable[]): void;
  130865. /**
  130866. * Disposes the resources of the material.
  130867. * @param forceDisposeTextures - Forces the disposal of all textures.
  130868. */
  130869. dispose(forceDisposeTextures?: boolean): void;
  130870. /**
  130871. * Get the current class name of the texture useful for serialization or dynamic coding.
  130872. * @returns "PBRAnisotropicConfiguration"
  130873. */
  130874. getClassName(): string;
  130875. /**
  130876. * Add fallbacks to the effect fallbacks list.
  130877. * @param defines defines the Base texture to use.
  130878. * @param fallbacks defines the current fallback list.
  130879. * @param currentRank defines the current fallback rank.
  130880. * @returns the new fallback rank.
  130881. */
  130882. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130883. /**
  130884. * Add the required uniforms to the current list.
  130885. * @param uniforms defines the current uniform list.
  130886. */
  130887. static AddUniforms(uniforms: string[]): void;
  130888. /**
  130889. * Add the required uniforms to the current buffer.
  130890. * @param uniformBuffer defines the current uniform buffer.
  130891. */
  130892. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130893. /**
  130894. * Add the required samplers to the current list.
  130895. * @param samplers defines the current sampler list.
  130896. */
  130897. static AddSamplers(samplers: string[]): void;
  130898. /**
  130899. * Makes a duplicate of the current configuration into another one.
  130900. * @param anisotropicConfiguration define the config where to copy the info
  130901. */
  130902. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  130903. /**
  130904. * Serializes this anisotropy configuration.
  130905. * @returns - An object with the serialized config.
  130906. */
  130907. serialize(): any;
  130908. /**
  130909. * Parses a anisotropy Configuration from a serialized object.
  130910. * @param source - Serialized object.
  130911. * @param scene Defines the scene we are parsing for
  130912. * @param rootUrl Defines the rootUrl to load from
  130913. */
  130914. parse(source: any, scene: Scene, rootUrl: string): void;
  130915. }
  130916. }
  130917. declare module BABYLON {
  130918. /**
  130919. * @hidden
  130920. */
  130921. export interface IMaterialBRDFDefines {
  130922. BRDF_V_HEIGHT_CORRELATED: boolean;
  130923. MS_BRDF_ENERGY_CONSERVATION: boolean;
  130924. SPHERICAL_HARMONICS: boolean;
  130925. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  130926. /** @hidden */
  130927. _areMiscDirty: boolean;
  130928. }
  130929. /**
  130930. * Define the code related to the BRDF parameters of the pbr material.
  130931. */
  130932. export class PBRBRDFConfiguration {
  130933. /**
  130934. * Default value used for the energy conservation.
  130935. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  130936. */
  130937. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  130938. /**
  130939. * Default value used for the Smith Visibility Height Correlated mode.
  130940. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  130941. */
  130942. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  130943. /**
  130944. * Default value used for the IBL diffuse part.
  130945. * This can help switching back to the polynomials mode globally which is a tiny bit
  130946. * less GPU intensive at the drawback of a lower quality.
  130947. */
  130948. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  130949. /**
  130950. * Default value used for activating energy conservation for the specular workflow.
  130951. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  130952. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  130953. */
  130954. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  130955. private _useEnergyConservation;
  130956. /**
  130957. * Defines if the material uses energy conservation.
  130958. */
  130959. useEnergyConservation: boolean;
  130960. private _useSmithVisibilityHeightCorrelated;
  130961. /**
  130962. * LEGACY Mode set to false
  130963. * Defines if the material uses height smith correlated visibility term.
  130964. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  130965. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  130966. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  130967. * Not relying on height correlated will also disable energy conservation.
  130968. */
  130969. useSmithVisibilityHeightCorrelated: boolean;
  130970. private _useSphericalHarmonics;
  130971. /**
  130972. * LEGACY Mode set to false
  130973. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  130974. * diffuse part of the IBL.
  130975. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  130976. * to the ground truth.
  130977. */
  130978. useSphericalHarmonics: boolean;
  130979. private _useSpecularGlossinessInputEnergyConservation;
  130980. /**
  130981. * Defines if the material uses energy conservation, when the specular workflow is active.
  130982. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  130983. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  130984. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  130985. */
  130986. useSpecularGlossinessInputEnergyConservation: boolean;
  130987. /** @hidden */
  130988. private _internalMarkAllSubMeshesAsMiscDirty;
  130989. /** @hidden */
  130990. _markAllSubMeshesAsMiscDirty(): void;
  130991. /**
  130992. * Instantiate a new istance of clear coat configuration.
  130993. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  130994. */
  130995. constructor(markAllSubMeshesAsMiscDirty: () => void);
  130996. /**
  130997. * Checks to see if a texture is used in the material.
  130998. * @param defines the list of "defines" to update.
  130999. */
  131000. prepareDefines(defines: IMaterialBRDFDefines): void;
  131001. /**
  131002. * Get the current class name of the texture useful for serialization or dynamic coding.
  131003. * @returns "PBRClearCoatConfiguration"
  131004. */
  131005. getClassName(): string;
  131006. /**
  131007. * Makes a duplicate of the current configuration into another one.
  131008. * @param brdfConfiguration define the config where to copy the info
  131009. */
  131010. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  131011. /**
  131012. * Serializes this BRDF configuration.
  131013. * @returns - An object with the serialized config.
  131014. */
  131015. serialize(): any;
  131016. /**
  131017. * Parses a anisotropy Configuration from a serialized object.
  131018. * @param source - Serialized object.
  131019. * @param scene Defines the scene we are parsing for
  131020. * @param rootUrl Defines the rootUrl to load from
  131021. */
  131022. parse(source: any, scene: Scene, rootUrl: string): void;
  131023. }
  131024. }
  131025. declare module BABYLON {
  131026. /**
  131027. * @hidden
  131028. */
  131029. export interface IMaterialSheenDefines {
  131030. SHEEN: boolean;
  131031. SHEEN_TEXTURE: boolean;
  131032. SHEEN_TEXTUREDIRECTUV: number;
  131033. SHEEN_LINKWITHALBEDO: boolean;
  131034. SHEEN_ROUGHNESS: boolean;
  131035. SHEEN_ALBEDOSCALING: boolean;
  131036. /** @hidden */
  131037. _areTexturesDirty: boolean;
  131038. }
  131039. /**
  131040. * Define the code related to the Sheen parameters of the pbr material.
  131041. */
  131042. export class PBRSheenConfiguration {
  131043. private _isEnabled;
  131044. /**
  131045. * Defines if the material uses sheen.
  131046. */
  131047. isEnabled: boolean;
  131048. private _linkSheenWithAlbedo;
  131049. /**
  131050. * Defines if the sheen is linked to the sheen color.
  131051. */
  131052. linkSheenWithAlbedo: boolean;
  131053. /**
  131054. * Defines the sheen intensity.
  131055. */
  131056. intensity: number;
  131057. /**
  131058. * Defines the sheen color.
  131059. */
  131060. color: Color3;
  131061. private _texture;
  131062. /**
  131063. * Stores the sheen tint values in a texture.
  131064. * rgb is tint
  131065. * a is a intensity
  131066. */
  131067. texture: Nullable<BaseTexture>;
  131068. private _roughness;
  131069. /**
  131070. * Defines the sheen roughness.
  131071. * It is not taken into account if linkSheenWithAlbedo is true.
  131072. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  131073. */
  131074. roughness: Nullable<number>;
  131075. private _albedoScaling;
  131076. /**
  131077. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  131078. * It allows the strength of the sheen effect to not depend on the base color of the material,
  131079. * making it easier to setup and tweak the effect
  131080. */
  131081. albedoScaling: boolean;
  131082. /** @hidden */
  131083. private _internalMarkAllSubMeshesAsTexturesDirty;
  131084. /** @hidden */
  131085. _markAllSubMeshesAsTexturesDirty(): void;
  131086. /**
  131087. * Instantiate a new istance of clear coat configuration.
  131088. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131089. */
  131090. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131091. /**
  131092. * Specifies that the submesh is ready to be used.
  131093. * @param defines the list of "defines" to update.
  131094. * @param scene defines the scene the material belongs to.
  131095. * @returns - boolean indicating that the submesh is ready or not.
  131096. */
  131097. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  131098. /**
  131099. * Checks to see if a texture is used in the material.
  131100. * @param defines the list of "defines" to update.
  131101. * @param scene defines the scene the material belongs to.
  131102. */
  131103. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  131104. /**
  131105. * Binds the material data.
  131106. * @param uniformBuffer defines the Uniform buffer to fill in.
  131107. * @param scene defines the scene the material belongs to.
  131108. * @param isFrozen defines wether the material is frozen or not.
  131109. */
  131110. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  131111. /**
  131112. * Checks to see if a texture is used in the material.
  131113. * @param texture - Base texture to use.
  131114. * @returns - Boolean specifying if a texture is used in the material.
  131115. */
  131116. hasTexture(texture: BaseTexture): boolean;
  131117. /**
  131118. * Returns an array of the actively used textures.
  131119. * @param activeTextures Array of BaseTextures
  131120. */
  131121. getActiveTextures(activeTextures: BaseTexture[]): void;
  131122. /**
  131123. * Returns the animatable textures.
  131124. * @param animatables Array of animatable textures.
  131125. */
  131126. getAnimatables(animatables: IAnimatable[]): void;
  131127. /**
  131128. * Disposes the resources of the material.
  131129. * @param forceDisposeTextures - Forces the disposal of all textures.
  131130. */
  131131. dispose(forceDisposeTextures?: boolean): void;
  131132. /**
  131133. * Get the current class name of the texture useful for serialization or dynamic coding.
  131134. * @returns "PBRSheenConfiguration"
  131135. */
  131136. getClassName(): string;
  131137. /**
  131138. * Add fallbacks to the effect fallbacks list.
  131139. * @param defines defines the Base texture to use.
  131140. * @param fallbacks defines the current fallback list.
  131141. * @param currentRank defines the current fallback rank.
  131142. * @returns the new fallback rank.
  131143. */
  131144. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131145. /**
  131146. * Add the required uniforms to the current list.
  131147. * @param uniforms defines the current uniform list.
  131148. */
  131149. static AddUniforms(uniforms: string[]): void;
  131150. /**
  131151. * Add the required uniforms to the current buffer.
  131152. * @param uniformBuffer defines the current uniform buffer.
  131153. */
  131154. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131155. /**
  131156. * Add the required samplers to the current list.
  131157. * @param samplers defines the current sampler list.
  131158. */
  131159. static AddSamplers(samplers: string[]): void;
  131160. /**
  131161. * Makes a duplicate of the current configuration into another one.
  131162. * @param sheenConfiguration define the config where to copy the info
  131163. */
  131164. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  131165. /**
  131166. * Serializes this BRDF configuration.
  131167. * @returns - An object with the serialized config.
  131168. */
  131169. serialize(): any;
  131170. /**
  131171. * Parses a anisotropy Configuration from a serialized object.
  131172. * @param source - Serialized object.
  131173. * @param scene Defines the scene we are parsing for
  131174. * @param rootUrl Defines the rootUrl to load from
  131175. */
  131176. parse(source: any, scene: Scene, rootUrl: string): void;
  131177. }
  131178. }
  131179. declare module BABYLON {
  131180. /**
  131181. * @hidden
  131182. */
  131183. export interface IMaterialSubSurfaceDefines {
  131184. SUBSURFACE: boolean;
  131185. SS_REFRACTION: boolean;
  131186. SS_TRANSLUCENCY: boolean;
  131187. SS_SCATERRING: boolean;
  131188. SS_THICKNESSANDMASK_TEXTURE: boolean;
  131189. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  131190. SS_REFRACTIONMAP_3D: boolean;
  131191. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  131192. SS_LODINREFRACTIONALPHA: boolean;
  131193. SS_GAMMAREFRACTION: boolean;
  131194. SS_RGBDREFRACTION: boolean;
  131195. SS_LINEARSPECULARREFRACTION: boolean;
  131196. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  131197. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  131198. /** @hidden */
  131199. _areTexturesDirty: boolean;
  131200. }
  131201. /**
  131202. * Define the code related to the sub surface parameters of the pbr material.
  131203. */
  131204. export class PBRSubSurfaceConfiguration {
  131205. private _isRefractionEnabled;
  131206. /**
  131207. * Defines if the refraction is enabled in the material.
  131208. */
  131209. isRefractionEnabled: boolean;
  131210. private _isTranslucencyEnabled;
  131211. /**
  131212. * Defines if the translucency is enabled in the material.
  131213. */
  131214. isTranslucencyEnabled: boolean;
  131215. private _isScatteringEnabled;
  131216. /**
  131217. * Defines the refraction intensity of the material.
  131218. * The refraction when enabled replaces the Diffuse part of the material.
  131219. * The intensity helps transitionning between diffuse and refraction.
  131220. */
  131221. refractionIntensity: number;
  131222. /**
  131223. * Defines the translucency intensity of the material.
  131224. * When translucency has been enabled, this defines how much of the "translucency"
  131225. * is addded to the diffuse part of the material.
  131226. */
  131227. translucencyIntensity: number;
  131228. /**
  131229. * Defines the scattering intensity of the material.
  131230. * When scattering has been enabled, this defines how much of the "scattered light"
  131231. * is addded to the diffuse part of the material.
  131232. */
  131233. scatteringIntensity: number;
  131234. private _thicknessTexture;
  131235. /**
  131236. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  131237. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  131238. * 0 would mean minimumThickness
  131239. * 1 would mean maximumThickness
  131240. * The other channels might be use as a mask to vary the different effects intensity.
  131241. */
  131242. thicknessTexture: Nullable<BaseTexture>;
  131243. private _refractionTexture;
  131244. /**
  131245. * Defines the texture to use for refraction.
  131246. */
  131247. refractionTexture: Nullable<BaseTexture>;
  131248. private _indexOfRefraction;
  131249. /**
  131250. * Index of refraction of the material base layer.
  131251. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  131252. *
  131253. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  131254. *
  131255. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  131256. */
  131257. indexOfRefraction: number;
  131258. private _invertRefractionY;
  131259. /**
  131260. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  131261. */
  131262. invertRefractionY: boolean;
  131263. private _linkRefractionWithTransparency;
  131264. /**
  131265. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  131266. * Materials half opaque for instance using refraction could benefit from this control.
  131267. */
  131268. linkRefractionWithTransparency: boolean;
  131269. /**
  131270. * Defines the minimum thickness stored in the thickness map.
  131271. * If no thickness map is defined, this value will be used to simulate thickness.
  131272. */
  131273. minimumThickness: number;
  131274. /**
  131275. * Defines the maximum thickness stored in the thickness map.
  131276. */
  131277. maximumThickness: number;
  131278. /**
  131279. * Defines the volume tint of the material.
  131280. * This is used for both translucency and scattering.
  131281. */
  131282. tintColor: Color3;
  131283. /**
  131284. * Defines the distance at which the tint color should be found in the media.
  131285. * This is used for refraction only.
  131286. */
  131287. tintColorAtDistance: number;
  131288. /**
  131289. * Defines how far each channel transmit through the media.
  131290. * It is defined as a color to simplify it selection.
  131291. */
  131292. diffusionDistance: Color3;
  131293. private _useMaskFromThicknessTexture;
  131294. /**
  131295. * Stores the intensity of the different subsurface effects in the thickness texture.
  131296. * * the green channel is the translucency intensity.
  131297. * * the blue channel is the scattering intensity.
  131298. * * the alpha channel is the refraction intensity.
  131299. */
  131300. useMaskFromThicknessTexture: boolean;
  131301. /** @hidden */
  131302. private _internalMarkAllSubMeshesAsTexturesDirty;
  131303. /** @hidden */
  131304. _markAllSubMeshesAsTexturesDirty(): void;
  131305. /**
  131306. * Instantiate a new istance of sub surface configuration.
  131307. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131308. */
  131309. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131310. /**
  131311. * Gets wehter the submesh is ready to be used or not.
  131312. * @param defines the list of "defines" to update.
  131313. * @param scene defines the scene the material belongs to.
  131314. * @returns - boolean indicating that the submesh is ready or not.
  131315. */
  131316. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  131317. /**
  131318. * Checks to see if a texture is used in the material.
  131319. * @param defines the list of "defines" to update.
  131320. * @param scene defines the scene to the material belongs to.
  131321. */
  131322. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  131323. /**
  131324. * Binds the material data.
  131325. * @param uniformBuffer defines the Uniform buffer to fill in.
  131326. * @param scene defines the scene the material belongs to.
  131327. * @param engine defines the engine the material belongs to.
  131328. * @param isFrozen defines whether the material is frozen or not.
  131329. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  131330. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  131331. */
  131332. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  131333. /**
  131334. * Unbinds the material from the mesh.
  131335. * @param activeEffect defines the effect that should be unbound from.
  131336. * @returns true if unbound, otherwise false
  131337. */
  131338. unbind(activeEffect: Effect): boolean;
  131339. /**
  131340. * Returns the texture used for refraction or null if none is used.
  131341. * @param scene defines the scene the material belongs to.
  131342. * @returns - Refraction texture if present. If no refraction texture and refraction
  131343. * is linked with transparency, returns environment texture. Otherwise, returns null.
  131344. */
  131345. private _getRefractionTexture;
  131346. /**
  131347. * Returns true if alpha blending should be disabled.
  131348. */
  131349. get disableAlphaBlending(): boolean;
  131350. /**
  131351. * Fills the list of render target textures.
  131352. * @param renderTargets the list of render targets to update
  131353. */
  131354. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  131355. /**
  131356. * Checks to see if a texture is used in the material.
  131357. * @param texture - Base texture to use.
  131358. * @returns - Boolean specifying if a texture is used in the material.
  131359. */
  131360. hasTexture(texture: BaseTexture): boolean;
  131361. /**
  131362. * Gets a boolean indicating that current material needs to register RTT
  131363. * @returns true if this uses a render target otherwise false.
  131364. */
  131365. hasRenderTargetTextures(): boolean;
  131366. /**
  131367. * Returns an array of the actively used textures.
  131368. * @param activeTextures Array of BaseTextures
  131369. */
  131370. getActiveTextures(activeTextures: BaseTexture[]): void;
  131371. /**
  131372. * Returns the animatable textures.
  131373. * @param animatables Array of animatable textures.
  131374. */
  131375. getAnimatables(animatables: IAnimatable[]): void;
  131376. /**
  131377. * Disposes the resources of the material.
  131378. * @param forceDisposeTextures - Forces the disposal of all textures.
  131379. */
  131380. dispose(forceDisposeTextures?: boolean): void;
  131381. /**
  131382. * Get the current class name of the texture useful for serialization or dynamic coding.
  131383. * @returns "PBRSubSurfaceConfiguration"
  131384. */
  131385. getClassName(): string;
  131386. /**
  131387. * Add fallbacks to the effect fallbacks list.
  131388. * @param defines defines the Base texture to use.
  131389. * @param fallbacks defines the current fallback list.
  131390. * @param currentRank defines the current fallback rank.
  131391. * @returns the new fallback rank.
  131392. */
  131393. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131394. /**
  131395. * Add the required uniforms to the current list.
  131396. * @param uniforms defines the current uniform list.
  131397. */
  131398. static AddUniforms(uniforms: string[]): void;
  131399. /**
  131400. * Add the required samplers to the current list.
  131401. * @param samplers defines the current sampler list.
  131402. */
  131403. static AddSamplers(samplers: string[]): void;
  131404. /**
  131405. * Add the required uniforms to the current buffer.
  131406. * @param uniformBuffer defines the current uniform buffer.
  131407. */
  131408. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131409. /**
  131410. * Makes a duplicate of the current configuration into another one.
  131411. * @param configuration define the config where to copy the info
  131412. */
  131413. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  131414. /**
  131415. * Serializes this Sub Surface configuration.
  131416. * @returns - An object with the serialized config.
  131417. */
  131418. serialize(): any;
  131419. /**
  131420. * Parses a anisotropy Configuration from a serialized object.
  131421. * @param source - Serialized object.
  131422. * @param scene Defines the scene we are parsing for
  131423. * @param rootUrl Defines the rootUrl to load from
  131424. */
  131425. parse(source: any, scene: Scene, rootUrl: string): void;
  131426. }
  131427. }
  131428. declare module BABYLON {
  131429. /** @hidden */
  131430. export var pbrFragmentDeclaration: {
  131431. name: string;
  131432. shader: string;
  131433. };
  131434. }
  131435. declare module BABYLON {
  131436. /** @hidden */
  131437. export var pbrUboDeclaration: {
  131438. name: string;
  131439. shader: string;
  131440. };
  131441. }
  131442. declare module BABYLON {
  131443. /** @hidden */
  131444. export var pbrFragmentExtraDeclaration: {
  131445. name: string;
  131446. shader: string;
  131447. };
  131448. }
  131449. declare module BABYLON {
  131450. /** @hidden */
  131451. export var pbrFragmentSamplersDeclaration: {
  131452. name: string;
  131453. shader: string;
  131454. };
  131455. }
  131456. declare module BABYLON {
  131457. /** @hidden */
  131458. export var importanceSampling: {
  131459. name: string;
  131460. shader: string;
  131461. };
  131462. }
  131463. declare module BABYLON {
  131464. /** @hidden */
  131465. export var pbrHelperFunctions: {
  131466. name: string;
  131467. shader: string;
  131468. };
  131469. }
  131470. declare module BABYLON {
  131471. /** @hidden */
  131472. export var harmonicsFunctions: {
  131473. name: string;
  131474. shader: string;
  131475. };
  131476. }
  131477. declare module BABYLON {
  131478. /** @hidden */
  131479. export var pbrDirectLightingSetupFunctions: {
  131480. name: string;
  131481. shader: string;
  131482. };
  131483. }
  131484. declare module BABYLON {
  131485. /** @hidden */
  131486. export var pbrDirectLightingFalloffFunctions: {
  131487. name: string;
  131488. shader: string;
  131489. };
  131490. }
  131491. declare module BABYLON {
  131492. /** @hidden */
  131493. export var pbrBRDFFunctions: {
  131494. name: string;
  131495. shader: string;
  131496. };
  131497. }
  131498. declare module BABYLON {
  131499. /** @hidden */
  131500. export var hdrFilteringFunctions: {
  131501. name: string;
  131502. shader: string;
  131503. };
  131504. }
  131505. declare module BABYLON {
  131506. /** @hidden */
  131507. export var pbrDirectLightingFunctions: {
  131508. name: string;
  131509. shader: string;
  131510. };
  131511. }
  131512. declare module BABYLON {
  131513. /** @hidden */
  131514. export var pbrIBLFunctions: {
  131515. name: string;
  131516. shader: string;
  131517. };
  131518. }
  131519. declare module BABYLON {
  131520. /** @hidden */
  131521. export var pbrBlockAlbedoOpacity: {
  131522. name: string;
  131523. shader: string;
  131524. };
  131525. }
  131526. declare module BABYLON {
  131527. /** @hidden */
  131528. export var pbrBlockReflectivity: {
  131529. name: string;
  131530. shader: string;
  131531. };
  131532. }
  131533. declare module BABYLON {
  131534. /** @hidden */
  131535. export var pbrBlockAmbientOcclusion: {
  131536. name: string;
  131537. shader: string;
  131538. };
  131539. }
  131540. declare module BABYLON {
  131541. /** @hidden */
  131542. export var pbrBlockAlphaFresnel: {
  131543. name: string;
  131544. shader: string;
  131545. };
  131546. }
  131547. declare module BABYLON {
  131548. /** @hidden */
  131549. export var pbrBlockAnisotropic: {
  131550. name: string;
  131551. shader: string;
  131552. };
  131553. }
  131554. declare module BABYLON {
  131555. /** @hidden */
  131556. export var pbrBlockReflection: {
  131557. name: string;
  131558. shader: string;
  131559. };
  131560. }
  131561. declare module BABYLON {
  131562. /** @hidden */
  131563. export var pbrBlockSheen: {
  131564. name: string;
  131565. shader: string;
  131566. };
  131567. }
  131568. declare module BABYLON {
  131569. /** @hidden */
  131570. export var pbrBlockClearcoat: {
  131571. name: string;
  131572. shader: string;
  131573. };
  131574. }
  131575. declare module BABYLON {
  131576. /** @hidden */
  131577. export var pbrBlockSubSurface: {
  131578. name: string;
  131579. shader: string;
  131580. };
  131581. }
  131582. declare module BABYLON {
  131583. /** @hidden */
  131584. export var pbrBlockNormalGeometric: {
  131585. name: string;
  131586. shader: string;
  131587. };
  131588. }
  131589. declare module BABYLON {
  131590. /** @hidden */
  131591. export var pbrBlockNormalFinal: {
  131592. name: string;
  131593. shader: string;
  131594. };
  131595. }
  131596. declare module BABYLON {
  131597. /** @hidden */
  131598. export var pbrBlockGeometryInfo: {
  131599. name: string;
  131600. shader: string;
  131601. };
  131602. }
  131603. declare module BABYLON {
  131604. /** @hidden */
  131605. export var pbrBlockReflectance0: {
  131606. name: string;
  131607. shader: string;
  131608. };
  131609. }
  131610. declare module BABYLON {
  131611. /** @hidden */
  131612. export var pbrBlockReflectance: {
  131613. name: string;
  131614. shader: string;
  131615. };
  131616. }
  131617. declare module BABYLON {
  131618. /** @hidden */
  131619. export var pbrBlockDirectLighting: {
  131620. name: string;
  131621. shader: string;
  131622. };
  131623. }
  131624. declare module BABYLON {
  131625. /** @hidden */
  131626. export var pbrBlockFinalLitComponents: {
  131627. name: string;
  131628. shader: string;
  131629. };
  131630. }
  131631. declare module BABYLON {
  131632. /** @hidden */
  131633. export var pbrBlockFinalUnlitComponents: {
  131634. name: string;
  131635. shader: string;
  131636. };
  131637. }
  131638. declare module BABYLON {
  131639. /** @hidden */
  131640. export var pbrBlockFinalColorComposition: {
  131641. name: string;
  131642. shader: string;
  131643. };
  131644. }
  131645. declare module BABYLON {
  131646. /** @hidden */
  131647. export var pbrBlockImageProcessing: {
  131648. name: string;
  131649. shader: string;
  131650. };
  131651. }
  131652. declare module BABYLON {
  131653. /** @hidden */
  131654. export var pbrDebug: {
  131655. name: string;
  131656. shader: string;
  131657. };
  131658. }
  131659. declare module BABYLON {
  131660. /** @hidden */
  131661. export var pbrPixelShader: {
  131662. name: string;
  131663. shader: string;
  131664. };
  131665. }
  131666. declare module BABYLON {
  131667. /** @hidden */
  131668. export var pbrVertexDeclaration: {
  131669. name: string;
  131670. shader: string;
  131671. };
  131672. }
  131673. declare module BABYLON {
  131674. /** @hidden */
  131675. export var pbrVertexShader: {
  131676. name: string;
  131677. shader: string;
  131678. };
  131679. }
  131680. declare module BABYLON {
  131681. /**
  131682. * Manages the defines for the PBR Material.
  131683. * @hidden
  131684. */
  131685. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  131686. PBR: boolean;
  131687. NUM_SAMPLES: string;
  131688. REALTIME_FILTERING: boolean;
  131689. MAINUV1: boolean;
  131690. MAINUV2: boolean;
  131691. UV1: boolean;
  131692. UV2: boolean;
  131693. ALBEDO: boolean;
  131694. GAMMAALBEDO: boolean;
  131695. ALBEDODIRECTUV: number;
  131696. VERTEXCOLOR: boolean;
  131697. AMBIENT: boolean;
  131698. AMBIENTDIRECTUV: number;
  131699. AMBIENTINGRAYSCALE: boolean;
  131700. OPACITY: boolean;
  131701. VERTEXALPHA: boolean;
  131702. OPACITYDIRECTUV: number;
  131703. OPACITYRGB: boolean;
  131704. ALPHATEST: boolean;
  131705. DEPTHPREPASS: boolean;
  131706. ALPHABLEND: boolean;
  131707. ALPHAFROMALBEDO: boolean;
  131708. ALPHATESTVALUE: string;
  131709. SPECULAROVERALPHA: boolean;
  131710. RADIANCEOVERALPHA: boolean;
  131711. ALPHAFRESNEL: boolean;
  131712. LINEARALPHAFRESNEL: boolean;
  131713. PREMULTIPLYALPHA: boolean;
  131714. EMISSIVE: boolean;
  131715. EMISSIVEDIRECTUV: number;
  131716. REFLECTIVITY: boolean;
  131717. REFLECTIVITYDIRECTUV: number;
  131718. SPECULARTERM: boolean;
  131719. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  131720. MICROSURFACEAUTOMATIC: boolean;
  131721. LODBASEDMICROSFURACE: boolean;
  131722. MICROSURFACEMAP: boolean;
  131723. MICROSURFACEMAPDIRECTUV: number;
  131724. METALLICWORKFLOW: boolean;
  131725. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  131726. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  131727. METALLNESSSTOREINMETALMAPBLUE: boolean;
  131728. AOSTOREINMETALMAPRED: boolean;
  131729. METALLIC_REFLECTANCE: boolean;
  131730. METALLIC_REFLECTANCEDIRECTUV: number;
  131731. ENVIRONMENTBRDF: boolean;
  131732. ENVIRONMENTBRDF_RGBD: boolean;
  131733. NORMAL: boolean;
  131734. TANGENT: boolean;
  131735. BUMP: boolean;
  131736. BUMPDIRECTUV: number;
  131737. OBJECTSPACE_NORMALMAP: boolean;
  131738. PARALLAX: boolean;
  131739. PARALLAXOCCLUSION: boolean;
  131740. NORMALXYSCALE: boolean;
  131741. LIGHTMAP: boolean;
  131742. LIGHTMAPDIRECTUV: number;
  131743. USELIGHTMAPASSHADOWMAP: boolean;
  131744. GAMMALIGHTMAP: boolean;
  131745. RGBDLIGHTMAP: boolean;
  131746. REFLECTION: boolean;
  131747. REFLECTIONMAP_3D: boolean;
  131748. REFLECTIONMAP_SPHERICAL: boolean;
  131749. REFLECTIONMAP_PLANAR: boolean;
  131750. REFLECTIONMAP_CUBIC: boolean;
  131751. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  131752. REFLECTIONMAP_PROJECTION: boolean;
  131753. REFLECTIONMAP_SKYBOX: boolean;
  131754. REFLECTIONMAP_EXPLICIT: boolean;
  131755. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  131756. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  131757. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  131758. INVERTCUBICMAP: boolean;
  131759. USESPHERICALFROMREFLECTIONMAP: boolean;
  131760. USEIRRADIANCEMAP: boolean;
  131761. SPHERICAL_HARMONICS: boolean;
  131762. USESPHERICALINVERTEX: boolean;
  131763. REFLECTIONMAP_OPPOSITEZ: boolean;
  131764. LODINREFLECTIONALPHA: boolean;
  131765. GAMMAREFLECTION: boolean;
  131766. RGBDREFLECTION: boolean;
  131767. LINEARSPECULARREFLECTION: boolean;
  131768. RADIANCEOCCLUSION: boolean;
  131769. HORIZONOCCLUSION: boolean;
  131770. INSTANCES: boolean;
  131771. THIN_INSTANCES: boolean;
  131772. NUM_BONE_INFLUENCERS: number;
  131773. BonesPerMesh: number;
  131774. BONETEXTURE: boolean;
  131775. NONUNIFORMSCALING: boolean;
  131776. MORPHTARGETS: boolean;
  131777. MORPHTARGETS_NORMAL: boolean;
  131778. MORPHTARGETS_TANGENT: boolean;
  131779. MORPHTARGETS_UV: boolean;
  131780. NUM_MORPH_INFLUENCERS: number;
  131781. IMAGEPROCESSING: boolean;
  131782. VIGNETTE: boolean;
  131783. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131784. VIGNETTEBLENDMODEOPAQUE: boolean;
  131785. TONEMAPPING: boolean;
  131786. TONEMAPPING_ACES: boolean;
  131787. CONTRAST: boolean;
  131788. COLORCURVES: boolean;
  131789. COLORGRADING: boolean;
  131790. COLORGRADING3D: boolean;
  131791. SAMPLER3DGREENDEPTH: boolean;
  131792. SAMPLER3DBGRMAP: boolean;
  131793. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131794. EXPOSURE: boolean;
  131795. MULTIVIEW: boolean;
  131796. USEPHYSICALLIGHTFALLOFF: boolean;
  131797. USEGLTFLIGHTFALLOFF: boolean;
  131798. TWOSIDEDLIGHTING: boolean;
  131799. SHADOWFLOAT: boolean;
  131800. CLIPPLANE: boolean;
  131801. CLIPPLANE2: boolean;
  131802. CLIPPLANE3: boolean;
  131803. CLIPPLANE4: boolean;
  131804. CLIPPLANE5: boolean;
  131805. CLIPPLANE6: boolean;
  131806. POINTSIZE: boolean;
  131807. FOG: boolean;
  131808. LOGARITHMICDEPTH: boolean;
  131809. FORCENORMALFORWARD: boolean;
  131810. SPECULARAA: boolean;
  131811. CLEARCOAT: boolean;
  131812. CLEARCOAT_DEFAULTIOR: boolean;
  131813. CLEARCOAT_TEXTURE: boolean;
  131814. CLEARCOAT_TEXTUREDIRECTUV: number;
  131815. CLEARCOAT_BUMP: boolean;
  131816. CLEARCOAT_BUMPDIRECTUV: number;
  131817. CLEARCOAT_TINT: boolean;
  131818. CLEARCOAT_TINT_TEXTURE: boolean;
  131819. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131820. ANISOTROPIC: boolean;
  131821. ANISOTROPIC_TEXTURE: boolean;
  131822. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131823. BRDF_V_HEIGHT_CORRELATED: boolean;
  131824. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131825. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131826. SHEEN: boolean;
  131827. SHEEN_TEXTURE: boolean;
  131828. SHEEN_TEXTUREDIRECTUV: number;
  131829. SHEEN_LINKWITHALBEDO: boolean;
  131830. SHEEN_ROUGHNESS: boolean;
  131831. SHEEN_ALBEDOSCALING: boolean;
  131832. SUBSURFACE: boolean;
  131833. SS_REFRACTION: boolean;
  131834. SS_TRANSLUCENCY: boolean;
  131835. SS_SCATERRING: boolean;
  131836. SS_THICKNESSANDMASK_TEXTURE: boolean;
  131837. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  131838. SS_REFRACTIONMAP_3D: boolean;
  131839. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  131840. SS_LODINREFRACTIONALPHA: boolean;
  131841. SS_GAMMAREFRACTION: boolean;
  131842. SS_RGBDREFRACTION: boolean;
  131843. SS_LINEARSPECULARREFRACTION: boolean;
  131844. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  131845. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  131846. UNLIT: boolean;
  131847. DEBUGMODE: number;
  131848. /**
  131849. * Initializes the PBR Material defines.
  131850. */
  131851. constructor();
  131852. /**
  131853. * Resets the PBR Material defines.
  131854. */
  131855. reset(): void;
  131856. }
  131857. /**
  131858. * The Physically based material base class of BJS.
  131859. *
  131860. * This offers the main features of a standard PBR material.
  131861. * For more information, please refer to the documentation :
  131862. * https://doc.babylonjs.com/how_to/physically_based_rendering
  131863. */
  131864. export abstract class PBRBaseMaterial extends PushMaterial {
  131865. /**
  131866. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  131867. */
  131868. static readonly PBRMATERIAL_OPAQUE: number;
  131869. /**
  131870. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  131871. */
  131872. static readonly PBRMATERIAL_ALPHATEST: number;
  131873. /**
  131874. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  131875. */
  131876. static readonly PBRMATERIAL_ALPHABLEND: number;
  131877. /**
  131878. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  131879. * They are also discarded below the alpha cutoff threshold to improve performances.
  131880. */
  131881. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  131882. /**
  131883. * Defines the default value of how much AO map is occluding the analytical lights
  131884. * (point spot...).
  131885. */
  131886. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  131887. /**
  131888. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  131889. */
  131890. static readonly LIGHTFALLOFF_PHYSICAL: number;
  131891. /**
  131892. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  131893. * to enhance interoperability with other engines.
  131894. */
  131895. static readonly LIGHTFALLOFF_GLTF: number;
  131896. /**
  131897. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  131898. * to enhance interoperability with other materials.
  131899. */
  131900. static readonly LIGHTFALLOFF_STANDARD: number;
  131901. /**
  131902. * Intensity of the direct lights e.g. the four lights available in your scene.
  131903. * This impacts both the direct diffuse and specular highlights.
  131904. */
  131905. protected _directIntensity: number;
  131906. /**
  131907. * Intensity of the emissive part of the material.
  131908. * This helps controlling the emissive effect without modifying the emissive color.
  131909. */
  131910. protected _emissiveIntensity: number;
  131911. /**
  131912. * Intensity of the environment e.g. how much the environment will light the object
  131913. * either through harmonics for rough material or through the refelction for shiny ones.
  131914. */
  131915. protected _environmentIntensity: number;
  131916. /**
  131917. * This is a special control allowing the reduction of the specular highlights coming from the
  131918. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  131919. */
  131920. protected _specularIntensity: number;
  131921. /**
  131922. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  131923. */
  131924. private _lightingInfos;
  131925. /**
  131926. * Debug Control allowing disabling the bump map on this material.
  131927. */
  131928. protected _disableBumpMap: boolean;
  131929. /**
  131930. * AKA Diffuse Texture in standard nomenclature.
  131931. */
  131932. protected _albedoTexture: Nullable<BaseTexture>;
  131933. /**
  131934. * AKA Occlusion Texture in other nomenclature.
  131935. */
  131936. protected _ambientTexture: Nullable<BaseTexture>;
  131937. /**
  131938. * AKA Occlusion Texture Intensity in other nomenclature.
  131939. */
  131940. protected _ambientTextureStrength: number;
  131941. /**
  131942. * Defines how much the AO map is occluding the analytical lights (point spot...).
  131943. * 1 means it completely occludes it
  131944. * 0 mean it has no impact
  131945. */
  131946. protected _ambientTextureImpactOnAnalyticalLights: number;
  131947. /**
  131948. * Stores the alpha values in a texture.
  131949. */
  131950. protected _opacityTexture: Nullable<BaseTexture>;
  131951. /**
  131952. * Stores the reflection values in a texture.
  131953. */
  131954. protected _reflectionTexture: Nullable<BaseTexture>;
  131955. /**
  131956. * Stores the emissive values in a texture.
  131957. */
  131958. protected _emissiveTexture: Nullable<BaseTexture>;
  131959. /**
  131960. * AKA Specular texture in other nomenclature.
  131961. */
  131962. protected _reflectivityTexture: Nullable<BaseTexture>;
  131963. /**
  131964. * Used to switch from specular/glossiness to metallic/roughness workflow.
  131965. */
  131966. protected _metallicTexture: Nullable<BaseTexture>;
  131967. /**
  131968. * Specifies the metallic scalar of the metallic/roughness workflow.
  131969. * Can also be used to scale the metalness values of the metallic texture.
  131970. */
  131971. protected _metallic: Nullable<number>;
  131972. /**
  131973. * Specifies the roughness scalar of the metallic/roughness workflow.
  131974. * Can also be used to scale the roughness values of the metallic texture.
  131975. */
  131976. protected _roughness: Nullable<number>;
  131977. /**
  131978. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  131979. * By default the indexOfrefraction is used to compute F0;
  131980. *
  131981. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  131982. *
  131983. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  131984. * F90 = metallicReflectanceColor;
  131985. */
  131986. protected _metallicF0Factor: number;
  131987. /**
  131988. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  131989. * By default the F90 is always 1;
  131990. *
  131991. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  131992. *
  131993. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  131994. * F90 = metallicReflectanceColor;
  131995. */
  131996. protected _metallicReflectanceColor: Color3;
  131997. /**
  131998. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  131999. * This is multiply against the scalar values defined in the material.
  132000. */
  132001. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  132002. /**
  132003. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132004. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132005. */
  132006. protected _microSurfaceTexture: Nullable<BaseTexture>;
  132007. /**
  132008. * Stores surface normal data used to displace a mesh in a texture.
  132009. */
  132010. protected _bumpTexture: Nullable<BaseTexture>;
  132011. /**
  132012. * Stores the pre-calculated light information of a mesh in a texture.
  132013. */
  132014. protected _lightmapTexture: Nullable<BaseTexture>;
  132015. /**
  132016. * The color of a material in ambient lighting.
  132017. */
  132018. protected _ambientColor: Color3;
  132019. /**
  132020. * AKA Diffuse Color in other nomenclature.
  132021. */
  132022. protected _albedoColor: Color3;
  132023. /**
  132024. * AKA Specular Color in other nomenclature.
  132025. */
  132026. protected _reflectivityColor: Color3;
  132027. /**
  132028. * The color applied when light is reflected from a material.
  132029. */
  132030. protected _reflectionColor: Color3;
  132031. /**
  132032. * The color applied when light is emitted from a material.
  132033. */
  132034. protected _emissiveColor: Color3;
  132035. /**
  132036. * AKA Glossiness in other nomenclature.
  132037. */
  132038. protected _microSurface: number;
  132039. /**
  132040. * Specifies that the material will use the light map as a show map.
  132041. */
  132042. protected _useLightmapAsShadowmap: boolean;
  132043. /**
  132044. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  132045. * makes the reflect vector face the model (under horizon).
  132046. */
  132047. protected _useHorizonOcclusion: boolean;
  132048. /**
  132049. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  132050. * too much the area relying on ambient texture to define their ambient occlusion.
  132051. */
  132052. protected _useRadianceOcclusion: boolean;
  132053. /**
  132054. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  132055. */
  132056. protected _useAlphaFromAlbedoTexture: boolean;
  132057. /**
  132058. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  132059. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  132060. */
  132061. protected _useSpecularOverAlpha: boolean;
  132062. /**
  132063. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  132064. */
  132065. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  132066. /**
  132067. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  132068. */
  132069. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  132070. /**
  132071. * Specifies if the metallic texture contains the roughness information in its green channel.
  132072. */
  132073. protected _useRoughnessFromMetallicTextureGreen: boolean;
  132074. /**
  132075. * Specifies if the metallic texture contains the metallness information in its blue channel.
  132076. */
  132077. protected _useMetallnessFromMetallicTextureBlue: boolean;
  132078. /**
  132079. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  132080. */
  132081. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  132082. /**
  132083. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  132084. */
  132085. protected _useAmbientInGrayScale: boolean;
  132086. /**
  132087. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  132088. * The material will try to infer what glossiness each pixel should be.
  132089. */
  132090. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  132091. /**
  132092. * Defines the falloff type used in this material.
  132093. * It by default is Physical.
  132094. */
  132095. protected _lightFalloff: number;
  132096. /**
  132097. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  132098. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  132099. */
  132100. protected _useRadianceOverAlpha: boolean;
  132101. /**
  132102. * Allows using an object space normal map (instead of tangent space).
  132103. */
  132104. protected _useObjectSpaceNormalMap: boolean;
  132105. /**
  132106. * Allows using the bump map in parallax mode.
  132107. */
  132108. protected _useParallax: boolean;
  132109. /**
  132110. * Allows using the bump map in parallax occlusion mode.
  132111. */
  132112. protected _useParallaxOcclusion: boolean;
  132113. /**
  132114. * Controls the scale bias of the parallax mode.
  132115. */
  132116. protected _parallaxScaleBias: number;
  132117. /**
  132118. * If sets to true, disables all the lights affecting the material.
  132119. */
  132120. protected _disableLighting: boolean;
  132121. /**
  132122. * Number of Simultaneous lights allowed on the material.
  132123. */
  132124. protected _maxSimultaneousLights: number;
  132125. /**
  132126. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132127. */
  132128. protected _invertNormalMapX: boolean;
  132129. /**
  132130. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132131. */
  132132. protected _invertNormalMapY: boolean;
  132133. /**
  132134. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132135. */
  132136. protected _twoSidedLighting: boolean;
  132137. /**
  132138. * Defines the alpha limits in alpha test mode.
  132139. */
  132140. protected _alphaCutOff: number;
  132141. /**
  132142. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  132143. */
  132144. protected _forceAlphaTest: boolean;
  132145. /**
  132146. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132147. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  132148. */
  132149. protected _useAlphaFresnel: boolean;
  132150. /**
  132151. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132152. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  132153. */
  132154. protected _useLinearAlphaFresnel: boolean;
  132155. /**
  132156. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  132157. * from cos thetav and roughness:
  132158. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  132159. */
  132160. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  132161. /**
  132162. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  132163. */
  132164. protected _forceIrradianceInFragment: boolean;
  132165. private _realTimeFiltering;
  132166. /**
  132167. * Enables realtime filtering on the texture.
  132168. */
  132169. get realTimeFiltering(): boolean;
  132170. set realTimeFiltering(b: boolean);
  132171. private _realTimeFilteringQuality;
  132172. /**
  132173. * Quality switch for realtime filtering
  132174. */
  132175. get realTimeFilteringQuality(): number;
  132176. set realTimeFilteringQuality(n: number);
  132177. /**
  132178. * Force normal to face away from face.
  132179. */
  132180. protected _forceNormalForward: boolean;
  132181. /**
  132182. * Enables specular anti aliasing in the PBR shader.
  132183. * It will both interacts on the Geometry for analytical and IBL lighting.
  132184. * It also prefilter the roughness map based on the bump values.
  132185. */
  132186. protected _enableSpecularAntiAliasing: boolean;
  132187. /**
  132188. * Default configuration related to image processing available in the PBR Material.
  132189. */
  132190. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  132191. /**
  132192. * Keep track of the image processing observer to allow dispose and replace.
  132193. */
  132194. private _imageProcessingObserver;
  132195. /**
  132196. * Attaches a new image processing configuration to the PBR Material.
  132197. * @param configuration
  132198. */
  132199. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  132200. /**
  132201. * Stores the available render targets.
  132202. */
  132203. private _renderTargets;
  132204. /**
  132205. * Sets the global ambient color for the material used in lighting calculations.
  132206. */
  132207. private _globalAmbientColor;
  132208. /**
  132209. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  132210. */
  132211. private _useLogarithmicDepth;
  132212. /**
  132213. * If set to true, no lighting calculations will be applied.
  132214. */
  132215. private _unlit;
  132216. private _debugMode;
  132217. /**
  132218. * @hidden
  132219. * This is reserved for the inspector.
  132220. * Defines the material debug mode.
  132221. * It helps seeing only some components of the material while troubleshooting.
  132222. */
  132223. debugMode: number;
  132224. /**
  132225. * @hidden
  132226. * This is reserved for the inspector.
  132227. * Specify from where on screen the debug mode should start.
  132228. * The value goes from -1 (full screen) to 1 (not visible)
  132229. * It helps with side by side comparison against the final render
  132230. * This defaults to -1
  132231. */
  132232. private debugLimit;
  132233. /**
  132234. * @hidden
  132235. * This is reserved for the inspector.
  132236. * As the default viewing range might not be enough (if the ambient is really small for instance)
  132237. * You can use the factor to better multiply the final value.
  132238. */
  132239. private debugFactor;
  132240. /**
  132241. * Defines the clear coat layer parameters for the material.
  132242. */
  132243. readonly clearCoat: PBRClearCoatConfiguration;
  132244. /**
  132245. * Defines the anisotropic parameters for the material.
  132246. */
  132247. readonly anisotropy: PBRAnisotropicConfiguration;
  132248. /**
  132249. * Defines the BRDF parameters for the material.
  132250. */
  132251. readonly brdf: PBRBRDFConfiguration;
  132252. /**
  132253. * Defines the Sheen parameters for the material.
  132254. */
  132255. readonly sheen: PBRSheenConfiguration;
  132256. /**
  132257. * Defines the SubSurface parameters for the material.
  132258. */
  132259. readonly subSurface: PBRSubSurfaceConfiguration;
  132260. protected _rebuildInParallel: boolean;
  132261. /**
  132262. * Instantiates a new PBRMaterial instance.
  132263. *
  132264. * @param name The material name
  132265. * @param scene The scene the material will be use in.
  132266. */
  132267. constructor(name: string, scene: Scene);
  132268. /**
  132269. * Gets a boolean indicating that current material needs to register RTT
  132270. */
  132271. get hasRenderTargetTextures(): boolean;
  132272. /**
  132273. * Gets the name of the material class.
  132274. */
  132275. getClassName(): string;
  132276. /**
  132277. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132278. */
  132279. get useLogarithmicDepth(): boolean;
  132280. /**
  132281. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132282. */
  132283. set useLogarithmicDepth(value: boolean);
  132284. /**
  132285. * Returns true if alpha blending should be disabled.
  132286. */
  132287. protected get _disableAlphaBlending(): boolean;
  132288. /**
  132289. * Specifies whether or not this material should be rendered in alpha blend mode.
  132290. */
  132291. needAlphaBlending(): boolean;
  132292. /**
  132293. * Specifies whether or not this material should be rendered in alpha test mode.
  132294. */
  132295. needAlphaTesting(): boolean;
  132296. /**
  132297. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  132298. */
  132299. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  132300. /**
  132301. * Gets the texture used for the alpha test.
  132302. */
  132303. getAlphaTestTexture(): Nullable<BaseTexture>;
  132304. /**
  132305. * Specifies that the submesh is ready to be used.
  132306. * @param mesh - BJS mesh.
  132307. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  132308. * @param useInstances - Specifies that instances should be used.
  132309. * @returns - boolean indicating that the submesh is ready or not.
  132310. */
  132311. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132312. /**
  132313. * Specifies if the material uses metallic roughness workflow.
  132314. * @returns boolean specifiying if the material uses metallic roughness workflow.
  132315. */
  132316. isMetallicWorkflow(): boolean;
  132317. private _prepareEffect;
  132318. private _prepareDefines;
  132319. /**
  132320. * Force shader compilation
  132321. */
  132322. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  132323. /**
  132324. * Initializes the uniform buffer layout for the shader.
  132325. */
  132326. buildUniformLayout(): void;
  132327. /**
  132328. * Unbinds the material from the mesh
  132329. */
  132330. unbind(): void;
  132331. /**
  132332. * Binds the submesh data.
  132333. * @param world - The world matrix.
  132334. * @param mesh - The BJS mesh.
  132335. * @param subMesh - A submesh of the BJS mesh.
  132336. */
  132337. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132338. /**
  132339. * Returns the animatable textures.
  132340. * @returns - Array of animatable textures.
  132341. */
  132342. getAnimatables(): IAnimatable[];
  132343. /**
  132344. * Returns the texture used for reflections.
  132345. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  132346. */
  132347. private _getReflectionTexture;
  132348. /**
  132349. * Returns an array of the actively used textures.
  132350. * @returns - Array of BaseTextures
  132351. */
  132352. getActiveTextures(): BaseTexture[];
  132353. /**
  132354. * Checks to see if a texture is used in the material.
  132355. * @param texture - Base texture to use.
  132356. * @returns - Boolean specifying if a texture is used in the material.
  132357. */
  132358. hasTexture(texture: BaseTexture): boolean;
  132359. /**
  132360. * Disposes the resources of the material.
  132361. * @param forceDisposeEffect - Forces the disposal of effects.
  132362. * @param forceDisposeTextures - Forces the disposal of all textures.
  132363. */
  132364. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  132365. }
  132366. }
  132367. declare module BABYLON {
  132368. /**
  132369. * The Physically based material of BJS.
  132370. *
  132371. * This offers the main features of a standard PBR material.
  132372. * For more information, please refer to the documentation :
  132373. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132374. */
  132375. export class PBRMaterial extends PBRBaseMaterial {
  132376. /**
  132377. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132378. */
  132379. static readonly PBRMATERIAL_OPAQUE: number;
  132380. /**
  132381. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132382. */
  132383. static readonly PBRMATERIAL_ALPHATEST: number;
  132384. /**
  132385. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132386. */
  132387. static readonly PBRMATERIAL_ALPHABLEND: number;
  132388. /**
  132389. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132390. * They are also discarded below the alpha cutoff threshold to improve performances.
  132391. */
  132392. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132393. /**
  132394. * Defines the default value of how much AO map is occluding the analytical lights
  132395. * (point spot...).
  132396. */
  132397. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132398. /**
  132399. * Intensity of the direct lights e.g. the four lights available in your scene.
  132400. * This impacts both the direct diffuse and specular highlights.
  132401. */
  132402. directIntensity: number;
  132403. /**
  132404. * Intensity of the emissive part of the material.
  132405. * This helps controlling the emissive effect without modifying the emissive color.
  132406. */
  132407. emissiveIntensity: number;
  132408. /**
  132409. * Intensity of the environment e.g. how much the environment will light the object
  132410. * either through harmonics for rough material or through the refelction for shiny ones.
  132411. */
  132412. environmentIntensity: number;
  132413. /**
  132414. * This is a special control allowing the reduction of the specular highlights coming from the
  132415. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132416. */
  132417. specularIntensity: number;
  132418. /**
  132419. * Debug Control allowing disabling the bump map on this material.
  132420. */
  132421. disableBumpMap: boolean;
  132422. /**
  132423. * AKA Diffuse Texture in standard nomenclature.
  132424. */
  132425. albedoTexture: BaseTexture;
  132426. /**
  132427. * AKA Occlusion Texture in other nomenclature.
  132428. */
  132429. ambientTexture: BaseTexture;
  132430. /**
  132431. * AKA Occlusion Texture Intensity in other nomenclature.
  132432. */
  132433. ambientTextureStrength: number;
  132434. /**
  132435. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132436. * 1 means it completely occludes it
  132437. * 0 mean it has no impact
  132438. */
  132439. ambientTextureImpactOnAnalyticalLights: number;
  132440. /**
  132441. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  132442. */
  132443. opacityTexture: BaseTexture;
  132444. /**
  132445. * Stores the reflection values in a texture.
  132446. */
  132447. reflectionTexture: Nullable<BaseTexture>;
  132448. /**
  132449. * Stores the emissive values in a texture.
  132450. */
  132451. emissiveTexture: BaseTexture;
  132452. /**
  132453. * AKA Specular texture in other nomenclature.
  132454. */
  132455. reflectivityTexture: BaseTexture;
  132456. /**
  132457. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132458. */
  132459. metallicTexture: BaseTexture;
  132460. /**
  132461. * Specifies the metallic scalar of the metallic/roughness workflow.
  132462. * Can also be used to scale the metalness values of the metallic texture.
  132463. */
  132464. metallic: Nullable<number>;
  132465. /**
  132466. * Specifies the roughness scalar of the metallic/roughness workflow.
  132467. * Can also be used to scale the roughness values of the metallic texture.
  132468. */
  132469. roughness: Nullable<number>;
  132470. /**
  132471. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132472. * By default the indexOfrefraction is used to compute F0;
  132473. *
  132474. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132475. *
  132476. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132477. * F90 = metallicReflectanceColor;
  132478. */
  132479. metallicF0Factor: number;
  132480. /**
  132481. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132482. * By default the F90 is always 1;
  132483. *
  132484. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132485. *
  132486. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132487. * F90 = metallicReflectanceColor;
  132488. */
  132489. metallicReflectanceColor: Color3;
  132490. /**
  132491. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132492. * This is multiply against the scalar values defined in the material.
  132493. */
  132494. metallicReflectanceTexture: Nullable<BaseTexture>;
  132495. /**
  132496. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132497. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132498. */
  132499. microSurfaceTexture: BaseTexture;
  132500. /**
  132501. * Stores surface normal data used to displace a mesh in a texture.
  132502. */
  132503. bumpTexture: BaseTexture;
  132504. /**
  132505. * Stores the pre-calculated light information of a mesh in a texture.
  132506. */
  132507. lightmapTexture: BaseTexture;
  132508. /**
  132509. * Stores the refracted light information in a texture.
  132510. */
  132511. get refractionTexture(): Nullable<BaseTexture>;
  132512. set refractionTexture(value: Nullable<BaseTexture>);
  132513. /**
  132514. * The color of a material in ambient lighting.
  132515. */
  132516. ambientColor: Color3;
  132517. /**
  132518. * AKA Diffuse Color in other nomenclature.
  132519. */
  132520. albedoColor: Color3;
  132521. /**
  132522. * AKA Specular Color in other nomenclature.
  132523. */
  132524. reflectivityColor: Color3;
  132525. /**
  132526. * The color reflected from the material.
  132527. */
  132528. reflectionColor: Color3;
  132529. /**
  132530. * The color emitted from the material.
  132531. */
  132532. emissiveColor: Color3;
  132533. /**
  132534. * AKA Glossiness in other nomenclature.
  132535. */
  132536. microSurface: number;
  132537. /**
  132538. * Index of refraction of the material base layer.
  132539. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132540. *
  132541. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132542. *
  132543. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132544. */
  132545. get indexOfRefraction(): number;
  132546. set indexOfRefraction(value: number);
  132547. /**
  132548. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132549. */
  132550. get invertRefractionY(): boolean;
  132551. set invertRefractionY(value: boolean);
  132552. /**
  132553. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132554. * Materials half opaque for instance using refraction could benefit from this control.
  132555. */
  132556. get linkRefractionWithTransparency(): boolean;
  132557. set linkRefractionWithTransparency(value: boolean);
  132558. /**
  132559. * If true, the light map contains occlusion information instead of lighting info.
  132560. */
  132561. useLightmapAsShadowmap: boolean;
  132562. /**
  132563. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  132564. */
  132565. useAlphaFromAlbedoTexture: boolean;
  132566. /**
  132567. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  132568. */
  132569. forceAlphaTest: boolean;
  132570. /**
  132571. * Defines the alpha limits in alpha test mode.
  132572. */
  132573. alphaCutOff: number;
  132574. /**
  132575. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  132576. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  132577. */
  132578. useSpecularOverAlpha: boolean;
  132579. /**
  132580. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  132581. */
  132582. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  132583. /**
  132584. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  132585. */
  132586. useRoughnessFromMetallicTextureAlpha: boolean;
  132587. /**
  132588. * Specifies if the metallic texture contains the roughness information in its green channel.
  132589. */
  132590. useRoughnessFromMetallicTextureGreen: boolean;
  132591. /**
  132592. * Specifies if the metallic texture contains the metallness information in its blue channel.
  132593. */
  132594. useMetallnessFromMetallicTextureBlue: boolean;
  132595. /**
  132596. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  132597. */
  132598. useAmbientOcclusionFromMetallicTextureRed: boolean;
  132599. /**
  132600. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  132601. */
  132602. useAmbientInGrayScale: boolean;
  132603. /**
  132604. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  132605. * The material will try to infer what glossiness each pixel should be.
  132606. */
  132607. useAutoMicroSurfaceFromReflectivityMap: boolean;
  132608. /**
  132609. * BJS is using an harcoded light falloff based on a manually sets up range.
  132610. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132611. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132612. */
  132613. get usePhysicalLightFalloff(): boolean;
  132614. /**
  132615. * BJS is using an harcoded light falloff based on a manually sets up range.
  132616. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132617. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132618. */
  132619. set usePhysicalLightFalloff(value: boolean);
  132620. /**
  132621. * In order to support the falloff compatibility with gltf, a special mode has been added
  132622. * to reproduce the gltf light falloff.
  132623. */
  132624. get useGLTFLightFalloff(): boolean;
  132625. /**
  132626. * In order to support the falloff compatibility with gltf, a special mode has been added
  132627. * to reproduce the gltf light falloff.
  132628. */
  132629. set useGLTFLightFalloff(value: boolean);
  132630. /**
  132631. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  132632. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  132633. */
  132634. useRadianceOverAlpha: boolean;
  132635. /**
  132636. * Allows using an object space normal map (instead of tangent space).
  132637. */
  132638. useObjectSpaceNormalMap: boolean;
  132639. /**
  132640. * Allows using the bump map in parallax mode.
  132641. */
  132642. useParallax: boolean;
  132643. /**
  132644. * Allows using the bump map in parallax occlusion mode.
  132645. */
  132646. useParallaxOcclusion: boolean;
  132647. /**
  132648. * Controls the scale bias of the parallax mode.
  132649. */
  132650. parallaxScaleBias: number;
  132651. /**
  132652. * If sets to true, disables all the lights affecting the material.
  132653. */
  132654. disableLighting: boolean;
  132655. /**
  132656. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  132657. */
  132658. forceIrradianceInFragment: boolean;
  132659. /**
  132660. * Number of Simultaneous lights allowed on the material.
  132661. */
  132662. maxSimultaneousLights: number;
  132663. /**
  132664. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132665. */
  132666. invertNormalMapX: boolean;
  132667. /**
  132668. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132669. */
  132670. invertNormalMapY: boolean;
  132671. /**
  132672. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132673. */
  132674. twoSidedLighting: boolean;
  132675. /**
  132676. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132677. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  132678. */
  132679. useAlphaFresnel: boolean;
  132680. /**
  132681. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132682. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  132683. */
  132684. useLinearAlphaFresnel: boolean;
  132685. /**
  132686. * Let user defines the brdf lookup texture used for IBL.
  132687. * A default 8bit version is embedded but you could point at :
  132688. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  132689. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  132690. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  132691. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  132692. */
  132693. environmentBRDFTexture: Nullable<BaseTexture>;
  132694. /**
  132695. * Force normal to face away from face.
  132696. */
  132697. forceNormalForward: boolean;
  132698. /**
  132699. * Enables specular anti aliasing in the PBR shader.
  132700. * It will both interacts on the Geometry for analytical and IBL lighting.
  132701. * It also prefilter the roughness map based on the bump values.
  132702. */
  132703. enableSpecularAntiAliasing: boolean;
  132704. /**
  132705. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  132706. * makes the reflect vector face the model (under horizon).
  132707. */
  132708. useHorizonOcclusion: boolean;
  132709. /**
  132710. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  132711. * too much the area relying on ambient texture to define their ambient occlusion.
  132712. */
  132713. useRadianceOcclusion: boolean;
  132714. /**
  132715. * If set to true, no lighting calculations will be applied.
  132716. */
  132717. unlit: boolean;
  132718. /**
  132719. * Gets the image processing configuration used either in this material.
  132720. */
  132721. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  132722. /**
  132723. * Sets the Default image processing configuration used either in the this material.
  132724. *
  132725. * If sets to null, the scene one is in use.
  132726. */
  132727. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  132728. /**
  132729. * Gets wether the color curves effect is enabled.
  132730. */
  132731. get cameraColorCurvesEnabled(): boolean;
  132732. /**
  132733. * Sets wether the color curves effect is enabled.
  132734. */
  132735. set cameraColorCurvesEnabled(value: boolean);
  132736. /**
  132737. * Gets wether the color grading effect is enabled.
  132738. */
  132739. get cameraColorGradingEnabled(): boolean;
  132740. /**
  132741. * Gets wether the color grading effect is enabled.
  132742. */
  132743. set cameraColorGradingEnabled(value: boolean);
  132744. /**
  132745. * Gets wether tonemapping is enabled or not.
  132746. */
  132747. get cameraToneMappingEnabled(): boolean;
  132748. /**
  132749. * Sets wether tonemapping is enabled or not
  132750. */
  132751. set cameraToneMappingEnabled(value: boolean);
  132752. /**
  132753. * The camera exposure used on this material.
  132754. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132755. * This corresponds to a photographic exposure.
  132756. */
  132757. get cameraExposure(): number;
  132758. /**
  132759. * The camera exposure used on this material.
  132760. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132761. * This corresponds to a photographic exposure.
  132762. */
  132763. set cameraExposure(value: number);
  132764. /**
  132765. * Gets The camera contrast used on this material.
  132766. */
  132767. get cameraContrast(): number;
  132768. /**
  132769. * Sets The camera contrast used on this material.
  132770. */
  132771. set cameraContrast(value: number);
  132772. /**
  132773. * Gets the Color Grading 2D Lookup Texture.
  132774. */
  132775. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  132776. /**
  132777. * Sets the Color Grading 2D Lookup Texture.
  132778. */
  132779. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  132780. /**
  132781. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132782. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132783. * 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;
  132784. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132785. */
  132786. get cameraColorCurves(): Nullable<ColorCurves>;
  132787. /**
  132788. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132789. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132790. * 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;
  132791. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132792. */
  132793. set cameraColorCurves(value: Nullable<ColorCurves>);
  132794. /**
  132795. * Instantiates a new PBRMaterial instance.
  132796. *
  132797. * @param name The material name
  132798. * @param scene The scene the material will be use in.
  132799. */
  132800. constructor(name: string, scene: Scene);
  132801. /**
  132802. * Returns the name of this material class.
  132803. */
  132804. getClassName(): string;
  132805. /**
  132806. * Makes a duplicate of the current material.
  132807. * @param name - name to use for the new material.
  132808. */
  132809. clone(name: string): PBRMaterial;
  132810. /**
  132811. * Serializes this PBR Material.
  132812. * @returns - An object with the serialized material.
  132813. */
  132814. serialize(): any;
  132815. /**
  132816. * Parses a PBR Material from a serialized object.
  132817. * @param source - Serialized object.
  132818. * @param scene - BJS scene instance.
  132819. * @param rootUrl - url for the scene object
  132820. * @returns - PBRMaterial
  132821. */
  132822. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  132823. }
  132824. }
  132825. declare module BABYLON {
  132826. /**
  132827. * Direct draw surface info
  132828. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  132829. */
  132830. export interface DDSInfo {
  132831. /**
  132832. * Width of the texture
  132833. */
  132834. width: number;
  132835. /**
  132836. * Width of the texture
  132837. */
  132838. height: number;
  132839. /**
  132840. * Number of Mipmaps for the texture
  132841. * @see https://en.wikipedia.org/wiki/Mipmap
  132842. */
  132843. mipmapCount: number;
  132844. /**
  132845. * If the textures format is a known fourCC format
  132846. * @see https://www.fourcc.org/
  132847. */
  132848. isFourCC: boolean;
  132849. /**
  132850. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  132851. */
  132852. isRGB: boolean;
  132853. /**
  132854. * If the texture is a lumincance format
  132855. */
  132856. isLuminance: boolean;
  132857. /**
  132858. * If this is a cube texture
  132859. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  132860. */
  132861. isCube: boolean;
  132862. /**
  132863. * If the texture is a compressed format eg. FOURCC_DXT1
  132864. */
  132865. isCompressed: boolean;
  132866. /**
  132867. * The dxgiFormat of the texture
  132868. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  132869. */
  132870. dxgiFormat: number;
  132871. /**
  132872. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  132873. */
  132874. textureType: number;
  132875. /**
  132876. * Sphericle polynomial created for the dds texture
  132877. */
  132878. sphericalPolynomial?: SphericalPolynomial;
  132879. }
  132880. /**
  132881. * Class used to provide DDS decompression tools
  132882. */
  132883. export class DDSTools {
  132884. /**
  132885. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  132886. */
  132887. static StoreLODInAlphaChannel: boolean;
  132888. /**
  132889. * Gets DDS information from an array buffer
  132890. * @param data defines the array buffer view to read data from
  132891. * @returns the DDS information
  132892. */
  132893. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  132894. private static _FloatView;
  132895. private static _Int32View;
  132896. private static _ToHalfFloat;
  132897. private static _FromHalfFloat;
  132898. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  132899. private static _GetHalfFloatRGBAArrayBuffer;
  132900. private static _GetFloatRGBAArrayBuffer;
  132901. private static _GetFloatAsUIntRGBAArrayBuffer;
  132902. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  132903. private static _GetRGBAArrayBuffer;
  132904. private static _ExtractLongWordOrder;
  132905. private static _GetRGBArrayBuffer;
  132906. private static _GetLuminanceArrayBuffer;
  132907. /**
  132908. * Uploads DDS Levels to a Babylon Texture
  132909. * @hidden
  132910. */
  132911. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  132912. }
  132913. interface ThinEngine {
  132914. /**
  132915. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  132916. * @param rootUrl defines the url where the file to load is located
  132917. * @param scene defines the current scene
  132918. * @param lodScale defines scale to apply to the mip map selection
  132919. * @param lodOffset defines offset to apply to the mip map selection
  132920. * @param onLoad defines an optional callback raised when the texture is loaded
  132921. * @param onError defines an optional callback raised if there is an issue to load the texture
  132922. * @param format defines the format of the data
  132923. * @param forcedExtension defines the extension to use to pick the right loader
  132924. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  132925. * @returns the cube texture as an InternalTexture
  132926. */
  132927. 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;
  132928. }
  132929. }
  132930. declare module BABYLON {
  132931. /**
  132932. * Implementation of the DDS Texture Loader.
  132933. * @hidden
  132934. */
  132935. export class _DDSTextureLoader implements IInternalTextureLoader {
  132936. /**
  132937. * Defines wether the loader supports cascade loading the different faces.
  132938. */
  132939. readonly supportCascades: boolean;
  132940. /**
  132941. * This returns if the loader support the current file information.
  132942. * @param extension defines the file extension of the file being loaded
  132943. * @returns true if the loader can load the specified file
  132944. */
  132945. canLoad(extension: string): boolean;
  132946. /**
  132947. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132948. * @param data contains the texture data
  132949. * @param texture defines the BabylonJS internal texture
  132950. * @param createPolynomials will be true if polynomials have been requested
  132951. * @param onLoad defines the callback to trigger once the texture is ready
  132952. * @param onError defines the callback to trigger in case of error
  132953. */
  132954. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132955. /**
  132956. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132957. * @param data contains the texture data
  132958. * @param texture defines the BabylonJS internal texture
  132959. * @param callback defines the method to call once ready to upload
  132960. */
  132961. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132962. }
  132963. }
  132964. declare module BABYLON {
  132965. /**
  132966. * Implementation of the ENV Texture Loader.
  132967. * @hidden
  132968. */
  132969. export class _ENVTextureLoader implements IInternalTextureLoader {
  132970. /**
  132971. * Defines wether the loader supports cascade loading the different faces.
  132972. */
  132973. readonly supportCascades: boolean;
  132974. /**
  132975. * This returns if the loader support the current file information.
  132976. * @param extension defines the file extension of the file being loaded
  132977. * @returns true if the loader can load the specified file
  132978. */
  132979. canLoad(extension: string): boolean;
  132980. /**
  132981. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132982. * @param data contains the texture data
  132983. * @param texture defines the BabylonJS internal texture
  132984. * @param createPolynomials will be true if polynomials have been requested
  132985. * @param onLoad defines the callback to trigger once the texture is ready
  132986. * @param onError defines the callback to trigger in case of error
  132987. */
  132988. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132989. /**
  132990. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132991. * @param data contains the texture data
  132992. * @param texture defines the BabylonJS internal texture
  132993. * @param callback defines the method to call once ready to upload
  132994. */
  132995. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132996. }
  132997. }
  132998. declare module BABYLON {
  132999. /**
  133000. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  133001. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  133002. */
  133003. export class KhronosTextureContainer {
  133004. /** contents of the KTX container file */
  133005. data: ArrayBufferView;
  133006. private static HEADER_LEN;
  133007. private static COMPRESSED_2D;
  133008. private static COMPRESSED_3D;
  133009. private static TEX_2D;
  133010. private static TEX_3D;
  133011. /**
  133012. * Gets the openGL type
  133013. */
  133014. glType: number;
  133015. /**
  133016. * Gets the openGL type size
  133017. */
  133018. glTypeSize: number;
  133019. /**
  133020. * Gets the openGL format
  133021. */
  133022. glFormat: number;
  133023. /**
  133024. * Gets the openGL internal format
  133025. */
  133026. glInternalFormat: number;
  133027. /**
  133028. * Gets the base internal format
  133029. */
  133030. glBaseInternalFormat: number;
  133031. /**
  133032. * Gets image width in pixel
  133033. */
  133034. pixelWidth: number;
  133035. /**
  133036. * Gets image height in pixel
  133037. */
  133038. pixelHeight: number;
  133039. /**
  133040. * Gets image depth in pixels
  133041. */
  133042. pixelDepth: number;
  133043. /**
  133044. * Gets the number of array elements
  133045. */
  133046. numberOfArrayElements: number;
  133047. /**
  133048. * Gets the number of faces
  133049. */
  133050. numberOfFaces: number;
  133051. /**
  133052. * Gets the number of mipmap levels
  133053. */
  133054. numberOfMipmapLevels: number;
  133055. /**
  133056. * Gets the bytes of key value data
  133057. */
  133058. bytesOfKeyValueData: number;
  133059. /**
  133060. * Gets the load type
  133061. */
  133062. loadType: number;
  133063. /**
  133064. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  133065. */
  133066. isInvalid: boolean;
  133067. /**
  133068. * Creates a new KhronosTextureContainer
  133069. * @param data contents of the KTX container file
  133070. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  133071. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  133072. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  133073. */
  133074. constructor(
  133075. /** contents of the KTX container file */
  133076. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  133077. /**
  133078. * Uploads KTX content to a Babylon Texture.
  133079. * It is assumed that the texture has already been created & is currently bound
  133080. * @hidden
  133081. */
  133082. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  133083. private _upload2DCompressedLevels;
  133084. /**
  133085. * Checks if the given data starts with a KTX file identifier.
  133086. * @param data the data to check
  133087. * @returns true if the data is a KTX file or false otherwise
  133088. */
  133089. static IsValid(data: ArrayBufferView): boolean;
  133090. }
  133091. }
  133092. declare module BABYLON {
  133093. /**
  133094. * Class for loading KTX2 files
  133095. * !!! Experimental Extension Subject to Changes !!!
  133096. * @hidden
  133097. */
  133098. export class KhronosTextureContainer2 {
  133099. private static _ModulePromise;
  133100. private static _TranscodeFormat;
  133101. constructor(engine: ThinEngine);
  133102. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  133103. private _determineTranscodeFormat;
  133104. /**
  133105. * Checks if the given data starts with a KTX2 file identifier.
  133106. * @param data the data to check
  133107. * @returns true if the data is a KTX2 file or false otherwise
  133108. */
  133109. static IsValid(data: ArrayBufferView): boolean;
  133110. }
  133111. }
  133112. declare module BABYLON {
  133113. /**
  133114. * Implementation of the KTX Texture Loader.
  133115. * @hidden
  133116. */
  133117. export class _KTXTextureLoader implements IInternalTextureLoader {
  133118. /**
  133119. * Defines wether the loader supports cascade loading the different faces.
  133120. */
  133121. readonly supportCascades: boolean;
  133122. /**
  133123. * This returns if the loader support the current file information.
  133124. * @param extension defines the file extension of the file being loaded
  133125. * @returns true if the loader can load the specified file
  133126. */
  133127. canLoad(extension: string): boolean;
  133128. /**
  133129. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133130. * @param data contains the texture data
  133131. * @param texture defines the BabylonJS internal texture
  133132. * @param createPolynomials will be true if polynomials have been requested
  133133. * @param onLoad defines the callback to trigger once the texture is ready
  133134. * @param onError defines the callback to trigger in case of error
  133135. */
  133136. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133137. /**
  133138. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133139. * @param data contains the texture data
  133140. * @param texture defines the BabylonJS internal texture
  133141. * @param callback defines the method to call once ready to upload
  133142. */
  133143. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  133144. }
  133145. }
  133146. declare module BABYLON {
  133147. /** @hidden */
  133148. export var _forceSceneHelpersToBundle: boolean;
  133149. interface Scene {
  133150. /**
  133151. * Creates a default light for the scene.
  133152. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  133153. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  133154. */
  133155. createDefaultLight(replace?: boolean): void;
  133156. /**
  133157. * Creates a default camera for the scene.
  133158. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  133159. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  133160. * @param replace has default false, when true replaces the active camera in the scene
  133161. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  133162. */
  133163. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  133164. /**
  133165. * Creates a default camera and a default light.
  133166. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  133167. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  133168. * @param replace has the default false, when true replaces the active camera/light in the scene
  133169. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  133170. */
  133171. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  133172. /**
  133173. * Creates a new sky box
  133174. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  133175. * @param environmentTexture defines the texture to use as environment texture
  133176. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  133177. * @param scale defines the overall scale of the skybox
  133178. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  133179. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  133180. * @returns a new mesh holding the sky box
  133181. */
  133182. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  133183. /**
  133184. * Creates a new environment
  133185. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  133186. * @param options defines the options you can use to configure the environment
  133187. * @returns the new EnvironmentHelper
  133188. */
  133189. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  133190. /**
  133191. * Creates a new VREXperienceHelper
  133192. * @see http://doc.babylonjs.com/how_to/webvr_helper
  133193. * @param webVROptions defines the options used to create the new VREXperienceHelper
  133194. * @returns a new VREXperienceHelper
  133195. */
  133196. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  133197. /**
  133198. * Creates a new WebXRDefaultExperience
  133199. * @see http://doc.babylonjs.com/how_to/webxr
  133200. * @param options experience options
  133201. * @returns a promise for a new WebXRDefaultExperience
  133202. */
  133203. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133204. }
  133205. }
  133206. declare module BABYLON {
  133207. /**
  133208. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  133209. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  133210. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  133211. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133212. */
  133213. export class VideoDome extends TransformNode {
  133214. /**
  133215. * Define the video source as a Monoscopic panoramic 360 video.
  133216. */
  133217. static readonly MODE_MONOSCOPIC: number;
  133218. /**
  133219. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  133220. */
  133221. static readonly MODE_TOPBOTTOM: number;
  133222. /**
  133223. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  133224. */
  133225. static readonly MODE_SIDEBYSIDE: number;
  133226. private _halfDome;
  133227. private _useDirectMapping;
  133228. /**
  133229. * The video texture being displayed on the sphere
  133230. */
  133231. protected _videoTexture: VideoTexture;
  133232. /**
  133233. * Gets the video texture being displayed on the sphere
  133234. */
  133235. get videoTexture(): VideoTexture;
  133236. /**
  133237. * The skybox material
  133238. */
  133239. protected _material: BackgroundMaterial;
  133240. /**
  133241. * The surface used for the skybox
  133242. */
  133243. protected _mesh: Mesh;
  133244. /**
  133245. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  133246. */
  133247. private _halfDomeMask;
  133248. /**
  133249. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133250. * Also see the options.resolution property.
  133251. */
  133252. get fovMultiplier(): number;
  133253. set fovMultiplier(value: number);
  133254. private _videoMode;
  133255. /**
  133256. * Gets or set the current video mode for the video. It can be:
  133257. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  133258. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  133259. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  133260. */
  133261. get videoMode(): number;
  133262. set videoMode(value: number);
  133263. /**
  133264. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  133265. *
  133266. */
  133267. get halfDome(): boolean;
  133268. /**
  133269. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  133270. */
  133271. set halfDome(enabled: boolean);
  133272. /**
  133273. * Oberserver used in Stereoscopic VR Mode.
  133274. */
  133275. private _onBeforeCameraRenderObserver;
  133276. /**
  133277. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  133278. * @param name Element's name, child elements will append suffixes for their own names.
  133279. * @param urlsOrVideo defines the url(s) or the video element to use
  133280. * @param options An object containing optional or exposed sub element properties
  133281. */
  133282. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  133283. resolution?: number;
  133284. clickToPlay?: boolean;
  133285. autoPlay?: boolean;
  133286. loop?: boolean;
  133287. size?: number;
  133288. poster?: string;
  133289. faceForward?: boolean;
  133290. useDirectMapping?: boolean;
  133291. halfDomeMode?: boolean;
  133292. }, scene: Scene);
  133293. private _changeVideoMode;
  133294. /**
  133295. * Releases resources associated with this node.
  133296. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133297. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133298. */
  133299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133300. }
  133301. }
  133302. declare module BABYLON {
  133303. /**
  133304. * This class can be used to get instrumentation data from a Babylon engine
  133305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133306. */
  133307. export class EngineInstrumentation implements IDisposable {
  133308. /**
  133309. * Define the instrumented engine.
  133310. */
  133311. engine: Engine;
  133312. private _captureGPUFrameTime;
  133313. private _gpuFrameTimeToken;
  133314. private _gpuFrameTime;
  133315. private _captureShaderCompilationTime;
  133316. private _shaderCompilationTime;
  133317. private _onBeginFrameObserver;
  133318. private _onEndFrameObserver;
  133319. private _onBeforeShaderCompilationObserver;
  133320. private _onAfterShaderCompilationObserver;
  133321. /**
  133322. * Gets the perf counter used for GPU frame time
  133323. */
  133324. get gpuFrameTimeCounter(): PerfCounter;
  133325. /**
  133326. * Gets the GPU frame time capture status
  133327. */
  133328. get captureGPUFrameTime(): boolean;
  133329. /**
  133330. * Enable or disable the GPU frame time capture
  133331. */
  133332. set captureGPUFrameTime(value: boolean);
  133333. /**
  133334. * Gets the perf counter used for shader compilation time
  133335. */
  133336. get shaderCompilationTimeCounter(): PerfCounter;
  133337. /**
  133338. * Gets the shader compilation time capture status
  133339. */
  133340. get captureShaderCompilationTime(): boolean;
  133341. /**
  133342. * Enable or disable the shader compilation time capture
  133343. */
  133344. set captureShaderCompilationTime(value: boolean);
  133345. /**
  133346. * Instantiates a new engine instrumentation.
  133347. * This class can be used to get instrumentation data from a Babylon engine
  133348. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133349. * @param engine Defines the engine to instrument
  133350. */
  133351. constructor(
  133352. /**
  133353. * Define the instrumented engine.
  133354. */
  133355. engine: Engine);
  133356. /**
  133357. * Dispose and release associated resources.
  133358. */
  133359. dispose(): void;
  133360. }
  133361. }
  133362. declare module BABYLON {
  133363. /**
  133364. * This class can be used to get instrumentation data from a Babylon engine
  133365. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133366. */
  133367. export class SceneInstrumentation implements IDisposable {
  133368. /**
  133369. * Defines the scene to instrument
  133370. */
  133371. scene: Scene;
  133372. private _captureActiveMeshesEvaluationTime;
  133373. private _activeMeshesEvaluationTime;
  133374. private _captureRenderTargetsRenderTime;
  133375. private _renderTargetsRenderTime;
  133376. private _captureFrameTime;
  133377. private _frameTime;
  133378. private _captureRenderTime;
  133379. private _renderTime;
  133380. private _captureInterFrameTime;
  133381. private _interFrameTime;
  133382. private _captureParticlesRenderTime;
  133383. private _particlesRenderTime;
  133384. private _captureSpritesRenderTime;
  133385. private _spritesRenderTime;
  133386. private _capturePhysicsTime;
  133387. private _physicsTime;
  133388. private _captureAnimationsTime;
  133389. private _animationsTime;
  133390. private _captureCameraRenderTime;
  133391. private _cameraRenderTime;
  133392. private _onBeforeActiveMeshesEvaluationObserver;
  133393. private _onAfterActiveMeshesEvaluationObserver;
  133394. private _onBeforeRenderTargetsRenderObserver;
  133395. private _onAfterRenderTargetsRenderObserver;
  133396. private _onAfterRenderObserver;
  133397. private _onBeforeDrawPhaseObserver;
  133398. private _onAfterDrawPhaseObserver;
  133399. private _onBeforeAnimationsObserver;
  133400. private _onBeforeParticlesRenderingObserver;
  133401. private _onAfterParticlesRenderingObserver;
  133402. private _onBeforeSpritesRenderingObserver;
  133403. private _onAfterSpritesRenderingObserver;
  133404. private _onBeforePhysicsObserver;
  133405. private _onAfterPhysicsObserver;
  133406. private _onAfterAnimationsObserver;
  133407. private _onBeforeCameraRenderObserver;
  133408. private _onAfterCameraRenderObserver;
  133409. /**
  133410. * Gets the perf counter used for active meshes evaluation time
  133411. */
  133412. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  133413. /**
  133414. * Gets the active meshes evaluation time capture status
  133415. */
  133416. get captureActiveMeshesEvaluationTime(): boolean;
  133417. /**
  133418. * Enable or disable the active meshes evaluation time capture
  133419. */
  133420. set captureActiveMeshesEvaluationTime(value: boolean);
  133421. /**
  133422. * Gets the perf counter used for render targets render time
  133423. */
  133424. get renderTargetsRenderTimeCounter(): PerfCounter;
  133425. /**
  133426. * Gets the render targets render time capture status
  133427. */
  133428. get captureRenderTargetsRenderTime(): boolean;
  133429. /**
  133430. * Enable or disable the render targets render time capture
  133431. */
  133432. set captureRenderTargetsRenderTime(value: boolean);
  133433. /**
  133434. * Gets the perf counter used for particles render time
  133435. */
  133436. get particlesRenderTimeCounter(): PerfCounter;
  133437. /**
  133438. * Gets the particles render time capture status
  133439. */
  133440. get captureParticlesRenderTime(): boolean;
  133441. /**
  133442. * Enable or disable the particles render time capture
  133443. */
  133444. set captureParticlesRenderTime(value: boolean);
  133445. /**
  133446. * Gets the perf counter used for sprites render time
  133447. */
  133448. get spritesRenderTimeCounter(): PerfCounter;
  133449. /**
  133450. * Gets the sprites render time capture status
  133451. */
  133452. get captureSpritesRenderTime(): boolean;
  133453. /**
  133454. * Enable or disable the sprites render time capture
  133455. */
  133456. set captureSpritesRenderTime(value: boolean);
  133457. /**
  133458. * Gets the perf counter used for physics time
  133459. */
  133460. get physicsTimeCounter(): PerfCounter;
  133461. /**
  133462. * Gets the physics time capture status
  133463. */
  133464. get capturePhysicsTime(): boolean;
  133465. /**
  133466. * Enable or disable the physics time capture
  133467. */
  133468. set capturePhysicsTime(value: boolean);
  133469. /**
  133470. * Gets the perf counter used for animations time
  133471. */
  133472. get animationsTimeCounter(): PerfCounter;
  133473. /**
  133474. * Gets the animations time capture status
  133475. */
  133476. get captureAnimationsTime(): boolean;
  133477. /**
  133478. * Enable or disable the animations time capture
  133479. */
  133480. set captureAnimationsTime(value: boolean);
  133481. /**
  133482. * Gets the perf counter used for frame time capture
  133483. */
  133484. get frameTimeCounter(): PerfCounter;
  133485. /**
  133486. * Gets the frame time capture status
  133487. */
  133488. get captureFrameTime(): boolean;
  133489. /**
  133490. * Enable or disable the frame time capture
  133491. */
  133492. set captureFrameTime(value: boolean);
  133493. /**
  133494. * Gets the perf counter used for inter-frames time capture
  133495. */
  133496. get interFrameTimeCounter(): PerfCounter;
  133497. /**
  133498. * Gets the inter-frames time capture status
  133499. */
  133500. get captureInterFrameTime(): boolean;
  133501. /**
  133502. * Enable or disable the inter-frames time capture
  133503. */
  133504. set captureInterFrameTime(value: boolean);
  133505. /**
  133506. * Gets the perf counter used for render time capture
  133507. */
  133508. get renderTimeCounter(): PerfCounter;
  133509. /**
  133510. * Gets the render time capture status
  133511. */
  133512. get captureRenderTime(): boolean;
  133513. /**
  133514. * Enable or disable the render time capture
  133515. */
  133516. set captureRenderTime(value: boolean);
  133517. /**
  133518. * Gets the perf counter used for camera render time capture
  133519. */
  133520. get cameraRenderTimeCounter(): PerfCounter;
  133521. /**
  133522. * Gets the camera render time capture status
  133523. */
  133524. get captureCameraRenderTime(): boolean;
  133525. /**
  133526. * Enable or disable the camera render time capture
  133527. */
  133528. set captureCameraRenderTime(value: boolean);
  133529. /**
  133530. * Gets the perf counter used for draw calls
  133531. */
  133532. get drawCallsCounter(): PerfCounter;
  133533. /**
  133534. * Instantiates a new scene instrumentation.
  133535. * This class can be used to get instrumentation data from a Babylon engine
  133536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133537. * @param scene Defines the scene to instrument
  133538. */
  133539. constructor(
  133540. /**
  133541. * Defines the scene to instrument
  133542. */
  133543. scene: Scene);
  133544. /**
  133545. * Dispose and release associated resources.
  133546. */
  133547. dispose(): void;
  133548. }
  133549. }
  133550. declare module BABYLON {
  133551. /** @hidden */
  133552. export var glowMapGenerationPixelShader: {
  133553. name: string;
  133554. shader: string;
  133555. };
  133556. }
  133557. declare module BABYLON {
  133558. /** @hidden */
  133559. export var glowMapGenerationVertexShader: {
  133560. name: string;
  133561. shader: string;
  133562. };
  133563. }
  133564. declare module BABYLON {
  133565. /**
  133566. * Effect layer options. This helps customizing the behaviour
  133567. * of the effect layer.
  133568. */
  133569. export interface IEffectLayerOptions {
  133570. /**
  133571. * Multiplication factor apply to the canvas size to compute the render target size
  133572. * used to generated the objects (the smaller the faster).
  133573. */
  133574. mainTextureRatio: number;
  133575. /**
  133576. * Enforces a fixed size texture to ensure effect stability across devices.
  133577. */
  133578. mainTextureFixedSize?: number;
  133579. /**
  133580. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  133581. */
  133582. alphaBlendingMode: number;
  133583. /**
  133584. * The camera attached to the layer.
  133585. */
  133586. camera: Nullable<Camera>;
  133587. /**
  133588. * The rendering group to draw the layer in.
  133589. */
  133590. renderingGroupId: number;
  133591. }
  133592. /**
  133593. * The effect layer Helps adding post process effect blended with the main pass.
  133594. *
  133595. * This can be for instance use to generate glow or higlight effects on the scene.
  133596. *
  133597. * The effect layer class can not be used directly and is intented to inherited from to be
  133598. * customized per effects.
  133599. */
  133600. export abstract class EffectLayer {
  133601. private _vertexBuffers;
  133602. private _indexBuffer;
  133603. private _cachedDefines;
  133604. private _effectLayerMapGenerationEffect;
  133605. private _effectLayerOptions;
  133606. private _mergeEffect;
  133607. protected _scene: Scene;
  133608. protected _engine: Engine;
  133609. protected _maxSize: number;
  133610. protected _mainTextureDesiredSize: ISize;
  133611. protected _mainTexture: RenderTargetTexture;
  133612. protected _shouldRender: boolean;
  133613. protected _postProcesses: PostProcess[];
  133614. protected _textures: BaseTexture[];
  133615. protected _emissiveTextureAndColor: {
  133616. texture: Nullable<BaseTexture>;
  133617. color: Color4;
  133618. };
  133619. /**
  133620. * The name of the layer
  133621. */
  133622. name: string;
  133623. /**
  133624. * The clear color of the texture used to generate the glow map.
  133625. */
  133626. neutralColor: Color4;
  133627. /**
  133628. * Specifies whether the highlight layer is enabled or not.
  133629. */
  133630. isEnabled: boolean;
  133631. /**
  133632. * Gets the camera attached to the layer.
  133633. */
  133634. get camera(): Nullable<Camera>;
  133635. /**
  133636. * Gets the rendering group id the layer should render in.
  133637. */
  133638. get renderingGroupId(): number;
  133639. set renderingGroupId(renderingGroupId: number);
  133640. /**
  133641. * An event triggered when the effect layer has been disposed.
  133642. */
  133643. onDisposeObservable: Observable<EffectLayer>;
  133644. /**
  133645. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  133646. */
  133647. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  133648. /**
  133649. * An event triggered when the generated texture is being merged in the scene.
  133650. */
  133651. onBeforeComposeObservable: Observable<EffectLayer>;
  133652. /**
  133653. * An event triggered when the mesh is rendered into the effect render target.
  133654. */
  133655. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  133656. /**
  133657. * An event triggered after the mesh has been rendered into the effect render target.
  133658. */
  133659. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  133660. /**
  133661. * An event triggered when the generated texture has been merged in the scene.
  133662. */
  133663. onAfterComposeObservable: Observable<EffectLayer>;
  133664. /**
  133665. * An event triggered when the efffect layer changes its size.
  133666. */
  133667. onSizeChangedObservable: Observable<EffectLayer>;
  133668. /** @hidden */
  133669. static _SceneComponentInitialization: (scene: Scene) => void;
  133670. /**
  133671. * Instantiates a new effect Layer and references it in the scene.
  133672. * @param name The name of the layer
  133673. * @param scene The scene to use the layer in
  133674. */
  133675. constructor(
  133676. /** The Friendly of the effect in the scene */
  133677. name: string, scene: Scene);
  133678. /**
  133679. * Get the effect name of the layer.
  133680. * @return The effect name
  133681. */
  133682. abstract getEffectName(): string;
  133683. /**
  133684. * Checks for the readiness of the element composing the layer.
  133685. * @param subMesh the mesh to check for
  133686. * @param useInstances specify whether or not to use instances to render the mesh
  133687. * @return true if ready otherwise, false
  133688. */
  133689. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133690. /**
  133691. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  133692. * @returns true if the effect requires stencil during the main canvas render pass.
  133693. */
  133694. abstract needStencil(): boolean;
  133695. /**
  133696. * Create the merge effect. This is the shader use to blit the information back
  133697. * to the main canvas at the end of the scene rendering.
  133698. * @returns The effect containing the shader used to merge the effect on the main canvas
  133699. */
  133700. protected abstract _createMergeEffect(): Effect;
  133701. /**
  133702. * Creates the render target textures and post processes used in the effect layer.
  133703. */
  133704. protected abstract _createTextureAndPostProcesses(): void;
  133705. /**
  133706. * Implementation specific of rendering the generating effect on the main canvas.
  133707. * @param effect The effect used to render through
  133708. */
  133709. protected abstract _internalRender(effect: Effect): void;
  133710. /**
  133711. * Sets the required values for both the emissive texture and and the main color.
  133712. */
  133713. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  133714. /**
  133715. * Free any resources and references associated to a mesh.
  133716. * Internal use
  133717. * @param mesh The mesh to free.
  133718. */
  133719. abstract _disposeMesh(mesh: Mesh): void;
  133720. /**
  133721. * Serializes this layer (Glow or Highlight for example)
  133722. * @returns a serialized layer object
  133723. */
  133724. abstract serialize?(): any;
  133725. /**
  133726. * Initializes the effect layer with the required options.
  133727. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  133728. */
  133729. protected _init(options: Partial<IEffectLayerOptions>): void;
  133730. /**
  133731. * Generates the index buffer of the full screen quad blending to the main canvas.
  133732. */
  133733. private _generateIndexBuffer;
  133734. /**
  133735. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  133736. */
  133737. private _generateVertexBuffer;
  133738. /**
  133739. * Sets the main texture desired size which is the closest power of two
  133740. * of the engine canvas size.
  133741. */
  133742. private _setMainTextureSize;
  133743. /**
  133744. * Creates the main texture for the effect layer.
  133745. */
  133746. protected _createMainTexture(): void;
  133747. /**
  133748. * Adds specific effects defines.
  133749. * @param defines The defines to add specifics to.
  133750. */
  133751. protected _addCustomEffectDefines(defines: string[]): void;
  133752. /**
  133753. * Checks for the readiness of the element composing the layer.
  133754. * @param subMesh the mesh to check for
  133755. * @param useInstances specify whether or not to use instances to render the mesh
  133756. * @param emissiveTexture the associated emissive texture used to generate the glow
  133757. * @return true if ready otherwise, false
  133758. */
  133759. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  133760. /**
  133761. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  133762. */
  133763. render(): void;
  133764. /**
  133765. * Determine if a given mesh will be used in the current effect.
  133766. * @param mesh mesh to test
  133767. * @returns true if the mesh will be used
  133768. */
  133769. hasMesh(mesh: AbstractMesh): boolean;
  133770. /**
  133771. * Returns true if the layer contains information to display, otherwise false.
  133772. * @returns true if the glow layer should be rendered
  133773. */
  133774. shouldRender(): boolean;
  133775. /**
  133776. * Returns true if the mesh should render, otherwise false.
  133777. * @param mesh The mesh to render
  133778. * @returns true if it should render otherwise false
  133779. */
  133780. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  133781. /**
  133782. * Returns true if the mesh can be rendered, otherwise false.
  133783. * @param mesh The mesh to render
  133784. * @param material The material used on the mesh
  133785. * @returns true if it can be rendered otherwise false
  133786. */
  133787. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  133788. /**
  133789. * Returns true if the mesh should render, otherwise false.
  133790. * @param mesh The mesh to render
  133791. * @returns true if it should render otherwise false
  133792. */
  133793. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  133794. /**
  133795. * Renders the submesh passed in parameter to the generation map.
  133796. */
  133797. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  133798. /**
  133799. * Defines whether the current material of the mesh should be use to render the effect.
  133800. * @param mesh defines the current mesh to render
  133801. */
  133802. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  133803. /**
  133804. * Rebuild the required buffers.
  133805. * @hidden Internal use only.
  133806. */
  133807. _rebuild(): void;
  133808. /**
  133809. * Dispose only the render target textures and post process.
  133810. */
  133811. private _disposeTextureAndPostProcesses;
  133812. /**
  133813. * Dispose the highlight layer and free resources.
  133814. */
  133815. dispose(): void;
  133816. /**
  133817. * Gets the class name of the effect layer
  133818. * @returns the string with the class name of the effect layer
  133819. */
  133820. getClassName(): string;
  133821. /**
  133822. * Creates an effect layer from parsed effect layer data
  133823. * @param parsedEffectLayer defines effect layer data
  133824. * @param scene defines the current scene
  133825. * @param rootUrl defines the root URL containing the effect layer information
  133826. * @returns a parsed effect Layer
  133827. */
  133828. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  133829. }
  133830. }
  133831. declare module BABYLON {
  133832. interface AbstractScene {
  133833. /**
  133834. * The list of effect layers (highlights/glow) added to the scene
  133835. * @see http://doc.babylonjs.com/how_to/highlight_layer
  133836. * @see http://doc.babylonjs.com/how_to/glow_layer
  133837. */
  133838. effectLayers: Array<EffectLayer>;
  133839. /**
  133840. * Removes the given effect layer from this scene.
  133841. * @param toRemove defines the effect layer to remove
  133842. * @returns the index of the removed effect layer
  133843. */
  133844. removeEffectLayer(toRemove: EffectLayer): number;
  133845. /**
  133846. * Adds the given effect layer to this scene
  133847. * @param newEffectLayer defines the effect layer to add
  133848. */
  133849. addEffectLayer(newEffectLayer: EffectLayer): void;
  133850. }
  133851. /**
  133852. * Defines the layer scene component responsible to manage any effect layers
  133853. * in a given scene.
  133854. */
  133855. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  133856. /**
  133857. * The component name helpfull to identify the component in the list of scene components.
  133858. */
  133859. readonly name: string;
  133860. /**
  133861. * The scene the component belongs to.
  133862. */
  133863. scene: Scene;
  133864. private _engine;
  133865. private _renderEffects;
  133866. private _needStencil;
  133867. private _previousStencilState;
  133868. /**
  133869. * Creates a new instance of the component for the given scene
  133870. * @param scene Defines the scene to register the component in
  133871. */
  133872. constructor(scene: Scene);
  133873. /**
  133874. * Registers the component in a given scene
  133875. */
  133876. register(): void;
  133877. /**
  133878. * Rebuilds the elements related to this component in case of
  133879. * context lost for instance.
  133880. */
  133881. rebuild(): void;
  133882. /**
  133883. * Serializes the component data to the specified json object
  133884. * @param serializationObject The object to serialize to
  133885. */
  133886. serialize(serializationObject: any): void;
  133887. /**
  133888. * Adds all the elements from the container to the scene
  133889. * @param container the container holding the elements
  133890. */
  133891. addFromContainer(container: AbstractScene): void;
  133892. /**
  133893. * Removes all the elements in the container from the scene
  133894. * @param container contains the elements to remove
  133895. * @param dispose if the removed element should be disposed (default: false)
  133896. */
  133897. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  133898. /**
  133899. * Disposes the component and the associated ressources.
  133900. */
  133901. dispose(): void;
  133902. private _isReadyForMesh;
  133903. private _renderMainTexture;
  133904. private _setStencil;
  133905. private _setStencilBack;
  133906. private _draw;
  133907. private _drawCamera;
  133908. private _drawRenderingGroup;
  133909. }
  133910. }
  133911. declare module BABYLON {
  133912. /** @hidden */
  133913. export var glowMapMergePixelShader: {
  133914. name: string;
  133915. shader: string;
  133916. };
  133917. }
  133918. declare module BABYLON {
  133919. /** @hidden */
  133920. export var glowMapMergeVertexShader: {
  133921. name: string;
  133922. shader: string;
  133923. };
  133924. }
  133925. declare module BABYLON {
  133926. interface AbstractScene {
  133927. /**
  133928. * Return a the first highlight layer of the scene with a given name.
  133929. * @param name The name of the highlight layer to look for.
  133930. * @return The highlight layer if found otherwise null.
  133931. */
  133932. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  133933. }
  133934. /**
  133935. * Glow layer options. This helps customizing the behaviour
  133936. * of the glow layer.
  133937. */
  133938. export interface IGlowLayerOptions {
  133939. /**
  133940. * Multiplication factor apply to the canvas size to compute the render target size
  133941. * used to generated the glowing objects (the smaller the faster).
  133942. */
  133943. mainTextureRatio: number;
  133944. /**
  133945. * Enforces a fixed size texture to ensure resize independant blur.
  133946. */
  133947. mainTextureFixedSize?: number;
  133948. /**
  133949. * How big is the kernel of the blur texture.
  133950. */
  133951. blurKernelSize: number;
  133952. /**
  133953. * The camera attached to the layer.
  133954. */
  133955. camera: Nullable<Camera>;
  133956. /**
  133957. * Enable MSAA by chosing the number of samples.
  133958. */
  133959. mainTextureSamples?: number;
  133960. /**
  133961. * The rendering group to draw the layer in.
  133962. */
  133963. renderingGroupId: number;
  133964. }
  133965. /**
  133966. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  133967. *
  133968. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  133969. *
  133970. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  133971. */
  133972. export class GlowLayer extends EffectLayer {
  133973. /**
  133974. * Effect Name of the layer.
  133975. */
  133976. static readonly EffectName: string;
  133977. /**
  133978. * The default blur kernel size used for the glow.
  133979. */
  133980. static DefaultBlurKernelSize: number;
  133981. /**
  133982. * The default texture size ratio used for the glow.
  133983. */
  133984. static DefaultTextureRatio: number;
  133985. /**
  133986. * Sets the kernel size of the blur.
  133987. */
  133988. set blurKernelSize(value: number);
  133989. /**
  133990. * Gets the kernel size of the blur.
  133991. */
  133992. get blurKernelSize(): number;
  133993. /**
  133994. * Sets the glow intensity.
  133995. */
  133996. set intensity(value: number);
  133997. /**
  133998. * Gets the glow intensity.
  133999. */
  134000. get intensity(): number;
  134001. private _options;
  134002. private _intensity;
  134003. private _horizontalBlurPostprocess1;
  134004. private _verticalBlurPostprocess1;
  134005. private _horizontalBlurPostprocess2;
  134006. private _verticalBlurPostprocess2;
  134007. private _blurTexture1;
  134008. private _blurTexture2;
  134009. private _postProcesses1;
  134010. private _postProcesses2;
  134011. private _includedOnlyMeshes;
  134012. private _excludedMeshes;
  134013. private _meshesUsingTheirOwnMaterials;
  134014. /**
  134015. * Callback used to let the user override the color selection on a per mesh basis
  134016. */
  134017. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  134018. /**
  134019. * Callback used to let the user override the texture selection on a per mesh basis
  134020. */
  134021. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  134022. /**
  134023. * Instantiates a new glow Layer and references it to the scene.
  134024. * @param name The name of the layer
  134025. * @param scene The scene to use the layer in
  134026. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  134027. */
  134028. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  134029. /**
  134030. * Get the effect name of the layer.
  134031. * @return The effect name
  134032. */
  134033. getEffectName(): string;
  134034. /**
  134035. * Create the merge effect. This is the shader use to blit the information back
  134036. * to the main canvas at the end of the scene rendering.
  134037. */
  134038. protected _createMergeEffect(): Effect;
  134039. /**
  134040. * Creates the render target textures and post processes used in the glow layer.
  134041. */
  134042. protected _createTextureAndPostProcesses(): void;
  134043. /**
  134044. * Checks for the readiness of the element composing the layer.
  134045. * @param subMesh the mesh to check for
  134046. * @param useInstances specify wether or not to use instances to render the mesh
  134047. * @param emissiveTexture the associated emissive texture used to generate the glow
  134048. * @return true if ready otherwise, false
  134049. */
  134050. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134051. /**
  134052. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  134053. */
  134054. needStencil(): boolean;
  134055. /**
  134056. * Returns true if the mesh can be rendered, otherwise false.
  134057. * @param mesh The mesh to render
  134058. * @param material The material used on the mesh
  134059. * @returns true if it can be rendered otherwise false
  134060. */
  134061. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  134062. /**
  134063. * Implementation specific of rendering the generating effect on the main canvas.
  134064. * @param effect The effect used to render through
  134065. */
  134066. protected _internalRender(effect: Effect): void;
  134067. /**
  134068. * Sets the required values for both the emissive texture and and the main color.
  134069. */
  134070. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134071. /**
  134072. * Returns true if the mesh should render, otherwise false.
  134073. * @param mesh The mesh to render
  134074. * @returns true if it should render otherwise false
  134075. */
  134076. protected _shouldRenderMesh(mesh: Mesh): boolean;
  134077. /**
  134078. * Adds specific effects defines.
  134079. * @param defines The defines to add specifics to.
  134080. */
  134081. protected _addCustomEffectDefines(defines: string[]): void;
  134082. /**
  134083. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  134084. * @param mesh The mesh to exclude from the glow layer
  134085. */
  134086. addExcludedMesh(mesh: Mesh): void;
  134087. /**
  134088. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  134089. * @param mesh The mesh to remove
  134090. */
  134091. removeExcludedMesh(mesh: Mesh): void;
  134092. /**
  134093. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  134094. * @param mesh The mesh to include in the glow layer
  134095. */
  134096. addIncludedOnlyMesh(mesh: Mesh): void;
  134097. /**
  134098. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  134099. * @param mesh The mesh to remove
  134100. */
  134101. removeIncludedOnlyMesh(mesh: Mesh): void;
  134102. /**
  134103. * Determine if a given mesh will be used in the glow layer
  134104. * @param mesh The mesh to test
  134105. * @returns true if the mesh will be highlighted by the current glow layer
  134106. */
  134107. hasMesh(mesh: AbstractMesh): boolean;
  134108. /**
  134109. * Defines whether the current material of the mesh should be use to render the effect.
  134110. * @param mesh defines the current mesh to render
  134111. */
  134112. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  134113. /**
  134114. * Add a mesh to be rendered through its own material and not with emissive only.
  134115. * @param mesh The mesh for which we need to use its material
  134116. */
  134117. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  134118. /**
  134119. * Remove a mesh from being rendered through its own material and not with emissive only.
  134120. * @param mesh The mesh for which we need to not use its material
  134121. */
  134122. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  134123. /**
  134124. * Free any resources and references associated to a mesh.
  134125. * Internal use
  134126. * @param mesh The mesh to free.
  134127. * @hidden
  134128. */
  134129. _disposeMesh(mesh: Mesh): void;
  134130. /**
  134131. * Gets the class name of the effect layer
  134132. * @returns the string with the class name of the effect layer
  134133. */
  134134. getClassName(): string;
  134135. /**
  134136. * Serializes this glow layer
  134137. * @returns a serialized glow layer object
  134138. */
  134139. serialize(): any;
  134140. /**
  134141. * Creates a Glow Layer from parsed glow layer data
  134142. * @param parsedGlowLayer defines glow layer data
  134143. * @param scene defines the current scene
  134144. * @param rootUrl defines the root URL containing the glow layer information
  134145. * @returns a parsed Glow Layer
  134146. */
  134147. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  134148. }
  134149. }
  134150. declare module BABYLON {
  134151. /** @hidden */
  134152. export var glowBlurPostProcessPixelShader: {
  134153. name: string;
  134154. shader: string;
  134155. };
  134156. }
  134157. declare module BABYLON {
  134158. interface AbstractScene {
  134159. /**
  134160. * Return a the first highlight layer of the scene with a given name.
  134161. * @param name The name of the highlight layer to look for.
  134162. * @return The highlight layer if found otherwise null.
  134163. */
  134164. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  134165. }
  134166. /**
  134167. * Highlight layer options. This helps customizing the behaviour
  134168. * of the highlight layer.
  134169. */
  134170. export interface IHighlightLayerOptions {
  134171. /**
  134172. * Multiplication factor apply to the canvas size to compute the render target size
  134173. * used to generated the glowing objects (the smaller the faster).
  134174. */
  134175. mainTextureRatio: number;
  134176. /**
  134177. * Enforces a fixed size texture to ensure resize independant blur.
  134178. */
  134179. mainTextureFixedSize?: number;
  134180. /**
  134181. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  134182. * of the picture to blur (the smaller the faster).
  134183. */
  134184. blurTextureSizeRatio: number;
  134185. /**
  134186. * How big in texel of the blur texture is the vertical blur.
  134187. */
  134188. blurVerticalSize: number;
  134189. /**
  134190. * How big in texel of the blur texture is the horizontal blur.
  134191. */
  134192. blurHorizontalSize: number;
  134193. /**
  134194. * Alpha blending mode used to apply the blur. Default is combine.
  134195. */
  134196. alphaBlendingMode: number;
  134197. /**
  134198. * The camera attached to the layer.
  134199. */
  134200. camera: Nullable<Camera>;
  134201. /**
  134202. * Should we display highlight as a solid stroke?
  134203. */
  134204. isStroke?: boolean;
  134205. /**
  134206. * The rendering group to draw the layer in.
  134207. */
  134208. renderingGroupId: number;
  134209. }
  134210. /**
  134211. * The highlight layer Helps adding a glow effect around a mesh.
  134212. *
  134213. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  134214. * glowy meshes to your scene.
  134215. *
  134216. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  134217. */
  134218. export class HighlightLayer extends EffectLayer {
  134219. name: string;
  134220. /**
  134221. * Effect Name of the highlight layer.
  134222. */
  134223. static readonly EffectName: string;
  134224. /**
  134225. * The neutral color used during the preparation of the glow effect.
  134226. * This is black by default as the blend operation is a blend operation.
  134227. */
  134228. static NeutralColor: Color4;
  134229. /**
  134230. * Stencil value used for glowing meshes.
  134231. */
  134232. static GlowingMeshStencilReference: number;
  134233. /**
  134234. * Stencil value used for the other meshes in the scene.
  134235. */
  134236. static NormalMeshStencilReference: number;
  134237. /**
  134238. * Specifies whether or not the inner glow is ACTIVE in the layer.
  134239. */
  134240. innerGlow: boolean;
  134241. /**
  134242. * Specifies whether or not the outer glow is ACTIVE in the layer.
  134243. */
  134244. outerGlow: boolean;
  134245. /**
  134246. * Specifies the horizontal size of the blur.
  134247. */
  134248. set blurHorizontalSize(value: number);
  134249. /**
  134250. * Specifies the vertical size of the blur.
  134251. */
  134252. set blurVerticalSize(value: number);
  134253. /**
  134254. * Gets the horizontal size of the blur.
  134255. */
  134256. get blurHorizontalSize(): number;
  134257. /**
  134258. * Gets the vertical size of the blur.
  134259. */
  134260. get blurVerticalSize(): number;
  134261. /**
  134262. * An event triggered when the highlight layer is being blurred.
  134263. */
  134264. onBeforeBlurObservable: Observable<HighlightLayer>;
  134265. /**
  134266. * An event triggered when the highlight layer has been blurred.
  134267. */
  134268. onAfterBlurObservable: Observable<HighlightLayer>;
  134269. private _instanceGlowingMeshStencilReference;
  134270. private _options;
  134271. private _downSamplePostprocess;
  134272. private _horizontalBlurPostprocess;
  134273. private _verticalBlurPostprocess;
  134274. private _blurTexture;
  134275. private _meshes;
  134276. private _excludedMeshes;
  134277. /**
  134278. * Instantiates a new highlight Layer and references it to the scene..
  134279. * @param name The name of the layer
  134280. * @param scene The scene to use the layer in
  134281. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  134282. */
  134283. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  134284. /**
  134285. * Get the effect name of the layer.
  134286. * @return The effect name
  134287. */
  134288. getEffectName(): string;
  134289. /**
  134290. * Create the merge effect. This is the shader use to blit the information back
  134291. * to the main canvas at the end of the scene rendering.
  134292. */
  134293. protected _createMergeEffect(): Effect;
  134294. /**
  134295. * Creates the render target textures and post processes used in the highlight layer.
  134296. */
  134297. protected _createTextureAndPostProcesses(): void;
  134298. /**
  134299. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  134300. */
  134301. needStencil(): boolean;
  134302. /**
  134303. * Checks for the readiness of the element composing the layer.
  134304. * @param subMesh the mesh to check for
  134305. * @param useInstances specify wether or not to use instances to render the mesh
  134306. * @param emissiveTexture the associated emissive texture used to generate the glow
  134307. * @return true if ready otherwise, false
  134308. */
  134309. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134310. /**
  134311. * Implementation specific of rendering the generating effect on the main canvas.
  134312. * @param effect The effect used to render through
  134313. */
  134314. protected _internalRender(effect: Effect): void;
  134315. /**
  134316. * Returns true if the layer contains information to display, otherwise false.
  134317. */
  134318. shouldRender(): boolean;
  134319. /**
  134320. * Returns true if the mesh should render, otherwise false.
  134321. * @param mesh The mesh to render
  134322. * @returns true if it should render otherwise false
  134323. */
  134324. protected _shouldRenderMesh(mesh: Mesh): boolean;
  134325. /**
  134326. * Adds specific effects defines.
  134327. * @param defines The defines to add specifics to.
  134328. */
  134329. protected _addCustomEffectDefines(defines: string[]): void;
  134330. /**
  134331. * Sets the required values for both the emissive texture and and the main color.
  134332. */
  134333. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134334. /**
  134335. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  134336. * @param mesh The mesh to exclude from the highlight layer
  134337. */
  134338. addExcludedMesh(mesh: Mesh): void;
  134339. /**
  134340. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  134341. * @param mesh The mesh to highlight
  134342. */
  134343. removeExcludedMesh(mesh: Mesh): void;
  134344. /**
  134345. * Determine if a given mesh will be highlighted by the current HighlightLayer
  134346. * @param mesh mesh to test
  134347. * @returns true if the mesh will be highlighted by the current HighlightLayer
  134348. */
  134349. hasMesh(mesh: AbstractMesh): boolean;
  134350. /**
  134351. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  134352. * @param mesh The mesh to highlight
  134353. * @param color The color of the highlight
  134354. * @param glowEmissiveOnly Extract the glow from the emissive texture
  134355. */
  134356. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  134357. /**
  134358. * Remove a mesh from the highlight layer in order to make it stop glowing.
  134359. * @param mesh The mesh to highlight
  134360. */
  134361. removeMesh(mesh: Mesh): void;
  134362. /**
  134363. * Remove all the meshes currently referenced in the highlight layer
  134364. */
  134365. removeAllMeshes(): void;
  134366. /**
  134367. * Force the stencil to the normal expected value for none glowing parts
  134368. */
  134369. private _defaultStencilReference;
  134370. /**
  134371. * Free any resources and references associated to a mesh.
  134372. * Internal use
  134373. * @param mesh The mesh to free.
  134374. * @hidden
  134375. */
  134376. _disposeMesh(mesh: Mesh): void;
  134377. /**
  134378. * Dispose the highlight layer and free resources.
  134379. */
  134380. dispose(): void;
  134381. /**
  134382. * Gets the class name of the effect layer
  134383. * @returns the string with the class name of the effect layer
  134384. */
  134385. getClassName(): string;
  134386. /**
  134387. * Serializes this Highlight layer
  134388. * @returns a serialized Highlight layer object
  134389. */
  134390. serialize(): any;
  134391. /**
  134392. * Creates a Highlight layer from parsed Highlight layer data
  134393. * @param parsedHightlightLayer defines the Highlight layer data
  134394. * @param scene defines the current scene
  134395. * @param rootUrl defines the root URL containing the Highlight layer information
  134396. * @returns a parsed Highlight layer
  134397. */
  134398. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  134399. }
  134400. }
  134401. declare module BABYLON {
  134402. interface AbstractScene {
  134403. /**
  134404. * The list of layers (background and foreground) of the scene
  134405. */
  134406. layers: Array<Layer>;
  134407. }
  134408. /**
  134409. * Defines the layer scene component responsible to manage any layers
  134410. * in a given scene.
  134411. */
  134412. export class LayerSceneComponent implements ISceneComponent {
  134413. /**
  134414. * The component name helpfull to identify the component in the list of scene components.
  134415. */
  134416. readonly name: string;
  134417. /**
  134418. * The scene the component belongs to.
  134419. */
  134420. scene: Scene;
  134421. private _engine;
  134422. /**
  134423. * Creates a new instance of the component for the given scene
  134424. * @param scene Defines the scene to register the component in
  134425. */
  134426. constructor(scene: Scene);
  134427. /**
  134428. * Registers the component in a given scene
  134429. */
  134430. register(): void;
  134431. /**
  134432. * Rebuilds the elements related to this component in case of
  134433. * context lost for instance.
  134434. */
  134435. rebuild(): void;
  134436. /**
  134437. * Disposes the component and the associated ressources.
  134438. */
  134439. dispose(): void;
  134440. private _draw;
  134441. private _drawCameraPredicate;
  134442. private _drawCameraBackground;
  134443. private _drawCameraForeground;
  134444. private _drawRenderTargetPredicate;
  134445. private _drawRenderTargetBackground;
  134446. private _drawRenderTargetForeground;
  134447. /**
  134448. * Adds all the elements from the container to the scene
  134449. * @param container the container holding the elements
  134450. */
  134451. addFromContainer(container: AbstractScene): void;
  134452. /**
  134453. * Removes all the elements in the container from the scene
  134454. * @param container contains the elements to remove
  134455. * @param dispose if the removed element should be disposed (default: false)
  134456. */
  134457. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134458. }
  134459. }
  134460. declare module BABYLON {
  134461. /** @hidden */
  134462. export var layerPixelShader: {
  134463. name: string;
  134464. shader: string;
  134465. };
  134466. }
  134467. declare module BABYLON {
  134468. /** @hidden */
  134469. export var layerVertexShader: {
  134470. name: string;
  134471. shader: string;
  134472. };
  134473. }
  134474. declare module BABYLON {
  134475. /**
  134476. * This represents a full screen 2d layer.
  134477. * This can be useful to display a picture in the background of your scene for instance.
  134478. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134479. */
  134480. export class Layer {
  134481. /**
  134482. * Define the name of the layer.
  134483. */
  134484. name: string;
  134485. /**
  134486. * Define the texture the layer should display.
  134487. */
  134488. texture: Nullable<Texture>;
  134489. /**
  134490. * Is the layer in background or foreground.
  134491. */
  134492. isBackground: boolean;
  134493. /**
  134494. * Define the color of the layer (instead of texture).
  134495. */
  134496. color: Color4;
  134497. /**
  134498. * Define the scale of the layer in order to zoom in out of the texture.
  134499. */
  134500. scale: Vector2;
  134501. /**
  134502. * Define an offset for the layer in order to shift the texture.
  134503. */
  134504. offset: Vector2;
  134505. /**
  134506. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  134507. */
  134508. alphaBlendingMode: number;
  134509. /**
  134510. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  134511. * Alpha test will not mix with the background color in case of transparency.
  134512. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  134513. */
  134514. alphaTest: boolean;
  134515. /**
  134516. * Define a mask to restrict the layer to only some of the scene cameras.
  134517. */
  134518. layerMask: number;
  134519. /**
  134520. * Define the list of render target the layer is visible into.
  134521. */
  134522. renderTargetTextures: RenderTargetTexture[];
  134523. /**
  134524. * Define if the layer is only used in renderTarget or if it also
  134525. * renders in the main frame buffer of the canvas.
  134526. */
  134527. renderOnlyInRenderTargetTextures: boolean;
  134528. private _scene;
  134529. private _vertexBuffers;
  134530. private _indexBuffer;
  134531. private _effect;
  134532. private _previousDefines;
  134533. /**
  134534. * An event triggered when the layer is disposed.
  134535. */
  134536. onDisposeObservable: Observable<Layer>;
  134537. private _onDisposeObserver;
  134538. /**
  134539. * Back compatibility with callback before the onDisposeObservable existed.
  134540. * The set callback will be triggered when the layer has been disposed.
  134541. */
  134542. set onDispose(callback: () => void);
  134543. /**
  134544. * An event triggered before rendering the scene
  134545. */
  134546. onBeforeRenderObservable: Observable<Layer>;
  134547. private _onBeforeRenderObserver;
  134548. /**
  134549. * Back compatibility with callback before the onBeforeRenderObservable existed.
  134550. * The set callback will be triggered just before rendering the layer.
  134551. */
  134552. set onBeforeRender(callback: () => void);
  134553. /**
  134554. * An event triggered after rendering the scene
  134555. */
  134556. onAfterRenderObservable: Observable<Layer>;
  134557. private _onAfterRenderObserver;
  134558. /**
  134559. * Back compatibility with callback before the onAfterRenderObservable existed.
  134560. * The set callback will be triggered just after rendering the layer.
  134561. */
  134562. set onAfterRender(callback: () => void);
  134563. /**
  134564. * Instantiates a new layer.
  134565. * This represents a full screen 2d layer.
  134566. * This can be useful to display a picture in the background of your scene for instance.
  134567. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134568. * @param name Define the name of the layer in the scene
  134569. * @param imgUrl Define the url of the texture to display in the layer
  134570. * @param scene Define the scene the layer belongs to
  134571. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  134572. * @param color Defines a color for the layer
  134573. */
  134574. constructor(
  134575. /**
  134576. * Define the name of the layer.
  134577. */
  134578. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  134579. private _createIndexBuffer;
  134580. /** @hidden */
  134581. _rebuild(): void;
  134582. /**
  134583. * Renders the layer in the scene.
  134584. */
  134585. render(): void;
  134586. /**
  134587. * Disposes and releases the associated ressources.
  134588. */
  134589. dispose(): void;
  134590. }
  134591. }
  134592. declare module BABYLON {
  134593. /** @hidden */
  134594. export var lensFlarePixelShader: {
  134595. name: string;
  134596. shader: string;
  134597. };
  134598. }
  134599. declare module BABYLON {
  134600. /** @hidden */
  134601. export var lensFlareVertexShader: {
  134602. name: string;
  134603. shader: string;
  134604. };
  134605. }
  134606. declare module BABYLON {
  134607. /**
  134608. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134609. * It is usually composed of several `lensFlare`.
  134610. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134611. */
  134612. export class LensFlareSystem {
  134613. /**
  134614. * Define the name of the lens flare system
  134615. */
  134616. name: string;
  134617. /**
  134618. * List of lens flares used in this system.
  134619. */
  134620. lensFlares: LensFlare[];
  134621. /**
  134622. * Define a limit from the border the lens flare can be visible.
  134623. */
  134624. borderLimit: number;
  134625. /**
  134626. * Define a viewport border we do not want to see the lens flare in.
  134627. */
  134628. viewportBorder: number;
  134629. /**
  134630. * Define a predicate which could limit the list of meshes able to occlude the effect.
  134631. */
  134632. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  134633. /**
  134634. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  134635. */
  134636. layerMask: number;
  134637. /**
  134638. * Define the id of the lens flare system in the scene.
  134639. * (equal to name by default)
  134640. */
  134641. id: string;
  134642. private _scene;
  134643. private _emitter;
  134644. private _vertexBuffers;
  134645. private _indexBuffer;
  134646. private _effect;
  134647. private _positionX;
  134648. private _positionY;
  134649. private _isEnabled;
  134650. /** @hidden */
  134651. static _SceneComponentInitialization: (scene: Scene) => void;
  134652. /**
  134653. * Instantiates a lens flare system.
  134654. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134655. * It is usually composed of several `lensFlare`.
  134656. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134657. * @param name Define the name of the lens flare system in the scene
  134658. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  134659. * @param scene Define the scene the lens flare system belongs to
  134660. */
  134661. constructor(
  134662. /**
  134663. * Define the name of the lens flare system
  134664. */
  134665. name: string, emitter: any, scene: Scene);
  134666. /**
  134667. * Define if the lens flare system is enabled.
  134668. */
  134669. get isEnabled(): boolean;
  134670. set isEnabled(value: boolean);
  134671. /**
  134672. * Get the scene the effects belongs to.
  134673. * @returns the scene holding the lens flare system
  134674. */
  134675. getScene(): Scene;
  134676. /**
  134677. * Get the emitter of the lens flare system.
  134678. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134679. * @returns the emitter of the lens flare system
  134680. */
  134681. getEmitter(): any;
  134682. /**
  134683. * Set the emitter of the lens flare system.
  134684. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134685. * @param newEmitter Define the new emitter of the system
  134686. */
  134687. setEmitter(newEmitter: any): void;
  134688. /**
  134689. * Get the lens flare system emitter position.
  134690. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  134691. * @returns the position
  134692. */
  134693. getEmitterPosition(): Vector3;
  134694. /**
  134695. * @hidden
  134696. */
  134697. computeEffectivePosition(globalViewport: Viewport): boolean;
  134698. /** @hidden */
  134699. _isVisible(): boolean;
  134700. /**
  134701. * @hidden
  134702. */
  134703. render(): boolean;
  134704. /**
  134705. * Dispose and release the lens flare with its associated resources.
  134706. */
  134707. dispose(): void;
  134708. /**
  134709. * Parse a lens flare system from a JSON repressentation
  134710. * @param parsedLensFlareSystem Define the JSON to parse
  134711. * @param scene Define the scene the parsed system should be instantiated in
  134712. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  134713. * @returns the parsed system
  134714. */
  134715. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  134716. /**
  134717. * Serialize the current Lens Flare System into a JSON representation.
  134718. * @returns the serialized JSON
  134719. */
  134720. serialize(): any;
  134721. }
  134722. }
  134723. declare module BABYLON {
  134724. /**
  134725. * This represents one of the lens effect in a `lensFlareSystem`.
  134726. * It controls one of the indiviual texture used in the effect.
  134727. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134728. */
  134729. export class LensFlare {
  134730. /**
  134731. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134732. */
  134733. size: number;
  134734. /**
  134735. * 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.
  134736. */
  134737. position: number;
  134738. /**
  134739. * Define the lens color.
  134740. */
  134741. color: Color3;
  134742. /**
  134743. * Define the lens texture.
  134744. */
  134745. texture: Nullable<Texture>;
  134746. /**
  134747. * Define the alpha mode to render this particular lens.
  134748. */
  134749. alphaMode: number;
  134750. private _system;
  134751. /**
  134752. * Creates a new Lens Flare.
  134753. * This represents one of the lens effect in a `lensFlareSystem`.
  134754. * It controls one of the indiviual texture used in the effect.
  134755. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134756. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  134757. * @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.
  134758. * @param color Define the lens color
  134759. * @param imgUrl Define the lens texture url
  134760. * @param system Define the `lensFlareSystem` this flare is part of
  134761. * @returns The newly created Lens Flare
  134762. */
  134763. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  134764. /**
  134765. * Instantiates a new Lens Flare.
  134766. * This represents one of the lens effect in a `lensFlareSystem`.
  134767. * It controls one of the indiviual texture used in the effect.
  134768. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134769. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  134770. * @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.
  134771. * @param color Define the lens color
  134772. * @param imgUrl Define the lens texture url
  134773. * @param system Define the `lensFlareSystem` this flare is part of
  134774. */
  134775. constructor(
  134776. /**
  134777. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134778. */
  134779. size: number,
  134780. /**
  134781. * 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.
  134782. */
  134783. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  134784. /**
  134785. * Dispose and release the lens flare with its associated resources.
  134786. */
  134787. dispose(): void;
  134788. }
  134789. }
  134790. declare module BABYLON {
  134791. interface AbstractScene {
  134792. /**
  134793. * The list of lens flare system added to the scene
  134794. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134795. */
  134796. lensFlareSystems: Array<LensFlareSystem>;
  134797. /**
  134798. * Removes the given lens flare system from this scene.
  134799. * @param toRemove The lens flare system to remove
  134800. * @returns The index of the removed lens flare system
  134801. */
  134802. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  134803. /**
  134804. * Adds the given lens flare system to this scene
  134805. * @param newLensFlareSystem The lens flare system to add
  134806. */
  134807. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  134808. /**
  134809. * Gets a lens flare system using its name
  134810. * @param name defines the name to look for
  134811. * @returns the lens flare system or null if not found
  134812. */
  134813. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  134814. /**
  134815. * Gets a lens flare system using its id
  134816. * @param id defines the id to look for
  134817. * @returns the lens flare system or null if not found
  134818. */
  134819. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  134820. }
  134821. /**
  134822. * Defines the lens flare scene component responsible to manage any lens flares
  134823. * in a given scene.
  134824. */
  134825. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  134826. /**
  134827. * The component name helpfull to identify the component in the list of scene components.
  134828. */
  134829. readonly name: string;
  134830. /**
  134831. * The scene the component belongs to.
  134832. */
  134833. scene: Scene;
  134834. /**
  134835. * Creates a new instance of the component for the given scene
  134836. * @param scene Defines the scene to register the component in
  134837. */
  134838. constructor(scene: Scene);
  134839. /**
  134840. * Registers the component in a given scene
  134841. */
  134842. register(): void;
  134843. /**
  134844. * Rebuilds the elements related to this component in case of
  134845. * context lost for instance.
  134846. */
  134847. rebuild(): void;
  134848. /**
  134849. * Adds all the elements from the container to the scene
  134850. * @param container the container holding the elements
  134851. */
  134852. addFromContainer(container: AbstractScene): void;
  134853. /**
  134854. * Removes all the elements in the container from the scene
  134855. * @param container contains the elements to remove
  134856. * @param dispose if the removed element should be disposed (default: false)
  134857. */
  134858. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134859. /**
  134860. * Serializes the component data to the specified json object
  134861. * @param serializationObject The object to serialize to
  134862. */
  134863. serialize(serializationObject: any): void;
  134864. /**
  134865. * Disposes the component and the associated ressources.
  134866. */
  134867. dispose(): void;
  134868. private _draw;
  134869. }
  134870. }
  134871. declare module BABYLON {
  134872. /** @hidden */
  134873. export var depthPixelShader: {
  134874. name: string;
  134875. shader: string;
  134876. };
  134877. }
  134878. declare module BABYLON {
  134879. /** @hidden */
  134880. export var depthVertexShader: {
  134881. name: string;
  134882. shader: string;
  134883. };
  134884. }
  134885. declare module BABYLON {
  134886. /**
  134887. * This represents a depth renderer in Babylon.
  134888. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  134889. */
  134890. export class DepthRenderer {
  134891. private _scene;
  134892. private _depthMap;
  134893. private _effect;
  134894. private readonly _storeNonLinearDepth;
  134895. private readonly _clearColor;
  134896. /** Get if the depth renderer is using packed depth or not */
  134897. readonly isPacked: boolean;
  134898. private _cachedDefines;
  134899. private _camera;
  134900. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  134901. enabled: boolean;
  134902. /**
  134903. * Specifiess that the depth renderer will only be used within
  134904. * the camera it is created for.
  134905. * This can help forcing its rendering during the camera processing.
  134906. */
  134907. useOnlyInActiveCamera: boolean;
  134908. /** @hidden */
  134909. static _SceneComponentInitialization: (scene: Scene) => void;
  134910. /**
  134911. * Instantiates a depth renderer
  134912. * @param scene The scene the renderer belongs to
  134913. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  134914. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  134915. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  134916. */
  134917. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  134918. /**
  134919. * Creates the depth rendering effect and checks if the effect is ready.
  134920. * @param subMesh The submesh to be used to render the depth map of
  134921. * @param useInstances If multiple world instances should be used
  134922. * @returns if the depth renderer is ready to render the depth map
  134923. */
  134924. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134925. /**
  134926. * Gets the texture which the depth map will be written to.
  134927. * @returns The depth map texture
  134928. */
  134929. getDepthMap(): RenderTargetTexture;
  134930. /**
  134931. * Disposes of the depth renderer.
  134932. */
  134933. dispose(): void;
  134934. }
  134935. }
  134936. declare module BABYLON {
  134937. /** @hidden */
  134938. export var minmaxReduxPixelShader: {
  134939. name: string;
  134940. shader: string;
  134941. };
  134942. }
  134943. declare module BABYLON {
  134944. /**
  134945. * This class computes a min/max reduction from a texture: it means it computes the minimum
  134946. * and maximum values from all values of the texture.
  134947. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  134948. * The source values are read from the red channel of the texture.
  134949. */
  134950. export class MinMaxReducer {
  134951. /**
  134952. * Observable triggered when the computation has been performed
  134953. */
  134954. onAfterReductionPerformed: Observable<{
  134955. min: number;
  134956. max: number;
  134957. }>;
  134958. protected _camera: Camera;
  134959. protected _sourceTexture: Nullable<RenderTargetTexture>;
  134960. protected _reductionSteps: Nullable<Array<PostProcess>>;
  134961. protected _postProcessManager: PostProcessManager;
  134962. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  134963. protected _forceFullscreenViewport: boolean;
  134964. /**
  134965. * Creates a min/max reducer
  134966. * @param camera The camera to use for the post processes
  134967. */
  134968. constructor(camera: Camera);
  134969. /**
  134970. * Gets the texture used to read the values from.
  134971. */
  134972. get sourceTexture(): Nullable<RenderTargetTexture>;
  134973. /**
  134974. * Sets the source texture to read the values from.
  134975. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  134976. * because in such textures '1' value must not be taken into account to compute the maximum
  134977. * as this value is used to clear the texture.
  134978. * Note that the computation is not activated by calling this function, you must call activate() for that!
  134979. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  134980. * @param depthRedux Indicates if the texture is a depth texture or not
  134981. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  134982. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  134983. */
  134984. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  134985. /**
  134986. * Defines the refresh rate of the computation.
  134987. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  134988. */
  134989. get refreshRate(): number;
  134990. set refreshRate(value: number);
  134991. protected _activated: boolean;
  134992. /**
  134993. * Gets the activation status of the reducer
  134994. */
  134995. get activated(): boolean;
  134996. /**
  134997. * Activates the reduction computation.
  134998. * When activated, the observers registered in onAfterReductionPerformed are
  134999. * called after the compuation is performed
  135000. */
  135001. activate(): void;
  135002. /**
  135003. * Deactivates the reduction computation.
  135004. */
  135005. deactivate(): void;
  135006. /**
  135007. * Disposes the min/max reducer
  135008. * @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.
  135009. */
  135010. dispose(disposeAll?: boolean): void;
  135011. }
  135012. }
  135013. declare module BABYLON {
  135014. /**
  135015. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  135016. */
  135017. export class DepthReducer extends MinMaxReducer {
  135018. private _depthRenderer;
  135019. private _depthRendererId;
  135020. /**
  135021. * Gets the depth renderer used for the computation.
  135022. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  135023. */
  135024. get depthRenderer(): Nullable<DepthRenderer>;
  135025. /**
  135026. * Creates a depth reducer
  135027. * @param camera The camera used to render the depth texture
  135028. */
  135029. constructor(camera: Camera);
  135030. /**
  135031. * Sets the depth renderer to use to generate the depth map
  135032. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  135033. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  135034. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135035. */
  135036. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  135037. /** @hidden */
  135038. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135039. /**
  135040. * Activates the reduction computation.
  135041. * When activated, the observers registered in onAfterReductionPerformed are
  135042. * called after the compuation is performed
  135043. */
  135044. activate(): void;
  135045. /**
  135046. * Deactivates the reduction computation.
  135047. */
  135048. deactivate(): void;
  135049. /**
  135050. * Disposes the depth reducer
  135051. * @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.
  135052. */
  135053. dispose(disposeAll?: boolean): void;
  135054. }
  135055. }
  135056. declare module BABYLON {
  135057. /**
  135058. * A CSM implementation allowing casting shadows on large scenes.
  135059. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  135060. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  135061. */
  135062. export class CascadedShadowGenerator extends ShadowGenerator {
  135063. private static readonly frustumCornersNDCSpace;
  135064. /**
  135065. * Name of the CSM class
  135066. */
  135067. static CLASSNAME: string;
  135068. /**
  135069. * Defines the default number of cascades used by the CSM.
  135070. */
  135071. static readonly DEFAULT_CASCADES_COUNT: number;
  135072. /**
  135073. * Defines the minimum number of cascades used by the CSM.
  135074. */
  135075. static readonly MIN_CASCADES_COUNT: number;
  135076. /**
  135077. * Defines the maximum number of cascades used by the CSM.
  135078. */
  135079. static readonly MAX_CASCADES_COUNT: number;
  135080. protected _validateFilter(filter: number): number;
  135081. /**
  135082. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  135083. */
  135084. penumbraDarkness: number;
  135085. private _numCascades;
  135086. /**
  135087. * Gets or set the number of cascades used by the CSM.
  135088. */
  135089. get numCascades(): number;
  135090. set numCascades(value: number);
  135091. /**
  135092. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  135093. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  135094. */
  135095. stabilizeCascades: boolean;
  135096. private _freezeShadowCastersBoundingInfo;
  135097. private _freezeShadowCastersBoundingInfoObservable;
  135098. /**
  135099. * Enables or disables the shadow casters bounding info computation.
  135100. * If your shadow casters don't move, you can disable this feature.
  135101. * If it is enabled, the bounding box computation is done every frame.
  135102. */
  135103. get freezeShadowCastersBoundingInfo(): boolean;
  135104. set freezeShadowCastersBoundingInfo(freeze: boolean);
  135105. private _scbiMin;
  135106. private _scbiMax;
  135107. protected _computeShadowCastersBoundingInfo(): void;
  135108. protected _shadowCastersBoundingInfo: BoundingInfo;
  135109. /**
  135110. * Gets or sets the shadow casters bounding info.
  135111. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  135112. * so that the system won't overwrite the bounds you provide
  135113. */
  135114. get shadowCastersBoundingInfo(): BoundingInfo;
  135115. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  135116. protected _breaksAreDirty: boolean;
  135117. protected _minDistance: number;
  135118. protected _maxDistance: number;
  135119. /**
  135120. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  135121. *
  135122. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  135123. * If you don't know these values, simply leave them to their defaults and don't call this function.
  135124. * @param min minimal distance for the breaks (default to 0.)
  135125. * @param max maximal distance for the breaks (default to 1.)
  135126. */
  135127. setMinMaxDistance(min: number, max: number): void;
  135128. /** Gets the minimal distance used in the cascade break computation */
  135129. get minDistance(): number;
  135130. /** Gets the maximal distance used in the cascade break computation */
  135131. get maxDistance(): number;
  135132. /**
  135133. * Gets the class name of that object
  135134. * @returns "CascadedShadowGenerator"
  135135. */
  135136. getClassName(): string;
  135137. private _cascadeMinExtents;
  135138. private _cascadeMaxExtents;
  135139. /**
  135140. * Gets a cascade minimum extents
  135141. * @param cascadeIndex index of the cascade
  135142. * @returns the minimum cascade extents
  135143. */
  135144. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  135145. /**
  135146. * Gets a cascade maximum extents
  135147. * @param cascadeIndex index of the cascade
  135148. * @returns the maximum cascade extents
  135149. */
  135150. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  135151. private _cascades;
  135152. private _currentLayer;
  135153. private _viewSpaceFrustumsZ;
  135154. private _viewMatrices;
  135155. private _projectionMatrices;
  135156. private _transformMatrices;
  135157. private _transformMatricesAsArray;
  135158. private _frustumLengths;
  135159. private _lightSizeUVCorrection;
  135160. private _depthCorrection;
  135161. private _frustumCornersWorldSpace;
  135162. private _frustumCenter;
  135163. private _shadowCameraPos;
  135164. private _shadowMaxZ;
  135165. /**
  135166. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  135167. * It defaults to camera.maxZ
  135168. */
  135169. get shadowMaxZ(): number;
  135170. /**
  135171. * Sets the shadow max z distance.
  135172. */
  135173. set shadowMaxZ(value: number);
  135174. protected _debug: boolean;
  135175. /**
  135176. * Gets or sets the debug flag.
  135177. * When enabled, the cascades are materialized by different colors on the screen.
  135178. */
  135179. get debug(): boolean;
  135180. set debug(dbg: boolean);
  135181. private _depthClamp;
  135182. /**
  135183. * Gets or sets the depth clamping value.
  135184. *
  135185. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  135186. * to account for the shadow casters far away.
  135187. *
  135188. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  135189. */
  135190. get depthClamp(): boolean;
  135191. set depthClamp(value: boolean);
  135192. private _cascadeBlendPercentage;
  135193. /**
  135194. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  135195. * It defaults to 0.1 (10% blending).
  135196. */
  135197. get cascadeBlendPercentage(): number;
  135198. set cascadeBlendPercentage(value: number);
  135199. private _lambda;
  135200. /**
  135201. * Gets or set the lambda parameter.
  135202. * This parameter is used to split the camera frustum and create the cascades.
  135203. * 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.
  135204. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  135205. */
  135206. get lambda(): number;
  135207. set lambda(value: number);
  135208. /**
  135209. * Gets the view matrix corresponding to a given cascade
  135210. * @param cascadeNum cascade to retrieve the view matrix from
  135211. * @returns the cascade view matrix
  135212. */
  135213. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  135214. /**
  135215. * Gets the projection matrix corresponding to a given cascade
  135216. * @param cascadeNum cascade to retrieve the projection matrix from
  135217. * @returns the cascade projection matrix
  135218. */
  135219. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  135220. /**
  135221. * Gets the transformation matrix corresponding to a given cascade
  135222. * @param cascadeNum cascade to retrieve the transformation matrix from
  135223. * @returns the cascade transformation matrix
  135224. */
  135225. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  135226. private _depthRenderer;
  135227. /**
  135228. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  135229. *
  135230. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  135231. *
  135232. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  135233. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  135234. * @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
  135235. */
  135236. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  135237. private _depthReducer;
  135238. private _autoCalcDepthBounds;
  135239. /**
  135240. * Gets or sets the autoCalcDepthBounds property.
  135241. *
  135242. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  135243. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  135244. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  135245. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  135246. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  135247. */
  135248. get autoCalcDepthBounds(): boolean;
  135249. set autoCalcDepthBounds(value: boolean);
  135250. /**
  135251. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  135252. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135253. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  135254. * for setting the refresh rate on the renderer yourself!
  135255. */
  135256. get autoCalcDepthBoundsRefreshRate(): number;
  135257. set autoCalcDepthBoundsRefreshRate(value: number);
  135258. /**
  135259. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  135260. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  135261. * you change the camera near/far planes!
  135262. */
  135263. splitFrustum(): void;
  135264. private _splitFrustum;
  135265. private _computeMatrices;
  135266. private _computeFrustumInWorldSpace;
  135267. private _computeCascadeFrustum;
  135268. /**
  135269. * Support test.
  135270. */
  135271. static get IsSupported(): boolean;
  135272. /** @hidden */
  135273. static _SceneComponentInitialization: (scene: Scene) => void;
  135274. /**
  135275. * Creates a Cascaded Shadow Generator object.
  135276. * A ShadowGenerator is the required tool to use the shadows.
  135277. * Each directional light casting shadows needs to use its own ShadowGenerator.
  135278. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  135279. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  135280. * @param light The directional light object generating the shadows.
  135281. * @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.
  135282. */
  135283. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  135284. protected _initializeGenerator(): void;
  135285. protected _createTargetRenderTexture(): void;
  135286. protected _initializeShadowMap(): void;
  135287. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  135288. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  135289. /**
  135290. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  135291. * @param defines Defines of the material we want to update
  135292. * @param lightIndex Index of the light in the enabled light list of the material
  135293. */
  135294. prepareDefines(defines: any, lightIndex: number): void;
  135295. /**
  135296. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  135297. * defined in the generator but impacting the effect).
  135298. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  135299. * @param effect The effect we are binfing the information for
  135300. */
  135301. bindShadowLight(lightIndex: string, effect: Effect): void;
  135302. /**
  135303. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  135304. * (eq to view projection * shadow projection matrices)
  135305. * @returns The transform matrix used to create the shadow map
  135306. */
  135307. getTransformMatrix(): Matrix;
  135308. /**
  135309. * Disposes the ShadowGenerator.
  135310. * Returns nothing.
  135311. */
  135312. dispose(): void;
  135313. /**
  135314. * Serializes the shadow generator setup to a json object.
  135315. * @returns The serialized JSON object
  135316. */
  135317. serialize(): any;
  135318. /**
  135319. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  135320. * @param parsedShadowGenerator The JSON object to parse
  135321. * @param scene The scene to create the shadow map for
  135322. * @returns The parsed shadow generator
  135323. */
  135324. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  135325. }
  135326. }
  135327. declare module BABYLON {
  135328. /**
  135329. * Defines the shadow generator component responsible to manage any shadow generators
  135330. * in a given scene.
  135331. */
  135332. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  135333. /**
  135334. * The component name helpfull to identify the component in the list of scene components.
  135335. */
  135336. readonly name: string;
  135337. /**
  135338. * The scene the component belongs to.
  135339. */
  135340. scene: Scene;
  135341. /**
  135342. * Creates a new instance of the component for the given scene
  135343. * @param scene Defines the scene to register the component in
  135344. */
  135345. constructor(scene: Scene);
  135346. /**
  135347. * Registers the component in a given scene
  135348. */
  135349. register(): void;
  135350. /**
  135351. * Rebuilds the elements related to this component in case of
  135352. * context lost for instance.
  135353. */
  135354. rebuild(): void;
  135355. /**
  135356. * Serializes the component data to the specified json object
  135357. * @param serializationObject The object to serialize to
  135358. */
  135359. serialize(serializationObject: any): void;
  135360. /**
  135361. * Adds all the elements from the container to the scene
  135362. * @param container the container holding the elements
  135363. */
  135364. addFromContainer(container: AbstractScene): void;
  135365. /**
  135366. * Removes all the elements in the container from the scene
  135367. * @param container contains the elements to remove
  135368. * @param dispose if the removed element should be disposed (default: false)
  135369. */
  135370. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135371. /**
  135372. * Rebuilds the elements related to this component in case of
  135373. * context lost for instance.
  135374. */
  135375. dispose(): void;
  135376. private _gatherRenderTargets;
  135377. }
  135378. }
  135379. declare module BABYLON {
  135380. /**
  135381. * A point light is a light defined by an unique point in world space.
  135382. * The light is emitted in every direction from this point.
  135383. * A good example of a point light is a standard light bulb.
  135384. * Documentation: https://doc.babylonjs.com/babylon101/lights
  135385. */
  135386. export class PointLight extends ShadowLight {
  135387. private _shadowAngle;
  135388. /**
  135389. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135390. * This specifies what angle the shadow will use to be created.
  135391. *
  135392. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135393. */
  135394. get shadowAngle(): number;
  135395. /**
  135396. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135397. * This specifies what angle the shadow will use to be created.
  135398. *
  135399. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135400. */
  135401. set shadowAngle(value: number);
  135402. /**
  135403. * Gets the direction if it has been set.
  135404. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135405. */
  135406. get direction(): Vector3;
  135407. /**
  135408. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135409. */
  135410. set direction(value: Vector3);
  135411. /**
  135412. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  135413. * A PointLight emits the light in every direction.
  135414. * It can cast shadows.
  135415. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  135416. * ```javascript
  135417. * var pointLight = new PointLight("pl", camera.position, scene);
  135418. * ```
  135419. * Documentation : https://doc.babylonjs.com/babylon101/lights
  135420. * @param name The light friendly name
  135421. * @param position The position of the point light in the scene
  135422. * @param scene The scene the lights belongs to
  135423. */
  135424. constructor(name: string, position: Vector3, scene: Scene);
  135425. /**
  135426. * Returns the string "PointLight"
  135427. * @returns the class name
  135428. */
  135429. getClassName(): string;
  135430. /**
  135431. * Returns the integer 0.
  135432. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  135433. */
  135434. getTypeID(): number;
  135435. /**
  135436. * Specifies wether or not the shadowmap should be a cube texture.
  135437. * @returns true if the shadowmap needs to be a cube texture.
  135438. */
  135439. needCube(): boolean;
  135440. /**
  135441. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  135442. * @param faceIndex The index of the face we are computed the direction to generate shadow
  135443. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  135444. */
  135445. getShadowDirection(faceIndex?: number): Vector3;
  135446. /**
  135447. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  135448. * - fov = PI / 2
  135449. * - aspect ratio : 1.0
  135450. * - z-near and far equal to the active camera minZ and maxZ.
  135451. * Returns the PointLight.
  135452. */
  135453. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  135454. protected _buildUniformLayout(): void;
  135455. /**
  135456. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  135457. * @param effect The effect to update
  135458. * @param lightIndex The index of the light in the effect to update
  135459. * @returns The point light
  135460. */
  135461. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  135462. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  135463. /**
  135464. * Prepares the list of defines specific to the light type.
  135465. * @param defines the list of defines
  135466. * @param lightIndex defines the index of the light for the effect
  135467. */
  135468. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  135469. }
  135470. }
  135471. declare module BABYLON {
  135472. /**
  135473. * Header information of HDR texture files.
  135474. */
  135475. export interface HDRInfo {
  135476. /**
  135477. * The height of the texture in pixels.
  135478. */
  135479. height: number;
  135480. /**
  135481. * The width of the texture in pixels.
  135482. */
  135483. width: number;
  135484. /**
  135485. * The index of the beginning of the data in the binary file.
  135486. */
  135487. dataPosition: number;
  135488. }
  135489. /**
  135490. * This groups tools to convert HDR texture to native colors array.
  135491. */
  135492. export class HDRTools {
  135493. private static Ldexp;
  135494. private static Rgbe2float;
  135495. private static readStringLine;
  135496. /**
  135497. * Reads header information from an RGBE texture stored in a native array.
  135498. * More information on this format are available here:
  135499. * https://en.wikipedia.org/wiki/RGBE_image_format
  135500. *
  135501. * @param uint8array The binary file stored in native array.
  135502. * @return The header information.
  135503. */
  135504. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  135505. /**
  135506. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  135507. * This RGBE texture needs to store the information as a panorama.
  135508. *
  135509. * More information on this format are available here:
  135510. * https://en.wikipedia.org/wiki/RGBE_image_format
  135511. *
  135512. * @param buffer The binary file stored in an array buffer.
  135513. * @param size The expected size of the extracted cubemap.
  135514. * @return The Cube Map information.
  135515. */
  135516. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  135517. /**
  135518. * Returns the pixels data extracted from an RGBE texture.
  135519. * This pixels will be stored left to right up to down in the R G B order in one array.
  135520. *
  135521. * More information on this format are available here:
  135522. * https://en.wikipedia.org/wiki/RGBE_image_format
  135523. *
  135524. * @param uint8array The binary file stored in an array buffer.
  135525. * @param hdrInfo The header information of the file.
  135526. * @return The pixels data in RGB right to left up to down order.
  135527. */
  135528. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  135529. private static RGBE_ReadPixels_RLE;
  135530. }
  135531. }
  135532. declare module BABYLON {
  135533. /**
  135534. * Effect Render Options
  135535. */
  135536. export interface IEffectRendererOptions {
  135537. /**
  135538. * Defines the vertices positions.
  135539. */
  135540. positions?: number[];
  135541. /**
  135542. * Defines the indices.
  135543. */
  135544. indices?: number[];
  135545. }
  135546. /**
  135547. * Helper class to render one or more effects.
  135548. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  135549. */
  135550. export class EffectRenderer {
  135551. private engine;
  135552. private static _DefaultOptions;
  135553. private _vertexBuffers;
  135554. private _indexBuffer;
  135555. private _fullscreenViewport;
  135556. /**
  135557. * Creates an effect renderer
  135558. * @param engine the engine to use for rendering
  135559. * @param options defines the options of the effect renderer
  135560. */
  135561. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  135562. /**
  135563. * Sets the current viewport in normalized coordinates 0-1
  135564. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  135565. */
  135566. setViewport(viewport?: Viewport): void;
  135567. /**
  135568. * Binds the embedded attributes buffer to the effect.
  135569. * @param effect Defines the effect to bind the attributes for
  135570. */
  135571. bindBuffers(effect: Effect): void;
  135572. /**
  135573. * Sets the current effect wrapper to use during draw.
  135574. * The effect needs to be ready before calling this api.
  135575. * This also sets the default full screen position attribute.
  135576. * @param effectWrapper Defines the effect to draw with
  135577. */
  135578. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135579. /**
  135580. * Restores engine states
  135581. */
  135582. restoreStates(): void;
  135583. /**
  135584. * Draws a full screen quad.
  135585. */
  135586. draw(): void;
  135587. private isRenderTargetTexture;
  135588. /**
  135589. * renders one or more effects to a specified texture
  135590. * @param effectWrapper the effect to renderer
  135591. * @param outputTexture texture to draw to, if null it will render to the screen.
  135592. */
  135593. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135594. /**
  135595. * Disposes of the effect renderer
  135596. */
  135597. dispose(): void;
  135598. }
  135599. /**
  135600. * Options to create an EffectWrapper
  135601. */
  135602. interface EffectWrapperCreationOptions {
  135603. /**
  135604. * Engine to use to create the effect
  135605. */
  135606. engine: ThinEngine;
  135607. /**
  135608. * Fragment shader for the effect
  135609. */
  135610. fragmentShader: string;
  135611. /**
  135612. * Use the shader store instead of direct source code
  135613. */
  135614. useShaderStore?: boolean;
  135615. /**
  135616. * Vertex shader for the effect
  135617. */
  135618. vertexShader?: string;
  135619. /**
  135620. * Attributes to use in the shader
  135621. */
  135622. attributeNames?: Array<string>;
  135623. /**
  135624. * Uniforms to use in the shader
  135625. */
  135626. uniformNames?: Array<string>;
  135627. /**
  135628. * Texture sampler names to use in the shader
  135629. */
  135630. samplerNames?: Array<string>;
  135631. /**
  135632. * Defines to use in the shader
  135633. */
  135634. defines?: Array<string>;
  135635. /**
  135636. * Callback when effect is compiled
  135637. */
  135638. onCompiled?: Nullable<(effect: Effect) => void>;
  135639. /**
  135640. * The friendly name of the effect displayed in Spector.
  135641. */
  135642. name?: string;
  135643. }
  135644. /**
  135645. * Wraps an effect to be used for rendering
  135646. */
  135647. export class EffectWrapper {
  135648. /**
  135649. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135650. */
  135651. onApplyObservable: Observable<{}>;
  135652. /**
  135653. * The underlying effect
  135654. */
  135655. effect: Effect;
  135656. /**
  135657. * Creates an effect to be renderer
  135658. * @param creationOptions options to create the effect
  135659. */
  135660. constructor(creationOptions: EffectWrapperCreationOptions);
  135661. /**
  135662. * Disposes of the effect wrapper
  135663. */
  135664. dispose(): void;
  135665. }
  135666. }
  135667. declare module BABYLON {
  135668. /** @hidden */
  135669. export var hdrFilteringVertexShader: {
  135670. name: string;
  135671. shader: string;
  135672. };
  135673. }
  135674. declare module BABYLON {
  135675. /** @hidden */
  135676. export var hdrFilteringPixelShader: {
  135677. name: string;
  135678. shader: string;
  135679. };
  135680. }
  135681. declare module BABYLON {
  135682. /**
  135683. * Options for texture filtering
  135684. */
  135685. interface IHDRFilteringOptions {
  135686. /**
  135687. * Scales pixel intensity for the input HDR map.
  135688. */
  135689. hdrScale?: number;
  135690. /**
  135691. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  135692. */
  135693. quality?: number;
  135694. }
  135695. /**
  135696. * Filters HDR maps to get correct renderings of PBR reflections
  135697. */
  135698. export class HDRFiltering {
  135699. private _engine;
  135700. private _effectRenderer;
  135701. private _effectWrapper;
  135702. private _lodGenerationOffset;
  135703. private _lodGenerationScale;
  135704. /**
  135705. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  135706. * you care about baking speed.
  135707. */
  135708. quality: number;
  135709. /**
  135710. * Scales pixel intensity for the input HDR map.
  135711. */
  135712. hdrScale: number;
  135713. /**
  135714. * Instantiates HDR filter for reflection maps
  135715. *
  135716. * @param engine Thin engine
  135717. * @param options Options
  135718. */
  135719. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  135720. private _createRenderTarget;
  135721. private _prefilterInternal;
  135722. private _createEffect;
  135723. /**
  135724. * Get a value indicating if the filter is ready to be used
  135725. * @param texture Texture to filter
  135726. * @returns true if the filter is ready
  135727. */
  135728. isReady(texture: BaseTexture): boolean;
  135729. /**
  135730. * Prefilters a cube texture to have mipmap levels representing roughness values.
  135731. * Prefiltering will be invoked at the end of next rendering pass.
  135732. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  135733. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  135734. * @param texture Texture to filter
  135735. * @param onFinished Callback when filtering is done
  135736. * @return Promise called when prefiltering is done
  135737. */
  135738. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  135739. }
  135740. }
  135741. declare module BABYLON {
  135742. /**
  135743. * This represents a texture coming from an HDR input.
  135744. *
  135745. * The only supported format is currently panorama picture stored in RGBE format.
  135746. * Example of such files can be found on HDRLib: http://hdrlib.com/
  135747. */
  135748. export class HDRCubeTexture extends BaseTexture {
  135749. private static _facesMapping;
  135750. private _generateHarmonics;
  135751. private _noMipmap;
  135752. private _prefilterOnLoad;
  135753. private _textureMatrix;
  135754. private _size;
  135755. private _onLoad;
  135756. private _onError;
  135757. /**
  135758. * The texture URL.
  135759. */
  135760. url: string;
  135761. /**
  135762. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  135763. */
  135764. coordinatesMode: number;
  135765. protected _isBlocking: boolean;
  135766. /**
  135767. * Sets wether or not the texture is blocking during loading.
  135768. */
  135769. set isBlocking(value: boolean);
  135770. /**
  135771. * Gets wether or not the texture is blocking during loading.
  135772. */
  135773. get isBlocking(): boolean;
  135774. protected _rotationY: number;
  135775. /**
  135776. * Sets texture matrix rotation angle around Y axis in radians.
  135777. */
  135778. set rotationY(value: number);
  135779. /**
  135780. * Gets texture matrix rotation angle around Y axis radians.
  135781. */
  135782. get rotationY(): number;
  135783. /**
  135784. * Gets or sets the center of the bounding box associated with the cube texture
  135785. * It must define where the camera used to render the texture was set
  135786. */
  135787. boundingBoxPosition: Vector3;
  135788. private _boundingBoxSize;
  135789. /**
  135790. * Gets or sets the size of the bounding box associated with the cube texture
  135791. * When defined, the cubemap will switch to local mode
  135792. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  135793. * @example https://www.babylonjs-playground.com/#RNASML
  135794. */
  135795. set boundingBoxSize(value: Vector3);
  135796. get boundingBoxSize(): Vector3;
  135797. /**
  135798. * Instantiates an HDRTexture from the following parameters.
  135799. *
  135800. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  135801. * @param sceneOrEngine The scene or engine the texture will be used in
  135802. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  135803. * @param noMipmap Forces to not generate the mipmap if true
  135804. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  135805. * @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)
  135806. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  135807. */
  135808. 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>);
  135809. /**
  135810. * Get the current class name of the texture useful for serialization or dynamic coding.
  135811. * @returns "HDRCubeTexture"
  135812. */
  135813. getClassName(): string;
  135814. /**
  135815. * Occurs when the file is raw .hdr file.
  135816. */
  135817. private loadTexture;
  135818. clone(): HDRCubeTexture;
  135819. delayLoad(): void;
  135820. /**
  135821. * Get the texture reflection matrix used to rotate/transform the reflection.
  135822. * @returns the reflection matrix
  135823. */
  135824. getReflectionTextureMatrix(): Matrix;
  135825. /**
  135826. * Set the texture reflection matrix used to rotate/transform the reflection.
  135827. * @param value Define the reflection matrix to set
  135828. */
  135829. setReflectionTextureMatrix(value: Matrix): void;
  135830. /**
  135831. * Parses a JSON representation of an HDR Texture in order to create the texture
  135832. * @param parsedTexture Define the JSON representation
  135833. * @param scene Define the scene the texture should be created in
  135834. * @param rootUrl Define the root url in case we need to load relative dependencies
  135835. * @returns the newly created texture after parsing
  135836. */
  135837. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  135838. serialize(): any;
  135839. }
  135840. }
  135841. declare module BABYLON {
  135842. /**
  135843. * Class used to control physics engine
  135844. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  135845. */
  135846. export class PhysicsEngine implements IPhysicsEngine {
  135847. private _physicsPlugin;
  135848. /**
  135849. * Global value used to control the smallest number supported by the simulation
  135850. */
  135851. static Epsilon: number;
  135852. private _impostors;
  135853. private _joints;
  135854. private _subTimeStep;
  135855. /**
  135856. * Gets the gravity vector used by the simulation
  135857. */
  135858. gravity: Vector3;
  135859. /**
  135860. * Factory used to create the default physics plugin.
  135861. * @returns The default physics plugin
  135862. */
  135863. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  135864. /**
  135865. * Creates a new Physics Engine
  135866. * @param gravity defines the gravity vector used by the simulation
  135867. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  135868. */
  135869. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  135870. /**
  135871. * Sets the gravity vector used by the simulation
  135872. * @param gravity defines the gravity vector to use
  135873. */
  135874. setGravity(gravity: Vector3): void;
  135875. /**
  135876. * Set the time step of the physics engine.
  135877. * Default is 1/60.
  135878. * To slow it down, enter 1/600 for example.
  135879. * To speed it up, 1/30
  135880. * @param newTimeStep defines the new timestep to apply to this world.
  135881. */
  135882. setTimeStep(newTimeStep?: number): void;
  135883. /**
  135884. * Get the time step of the physics engine.
  135885. * @returns the current time step
  135886. */
  135887. getTimeStep(): number;
  135888. /**
  135889. * Set the sub time step of the physics engine.
  135890. * Default is 0 meaning there is no sub steps
  135891. * To increase physics resolution precision, set a small value (like 1 ms)
  135892. * @param subTimeStep defines the new sub timestep used for physics resolution.
  135893. */
  135894. setSubTimeStep(subTimeStep?: number): void;
  135895. /**
  135896. * Get the sub time step of the physics engine.
  135897. * @returns the current sub time step
  135898. */
  135899. getSubTimeStep(): number;
  135900. /**
  135901. * Release all resources
  135902. */
  135903. dispose(): void;
  135904. /**
  135905. * Gets the name of the current physics plugin
  135906. * @returns the name of the plugin
  135907. */
  135908. getPhysicsPluginName(): string;
  135909. /**
  135910. * Adding a new impostor for the impostor tracking.
  135911. * This will be done by the impostor itself.
  135912. * @param impostor the impostor to add
  135913. */
  135914. addImpostor(impostor: PhysicsImpostor): void;
  135915. /**
  135916. * Remove an impostor from the engine.
  135917. * This impostor and its mesh will not longer be updated by the physics engine.
  135918. * @param impostor the impostor to remove
  135919. */
  135920. removeImpostor(impostor: PhysicsImpostor): void;
  135921. /**
  135922. * Add a joint to the physics engine
  135923. * @param mainImpostor defines the main impostor to which the joint is added.
  135924. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  135925. * @param joint defines the joint that will connect both impostors.
  135926. */
  135927. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  135928. /**
  135929. * Removes a joint from the simulation
  135930. * @param mainImpostor defines the impostor used with the joint
  135931. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  135932. * @param joint defines the joint to remove
  135933. */
  135934. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  135935. /**
  135936. * Called by the scene. No need to call it.
  135937. * @param delta defines the timespam between frames
  135938. */
  135939. _step(delta: number): void;
  135940. /**
  135941. * Gets the current plugin used to run the simulation
  135942. * @returns current plugin
  135943. */
  135944. getPhysicsPlugin(): IPhysicsEnginePlugin;
  135945. /**
  135946. * Gets the list of physic impostors
  135947. * @returns an array of PhysicsImpostor
  135948. */
  135949. getImpostors(): Array<PhysicsImpostor>;
  135950. /**
  135951. * Gets the impostor for a physics enabled object
  135952. * @param object defines the object impersonated by the impostor
  135953. * @returns the PhysicsImpostor or null if not found
  135954. */
  135955. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  135956. /**
  135957. * Gets the impostor for a physics body object
  135958. * @param body defines physics body used by the impostor
  135959. * @returns the PhysicsImpostor or null if not found
  135960. */
  135961. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  135962. /**
  135963. * Does a raycast in the physics world
  135964. * @param from when should the ray start?
  135965. * @param to when should the ray end?
  135966. * @returns PhysicsRaycastResult
  135967. */
  135968. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  135969. }
  135970. }
  135971. declare module BABYLON {
  135972. /** @hidden */
  135973. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  135974. private _useDeltaForWorldStep;
  135975. world: any;
  135976. name: string;
  135977. private _physicsMaterials;
  135978. private _fixedTimeStep;
  135979. private _cannonRaycastResult;
  135980. private _raycastResult;
  135981. private _physicsBodysToRemoveAfterStep;
  135982. private _firstFrame;
  135983. BJSCANNON: any;
  135984. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  135985. setGravity(gravity: Vector3): void;
  135986. setTimeStep(timeStep: number): void;
  135987. getTimeStep(): number;
  135988. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  135989. private _removeMarkedPhysicsBodiesFromWorld;
  135990. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135991. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135992. generatePhysicsBody(impostor: PhysicsImpostor): void;
  135993. private _processChildMeshes;
  135994. removePhysicsBody(impostor: PhysicsImpostor): void;
  135995. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  135996. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  135997. private _addMaterial;
  135998. private _checkWithEpsilon;
  135999. private _createShape;
  136000. private _createHeightmap;
  136001. private _minus90X;
  136002. private _plus90X;
  136003. private _tmpPosition;
  136004. private _tmpDeltaPosition;
  136005. private _tmpUnityRotation;
  136006. private _updatePhysicsBodyTransformation;
  136007. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136008. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136009. isSupported(): boolean;
  136010. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136011. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136012. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136013. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136014. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136015. getBodyMass(impostor: PhysicsImpostor): number;
  136016. getBodyFriction(impostor: PhysicsImpostor): number;
  136017. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136018. getBodyRestitution(impostor: PhysicsImpostor): number;
  136019. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136020. sleepBody(impostor: PhysicsImpostor): void;
  136021. wakeUpBody(impostor: PhysicsImpostor): void;
  136022. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  136023. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136024. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136025. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136026. getRadius(impostor: PhysicsImpostor): number;
  136027. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136028. dispose(): void;
  136029. private _extendNamespace;
  136030. /**
  136031. * Does a raycast in the physics world
  136032. * @param from when should the ray start?
  136033. * @param to when should the ray end?
  136034. * @returns PhysicsRaycastResult
  136035. */
  136036. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136037. }
  136038. }
  136039. declare module BABYLON {
  136040. /** @hidden */
  136041. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  136042. private _useDeltaForWorldStep;
  136043. world: any;
  136044. name: string;
  136045. BJSOIMO: any;
  136046. private _raycastResult;
  136047. private _fixedTimeStep;
  136048. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  136049. setGravity(gravity: Vector3): void;
  136050. setTimeStep(timeStep: number): void;
  136051. getTimeStep(): number;
  136052. private _tmpImpostorsArray;
  136053. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136054. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136055. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136056. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136057. private _tmpPositionVector;
  136058. removePhysicsBody(impostor: PhysicsImpostor): void;
  136059. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136060. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136061. isSupported(): boolean;
  136062. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136063. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136064. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136065. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136066. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136067. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136068. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136069. getBodyMass(impostor: PhysicsImpostor): number;
  136070. getBodyFriction(impostor: PhysicsImpostor): number;
  136071. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136072. getBodyRestitution(impostor: PhysicsImpostor): number;
  136073. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136074. sleepBody(impostor: PhysicsImpostor): void;
  136075. wakeUpBody(impostor: PhysicsImpostor): void;
  136076. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  136077. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  136078. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  136079. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136080. getRadius(impostor: PhysicsImpostor): number;
  136081. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136082. dispose(): void;
  136083. /**
  136084. * Does a raycast in the physics world
  136085. * @param from when should the ray start?
  136086. * @param to when should the ray end?
  136087. * @returns PhysicsRaycastResult
  136088. */
  136089. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136090. }
  136091. }
  136092. declare module BABYLON {
  136093. /**
  136094. * Class containing static functions to help procedurally build meshes
  136095. */
  136096. export class RibbonBuilder {
  136097. /**
  136098. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136099. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  136100. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  136101. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  136102. * * 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
  136103. * * 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
  136104. * * 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
  136105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136107. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136108. * * 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
  136109. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  136110. * * 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
  136111. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  136112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136113. * @param name defines the name of the mesh
  136114. * @param options defines the options used to create the mesh
  136115. * @param scene defines the hosting scene
  136116. * @returns the ribbon mesh
  136117. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  136118. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136119. */
  136120. static CreateRibbon(name: string, options: {
  136121. pathArray: Vector3[][];
  136122. closeArray?: boolean;
  136123. closePath?: boolean;
  136124. offset?: number;
  136125. updatable?: boolean;
  136126. sideOrientation?: number;
  136127. frontUVs?: Vector4;
  136128. backUVs?: Vector4;
  136129. instance?: Mesh;
  136130. invertUV?: boolean;
  136131. uvs?: Vector2[];
  136132. colors?: Color4[];
  136133. }, scene?: Nullable<Scene>): Mesh;
  136134. }
  136135. }
  136136. declare module BABYLON {
  136137. /**
  136138. * Class containing static functions to help procedurally build meshes
  136139. */
  136140. export class ShapeBuilder {
  136141. /**
  136142. * 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.
  136143. * * 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.
  136144. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136145. * * 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.
  136146. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136147. * * 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
  136148. * * 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
  136149. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136152. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136154. * @param name defines the name of the mesh
  136155. * @param options defines the options used to create the mesh
  136156. * @param scene defines the hosting scene
  136157. * @returns the extruded shape mesh
  136158. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136159. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136160. */
  136161. static ExtrudeShape(name: string, options: {
  136162. shape: Vector3[];
  136163. path: Vector3[];
  136164. scale?: number;
  136165. rotation?: number;
  136166. cap?: number;
  136167. updatable?: boolean;
  136168. sideOrientation?: number;
  136169. frontUVs?: Vector4;
  136170. backUVs?: Vector4;
  136171. instance?: Mesh;
  136172. invertUV?: boolean;
  136173. }, scene?: Nullable<Scene>): Mesh;
  136174. /**
  136175. * Creates an custom extruded shape mesh.
  136176. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136177. * * 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.
  136178. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136179. * * 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
  136180. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136181. * * 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
  136182. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136183. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136184. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136185. * * 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
  136186. * * 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
  136187. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136190. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136192. * @param name defines the name of the mesh
  136193. * @param options defines the options used to create the mesh
  136194. * @param scene defines the hosting scene
  136195. * @returns the custom extruded shape mesh
  136196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136197. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136199. */
  136200. static ExtrudeShapeCustom(name: string, options: {
  136201. shape: Vector3[];
  136202. path: Vector3[];
  136203. scaleFunction?: any;
  136204. rotationFunction?: any;
  136205. ribbonCloseArray?: boolean;
  136206. ribbonClosePath?: boolean;
  136207. cap?: number;
  136208. updatable?: boolean;
  136209. sideOrientation?: number;
  136210. frontUVs?: Vector4;
  136211. backUVs?: Vector4;
  136212. instance?: Mesh;
  136213. invertUV?: boolean;
  136214. }, scene?: Nullable<Scene>): Mesh;
  136215. private static _ExtrudeShapeGeneric;
  136216. }
  136217. }
  136218. declare module BABYLON {
  136219. /**
  136220. * AmmoJS Physics plugin
  136221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  136222. * @see https://github.com/kripken/ammo.js/
  136223. */
  136224. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  136225. private _useDeltaForWorldStep;
  136226. /**
  136227. * Reference to the Ammo library
  136228. */
  136229. bjsAMMO: any;
  136230. /**
  136231. * Created ammoJS world which physics bodies are added to
  136232. */
  136233. world: any;
  136234. /**
  136235. * Name of the plugin
  136236. */
  136237. name: string;
  136238. private _timeStep;
  136239. private _fixedTimeStep;
  136240. private _maxSteps;
  136241. private _tmpQuaternion;
  136242. private _tmpAmmoTransform;
  136243. private _tmpAmmoQuaternion;
  136244. private _tmpAmmoConcreteContactResultCallback;
  136245. private _collisionConfiguration;
  136246. private _dispatcher;
  136247. private _overlappingPairCache;
  136248. private _solver;
  136249. private _softBodySolver;
  136250. private _tmpAmmoVectorA;
  136251. private _tmpAmmoVectorB;
  136252. private _tmpAmmoVectorC;
  136253. private _tmpAmmoVectorD;
  136254. private _tmpContactCallbackResult;
  136255. private _tmpAmmoVectorRCA;
  136256. private _tmpAmmoVectorRCB;
  136257. private _raycastResult;
  136258. private static readonly DISABLE_COLLISION_FLAG;
  136259. private static readonly KINEMATIC_FLAG;
  136260. private static readonly DISABLE_DEACTIVATION_FLAG;
  136261. /**
  136262. * Initializes the ammoJS plugin
  136263. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  136264. * @param ammoInjection can be used to inject your own ammo reference
  136265. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  136266. */
  136267. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  136268. /**
  136269. * Sets the gravity of the physics world (m/(s^2))
  136270. * @param gravity Gravity to set
  136271. */
  136272. setGravity(gravity: Vector3): void;
  136273. /**
  136274. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  136275. * @param timeStep timestep to use in seconds
  136276. */
  136277. setTimeStep(timeStep: number): void;
  136278. /**
  136279. * 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)
  136280. * @param fixedTimeStep fixedTimeStep to use in seconds
  136281. */
  136282. setFixedTimeStep(fixedTimeStep: number): void;
  136283. /**
  136284. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  136285. * @param maxSteps the maximum number of steps by the physics engine per frame
  136286. */
  136287. setMaxSteps(maxSteps: number): void;
  136288. /**
  136289. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  136290. * @returns the current timestep in seconds
  136291. */
  136292. getTimeStep(): number;
  136293. /**
  136294. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  136295. */
  136296. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  136297. private _isImpostorInContact;
  136298. private _isImpostorPairInContact;
  136299. private _stepSimulation;
  136300. /**
  136301. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  136302. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  136303. * After the step the babylon meshes are set to the position of the physics imposters
  136304. * @param delta amount of time to step forward
  136305. * @param impostors array of imposters to update before/after the step
  136306. */
  136307. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136308. /**
  136309. * Update babylon mesh to match physics world object
  136310. * @param impostor imposter to match
  136311. */
  136312. private _afterSoftStep;
  136313. /**
  136314. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136315. * @param impostor imposter to match
  136316. */
  136317. private _ropeStep;
  136318. /**
  136319. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136320. * @param impostor imposter to match
  136321. */
  136322. private _softbodyOrClothStep;
  136323. private _tmpMatrix;
  136324. /**
  136325. * Applies an impulse on the imposter
  136326. * @param impostor imposter to apply impulse to
  136327. * @param force amount of force to be applied to the imposter
  136328. * @param contactPoint the location to apply the impulse on the imposter
  136329. */
  136330. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136331. /**
  136332. * Applies a force on the imposter
  136333. * @param impostor imposter to apply force
  136334. * @param force amount of force to be applied to the imposter
  136335. * @param contactPoint the location to apply the force on the imposter
  136336. */
  136337. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136338. /**
  136339. * Creates a physics body using the plugin
  136340. * @param impostor the imposter to create the physics body on
  136341. */
  136342. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136343. /**
  136344. * Removes the physics body from the imposter and disposes of the body's memory
  136345. * @param impostor imposter to remove the physics body from
  136346. */
  136347. removePhysicsBody(impostor: PhysicsImpostor): void;
  136348. /**
  136349. * Generates a joint
  136350. * @param impostorJoint the imposter joint to create the joint with
  136351. */
  136352. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136353. /**
  136354. * Removes a joint
  136355. * @param impostorJoint the imposter joint to remove the joint from
  136356. */
  136357. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136358. private _addMeshVerts;
  136359. /**
  136360. * Initialise the soft body vertices to match its object's (mesh) vertices
  136361. * Softbody vertices (nodes) are in world space and to match this
  136362. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  136363. * @param impostor to create the softbody for
  136364. */
  136365. private _softVertexData;
  136366. /**
  136367. * Create an impostor's soft body
  136368. * @param impostor to create the softbody for
  136369. */
  136370. private _createSoftbody;
  136371. /**
  136372. * Create cloth for an impostor
  136373. * @param impostor to create the softbody for
  136374. */
  136375. private _createCloth;
  136376. /**
  136377. * Create rope for an impostor
  136378. * @param impostor to create the softbody for
  136379. */
  136380. private _createRope;
  136381. /**
  136382. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  136383. * @param impostor to create the custom physics shape for
  136384. */
  136385. private _createCustom;
  136386. private _addHullVerts;
  136387. private _createShape;
  136388. /**
  136389. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  136390. * @param impostor imposter containing the physics body and babylon object
  136391. */
  136392. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136393. /**
  136394. * Sets the babylon object's position/rotation from the physics body's position/rotation
  136395. * @param impostor imposter containing the physics body and babylon object
  136396. * @param newPosition new position
  136397. * @param newRotation new rotation
  136398. */
  136399. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136400. /**
  136401. * If this plugin is supported
  136402. * @returns true if its supported
  136403. */
  136404. isSupported(): boolean;
  136405. /**
  136406. * Sets the linear velocity of the physics body
  136407. * @param impostor imposter to set the velocity on
  136408. * @param velocity velocity to set
  136409. */
  136410. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136411. /**
  136412. * Sets the angular velocity of the physics body
  136413. * @param impostor imposter to set the velocity on
  136414. * @param velocity velocity to set
  136415. */
  136416. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136417. /**
  136418. * gets the linear velocity
  136419. * @param impostor imposter to get linear velocity from
  136420. * @returns linear velocity
  136421. */
  136422. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136423. /**
  136424. * gets the angular velocity
  136425. * @param impostor imposter to get angular velocity from
  136426. * @returns angular velocity
  136427. */
  136428. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136429. /**
  136430. * Sets the mass of physics body
  136431. * @param impostor imposter to set the mass on
  136432. * @param mass mass to set
  136433. */
  136434. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136435. /**
  136436. * Gets the mass of the physics body
  136437. * @param impostor imposter to get the mass from
  136438. * @returns mass
  136439. */
  136440. getBodyMass(impostor: PhysicsImpostor): number;
  136441. /**
  136442. * Gets friction of the impostor
  136443. * @param impostor impostor to get friction from
  136444. * @returns friction value
  136445. */
  136446. getBodyFriction(impostor: PhysicsImpostor): number;
  136447. /**
  136448. * Sets friction of the impostor
  136449. * @param impostor impostor to set friction on
  136450. * @param friction friction value
  136451. */
  136452. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136453. /**
  136454. * Gets restitution of the impostor
  136455. * @param impostor impostor to get restitution from
  136456. * @returns restitution value
  136457. */
  136458. getBodyRestitution(impostor: PhysicsImpostor): number;
  136459. /**
  136460. * Sets resitution of the impostor
  136461. * @param impostor impostor to set resitution on
  136462. * @param restitution resitution value
  136463. */
  136464. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136465. /**
  136466. * Gets pressure inside the impostor
  136467. * @param impostor impostor to get pressure from
  136468. * @returns pressure value
  136469. */
  136470. getBodyPressure(impostor: PhysicsImpostor): number;
  136471. /**
  136472. * Sets pressure inside a soft body impostor
  136473. * Cloth and rope must remain 0 pressure
  136474. * @param impostor impostor to set pressure on
  136475. * @param pressure pressure value
  136476. */
  136477. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  136478. /**
  136479. * Gets stiffness of the impostor
  136480. * @param impostor impostor to get stiffness from
  136481. * @returns pressure value
  136482. */
  136483. getBodyStiffness(impostor: PhysicsImpostor): number;
  136484. /**
  136485. * Sets stiffness of the impostor
  136486. * @param impostor impostor to set stiffness on
  136487. * @param stiffness stiffness value from 0 to 1
  136488. */
  136489. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  136490. /**
  136491. * Gets velocityIterations of the impostor
  136492. * @param impostor impostor to get velocity iterations from
  136493. * @returns velocityIterations value
  136494. */
  136495. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  136496. /**
  136497. * Sets velocityIterations of the impostor
  136498. * @param impostor impostor to set velocity iterations on
  136499. * @param velocityIterations velocityIterations value
  136500. */
  136501. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  136502. /**
  136503. * Gets positionIterations of the impostor
  136504. * @param impostor impostor to get position iterations from
  136505. * @returns positionIterations value
  136506. */
  136507. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  136508. /**
  136509. * Sets positionIterations of the impostor
  136510. * @param impostor impostor to set position on
  136511. * @param positionIterations positionIterations value
  136512. */
  136513. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  136514. /**
  136515. * Append an anchor to a cloth object
  136516. * @param impostor is the cloth impostor to add anchor to
  136517. * @param otherImpostor is the rigid impostor to anchor to
  136518. * @param width ratio across width from 0 to 1
  136519. * @param height ratio up height from 0 to 1
  136520. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  136521. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136522. */
  136523. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136524. /**
  136525. * Append an hook to a rope object
  136526. * @param impostor is the rope impostor to add hook to
  136527. * @param otherImpostor is the rigid impostor to hook to
  136528. * @param length ratio along the rope from 0 to 1
  136529. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  136530. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136531. */
  136532. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136533. /**
  136534. * Sleeps the physics body and stops it from being active
  136535. * @param impostor impostor to sleep
  136536. */
  136537. sleepBody(impostor: PhysicsImpostor): void;
  136538. /**
  136539. * Activates the physics body
  136540. * @param impostor impostor to activate
  136541. */
  136542. wakeUpBody(impostor: PhysicsImpostor): void;
  136543. /**
  136544. * Updates the distance parameters of the joint
  136545. * @param joint joint to update
  136546. * @param maxDistance maximum distance of the joint
  136547. * @param minDistance minimum distance of the joint
  136548. */
  136549. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  136550. /**
  136551. * Sets a motor on the joint
  136552. * @param joint joint to set motor on
  136553. * @param speed speed of the motor
  136554. * @param maxForce maximum force of the motor
  136555. * @param motorIndex index of the motor
  136556. */
  136557. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136558. /**
  136559. * Sets the motors limit
  136560. * @param joint joint to set limit on
  136561. * @param upperLimit upper limit
  136562. * @param lowerLimit lower limit
  136563. */
  136564. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136565. /**
  136566. * Syncs the position and rotation of a mesh with the impostor
  136567. * @param mesh mesh to sync
  136568. * @param impostor impostor to update the mesh with
  136569. */
  136570. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136571. /**
  136572. * Gets the radius of the impostor
  136573. * @param impostor impostor to get radius from
  136574. * @returns the radius
  136575. */
  136576. getRadius(impostor: PhysicsImpostor): number;
  136577. /**
  136578. * Gets the box size of the impostor
  136579. * @param impostor impostor to get box size from
  136580. * @param result the resulting box size
  136581. */
  136582. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136583. /**
  136584. * Disposes of the impostor
  136585. */
  136586. dispose(): void;
  136587. /**
  136588. * Does a raycast in the physics world
  136589. * @param from when should the ray start?
  136590. * @param to when should the ray end?
  136591. * @returns PhysicsRaycastResult
  136592. */
  136593. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136594. }
  136595. }
  136596. declare module BABYLON {
  136597. interface AbstractScene {
  136598. /**
  136599. * The list of reflection probes added to the scene
  136600. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136601. */
  136602. reflectionProbes: Array<ReflectionProbe>;
  136603. /**
  136604. * Removes the given reflection probe from this scene.
  136605. * @param toRemove The reflection probe to remove
  136606. * @returns The index of the removed reflection probe
  136607. */
  136608. removeReflectionProbe(toRemove: ReflectionProbe): number;
  136609. /**
  136610. * Adds the given reflection probe to this scene.
  136611. * @param newReflectionProbe The reflection probe to add
  136612. */
  136613. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  136614. }
  136615. /**
  136616. * Class used to generate realtime reflection / refraction cube textures
  136617. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136618. */
  136619. export class ReflectionProbe {
  136620. /** defines the name of the probe */
  136621. name: string;
  136622. private _scene;
  136623. private _renderTargetTexture;
  136624. private _projectionMatrix;
  136625. private _viewMatrix;
  136626. private _target;
  136627. private _add;
  136628. private _attachedMesh;
  136629. private _invertYAxis;
  136630. /** Gets or sets probe position (center of the cube map) */
  136631. position: Vector3;
  136632. /**
  136633. * Creates a new reflection probe
  136634. * @param name defines the name of the probe
  136635. * @param size defines the texture resolution (for each face)
  136636. * @param scene defines the hosting scene
  136637. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  136638. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  136639. */
  136640. constructor(
  136641. /** defines the name of the probe */
  136642. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  136643. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  136644. get samples(): number;
  136645. set samples(value: number);
  136646. /** Gets or sets the refresh rate to use (on every frame by default) */
  136647. get refreshRate(): number;
  136648. set refreshRate(value: number);
  136649. /**
  136650. * Gets the hosting scene
  136651. * @returns a Scene
  136652. */
  136653. getScene(): Scene;
  136654. /** Gets the internal CubeTexture used to render to */
  136655. get cubeTexture(): RenderTargetTexture;
  136656. /** Gets the list of meshes to render */
  136657. get renderList(): Nullable<AbstractMesh[]>;
  136658. /**
  136659. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  136660. * @param mesh defines the mesh to attach to
  136661. */
  136662. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136663. /**
  136664. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  136665. * @param renderingGroupId The rendering group id corresponding to its index
  136666. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  136667. */
  136668. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  136669. /**
  136670. * Clean all associated resources
  136671. */
  136672. dispose(): void;
  136673. /**
  136674. * Converts the reflection probe information to a readable string for debug purpose.
  136675. * @param fullDetails Supports for multiple levels of logging within scene loading
  136676. * @returns the human readable reflection probe info
  136677. */
  136678. toString(fullDetails?: boolean): string;
  136679. /**
  136680. * Get the class name of the relfection probe.
  136681. * @returns "ReflectionProbe"
  136682. */
  136683. getClassName(): string;
  136684. /**
  136685. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  136686. * @returns The JSON representation of the texture
  136687. */
  136688. serialize(): any;
  136689. /**
  136690. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  136691. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  136692. * @param scene Define the scene the parsed reflection probe should be instantiated in
  136693. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  136694. * @returns The parsed reflection probe if successful
  136695. */
  136696. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  136697. }
  136698. }
  136699. declare module BABYLON {
  136700. /** @hidden */
  136701. export var _BabylonLoaderRegistered: boolean;
  136702. /**
  136703. * Helps setting up some configuration for the babylon file loader.
  136704. */
  136705. export class BabylonFileLoaderConfiguration {
  136706. /**
  136707. * The loader does not allow injecting custom physix engine into the plugins.
  136708. * Unfortunately in ES6, we need to manually inject them into the plugin.
  136709. * So you could set this variable to your engine import to make it work.
  136710. */
  136711. static LoaderInjectedPhysicsEngine: any;
  136712. }
  136713. }
  136714. declare module BABYLON {
  136715. /**
  136716. * The Physically based simple base material of BJS.
  136717. *
  136718. * This enables better naming and convention enforcements on top of the pbrMaterial.
  136719. * It is used as the base class for both the specGloss and metalRough conventions.
  136720. */
  136721. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  136722. /**
  136723. * Number of Simultaneous lights allowed on the material.
  136724. */
  136725. maxSimultaneousLights: number;
  136726. /**
  136727. * If sets to true, disables all the lights affecting the material.
  136728. */
  136729. disableLighting: boolean;
  136730. /**
  136731. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  136732. */
  136733. environmentTexture: BaseTexture;
  136734. /**
  136735. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  136736. */
  136737. invertNormalMapX: boolean;
  136738. /**
  136739. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  136740. */
  136741. invertNormalMapY: boolean;
  136742. /**
  136743. * Normal map used in the model.
  136744. */
  136745. normalTexture: BaseTexture;
  136746. /**
  136747. * Emissivie color used to self-illuminate the model.
  136748. */
  136749. emissiveColor: Color3;
  136750. /**
  136751. * Emissivie texture used to self-illuminate the model.
  136752. */
  136753. emissiveTexture: BaseTexture;
  136754. /**
  136755. * Occlusion Channel Strenght.
  136756. */
  136757. occlusionStrength: number;
  136758. /**
  136759. * Occlusion Texture of the material (adding extra occlusion effects).
  136760. */
  136761. occlusionTexture: BaseTexture;
  136762. /**
  136763. * Defines the alpha limits in alpha test mode.
  136764. */
  136765. alphaCutOff: number;
  136766. /**
  136767. * Gets the current double sided mode.
  136768. */
  136769. get doubleSided(): boolean;
  136770. /**
  136771. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136772. */
  136773. set doubleSided(value: boolean);
  136774. /**
  136775. * Stores the pre-calculated light information of a mesh in a texture.
  136776. */
  136777. lightmapTexture: BaseTexture;
  136778. /**
  136779. * If true, the light map contains occlusion information instead of lighting info.
  136780. */
  136781. useLightmapAsShadowmap: boolean;
  136782. /**
  136783. * Instantiates a new PBRMaterial instance.
  136784. *
  136785. * @param name The material name
  136786. * @param scene The scene the material will be use in.
  136787. */
  136788. constructor(name: string, scene: Scene);
  136789. getClassName(): string;
  136790. }
  136791. }
  136792. declare module BABYLON {
  136793. /**
  136794. * The PBR material of BJS following the metal roughness convention.
  136795. *
  136796. * This fits to the PBR convention in the GLTF definition:
  136797. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  136798. */
  136799. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  136800. /**
  136801. * The base color has two different interpretations depending on the value of metalness.
  136802. * When the material is a metal, the base color is the specific measured reflectance value
  136803. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  136804. * of the material.
  136805. */
  136806. baseColor: Color3;
  136807. /**
  136808. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  136809. * well as opacity information in the alpha channel.
  136810. */
  136811. baseTexture: BaseTexture;
  136812. /**
  136813. * Specifies the metallic scalar value of the material.
  136814. * Can also be used to scale the metalness values of the metallic texture.
  136815. */
  136816. metallic: number;
  136817. /**
  136818. * Specifies the roughness scalar value of the material.
  136819. * Can also be used to scale the roughness values of the metallic texture.
  136820. */
  136821. roughness: number;
  136822. /**
  136823. * Texture containing both the metallic value in the B channel and the
  136824. * roughness value in the G channel to keep better precision.
  136825. */
  136826. metallicRoughnessTexture: BaseTexture;
  136827. /**
  136828. * Instantiates a new PBRMetalRoughnessMaterial instance.
  136829. *
  136830. * @param name The material name
  136831. * @param scene The scene the material will be use in.
  136832. */
  136833. constructor(name: string, scene: Scene);
  136834. /**
  136835. * Return the currrent class name of the material.
  136836. */
  136837. getClassName(): string;
  136838. /**
  136839. * Makes a duplicate of the current material.
  136840. * @param name - name to use for the new material.
  136841. */
  136842. clone(name: string): PBRMetallicRoughnessMaterial;
  136843. /**
  136844. * Serialize the material to a parsable JSON object.
  136845. */
  136846. serialize(): any;
  136847. /**
  136848. * Parses a JSON object correponding to the serialize function.
  136849. */
  136850. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  136851. }
  136852. }
  136853. declare module BABYLON {
  136854. /**
  136855. * The PBR material of BJS following the specular glossiness convention.
  136856. *
  136857. * This fits to the PBR convention in the GLTF definition:
  136858. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  136859. */
  136860. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  136861. /**
  136862. * Specifies the diffuse color of the material.
  136863. */
  136864. diffuseColor: Color3;
  136865. /**
  136866. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  136867. * channel.
  136868. */
  136869. diffuseTexture: BaseTexture;
  136870. /**
  136871. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  136872. */
  136873. specularColor: Color3;
  136874. /**
  136875. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  136876. */
  136877. glossiness: number;
  136878. /**
  136879. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  136880. */
  136881. specularGlossinessTexture: BaseTexture;
  136882. /**
  136883. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  136884. *
  136885. * @param name The material name
  136886. * @param scene The scene the material will be use in.
  136887. */
  136888. constructor(name: string, scene: Scene);
  136889. /**
  136890. * Return the currrent class name of the material.
  136891. */
  136892. getClassName(): string;
  136893. /**
  136894. * Makes a duplicate of the current material.
  136895. * @param name - name to use for the new material.
  136896. */
  136897. clone(name: string): PBRSpecularGlossinessMaterial;
  136898. /**
  136899. * Serialize the material to a parsable JSON object.
  136900. */
  136901. serialize(): any;
  136902. /**
  136903. * Parses a JSON object correponding to the serialize function.
  136904. */
  136905. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  136906. }
  136907. }
  136908. declare module BABYLON {
  136909. /**
  136910. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  136911. * It can help converting any input color in a desired output one. This can then be used to create effects
  136912. * from sepia, black and white to sixties or futuristic rendering...
  136913. *
  136914. * The only supported format is currently 3dl.
  136915. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  136916. */
  136917. export class ColorGradingTexture extends BaseTexture {
  136918. /**
  136919. * The texture URL.
  136920. */
  136921. url: string;
  136922. /**
  136923. * Empty line regex stored for GC.
  136924. */
  136925. private static _noneEmptyLineRegex;
  136926. private _textureMatrix;
  136927. private _onLoad;
  136928. /**
  136929. * Instantiates a ColorGradingTexture from the following parameters.
  136930. *
  136931. * @param url The location of the color gradind data (currently only supporting 3dl)
  136932. * @param sceneOrEngine The scene or engine the texture will be used in
  136933. * @param onLoad defines a callback triggered when the texture has been loaded
  136934. */
  136935. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  136936. /**
  136937. * Fires the onload event from the constructor if requested.
  136938. */
  136939. private _triggerOnLoad;
  136940. /**
  136941. * Returns the texture matrix used in most of the material.
  136942. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  136943. */
  136944. getTextureMatrix(): Matrix;
  136945. /**
  136946. * Occurs when the file being loaded is a .3dl LUT file.
  136947. */
  136948. private load3dlTexture;
  136949. /**
  136950. * Starts the loading process of the texture.
  136951. */
  136952. private loadTexture;
  136953. /**
  136954. * Clones the color gradind texture.
  136955. */
  136956. clone(): ColorGradingTexture;
  136957. /**
  136958. * Called during delayed load for textures.
  136959. */
  136960. delayLoad(): void;
  136961. /**
  136962. * Parses a color grading texture serialized by Babylon.
  136963. * @param parsedTexture The texture information being parsedTexture
  136964. * @param scene The scene to load the texture in
  136965. * @param rootUrl The root url of the data assets to load
  136966. * @return A color gradind texture
  136967. */
  136968. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  136969. /**
  136970. * Serializes the LUT texture to json format.
  136971. */
  136972. serialize(): any;
  136973. }
  136974. }
  136975. declare module BABYLON {
  136976. /**
  136977. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  136978. */
  136979. export class EquiRectangularCubeTexture extends BaseTexture {
  136980. /** The six faces of the cube. */
  136981. private static _FacesMapping;
  136982. private _noMipmap;
  136983. private _onLoad;
  136984. private _onError;
  136985. /** The size of the cubemap. */
  136986. private _size;
  136987. /** The buffer of the image. */
  136988. private _buffer;
  136989. /** The width of the input image. */
  136990. private _width;
  136991. /** The height of the input image. */
  136992. private _height;
  136993. /** The URL to the image. */
  136994. url: string;
  136995. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  136996. coordinatesMode: number;
  136997. /**
  136998. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  136999. * @param url The location of the image
  137000. * @param scene The scene the texture will be used in
  137001. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137002. * @param noMipmap Forces to not generate the mipmap if true
  137003. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  137004. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  137005. * @param onLoad — defines a callback called when texture is loaded
  137006. * @param onError — defines a callback called if there is an error
  137007. */
  137008. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  137009. /**
  137010. * Load the image data, by putting the image on a canvas and extracting its buffer.
  137011. */
  137012. private loadImage;
  137013. /**
  137014. * Convert the image buffer into a cubemap and create a CubeTexture.
  137015. */
  137016. private loadTexture;
  137017. /**
  137018. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  137019. * @param buffer The ArrayBuffer that should be converted.
  137020. * @returns The buffer as Float32Array.
  137021. */
  137022. private getFloat32ArrayFromArrayBuffer;
  137023. /**
  137024. * Get the current class name of the texture useful for serialization or dynamic coding.
  137025. * @returns "EquiRectangularCubeTexture"
  137026. */
  137027. getClassName(): string;
  137028. /**
  137029. * Create a clone of the current EquiRectangularCubeTexture and return it.
  137030. * @returns A clone of the current EquiRectangularCubeTexture.
  137031. */
  137032. clone(): EquiRectangularCubeTexture;
  137033. }
  137034. }
  137035. declare module BABYLON {
  137036. /**
  137037. * Defines the options related to the creation of an HtmlElementTexture
  137038. */
  137039. export interface IHtmlElementTextureOptions {
  137040. /**
  137041. * Defines wether mip maps should be created or not.
  137042. */
  137043. generateMipMaps?: boolean;
  137044. /**
  137045. * Defines the sampling mode of the texture.
  137046. */
  137047. samplingMode?: number;
  137048. /**
  137049. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  137050. */
  137051. engine: Nullable<ThinEngine>;
  137052. /**
  137053. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  137054. */
  137055. scene: Nullable<Scene>;
  137056. }
  137057. /**
  137058. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  137059. * To be as efficient as possible depending on your constraints nothing aside the first upload
  137060. * is automatically managed.
  137061. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  137062. * in your application.
  137063. *
  137064. * As the update is not automatic, you need to call them manually.
  137065. */
  137066. export class HtmlElementTexture extends BaseTexture {
  137067. /**
  137068. * The texture URL.
  137069. */
  137070. element: HTMLVideoElement | HTMLCanvasElement;
  137071. private static readonly DefaultOptions;
  137072. private _textureMatrix;
  137073. private _isVideo;
  137074. private _generateMipMaps;
  137075. private _samplingMode;
  137076. /**
  137077. * Instantiates a HtmlElementTexture from the following parameters.
  137078. *
  137079. * @param name Defines the name of the texture
  137080. * @param element Defines the video or canvas the texture is filled with
  137081. * @param options Defines the other none mandatory texture creation options
  137082. */
  137083. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  137084. private _createInternalTexture;
  137085. /**
  137086. * Returns the texture matrix used in most of the material.
  137087. */
  137088. getTextureMatrix(): Matrix;
  137089. /**
  137090. * Updates the content of the texture.
  137091. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  137092. */
  137093. update(invertY?: Nullable<boolean>): void;
  137094. }
  137095. }
  137096. declare module BABYLON {
  137097. /**
  137098. * Based on jsTGALoader - Javascript loader for TGA file
  137099. * By Vincent Thibault
  137100. * @see http://blog.robrowser.com/javascript-tga-loader.html
  137101. */
  137102. export class TGATools {
  137103. private static _TYPE_INDEXED;
  137104. private static _TYPE_RGB;
  137105. private static _TYPE_GREY;
  137106. private static _TYPE_RLE_INDEXED;
  137107. private static _TYPE_RLE_RGB;
  137108. private static _TYPE_RLE_GREY;
  137109. private static _ORIGIN_MASK;
  137110. private static _ORIGIN_SHIFT;
  137111. private static _ORIGIN_BL;
  137112. private static _ORIGIN_BR;
  137113. private static _ORIGIN_UL;
  137114. private static _ORIGIN_UR;
  137115. /**
  137116. * Gets the header of a TGA file
  137117. * @param data defines the TGA data
  137118. * @returns the header
  137119. */
  137120. static GetTGAHeader(data: Uint8Array): any;
  137121. /**
  137122. * Uploads TGA content to a Babylon Texture
  137123. * @hidden
  137124. */
  137125. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  137126. /** @hidden */
  137127. 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;
  137128. /** @hidden */
  137129. 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;
  137130. /** @hidden */
  137131. 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;
  137132. /** @hidden */
  137133. 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;
  137134. /** @hidden */
  137135. 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;
  137136. /** @hidden */
  137137. 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;
  137138. }
  137139. }
  137140. declare module BABYLON {
  137141. /**
  137142. * Implementation of the TGA Texture Loader.
  137143. * @hidden
  137144. */
  137145. export class _TGATextureLoader implements IInternalTextureLoader {
  137146. /**
  137147. * Defines wether the loader supports cascade loading the different faces.
  137148. */
  137149. readonly supportCascades: boolean;
  137150. /**
  137151. * This returns if the loader support the current file information.
  137152. * @param extension defines the file extension of the file being loaded
  137153. * @returns true if the loader can load the specified file
  137154. */
  137155. canLoad(extension: string): boolean;
  137156. /**
  137157. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137158. * @param data contains the texture data
  137159. * @param texture defines the BabylonJS internal texture
  137160. * @param createPolynomials will be true if polynomials have been requested
  137161. * @param onLoad defines the callback to trigger once the texture is ready
  137162. * @param onError defines the callback to trigger in case of error
  137163. */
  137164. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137165. /**
  137166. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137167. * @param data contains the texture data
  137168. * @param texture defines the BabylonJS internal texture
  137169. * @param callback defines the method to call once ready to upload
  137170. */
  137171. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137172. }
  137173. }
  137174. declare module BABYLON {
  137175. /**
  137176. * Info about the .basis files
  137177. */
  137178. class BasisFileInfo {
  137179. /**
  137180. * If the file has alpha
  137181. */
  137182. hasAlpha: boolean;
  137183. /**
  137184. * Info about each image of the basis file
  137185. */
  137186. images: Array<{
  137187. levels: Array<{
  137188. width: number;
  137189. height: number;
  137190. transcodedPixels: ArrayBufferView;
  137191. }>;
  137192. }>;
  137193. }
  137194. /**
  137195. * Result of transcoding a basis file
  137196. */
  137197. class TranscodeResult {
  137198. /**
  137199. * Info about the .basis file
  137200. */
  137201. fileInfo: BasisFileInfo;
  137202. /**
  137203. * Format to use when loading the file
  137204. */
  137205. format: number;
  137206. }
  137207. /**
  137208. * Configuration options for the Basis transcoder
  137209. */
  137210. export class BasisTranscodeConfiguration {
  137211. /**
  137212. * Supported compression formats used to determine the supported output format of the transcoder
  137213. */
  137214. supportedCompressionFormats?: {
  137215. /**
  137216. * etc1 compression format
  137217. */
  137218. etc1?: boolean;
  137219. /**
  137220. * s3tc compression format
  137221. */
  137222. s3tc?: boolean;
  137223. /**
  137224. * pvrtc compression format
  137225. */
  137226. pvrtc?: boolean;
  137227. /**
  137228. * etc2 compression format
  137229. */
  137230. etc2?: boolean;
  137231. };
  137232. /**
  137233. * If mipmap levels should be loaded for transcoded images (Default: true)
  137234. */
  137235. loadMipmapLevels?: boolean;
  137236. /**
  137237. * Index of a single image to load (Default: all images)
  137238. */
  137239. loadSingleImage?: number;
  137240. }
  137241. /**
  137242. * Used to load .Basis files
  137243. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  137244. */
  137245. export class BasisTools {
  137246. private static _IgnoreSupportedFormats;
  137247. /**
  137248. * URL to use when loading the basis transcoder
  137249. */
  137250. static JSModuleURL: string;
  137251. /**
  137252. * URL to use when loading the wasm module for the transcoder
  137253. */
  137254. static WasmModuleURL: string;
  137255. /**
  137256. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  137257. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  137258. * @returns internal format corresponding to the Basis format
  137259. */
  137260. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  137261. private static _WorkerPromise;
  137262. private static _Worker;
  137263. private static _actionId;
  137264. private static _CreateWorkerAsync;
  137265. /**
  137266. * Transcodes a loaded image file to compressed pixel data
  137267. * @param data image data to transcode
  137268. * @param config configuration options for the transcoding
  137269. * @returns a promise resulting in the transcoded image
  137270. */
  137271. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  137272. /**
  137273. * Loads a texture from the transcode result
  137274. * @param texture texture load to
  137275. * @param transcodeResult the result of transcoding the basis file to load from
  137276. */
  137277. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  137278. }
  137279. }
  137280. declare module BABYLON {
  137281. /**
  137282. * Loader for .basis file format
  137283. */
  137284. export class _BasisTextureLoader implements IInternalTextureLoader {
  137285. /**
  137286. * Defines whether the loader supports cascade loading the different faces.
  137287. */
  137288. readonly supportCascades: boolean;
  137289. /**
  137290. * This returns if the loader support the current file information.
  137291. * @param extension defines the file extension of the file being loaded
  137292. * @returns true if the loader can load the specified file
  137293. */
  137294. canLoad(extension: string): boolean;
  137295. /**
  137296. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137297. * @param data contains the texture data
  137298. * @param texture defines the BabylonJS internal texture
  137299. * @param createPolynomials will be true if polynomials have been requested
  137300. * @param onLoad defines the callback to trigger once the texture is ready
  137301. * @param onError defines the callback to trigger in case of error
  137302. */
  137303. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137304. /**
  137305. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137306. * @param data contains the texture data
  137307. * @param texture defines the BabylonJS internal texture
  137308. * @param callback defines the method to call once ready to upload
  137309. */
  137310. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137311. }
  137312. }
  137313. declare module BABYLON {
  137314. /**
  137315. * Defines the basic options interface of a TexturePacker Frame
  137316. */
  137317. export interface ITexturePackerFrame {
  137318. /**
  137319. * The frame ID
  137320. */
  137321. id: number;
  137322. /**
  137323. * The frames Scale
  137324. */
  137325. scale: Vector2;
  137326. /**
  137327. * The Frames offset
  137328. */
  137329. offset: Vector2;
  137330. }
  137331. /**
  137332. * This is a support class for frame Data on texture packer sets.
  137333. */
  137334. export class TexturePackerFrame implements ITexturePackerFrame {
  137335. /**
  137336. * The frame ID
  137337. */
  137338. id: number;
  137339. /**
  137340. * The frames Scale
  137341. */
  137342. scale: Vector2;
  137343. /**
  137344. * The Frames offset
  137345. */
  137346. offset: Vector2;
  137347. /**
  137348. * Initializes a texture package frame.
  137349. * @param id The numerical frame identifier
  137350. * @param scale Scalar Vector2 for UV frame
  137351. * @param offset Vector2 for the frame position in UV units.
  137352. * @returns TexturePackerFrame
  137353. */
  137354. constructor(id: number, scale: Vector2, offset: Vector2);
  137355. }
  137356. }
  137357. declare module BABYLON {
  137358. /**
  137359. * Defines the basic options interface of a TexturePacker
  137360. */
  137361. export interface ITexturePackerOptions {
  137362. /**
  137363. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  137364. */
  137365. map?: string[];
  137366. /**
  137367. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137368. */
  137369. uvsIn?: string;
  137370. /**
  137371. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137372. */
  137373. uvsOut?: string;
  137374. /**
  137375. * number representing the layout style. Defaults to LAYOUT_STRIP
  137376. */
  137377. layout?: number;
  137378. /**
  137379. * number of columns if using custom column count layout(2). This defaults to 4.
  137380. */
  137381. colnum?: number;
  137382. /**
  137383. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  137384. */
  137385. updateInputMeshes?: boolean;
  137386. /**
  137387. * boolean flag to dispose all the source textures. Defaults to true.
  137388. */
  137389. disposeSources?: boolean;
  137390. /**
  137391. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  137392. */
  137393. fillBlanks?: boolean;
  137394. /**
  137395. * string value representing the context fill style color. Defaults to 'black'.
  137396. */
  137397. customFillColor?: string;
  137398. /**
  137399. * Width and Height Value of each Frame in the TexturePacker Sets
  137400. */
  137401. frameSize?: number;
  137402. /**
  137403. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  137404. */
  137405. paddingRatio?: number;
  137406. /**
  137407. * Number that declares the fill method for the padding gutter.
  137408. */
  137409. paddingMode?: number;
  137410. /**
  137411. * If in SUBUV_COLOR padding mode what color to use.
  137412. */
  137413. paddingColor?: Color3 | Color4;
  137414. }
  137415. /**
  137416. * Defines the basic interface of a TexturePacker JSON File
  137417. */
  137418. export interface ITexturePackerJSON {
  137419. /**
  137420. * The frame ID
  137421. */
  137422. name: string;
  137423. /**
  137424. * The base64 channel data
  137425. */
  137426. sets: any;
  137427. /**
  137428. * The options of the Packer
  137429. */
  137430. options: ITexturePackerOptions;
  137431. /**
  137432. * The frame data of the Packer
  137433. */
  137434. frames: Array<number>;
  137435. }
  137436. /**
  137437. * This is a support class that generates a series of packed texture sets.
  137438. * @see https://doc.babylonjs.com/babylon101/materials
  137439. */
  137440. export class TexturePacker {
  137441. /** Packer Layout Constant 0 */
  137442. static readonly LAYOUT_STRIP: number;
  137443. /** Packer Layout Constant 1 */
  137444. static readonly LAYOUT_POWER2: number;
  137445. /** Packer Layout Constant 2 */
  137446. static readonly LAYOUT_COLNUM: number;
  137447. /** Packer Layout Constant 0 */
  137448. static readonly SUBUV_WRAP: number;
  137449. /** Packer Layout Constant 1 */
  137450. static readonly SUBUV_EXTEND: number;
  137451. /** Packer Layout Constant 2 */
  137452. static readonly SUBUV_COLOR: number;
  137453. /** The Name of the Texture Package */
  137454. name: string;
  137455. /** The scene scope of the TexturePacker */
  137456. scene: Scene;
  137457. /** The Meshes to target */
  137458. meshes: AbstractMesh[];
  137459. /** Arguments passed with the Constructor */
  137460. options: ITexturePackerOptions;
  137461. /** The promise that is started upon initialization */
  137462. promise: Nullable<Promise<TexturePacker | string>>;
  137463. /** The Container object for the channel sets that are generated */
  137464. sets: object;
  137465. /** The Container array for the frames that are generated */
  137466. frames: TexturePackerFrame[];
  137467. /** The expected number of textures the system is parsing. */
  137468. private _expecting;
  137469. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  137470. private _paddingValue;
  137471. /**
  137472. * Initializes a texture package series from an array of meshes or a single mesh.
  137473. * @param name The name of the package
  137474. * @param meshes The target meshes to compose the package from
  137475. * @param options The arguments that texture packer should follow while building.
  137476. * @param scene The scene which the textures are scoped to.
  137477. * @returns TexturePacker
  137478. */
  137479. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  137480. /**
  137481. * Starts the package process
  137482. * @param resolve The promises resolution function
  137483. * @returns TexturePacker
  137484. */
  137485. private _createFrames;
  137486. /**
  137487. * Calculates the Size of the Channel Sets
  137488. * @returns Vector2
  137489. */
  137490. private _calculateSize;
  137491. /**
  137492. * Calculates the UV data for the frames.
  137493. * @param baseSize the base frameSize
  137494. * @param padding the base frame padding
  137495. * @param dtSize size of the Dynamic Texture for that channel
  137496. * @param dtUnits is 1/dtSize
  137497. * @param update flag to update the input meshes
  137498. */
  137499. private _calculateMeshUVFrames;
  137500. /**
  137501. * Calculates the frames Offset.
  137502. * @param index of the frame
  137503. * @returns Vector2
  137504. */
  137505. private _getFrameOffset;
  137506. /**
  137507. * Updates a Mesh to the frame data
  137508. * @param mesh that is the target
  137509. * @param frameID or the frame index
  137510. */
  137511. private _updateMeshUV;
  137512. /**
  137513. * Updates a Meshes materials to use the texture packer channels
  137514. * @param m is the mesh to target
  137515. * @param force all channels on the packer to be set.
  137516. */
  137517. private _updateTextureReferences;
  137518. /**
  137519. * Public method to set a Mesh to a frame
  137520. * @param m that is the target
  137521. * @param frameID or the frame index
  137522. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  137523. */
  137524. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  137525. /**
  137526. * Starts the async promise to compile the texture packer.
  137527. * @returns Promise<void>
  137528. */
  137529. processAsync(): Promise<void>;
  137530. /**
  137531. * Disposes all textures associated with this packer
  137532. */
  137533. dispose(): void;
  137534. /**
  137535. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  137536. * @param imageType is the image type to use.
  137537. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  137538. */
  137539. download(imageType?: string, quality?: number): void;
  137540. /**
  137541. * Public method to load a texturePacker JSON file.
  137542. * @param data of the JSON file in string format.
  137543. */
  137544. updateFromJSON(data: string): void;
  137545. }
  137546. }
  137547. declare module BABYLON {
  137548. /**
  137549. * 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.
  137550. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137551. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137552. */
  137553. export class CustomProceduralTexture extends ProceduralTexture {
  137554. private _animate;
  137555. private _time;
  137556. private _config;
  137557. private _texturePath;
  137558. /**
  137559. * Instantiates a new Custom Procedural Texture.
  137560. * 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.
  137561. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137562. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137563. * @param name Define the name of the texture
  137564. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  137565. * @param size Define the size of the texture to create
  137566. * @param scene Define the scene the texture belongs to
  137567. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  137568. * @param generateMipMaps Define if the texture should creates mip maps or not
  137569. */
  137570. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137571. private _loadJson;
  137572. /**
  137573. * Is the texture ready to be used ? (rendered at least once)
  137574. * @returns true if ready, otherwise, false.
  137575. */
  137576. isReady(): boolean;
  137577. /**
  137578. * Render the texture to its associated render target.
  137579. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  137580. */
  137581. render(useCameraPostProcess?: boolean): void;
  137582. /**
  137583. * Update the list of dependant textures samplers in the shader.
  137584. */
  137585. updateTextures(): void;
  137586. /**
  137587. * Update the uniform values of the procedural texture in the shader.
  137588. */
  137589. updateShaderUniforms(): void;
  137590. /**
  137591. * Define if the texture animates or not.
  137592. */
  137593. get animate(): boolean;
  137594. set animate(value: boolean);
  137595. }
  137596. }
  137597. declare module BABYLON {
  137598. /** @hidden */
  137599. export var noisePixelShader: {
  137600. name: string;
  137601. shader: string;
  137602. };
  137603. }
  137604. declare module BABYLON {
  137605. /**
  137606. * Class used to generate noise procedural textures
  137607. */
  137608. export class NoiseProceduralTexture extends ProceduralTexture {
  137609. private _time;
  137610. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  137611. brightness: number;
  137612. /** Defines the number of octaves to process */
  137613. octaves: number;
  137614. /** Defines the level of persistence (0.8 by default) */
  137615. persistence: number;
  137616. /** Gets or sets animation speed factor (default is 1) */
  137617. animationSpeedFactor: number;
  137618. /**
  137619. * Creates a new NoiseProceduralTexture
  137620. * @param name defines the name fo the texture
  137621. * @param size defines the size of the texture (default is 256)
  137622. * @param scene defines the hosting scene
  137623. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  137624. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  137625. */
  137626. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137627. private _updateShaderUniforms;
  137628. protected _getDefines(): string;
  137629. /** Generate the current state of the procedural texture */
  137630. render(useCameraPostProcess?: boolean): void;
  137631. /**
  137632. * Serializes this noise procedural texture
  137633. * @returns a serialized noise procedural texture object
  137634. */
  137635. serialize(): any;
  137636. /**
  137637. * Clone the texture.
  137638. * @returns the cloned texture
  137639. */
  137640. clone(): NoiseProceduralTexture;
  137641. /**
  137642. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  137643. * @param parsedTexture defines parsed texture data
  137644. * @param scene defines the current scene
  137645. * @param rootUrl defines the root URL containing noise procedural texture information
  137646. * @returns a parsed NoiseProceduralTexture
  137647. */
  137648. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  137649. }
  137650. }
  137651. declare module BABYLON {
  137652. /**
  137653. * Raw cube texture where the raw buffers are passed in
  137654. */
  137655. export class RawCubeTexture extends CubeTexture {
  137656. /**
  137657. * Creates a cube texture where the raw buffers are passed in.
  137658. * @param scene defines the scene the texture is attached to
  137659. * @param data defines the array of data to use to create each face
  137660. * @param size defines the size of the textures
  137661. * @param format defines the format of the data
  137662. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  137663. * @param generateMipMaps defines if the engine should generate the mip levels
  137664. * @param invertY defines if data must be stored with Y axis inverted
  137665. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  137666. * @param compression defines the compression used (null by default)
  137667. */
  137668. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  137669. /**
  137670. * Updates the raw cube texture.
  137671. * @param data defines the data to store
  137672. * @param format defines the data format
  137673. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  137674. * @param invertY defines if data must be stored with Y axis inverted
  137675. * @param compression defines the compression used (null by default)
  137676. * @param level defines which level of the texture to update
  137677. */
  137678. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  137679. /**
  137680. * Updates a raw cube texture with RGBD encoded data.
  137681. * @param data defines the array of data [mipmap][face] to use to create each face
  137682. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  137683. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  137684. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  137685. * @returns a promsie that resolves when the operation is complete
  137686. */
  137687. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  137688. /**
  137689. * Clones the raw cube texture.
  137690. * @return a new cube texture
  137691. */
  137692. clone(): CubeTexture;
  137693. /** @hidden */
  137694. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  137695. }
  137696. }
  137697. declare module BABYLON {
  137698. /**
  137699. * Class used to store 2D array textures containing user data
  137700. */
  137701. export class RawTexture2DArray extends Texture {
  137702. /** Gets or sets the texture format to use */
  137703. format: number;
  137704. /**
  137705. * Create a new RawTexture2DArray
  137706. * @param data defines the data of the texture
  137707. * @param width defines the width of the texture
  137708. * @param height defines the height of the texture
  137709. * @param depth defines the number of layers of the texture
  137710. * @param format defines the texture format to use
  137711. * @param scene defines the hosting scene
  137712. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137713. * @param invertY defines if texture must be stored with Y axis inverted
  137714. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137715. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137716. */
  137717. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137718. /** Gets or sets the texture format to use */
  137719. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137720. /**
  137721. * Update the texture with new data
  137722. * @param data defines the data to store in the texture
  137723. */
  137724. update(data: ArrayBufferView): void;
  137725. }
  137726. }
  137727. declare module BABYLON {
  137728. /**
  137729. * Class used to store 3D textures containing user data
  137730. */
  137731. export class RawTexture3D extends Texture {
  137732. /** Gets or sets the texture format to use */
  137733. format: number;
  137734. /**
  137735. * Create a new RawTexture3D
  137736. * @param data defines the data of the texture
  137737. * @param width defines the width of the texture
  137738. * @param height defines the height of the texture
  137739. * @param depth defines the depth of the texture
  137740. * @param format defines the texture format to use
  137741. * @param scene defines the hosting scene
  137742. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137743. * @param invertY defines if texture must be stored with Y axis inverted
  137744. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137745. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137746. */
  137747. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137748. /** Gets or sets the texture format to use */
  137749. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137750. /**
  137751. * Update the texture with new data
  137752. * @param data defines the data to store in the texture
  137753. */
  137754. update(data: ArrayBufferView): void;
  137755. }
  137756. }
  137757. declare module BABYLON {
  137758. /**
  137759. * Creates a refraction texture used by refraction channel of the standard material.
  137760. * It is like a mirror but to see through a material.
  137761. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137762. */
  137763. export class RefractionTexture extends RenderTargetTexture {
  137764. /**
  137765. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  137766. * 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.
  137767. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137768. */
  137769. refractionPlane: Plane;
  137770. /**
  137771. * Define how deep under the surface we should see.
  137772. */
  137773. depth: number;
  137774. /**
  137775. * Creates a refraction texture used by refraction channel of the standard material.
  137776. * It is like a mirror but to see through a material.
  137777. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137778. * @param name Define the texture name
  137779. * @param size Define the size of the underlying texture
  137780. * @param scene Define the scene the refraction belongs to
  137781. * @param generateMipMaps Define if we need to generate mips level for the refraction
  137782. */
  137783. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  137784. /**
  137785. * Clone the refraction texture.
  137786. * @returns the cloned texture
  137787. */
  137788. clone(): RefractionTexture;
  137789. /**
  137790. * Serialize the texture to a JSON representation you could use in Parse later on
  137791. * @returns the serialized JSON representation
  137792. */
  137793. serialize(): any;
  137794. }
  137795. }
  137796. declare module BABYLON {
  137797. /**
  137798. * Block used to add support for vertex skinning (bones)
  137799. */
  137800. export class BonesBlock extends NodeMaterialBlock {
  137801. /**
  137802. * Creates a new BonesBlock
  137803. * @param name defines the block name
  137804. */
  137805. constructor(name: string);
  137806. /**
  137807. * Initialize the block and prepare the context for build
  137808. * @param state defines the state that will be used for the build
  137809. */
  137810. initialize(state: NodeMaterialBuildState): void;
  137811. /**
  137812. * Gets the current class name
  137813. * @returns the class name
  137814. */
  137815. getClassName(): string;
  137816. /**
  137817. * Gets the matrix indices input component
  137818. */
  137819. get matricesIndices(): NodeMaterialConnectionPoint;
  137820. /**
  137821. * Gets the matrix weights input component
  137822. */
  137823. get matricesWeights(): NodeMaterialConnectionPoint;
  137824. /**
  137825. * Gets the extra matrix indices input component
  137826. */
  137827. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  137828. /**
  137829. * Gets the extra matrix weights input component
  137830. */
  137831. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  137832. /**
  137833. * Gets the world input component
  137834. */
  137835. get world(): NodeMaterialConnectionPoint;
  137836. /**
  137837. * Gets the output component
  137838. */
  137839. get output(): NodeMaterialConnectionPoint;
  137840. autoConfigure(material: NodeMaterial): void;
  137841. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  137842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137843. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137844. protected _buildBlock(state: NodeMaterialBuildState): this;
  137845. }
  137846. }
  137847. declare module BABYLON {
  137848. /**
  137849. * Block used to add support for instances
  137850. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  137851. */
  137852. export class InstancesBlock extends NodeMaterialBlock {
  137853. /**
  137854. * Creates a new InstancesBlock
  137855. * @param name defines the block name
  137856. */
  137857. constructor(name: string);
  137858. /**
  137859. * Gets the current class name
  137860. * @returns the class name
  137861. */
  137862. getClassName(): string;
  137863. /**
  137864. * Gets the first world row input component
  137865. */
  137866. get world0(): NodeMaterialConnectionPoint;
  137867. /**
  137868. * Gets the second world row input component
  137869. */
  137870. get world1(): NodeMaterialConnectionPoint;
  137871. /**
  137872. * Gets the third world row input component
  137873. */
  137874. get world2(): NodeMaterialConnectionPoint;
  137875. /**
  137876. * Gets the forth world row input component
  137877. */
  137878. get world3(): NodeMaterialConnectionPoint;
  137879. /**
  137880. * Gets the world input component
  137881. */
  137882. get world(): NodeMaterialConnectionPoint;
  137883. /**
  137884. * Gets the output component
  137885. */
  137886. get output(): NodeMaterialConnectionPoint;
  137887. /**
  137888. * Gets the isntanceID component
  137889. */
  137890. get instanceID(): NodeMaterialConnectionPoint;
  137891. autoConfigure(material: NodeMaterial): void;
  137892. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  137893. protected _buildBlock(state: NodeMaterialBuildState): this;
  137894. }
  137895. }
  137896. declare module BABYLON {
  137897. /**
  137898. * Block used to add morph targets support to vertex shader
  137899. */
  137900. export class MorphTargetsBlock extends NodeMaterialBlock {
  137901. private _repeatableContentAnchor;
  137902. /**
  137903. * Create a new MorphTargetsBlock
  137904. * @param name defines the block name
  137905. */
  137906. constructor(name: string);
  137907. /**
  137908. * Gets the current class name
  137909. * @returns the class name
  137910. */
  137911. getClassName(): string;
  137912. /**
  137913. * Gets the position input component
  137914. */
  137915. get position(): NodeMaterialConnectionPoint;
  137916. /**
  137917. * Gets the normal input component
  137918. */
  137919. get normal(): NodeMaterialConnectionPoint;
  137920. /**
  137921. * Gets the tangent input component
  137922. */
  137923. get tangent(): NodeMaterialConnectionPoint;
  137924. /**
  137925. * Gets the tangent input component
  137926. */
  137927. get uv(): NodeMaterialConnectionPoint;
  137928. /**
  137929. * Gets the position output component
  137930. */
  137931. get positionOutput(): NodeMaterialConnectionPoint;
  137932. /**
  137933. * Gets the normal output component
  137934. */
  137935. get normalOutput(): NodeMaterialConnectionPoint;
  137936. /**
  137937. * Gets the tangent output component
  137938. */
  137939. get tangentOutput(): NodeMaterialConnectionPoint;
  137940. /**
  137941. * Gets the tangent output component
  137942. */
  137943. get uvOutput(): NodeMaterialConnectionPoint;
  137944. initialize(state: NodeMaterialBuildState): void;
  137945. autoConfigure(material: NodeMaterial): void;
  137946. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137947. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137948. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  137949. protected _buildBlock(state: NodeMaterialBuildState): this;
  137950. }
  137951. }
  137952. declare module BABYLON {
  137953. /**
  137954. * Block used to get data information from a light
  137955. */
  137956. export class LightInformationBlock extends NodeMaterialBlock {
  137957. private _lightDataUniformName;
  137958. private _lightColorUniformName;
  137959. private _lightTypeDefineName;
  137960. /**
  137961. * Gets or sets the light associated with this block
  137962. */
  137963. light: Nullable<Light>;
  137964. /**
  137965. * Creates a new LightInformationBlock
  137966. * @param name defines the block name
  137967. */
  137968. constructor(name: string);
  137969. /**
  137970. * Gets the current class name
  137971. * @returns the class name
  137972. */
  137973. getClassName(): string;
  137974. /**
  137975. * Gets the world position input component
  137976. */
  137977. get worldPosition(): NodeMaterialConnectionPoint;
  137978. /**
  137979. * Gets the direction output component
  137980. */
  137981. get direction(): NodeMaterialConnectionPoint;
  137982. /**
  137983. * Gets the direction output component
  137984. */
  137985. get color(): NodeMaterialConnectionPoint;
  137986. /**
  137987. * Gets the direction output component
  137988. */
  137989. get intensity(): NodeMaterialConnectionPoint;
  137990. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137992. protected _buildBlock(state: NodeMaterialBuildState): this;
  137993. serialize(): any;
  137994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137995. }
  137996. }
  137997. declare module BABYLON {
  137998. /**
  137999. * Block used to add image processing support to fragment shader
  138000. */
  138001. export class ImageProcessingBlock extends NodeMaterialBlock {
  138002. /**
  138003. * Create a new ImageProcessingBlock
  138004. * @param name defines the block name
  138005. */
  138006. constructor(name: string);
  138007. /**
  138008. * Gets the current class name
  138009. * @returns the class name
  138010. */
  138011. getClassName(): string;
  138012. /**
  138013. * Gets the color input component
  138014. */
  138015. get color(): NodeMaterialConnectionPoint;
  138016. /**
  138017. * Gets the output component
  138018. */
  138019. get output(): NodeMaterialConnectionPoint;
  138020. /**
  138021. * Initialize the block and prepare the context for build
  138022. * @param state defines the state that will be used for the build
  138023. */
  138024. initialize(state: NodeMaterialBuildState): void;
  138025. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  138026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138027. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138028. protected _buildBlock(state: NodeMaterialBuildState): this;
  138029. }
  138030. }
  138031. declare module BABYLON {
  138032. /**
  138033. * Block used to pertub normals based on a normal map
  138034. */
  138035. export class PerturbNormalBlock extends NodeMaterialBlock {
  138036. private _tangentSpaceParameterName;
  138037. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  138038. invertX: boolean;
  138039. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  138040. invertY: boolean;
  138041. /**
  138042. * Create a new PerturbNormalBlock
  138043. * @param name defines the block name
  138044. */
  138045. constructor(name: string);
  138046. /**
  138047. * Gets the current class name
  138048. * @returns the class name
  138049. */
  138050. getClassName(): string;
  138051. /**
  138052. * Gets the world position input component
  138053. */
  138054. get worldPosition(): NodeMaterialConnectionPoint;
  138055. /**
  138056. * Gets the world normal input component
  138057. */
  138058. get worldNormal(): NodeMaterialConnectionPoint;
  138059. /**
  138060. * Gets the world tangent input component
  138061. */
  138062. get worldTangent(): NodeMaterialConnectionPoint;
  138063. /**
  138064. * Gets the uv input component
  138065. */
  138066. get uv(): NodeMaterialConnectionPoint;
  138067. /**
  138068. * Gets the normal map color input component
  138069. */
  138070. get normalMapColor(): NodeMaterialConnectionPoint;
  138071. /**
  138072. * Gets the strength input component
  138073. */
  138074. get strength(): NodeMaterialConnectionPoint;
  138075. /**
  138076. * Gets the output component
  138077. */
  138078. get output(): NodeMaterialConnectionPoint;
  138079. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138080. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138081. autoConfigure(material: NodeMaterial): void;
  138082. protected _buildBlock(state: NodeMaterialBuildState): this;
  138083. protected _dumpPropertiesCode(): string;
  138084. serialize(): any;
  138085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138086. }
  138087. }
  138088. declare module BABYLON {
  138089. /**
  138090. * Block used to discard a pixel if a value is smaller than a cutoff
  138091. */
  138092. export class DiscardBlock extends NodeMaterialBlock {
  138093. /**
  138094. * Create a new DiscardBlock
  138095. * @param name defines the block name
  138096. */
  138097. constructor(name: string);
  138098. /**
  138099. * Gets the current class name
  138100. * @returns the class name
  138101. */
  138102. getClassName(): string;
  138103. /**
  138104. * Gets the color input component
  138105. */
  138106. get value(): NodeMaterialConnectionPoint;
  138107. /**
  138108. * Gets the cutoff input component
  138109. */
  138110. get cutoff(): NodeMaterialConnectionPoint;
  138111. protected _buildBlock(state: NodeMaterialBuildState): this;
  138112. }
  138113. }
  138114. declare module BABYLON {
  138115. /**
  138116. * Block used to test if the fragment shader is front facing
  138117. */
  138118. export class FrontFacingBlock extends NodeMaterialBlock {
  138119. /**
  138120. * Creates a new FrontFacingBlock
  138121. * @param name defines the block name
  138122. */
  138123. constructor(name: string);
  138124. /**
  138125. * Gets the current class name
  138126. * @returns the class name
  138127. */
  138128. getClassName(): string;
  138129. /**
  138130. * Gets the output component
  138131. */
  138132. get output(): NodeMaterialConnectionPoint;
  138133. protected _buildBlock(state: NodeMaterialBuildState): this;
  138134. }
  138135. }
  138136. declare module BABYLON {
  138137. /**
  138138. * Block used to get the derivative value on x and y of a given input
  138139. */
  138140. export class DerivativeBlock extends NodeMaterialBlock {
  138141. /**
  138142. * Create a new DerivativeBlock
  138143. * @param name defines the block name
  138144. */
  138145. constructor(name: string);
  138146. /**
  138147. * Gets the current class name
  138148. * @returns the class name
  138149. */
  138150. getClassName(): string;
  138151. /**
  138152. * Gets the input component
  138153. */
  138154. get input(): NodeMaterialConnectionPoint;
  138155. /**
  138156. * Gets the derivative output on x
  138157. */
  138158. get dx(): NodeMaterialConnectionPoint;
  138159. /**
  138160. * Gets the derivative output on y
  138161. */
  138162. get dy(): NodeMaterialConnectionPoint;
  138163. protected _buildBlock(state: NodeMaterialBuildState): this;
  138164. }
  138165. }
  138166. declare module BABYLON {
  138167. /**
  138168. * Block used to add support for scene fog
  138169. */
  138170. export class FogBlock extends NodeMaterialBlock {
  138171. private _fogDistanceName;
  138172. private _fogParameters;
  138173. /**
  138174. * Create a new FogBlock
  138175. * @param name defines the block name
  138176. */
  138177. constructor(name: string);
  138178. /**
  138179. * Gets the current class name
  138180. * @returns the class name
  138181. */
  138182. getClassName(): string;
  138183. /**
  138184. * Gets the world position input component
  138185. */
  138186. get worldPosition(): NodeMaterialConnectionPoint;
  138187. /**
  138188. * Gets the view input component
  138189. */
  138190. get view(): NodeMaterialConnectionPoint;
  138191. /**
  138192. * Gets the color input component
  138193. */
  138194. get input(): NodeMaterialConnectionPoint;
  138195. /**
  138196. * Gets the fog color input component
  138197. */
  138198. get fogColor(): NodeMaterialConnectionPoint;
  138199. /**
  138200. * Gets the output component
  138201. */
  138202. get output(): NodeMaterialConnectionPoint;
  138203. autoConfigure(material: NodeMaterial): void;
  138204. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138205. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138206. protected _buildBlock(state: NodeMaterialBuildState): this;
  138207. }
  138208. }
  138209. declare module BABYLON {
  138210. /**
  138211. * Block used to add light in the fragment shader
  138212. */
  138213. export class LightBlock extends NodeMaterialBlock {
  138214. private _lightId;
  138215. /**
  138216. * Gets or sets the light associated with this block
  138217. */
  138218. light: Nullable<Light>;
  138219. /**
  138220. * Create a new LightBlock
  138221. * @param name defines the block name
  138222. */
  138223. constructor(name: string);
  138224. /**
  138225. * Gets the current class name
  138226. * @returns the class name
  138227. */
  138228. getClassName(): string;
  138229. /**
  138230. * Gets the world position input component
  138231. */
  138232. get worldPosition(): NodeMaterialConnectionPoint;
  138233. /**
  138234. * Gets the world normal input component
  138235. */
  138236. get worldNormal(): NodeMaterialConnectionPoint;
  138237. /**
  138238. * Gets the camera (or eye) position component
  138239. */
  138240. get cameraPosition(): NodeMaterialConnectionPoint;
  138241. /**
  138242. * Gets the glossiness component
  138243. */
  138244. get glossiness(): NodeMaterialConnectionPoint;
  138245. /**
  138246. * Gets the glossinness power component
  138247. */
  138248. get glossPower(): NodeMaterialConnectionPoint;
  138249. /**
  138250. * Gets the diffuse color component
  138251. */
  138252. get diffuseColor(): NodeMaterialConnectionPoint;
  138253. /**
  138254. * Gets the specular color component
  138255. */
  138256. get specularColor(): NodeMaterialConnectionPoint;
  138257. /**
  138258. * Gets the diffuse output component
  138259. */
  138260. get diffuseOutput(): NodeMaterialConnectionPoint;
  138261. /**
  138262. * Gets the specular output component
  138263. */
  138264. get specularOutput(): NodeMaterialConnectionPoint;
  138265. /**
  138266. * Gets the shadow output component
  138267. */
  138268. get shadow(): NodeMaterialConnectionPoint;
  138269. autoConfigure(material: NodeMaterial): void;
  138270. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138271. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  138272. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138273. private _injectVertexCode;
  138274. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  138275. serialize(): any;
  138276. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138277. }
  138278. }
  138279. declare module BABYLON {
  138280. /**
  138281. * Block used to read a reflection texture from a sampler
  138282. */
  138283. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  138284. /**
  138285. * Create a new ReflectionTextureBlock
  138286. * @param name defines the block name
  138287. */
  138288. constructor(name: string);
  138289. /**
  138290. * Gets the current class name
  138291. * @returns the class name
  138292. */
  138293. getClassName(): string;
  138294. /**
  138295. * Gets the world position input component
  138296. */
  138297. get position(): NodeMaterialConnectionPoint;
  138298. /**
  138299. * Gets the world position input component
  138300. */
  138301. get worldPosition(): NodeMaterialConnectionPoint;
  138302. /**
  138303. * Gets the world normal input component
  138304. */
  138305. get worldNormal(): NodeMaterialConnectionPoint;
  138306. /**
  138307. * Gets the world input component
  138308. */
  138309. get world(): NodeMaterialConnectionPoint;
  138310. /**
  138311. * Gets the camera (or eye) position component
  138312. */
  138313. get cameraPosition(): NodeMaterialConnectionPoint;
  138314. /**
  138315. * Gets the view input component
  138316. */
  138317. get view(): NodeMaterialConnectionPoint;
  138318. /**
  138319. * Gets the rgb output component
  138320. */
  138321. get rgb(): NodeMaterialConnectionPoint;
  138322. /**
  138323. * Gets the r output component
  138324. */
  138325. get r(): NodeMaterialConnectionPoint;
  138326. /**
  138327. * Gets the g output component
  138328. */
  138329. get g(): NodeMaterialConnectionPoint;
  138330. /**
  138331. * Gets the b output component
  138332. */
  138333. get b(): NodeMaterialConnectionPoint;
  138334. autoConfigure(material: NodeMaterial): void;
  138335. protected _buildBlock(state: NodeMaterialBuildState): this;
  138336. }
  138337. }
  138338. declare module BABYLON {
  138339. /**
  138340. * Block used to add 2 vectors
  138341. */
  138342. export class AddBlock extends NodeMaterialBlock {
  138343. /**
  138344. * Creates a new AddBlock
  138345. * @param name defines the block name
  138346. */
  138347. constructor(name: string);
  138348. /**
  138349. * Gets the current class name
  138350. * @returns the class name
  138351. */
  138352. getClassName(): string;
  138353. /**
  138354. * Gets the left operand input component
  138355. */
  138356. get left(): NodeMaterialConnectionPoint;
  138357. /**
  138358. * Gets the right operand input component
  138359. */
  138360. get right(): NodeMaterialConnectionPoint;
  138361. /**
  138362. * Gets the output component
  138363. */
  138364. get output(): NodeMaterialConnectionPoint;
  138365. protected _buildBlock(state: NodeMaterialBuildState): this;
  138366. }
  138367. }
  138368. declare module BABYLON {
  138369. /**
  138370. * Block used to scale a vector by a float
  138371. */
  138372. export class ScaleBlock extends NodeMaterialBlock {
  138373. /**
  138374. * Creates a new ScaleBlock
  138375. * @param name defines the block name
  138376. */
  138377. constructor(name: string);
  138378. /**
  138379. * Gets the current class name
  138380. * @returns the class name
  138381. */
  138382. getClassName(): string;
  138383. /**
  138384. * Gets the input component
  138385. */
  138386. get input(): NodeMaterialConnectionPoint;
  138387. /**
  138388. * Gets the factor input component
  138389. */
  138390. get factor(): NodeMaterialConnectionPoint;
  138391. /**
  138392. * Gets the output component
  138393. */
  138394. get output(): NodeMaterialConnectionPoint;
  138395. protected _buildBlock(state: NodeMaterialBuildState): this;
  138396. }
  138397. }
  138398. declare module BABYLON {
  138399. /**
  138400. * Block used to clamp a float
  138401. */
  138402. export class ClampBlock extends NodeMaterialBlock {
  138403. /** Gets or sets the minimum range */
  138404. minimum: number;
  138405. /** Gets or sets the maximum range */
  138406. maximum: number;
  138407. /**
  138408. * Creates a new ClampBlock
  138409. * @param name defines the block name
  138410. */
  138411. constructor(name: string);
  138412. /**
  138413. * Gets the current class name
  138414. * @returns the class name
  138415. */
  138416. getClassName(): string;
  138417. /**
  138418. * Gets the value input component
  138419. */
  138420. get value(): NodeMaterialConnectionPoint;
  138421. /**
  138422. * Gets the output component
  138423. */
  138424. get output(): NodeMaterialConnectionPoint;
  138425. protected _buildBlock(state: NodeMaterialBuildState): this;
  138426. protected _dumpPropertiesCode(): string;
  138427. serialize(): any;
  138428. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138429. }
  138430. }
  138431. declare module BABYLON {
  138432. /**
  138433. * Block used to apply a cross product between 2 vectors
  138434. */
  138435. export class CrossBlock extends NodeMaterialBlock {
  138436. /**
  138437. * Creates a new CrossBlock
  138438. * @param name defines the block name
  138439. */
  138440. constructor(name: string);
  138441. /**
  138442. * Gets the current class name
  138443. * @returns the class name
  138444. */
  138445. getClassName(): string;
  138446. /**
  138447. * Gets the left operand input component
  138448. */
  138449. get left(): NodeMaterialConnectionPoint;
  138450. /**
  138451. * Gets the right operand input component
  138452. */
  138453. get right(): NodeMaterialConnectionPoint;
  138454. /**
  138455. * Gets the output component
  138456. */
  138457. get output(): NodeMaterialConnectionPoint;
  138458. protected _buildBlock(state: NodeMaterialBuildState): this;
  138459. }
  138460. }
  138461. declare module BABYLON {
  138462. /**
  138463. * Block used to apply a dot product between 2 vectors
  138464. */
  138465. export class DotBlock extends NodeMaterialBlock {
  138466. /**
  138467. * Creates a new DotBlock
  138468. * @param name defines the block name
  138469. */
  138470. constructor(name: string);
  138471. /**
  138472. * Gets the current class name
  138473. * @returns the class name
  138474. */
  138475. getClassName(): string;
  138476. /**
  138477. * Gets the left operand input component
  138478. */
  138479. get left(): NodeMaterialConnectionPoint;
  138480. /**
  138481. * Gets the right operand input component
  138482. */
  138483. get right(): NodeMaterialConnectionPoint;
  138484. /**
  138485. * Gets the output component
  138486. */
  138487. get output(): NodeMaterialConnectionPoint;
  138488. protected _buildBlock(state: NodeMaterialBuildState): this;
  138489. }
  138490. }
  138491. declare module BABYLON {
  138492. /**
  138493. * Block used to normalize a vector
  138494. */
  138495. export class NormalizeBlock extends NodeMaterialBlock {
  138496. /**
  138497. * Creates a new NormalizeBlock
  138498. * @param name defines the block name
  138499. */
  138500. constructor(name: string);
  138501. /**
  138502. * Gets the current class name
  138503. * @returns the class name
  138504. */
  138505. getClassName(): string;
  138506. /**
  138507. * Gets the input component
  138508. */
  138509. get input(): NodeMaterialConnectionPoint;
  138510. /**
  138511. * Gets the output component
  138512. */
  138513. get output(): NodeMaterialConnectionPoint;
  138514. protected _buildBlock(state: NodeMaterialBuildState): this;
  138515. }
  138516. }
  138517. declare module BABYLON {
  138518. /**
  138519. * Operations supported by the Trigonometry block
  138520. */
  138521. export enum TrigonometryBlockOperations {
  138522. /** Cos */
  138523. Cos = 0,
  138524. /** Sin */
  138525. Sin = 1,
  138526. /** Abs */
  138527. Abs = 2,
  138528. /** Exp */
  138529. Exp = 3,
  138530. /** Exp2 */
  138531. Exp2 = 4,
  138532. /** Round */
  138533. Round = 5,
  138534. /** Floor */
  138535. Floor = 6,
  138536. /** Ceiling */
  138537. Ceiling = 7,
  138538. /** Square root */
  138539. Sqrt = 8,
  138540. /** Log */
  138541. Log = 9,
  138542. /** Tangent */
  138543. Tan = 10,
  138544. /** Arc tangent */
  138545. ArcTan = 11,
  138546. /** Arc cosinus */
  138547. ArcCos = 12,
  138548. /** Arc sinus */
  138549. ArcSin = 13,
  138550. /** Fraction */
  138551. Fract = 14,
  138552. /** Sign */
  138553. Sign = 15,
  138554. /** To radians (from degrees) */
  138555. Radians = 16,
  138556. /** To degrees (from radians) */
  138557. Degrees = 17
  138558. }
  138559. /**
  138560. * Block used to apply trigonometry operation to floats
  138561. */
  138562. export class TrigonometryBlock extends NodeMaterialBlock {
  138563. /**
  138564. * Gets or sets the operation applied by the block
  138565. */
  138566. operation: TrigonometryBlockOperations;
  138567. /**
  138568. * Creates a new TrigonometryBlock
  138569. * @param name defines the block name
  138570. */
  138571. constructor(name: string);
  138572. /**
  138573. * Gets the current class name
  138574. * @returns the class name
  138575. */
  138576. getClassName(): string;
  138577. /**
  138578. * Gets the input component
  138579. */
  138580. get input(): NodeMaterialConnectionPoint;
  138581. /**
  138582. * Gets the output component
  138583. */
  138584. get output(): NodeMaterialConnectionPoint;
  138585. protected _buildBlock(state: NodeMaterialBuildState): this;
  138586. serialize(): any;
  138587. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138588. protected _dumpPropertiesCode(): string;
  138589. }
  138590. }
  138591. declare module BABYLON {
  138592. /**
  138593. * Block used to create a Color3/4 out of individual inputs (one for each component)
  138594. */
  138595. export class ColorMergerBlock extends NodeMaterialBlock {
  138596. /**
  138597. * Create a new ColorMergerBlock
  138598. * @param name defines the block name
  138599. */
  138600. constructor(name: string);
  138601. /**
  138602. * Gets the current class name
  138603. * @returns the class name
  138604. */
  138605. getClassName(): string;
  138606. /**
  138607. * Gets the rgb component (input)
  138608. */
  138609. get rgbIn(): NodeMaterialConnectionPoint;
  138610. /**
  138611. * Gets the r component (input)
  138612. */
  138613. get r(): NodeMaterialConnectionPoint;
  138614. /**
  138615. * Gets the g component (input)
  138616. */
  138617. get g(): NodeMaterialConnectionPoint;
  138618. /**
  138619. * Gets the b component (input)
  138620. */
  138621. get b(): NodeMaterialConnectionPoint;
  138622. /**
  138623. * Gets the a component (input)
  138624. */
  138625. get a(): NodeMaterialConnectionPoint;
  138626. /**
  138627. * Gets the rgba component (output)
  138628. */
  138629. get rgba(): NodeMaterialConnectionPoint;
  138630. /**
  138631. * Gets the rgb component (output)
  138632. */
  138633. get rgbOut(): NodeMaterialConnectionPoint;
  138634. /**
  138635. * Gets the rgb component (output)
  138636. * @deprecated Please use rgbOut instead.
  138637. */
  138638. get rgb(): NodeMaterialConnectionPoint;
  138639. protected _buildBlock(state: NodeMaterialBuildState): this;
  138640. }
  138641. }
  138642. declare module BABYLON {
  138643. /**
  138644. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  138645. */
  138646. export class VectorSplitterBlock extends NodeMaterialBlock {
  138647. /**
  138648. * Create a new VectorSplitterBlock
  138649. * @param name defines the block name
  138650. */
  138651. constructor(name: string);
  138652. /**
  138653. * Gets the current class name
  138654. * @returns the class name
  138655. */
  138656. getClassName(): string;
  138657. /**
  138658. * Gets the xyzw component (input)
  138659. */
  138660. get xyzw(): NodeMaterialConnectionPoint;
  138661. /**
  138662. * Gets the xyz component (input)
  138663. */
  138664. get xyzIn(): NodeMaterialConnectionPoint;
  138665. /**
  138666. * Gets the xy component (input)
  138667. */
  138668. get xyIn(): NodeMaterialConnectionPoint;
  138669. /**
  138670. * Gets the xyz component (output)
  138671. */
  138672. get xyzOut(): NodeMaterialConnectionPoint;
  138673. /**
  138674. * Gets the xy component (output)
  138675. */
  138676. get xyOut(): NodeMaterialConnectionPoint;
  138677. /**
  138678. * Gets the x component (output)
  138679. */
  138680. get x(): NodeMaterialConnectionPoint;
  138681. /**
  138682. * Gets the y component (output)
  138683. */
  138684. get y(): NodeMaterialConnectionPoint;
  138685. /**
  138686. * Gets the z component (output)
  138687. */
  138688. get z(): NodeMaterialConnectionPoint;
  138689. /**
  138690. * Gets the w component (output)
  138691. */
  138692. get w(): NodeMaterialConnectionPoint;
  138693. protected _inputRename(name: string): string;
  138694. protected _outputRename(name: string): string;
  138695. protected _buildBlock(state: NodeMaterialBuildState): this;
  138696. }
  138697. }
  138698. declare module BABYLON {
  138699. /**
  138700. * Block used to lerp between 2 values
  138701. */
  138702. export class LerpBlock extends NodeMaterialBlock {
  138703. /**
  138704. * Creates a new LerpBlock
  138705. * @param name defines the block name
  138706. */
  138707. constructor(name: string);
  138708. /**
  138709. * Gets the current class name
  138710. * @returns the class name
  138711. */
  138712. getClassName(): string;
  138713. /**
  138714. * Gets the left operand input component
  138715. */
  138716. get left(): NodeMaterialConnectionPoint;
  138717. /**
  138718. * Gets the right operand input component
  138719. */
  138720. get right(): NodeMaterialConnectionPoint;
  138721. /**
  138722. * Gets the gradient operand input component
  138723. */
  138724. get gradient(): NodeMaterialConnectionPoint;
  138725. /**
  138726. * Gets the output component
  138727. */
  138728. get output(): NodeMaterialConnectionPoint;
  138729. protected _buildBlock(state: NodeMaterialBuildState): this;
  138730. }
  138731. }
  138732. declare module BABYLON {
  138733. /**
  138734. * Block used to divide 2 vectors
  138735. */
  138736. export class DivideBlock extends NodeMaterialBlock {
  138737. /**
  138738. * Creates a new DivideBlock
  138739. * @param name defines the block name
  138740. */
  138741. constructor(name: string);
  138742. /**
  138743. * Gets the current class name
  138744. * @returns the class name
  138745. */
  138746. getClassName(): string;
  138747. /**
  138748. * Gets the left operand input component
  138749. */
  138750. get left(): NodeMaterialConnectionPoint;
  138751. /**
  138752. * Gets the right operand input component
  138753. */
  138754. get right(): NodeMaterialConnectionPoint;
  138755. /**
  138756. * Gets the output component
  138757. */
  138758. get output(): NodeMaterialConnectionPoint;
  138759. protected _buildBlock(state: NodeMaterialBuildState): this;
  138760. }
  138761. }
  138762. declare module BABYLON {
  138763. /**
  138764. * Block used to subtract 2 vectors
  138765. */
  138766. export class SubtractBlock extends NodeMaterialBlock {
  138767. /**
  138768. * Creates a new SubtractBlock
  138769. * @param name defines the block name
  138770. */
  138771. constructor(name: string);
  138772. /**
  138773. * Gets the current class name
  138774. * @returns the class name
  138775. */
  138776. getClassName(): string;
  138777. /**
  138778. * Gets the left operand input component
  138779. */
  138780. get left(): NodeMaterialConnectionPoint;
  138781. /**
  138782. * Gets the right operand input component
  138783. */
  138784. get right(): NodeMaterialConnectionPoint;
  138785. /**
  138786. * Gets the output component
  138787. */
  138788. get output(): NodeMaterialConnectionPoint;
  138789. protected _buildBlock(state: NodeMaterialBuildState): this;
  138790. }
  138791. }
  138792. declare module BABYLON {
  138793. /**
  138794. * Block used to step a value
  138795. */
  138796. export class StepBlock extends NodeMaterialBlock {
  138797. /**
  138798. * Creates a new StepBlock
  138799. * @param name defines the block name
  138800. */
  138801. constructor(name: string);
  138802. /**
  138803. * Gets the current class name
  138804. * @returns the class name
  138805. */
  138806. getClassName(): string;
  138807. /**
  138808. * Gets the value operand input component
  138809. */
  138810. get value(): NodeMaterialConnectionPoint;
  138811. /**
  138812. * Gets the edge operand input component
  138813. */
  138814. get edge(): NodeMaterialConnectionPoint;
  138815. /**
  138816. * Gets the output component
  138817. */
  138818. get output(): NodeMaterialConnectionPoint;
  138819. protected _buildBlock(state: NodeMaterialBuildState): this;
  138820. }
  138821. }
  138822. declare module BABYLON {
  138823. /**
  138824. * Block used to get the opposite (1 - x) of a value
  138825. */
  138826. export class OneMinusBlock extends NodeMaterialBlock {
  138827. /**
  138828. * Creates a new OneMinusBlock
  138829. * @param name defines the block name
  138830. */
  138831. constructor(name: string);
  138832. /**
  138833. * Gets the current class name
  138834. * @returns the class name
  138835. */
  138836. getClassName(): string;
  138837. /**
  138838. * Gets the input component
  138839. */
  138840. get input(): NodeMaterialConnectionPoint;
  138841. /**
  138842. * Gets the output component
  138843. */
  138844. get output(): NodeMaterialConnectionPoint;
  138845. protected _buildBlock(state: NodeMaterialBuildState): this;
  138846. }
  138847. }
  138848. declare module BABYLON {
  138849. /**
  138850. * Block used to get the view direction
  138851. */
  138852. export class ViewDirectionBlock extends NodeMaterialBlock {
  138853. /**
  138854. * Creates a new ViewDirectionBlock
  138855. * @param name defines the block name
  138856. */
  138857. constructor(name: string);
  138858. /**
  138859. * Gets the current class name
  138860. * @returns the class name
  138861. */
  138862. getClassName(): string;
  138863. /**
  138864. * Gets the world position component
  138865. */
  138866. get worldPosition(): NodeMaterialConnectionPoint;
  138867. /**
  138868. * Gets the camera position component
  138869. */
  138870. get cameraPosition(): NodeMaterialConnectionPoint;
  138871. /**
  138872. * Gets the output component
  138873. */
  138874. get output(): NodeMaterialConnectionPoint;
  138875. autoConfigure(material: NodeMaterial): void;
  138876. protected _buildBlock(state: NodeMaterialBuildState): this;
  138877. }
  138878. }
  138879. declare module BABYLON {
  138880. /**
  138881. * Block used to compute fresnel value
  138882. */
  138883. export class FresnelBlock extends NodeMaterialBlock {
  138884. /**
  138885. * Create a new FresnelBlock
  138886. * @param name defines the block name
  138887. */
  138888. constructor(name: string);
  138889. /**
  138890. * Gets the current class name
  138891. * @returns the class name
  138892. */
  138893. getClassName(): string;
  138894. /**
  138895. * Gets the world normal input component
  138896. */
  138897. get worldNormal(): NodeMaterialConnectionPoint;
  138898. /**
  138899. * Gets the view direction input component
  138900. */
  138901. get viewDirection(): NodeMaterialConnectionPoint;
  138902. /**
  138903. * Gets the bias input component
  138904. */
  138905. get bias(): NodeMaterialConnectionPoint;
  138906. /**
  138907. * Gets the camera (or eye) position component
  138908. */
  138909. get power(): NodeMaterialConnectionPoint;
  138910. /**
  138911. * Gets the fresnel output component
  138912. */
  138913. get fresnel(): NodeMaterialConnectionPoint;
  138914. autoConfigure(material: NodeMaterial): void;
  138915. protected _buildBlock(state: NodeMaterialBuildState): this;
  138916. }
  138917. }
  138918. declare module BABYLON {
  138919. /**
  138920. * Block used to get the max of 2 values
  138921. */
  138922. export class MaxBlock extends NodeMaterialBlock {
  138923. /**
  138924. * Creates a new MaxBlock
  138925. * @param name defines the block name
  138926. */
  138927. constructor(name: string);
  138928. /**
  138929. * Gets the current class name
  138930. * @returns the class name
  138931. */
  138932. getClassName(): string;
  138933. /**
  138934. * Gets the left operand input component
  138935. */
  138936. get left(): NodeMaterialConnectionPoint;
  138937. /**
  138938. * Gets the right operand input component
  138939. */
  138940. get right(): NodeMaterialConnectionPoint;
  138941. /**
  138942. * Gets the output component
  138943. */
  138944. get output(): NodeMaterialConnectionPoint;
  138945. protected _buildBlock(state: NodeMaterialBuildState): this;
  138946. }
  138947. }
  138948. declare module BABYLON {
  138949. /**
  138950. * Block used to get the min of 2 values
  138951. */
  138952. export class MinBlock extends NodeMaterialBlock {
  138953. /**
  138954. * Creates a new MinBlock
  138955. * @param name defines the block name
  138956. */
  138957. constructor(name: string);
  138958. /**
  138959. * Gets the current class name
  138960. * @returns the class name
  138961. */
  138962. getClassName(): string;
  138963. /**
  138964. * Gets the left operand input component
  138965. */
  138966. get left(): NodeMaterialConnectionPoint;
  138967. /**
  138968. * Gets the right operand input component
  138969. */
  138970. get right(): NodeMaterialConnectionPoint;
  138971. /**
  138972. * Gets the output component
  138973. */
  138974. get output(): NodeMaterialConnectionPoint;
  138975. protected _buildBlock(state: NodeMaterialBuildState): this;
  138976. }
  138977. }
  138978. declare module BABYLON {
  138979. /**
  138980. * Block used to get the distance between 2 values
  138981. */
  138982. export class DistanceBlock extends NodeMaterialBlock {
  138983. /**
  138984. * Creates a new DistanceBlock
  138985. * @param name defines the block name
  138986. */
  138987. constructor(name: string);
  138988. /**
  138989. * Gets the current class name
  138990. * @returns the class name
  138991. */
  138992. getClassName(): string;
  138993. /**
  138994. * Gets the left operand input component
  138995. */
  138996. get left(): NodeMaterialConnectionPoint;
  138997. /**
  138998. * Gets the right operand input component
  138999. */
  139000. get right(): NodeMaterialConnectionPoint;
  139001. /**
  139002. * Gets the output component
  139003. */
  139004. get output(): NodeMaterialConnectionPoint;
  139005. protected _buildBlock(state: NodeMaterialBuildState): this;
  139006. }
  139007. }
  139008. declare module BABYLON {
  139009. /**
  139010. * Block used to get the length of a vector
  139011. */
  139012. export class LengthBlock extends NodeMaterialBlock {
  139013. /**
  139014. * Creates a new LengthBlock
  139015. * @param name defines the block name
  139016. */
  139017. constructor(name: string);
  139018. /**
  139019. * Gets the current class name
  139020. * @returns the class name
  139021. */
  139022. getClassName(): string;
  139023. /**
  139024. * Gets the value input component
  139025. */
  139026. get value(): NodeMaterialConnectionPoint;
  139027. /**
  139028. * Gets the output component
  139029. */
  139030. get output(): NodeMaterialConnectionPoint;
  139031. protected _buildBlock(state: NodeMaterialBuildState): this;
  139032. }
  139033. }
  139034. declare module BABYLON {
  139035. /**
  139036. * Block used to get negative version of a value (i.e. x * -1)
  139037. */
  139038. export class NegateBlock extends NodeMaterialBlock {
  139039. /**
  139040. * Creates a new NegateBlock
  139041. * @param name defines the block name
  139042. */
  139043. constructor(name: string);
  139044. /**
  139045. * Gets the current class name
  139046. * @returns the class name
  139047. */
  139048. getClassName(): string;
  139049. /**
  139050. * Gets the value input component
  139051. */
  139052. get value(): NodeMaterialConnectionPoint;
  139053. /**
  139054. * Gets the output component
  139055. */
  139056. get output(): NodeMaterialConnectionPoint;
  139057. protected _buildBlock(state: NodeMaterialBuildState): this;
  139058. }
  139059. }
  139060. declare module BABYLON {
  139061. /**
  139062. * Block used to get the value of the first parameter raised to the power of the second
  139063. */
  139064. export class PowBlock extends NodeMaterialBlock {
  139065. /**
  139066. * Creates a new PowBlock
  139067. * @param name defines the block name
  139068. */
  139069. constructor(name: string);
  139070. /**
  139071. * Gets the current class name
  139072. * @returns the class name
  139073. */
  139074. getClassName(): string;
  139075. /**
  139076. * Gets the value operand input component
  139077. */
  139078. get value(): NodeMaterialConnectionPoint;
  139079. /**
  139080. * Gets the power operand input component
  139081. */
  139082. get power(): NodeMaterialConnectionPoint;
  139083. /**
  139084. * Gets the output component
  139085. */
  139086. get output(): NodeMaterialConnectionPoint;
  139087. protected _buildBlock(state: NodeMaterialBuildState): this;
  139088. }
  139089. }
  139090. declare module BABYLON {
  139091. /**
  139092. * Block used to get a random number
  139093. */
  139094. export class RandomNumberBlock extends NodeMaterialBlock {
  139095. /**
  139096. * Creates a new RandomNumberBlock
  139097. * @param name defines the block name
  139098. */
  139099. constructor(name: string);
  139100. /**
  139101. * Gets the current class name
  139102. * @returns the class name
  139103. */
  139104. getClassName(): string;
  139105. /**
  139106. * Gets the seed input component
  139107. */
  139108. get seed(): NodeMaterialConnectionPoint;
  139109. /**
  139110. * Gets the output component
  139111. */
  139112. get output(): NodeMaterialConnectionPoint;
  139113. protected _buildBlock(state: NodeMaterialBuildState): this;
  139114. }
  139115. }
  139116. declare module BABYLON {
  139117. /**
  139118. * Block used to compute arc tangent of 2 values
  139119. */
  139120. export class ArcTan2Block extends NodeMaterialBlock {
  139121. /**
  139122. * Creates a new ArcTan2Block
  139123. * @param name defines the block name
  139124. */
  139125. constructor(name: string);
  139126. /**
  139127. * Gets the current class name
  139128. * @returns the class name
  139129. */
  139130. getClassName(): string;
  139131. /**
  139132. * Gets the x operand input component
  139133. */
  139134. get x(): NodeMaterialConnectionPoint;
  139135. /**
  139136. * Gets the y operand input component
  139137. */
  139138. get y(): NodeMaterialConnectionPoint;
  139139. /**
  139140. * Gets the output component
  139141. */
  139142. get output(): NodeMaterialConnectionPoint;
  139143. protected _buildBlock(state: NodeMaterialBuildState): this;
  139144. }
  139145. }
  139146. declare module BABYLON {
  139147. /**
  139148. * Block used to smooth step a value
  139149. */
  139150. export class SmoothStepBlock extends NodeMaterialBlock {
  139151. /**
  139152. * Creates a new SmoothStepBlock
  139153. * @param name defines the block name
  139154. */
  139155. constructor(name: string);
  139156. /**
  139157. * Gets the current class name
  139158. * @returns the class name
  139159. */
  139160. getClassName(): string;
  139161. /**
  139162. * Gets the value operand input component
  139163. */
  139164. get value(): NodeMaterialConnectionPoint;
  139165. /**
  139166. * Gets the first edge operand input component
  139167. */
  139168. get edge0(): NodeMaterialConnectionPoint;
  139169. /**
  139170. * Gets the second edge operand input component
  139171. */
  139172. get edge1(): NodeMaterialConnectionPoint;
  139173. /**
  139174. * Gets the output component
  139175. */
  139176. get output(): NodeMaterialConnectionPoint;
  139177. protected _buildBlock(state: NodeMaterialBuildState): this;
  139178. }
  139179. }
  139180. declare module BABYLON {
  139181. /**
  139182. * Block used to get the reciprocal (1 / x) of a value
  139183. */
  139184. export class ReciprocalBlock extends NodeMaterialBlock {
  139185. /**
  139186. * Creates a new ReciprocalBlock
  139187. * @param name defines the block name
  139188. */
  139189. constructor(name: string);
  139190. /**
  139191. * Gets the current class name
  139192. * @returns the class name
  139193. */
  139194. getClassName(): string;
  139195. /**
  139196. * Gets the input component
  139197. */
  139198. get input(): NodeMaterialConnectionPoint;
  139199. /**
  139200. * Gets the output component
  139201. */
  139202. get output(): NodeMaterialConnectionPoint;
  139203. protected _buildBlock(state: NodeMaterialBuildState): this;
  139204. }
  139205. }
  139206. declare module BABYLON {
  139207. /**
  139208. * Block used to replace a color by another one
  139209. */
  139210. export class ReplaceColorBlock extends NodeMaterialBlock {
  139211. /**
  139212. * Creates a new ReplaceColorBlock
  139213. * @param name defines the block name
  139214. */
  139215. constructor(name: string);
  139216. /**
  139217. * Gets the current class name
  139218. * @returns the class name
  139219. */
  139220. getClassName(): string;
  139221. /**
  139222. * Gets the value input component
  139223. */
  139224. get value(): NodeMaterialConnectionPoint;
  139225. /**
  139226. * Gets the reference input component
  139227. */
  139228. get reference(): NodeMaterialConnectionPoint;
  139229. /**
  139230. * Gets the distance input component
  139231. */
  139232. get distance(): NodeMaterialConnectionPoint;
  139233. /**
  139234. * Gets the replacement input component
  139235. */
  139236. get replacement(): NodeMaterialConnectionPoint;
  139237. /**
  139238. * Gets the output component
  139239. */
  139240. get output(): NodeMaterialConnectionPoint;
  139241. protected _buildBlock(state: NodeMaterialBuildState): this;
  139242. }
  139243. }
  139244. declare module BABYLON {
  139245. /**
  139246. * Block used to posterize a value
  139247. * @see https://en.wikipedia.org/wiki/Posterization
  139248. */
  139249. export class PosterizeBlock extends NodeMaterialBlock {
  139250. /**
  139251. * Creates a new PosterizeBlock
  139252. * @param name defines the block name
  139253. */
  139254. constructor(name: string);
  139255. /**
  139256. * Gets the current class name
  139257. * @returns the class name
  139258. */
  139259. getClassName(): string;
  139260. /**
  139261. * Gets the value input component
  139262. */
  139263. get value(): NodeMaterialConnectionPoint;
  139264. /**
  139265. * Gets the steps input component
  139266. */
  139267. get steps(): NodeMaterialConnectionPoint;
  139268. /**
  139269. * Gets the output component
  139270. */
  139271. get output(): NodeMaterialConnectionPoint;
  139272. protected _buildBlock(state: NodeMaterialBuildState): this;
  139273. }
  139274. }
  139275. declare module BABYLON {
  139276. /**
  139277. * Operations supported by the Wave block
  139278. */
  139279. export enum WaveBlockKind {
  139280. /** SawTooth */
  139281. SawTooth = 0,
  139282. /** Square */
  139283. Square = 1,
  139284. /** Triangle */
  139285. Triangle = 2
  139286. }
  139287. /**
  139288. * Block used to apply wave operation to floats
  139289. */
  139290. export class WaveBlock extends NodeMaterialBlock {
  139291. /**
  139292. * Gets or sets the kibnd of wave to be applied by the block
  139293. */
  139294. kind: WaveBlockKind;
  139295. /**
  139296. * Creates a new WaveBlock
  139297. * @param name defines the block name
  139298. */
  139299. constructor(name: string);
  139300. /**
  139301. * Gets the current class name
  139302. * @returns the class name
  139303. */
  139304. getClassName(): string;
  139305. /**
  139306. * Gets the input component
  139307. */
  139308. get input(): NodeMaterialConnectionPoint;
  139309. /**
  139310. * Gets the output component
  139311. */
  139312. get output(): NodeMaterialConnectionPoint;
  139313. protected _buildBlock(state: NodeMaterialBuildState): this;
  139314. serialize(): any;
  139315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139316. }
  139317. }
  139318. declare module BABYLON {
  139319. /**
  139320. * Class used to store a color step for the GradientBlock
  139321. */
  139322. export class GradientBlockColorStep {
  139323. /**
  139324. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  139325. */
  139326. step: number;
  139327. /**
  139328. * Gets or sets the color associated with this step
  139329. */
  139330. color: Color3;
  139331. /**
  139332. * Creates a new GradientBlockColorStep
  139333. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  139334. * @param color defines the color associated with this step
  139335. */
  139336. constructor(
  139337. /**
  139338. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  139339. */
  139340. step: number,
  139341. /**
  139342. * Gets or sets the color associated with this step
  139343. */
  139344. color: Color3);
  139345. }
  139346. /**
  139347. * Block used to return a color from a gradient based on an input value between 0 and 1
  139348. */
  139349. export class GradientBlock extends NodeMaterialBlock {
  139350. /**
  139351. * Gets or sets the list of color steps
  139352. */
  139353. colorSteps: GradientBlockColorStep[];
  139354. /**
  139355. * Creates a new GradientBlock
  139356. * @param name defines the block name
  139357. */
  139358. constructor(name: string);
  139359. /**
  139360. * Gets the current class name
  139361. * @returns the class name
  139362. */
  139363. getClassName(): string;
  139364. /**
  139365. * Gets the gradient input component
  139366. */
  139367. get gradient(): NodeMaterialConnectionPoint;
  139368. /**
  139369. * Gets the output component
  139370. */
  139371. get output(): NodeMaterialConnectionPoint;
  139372. private _writeColorConstant;
  139373. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139374. serialize(): any;
  139375. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139376. protected _dumpPropertiesCode(): string;
  139377. }
  139378. }
  139379. declare module BABYLON {
  139380. /**
  139381. * Block used to normalize lerp between 2 values
  139382. */
  139383. export class NLerpBlock extends NodeMaterialBlock {
  139384. /**
  139385. * Creates a new NLerpBlock
  139386. * @param name defines the block name
  139387. */
  139388. constructor(name: string);
  139389. /**
  139390. * Gets the current class name
  139391. * @returns the class name
  139392. */
  139393. getClassName(): string;
  139394. /**
  139395. * Gets the left operand input component
  139396. */
  139397. get left(): NodeMaterialConnectionPoint;
  139398. /**
  139399. * Gets the right operand input component
  139400. */
  139401. get right(): NodeMaterialConnectionPoint;
  139402. /**
  139403. * Gets the gradient operand input component
  139404. */
  139405. get gradient(): NodeMaterialConnectionPoint;
  139406. /**
  139407. * Gets the output component
  139408. */
  139409. get output(): NodeMaterialConnectionPoint;
  139410. protected _buildBlock(state: NodeMaterialBuildState): this;
  139411. }
  139412. }
  139413. declare module BABYLON {
  139414. /**
  139415. * block used to Generate a Worley Noise 3D Noise Pattern
  139416. */
  139417. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  139418. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139419. manhattanDistance: boolean;
  139420. /**
  139421. * Creates a new WorleyNoise3DBlock
  139422. * @param name defines the block name
  139423. */
  139424. constructor(name: string);
  139425. /**
  139426. * Gets the current class name
  139427. * @returns the class name
  139428. */
  139429. getClassName(): string;
  139430. /**
  139431. * Gets the seed input component
  139432. */
  139433. get seed(): NodeMaterialConnectionPoint;
  139434. /**
  139435. * Gets the jitter input component
  139436. */
  139437. get jitter(): NodeMaterialConnectionPoint;
  139438. /**
  139439. * Gets the output component
  139440. */
  139441. get output(): NodeMaterialConnectionPoint;
  139442. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139443. /**
  139444. * Exposes the properties to the UI?
  139445. */
  139446. protected _dumpPropertiesCode(): string;
  139447. /**
  139448. * Exposes the properties to the Seralize?
  139449. */
  139450. serialize(): any;
  139451. /**
  139452. * Exposes the properties to the deseralize?
  139453. */
  139454. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139455. }
  139456. }
  139457. declare module BABYLON {
  139458. /**
  139459. * block used to Generate a Simplex Perlin 3d Noise Pattern
  139460. */
  139461. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  139462. /**
  139463. * Creates a new SimplexPerlin3DBlock
  139464. * @param name defines the block name
  139465. */
  139466. constructor(name: string);
  139467. /**
  139468. * Gets the current class name
  139469. * @returns the class name
  139470. */
  139471. getClassName(): string;
  139472. /**
  139473. * Gets the seed operand input component
  139474. */
  139475. get seed(): NodeMaterialConnectionPoint;
  139476. /**
  139477. * Gets the output component
  139478. */
  139479. get output(): NodeMaterialConnectionPoint;
  139480. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139481. }
  139482. }
  139483. declare module BABYLON {
  139484. /**
  139485. * Block used to blend normals
  139486. */
  139487. export class NormalBlendBlock extends NodeMaterialBlock {
  139488. /**
  139489. * Creates a new NormalBlendBlock
  139490. * @param name defines the block name
  139491. */
  139492. constructor(name: string);
  139493. /**
  139494. * Gets the current class name
  139495. * @returns the class name
  139496. */
  139497. getClassName(): string;
  139498. /**
  139499. * Gets the first input component
  139500. */
  139501. get normalMap0(): NodeMaterialConnectionPoint;
  139502. /**
  139503. * Gets the second input component
  139504. */
  139505. get normalMap1(): NodeMaterialConnectionPoint;
  139506. /**
  139507. * Gets the output component
  139508. */
  139509. get output(): NodeMaterialConnectionPoint;
  139510. protected _buildBlock(state: NodeMaterialBuildState): this;
  139511. }
  139512. }
  139513. declare module BABYLON {
  139514. /**
  139515. * Block used to rotate a 2d vector by a given angle
  139516. */
  139517. export class Rotate2dBlock extends NodeMaterialBlock {
  139518. /**
  139519. * Creates a new Rotate2dBlock
  139520. * @param name defines the block name
  139521. */
  139522. constructor(name: string);
  139523. /**
  139524. * Gets the current class name
  139525. * @returns the class name
  139526. */
  139527. getClassName(): string;
  139528. /**
  139529. * Gets the input vector
  139530. */
  139531. get input(): NodeMaterialConnectionPoint;
  139532. /**
  139533. * Gets the input angle
  139534. */
  139535. get angle(): NodeMaterialConnectionPoint;
  139536. /**
  139537. * Gets the output component
  139538. */
  139539. get output(): NodeMaterialConnectionPoint;
  139540. autoConfigure(material: NodeMaterial): void;
  139541. protected _buildBlock(state: NodeMaterialBuildState): this;
  139542. }
  139543. }
  139544. declare module BABYLON {
  139545. /**
  139546. * Block used to get the reflected vector from a direction and a normal
  139547. */
  139548. export class ReflectBlock extends NodeMaterialBlock {
  139549. /**
  139550. * Creates a new ReflectBlock
  139551. * @param name defines the block name
  139552. */
  139553. constructor(name: string);
  139554. /**
  139555. * Gets the current class name
  139556. * @returns the class name
  139557. */
  139558. getClassName(): string;
  139559. /**
  139560. * Gets the incident component
  139561. */
  139562. get incident(): NodeMaterialConnectionPoint;
  139563. /**
  139564. * Gets the normal component
  139565. */
  139566. get normal(): NodeMaterialConnectionPoint;
  139567. /**
  139568. * Gets the output component
  139569. */
  139570. get output(): NodeMaterialConnectionPoint;
  139571. protected _buildBlock(state: NodeMaterialBuildState): this;
  139572. }
  139573. }
  139574. declare module BABYLON {
  139575. /**
  139576. * Block used to get the refracted vector from a direction and a normal
  139577. */
  139578. export class RefractBlock extends NodeMaterialBlock {
  139579. /**
  139580. * Creates a new RefractBlock
  139581. * @param name defines the block name
  139582. */
  139583. constructor(name: string);
  139584. /**
  139585. * Gets the current class name
  139586. * @returns the class name
  139587. */
  139588. getClassName(): string;
  139589. /**
  139590. * Gets the incident component
  139591. */
  139592. get incident(): NodeMaterialConnectionPoint;
  139593. /**
  139594. * Gets the normal component
  139595. */
  139596. get normal(): NodeMaterialConnectionPoint;
  139597. /**
  139598. * Gets the index of refraction component
  139599. */
  139600. get ior(): NodeMaterialConnectionPoint;
  139601. /**
  139602. * Gets the output component
  139603. */
  139604. get output(): NodeMaterialConnectionPoint;
  139605. protected _buildBlock(state: NodeMaterialBuildState): this;
  139606. }
  139607. }
  139608. declare module BABYLON {
  139609. /**
  139610. * Block used to desaturate a color
  139611. */
  139612. export class DesaturateBlock extends NodeMaterialBlock {
  139613. /**
  139614. * Creates a new DesaturateBlock
  139615. * @param name defines the block name
  139616. */
  139617. constructor(name: string);
  139618. /**
  139619. * Gets the current class name
  139620. * @returns the class name
  139621. */
  139622. getClassName(): string;
  139623. /**
  139624. * Gets the color operand input component
  139625. */
  139626. get color(): NodeMaterialConnectionPoint;
  139627. /**
  139628. * Gets the level operand input component
  139629. */
  139630. get level(): NodeMaterialConnectionPoint;
  139631. /**
  139632. * Gets the output component
  139633. */
  139634. get output(): NodeMaterialConnectionPoint;
  139635. protected _buildBlock(state: NodeMaterialBuildState): this;
  139636. }
  139637. }
  139638. declare module BABYLON {
  139639. /**
  139640. * Block used to implement the ambient occlusion module of the PBR material
  139641. */
  139642. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  139643. /**
  139644. * Create a new AmbientOcclusionBlock
  139645. * @param name defines the block name
  139646. */
  139647. constructor(name: string);
  139648. /**
  139649. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  139650. */
  139651. useAmbientInGrayScale: boolean;
  139652. /**
  139653. * Initialize the block and prepare the context for build
  139654. * @param state defines the state that will be used for the build
  139655. */
  139656. initialize(state: NodeMaterialBuildState): void;
  139657. /**
  139658. * Gets the current class name
  139659. * @returns the class name
  139660. */
  139661. getClassName(): string;
  139662. /**
  139663. * Gets the texture input component
  139664. */
  139665. get texture(): NodeMaterialConnectionPoint;
  139666. /**
  139667. * Gets the texture intensity component
  139668. */
  139669. get intensity(): NodeMaterialConnectionPoint;
  139670. /**
  139671. * Gets the direct light intensity input component
  139672. */
  139673. get directLightIntensity(): NodeMaterialConnectionPoint;
  139674. /**
  139675. * Gets the ambient occlusion object output component
  139676. */
  139677. get ambientOcclusion(): NodeMaterialConnectionPoint;
  139678. /**
  139679. * Gets the main code of the block (fragment side)
  139680. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  139681. * @returns the shader code
  139682. */
  139683. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  139684. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139685. protected _buildBlock(state: NodeMaterialBuildState): this;
  139686. protected _dumpPropertiesCode(): string;
  139687. serialize(): any;
  139688. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139689. }
  139690. }
  139691. declare module BABYLON {
  139692. /**
  139693. * Block used to implement the reflection module of the PBR material
  139694. */
  139695. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  139696. /** @hidden */
  139697. _defineLODReflectionAlpha: string;
  139698. /** @hidden */
  139699. _defineLinearSpecularReflection: string;
  139700. private _vEnvironmentIrradianceName;
  139701. /** @hidden */
  139702. _vReflectionMicrosurfaceInfosName: string;
  139703. /** @hidden */
  139704. _vReflectionInfosName: string;
  139705. private _scene;
  139706. /**
  139707. * The three properties below are set by the main PBR block prior to calling methods of this class.
  139708. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  139709. * It's less burden on the user side in the editor part.
  139710. */
  139711. /** @hidden */
  139712. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  139713. /** @hidden */
  139714. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  139715. /** @hidden */
  139716. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  139717. /**
  139718. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  139719. * diffuse part of the IBL.
  139720. */
  139721. useSphericalHarmonics: boolean;
  139722. /**
  139723. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  139724. */
  139725. forceIrradianceInFragment: boolean;
  139726. /**
  139727. * Create a new ReflectionBlock
  139728. * @param name defines the block name
  139729. */
  139730. constructor(name: string);
  139731. /**
  139732. * Gets the current class name
  139733. * @returns the class name
  139734. */
  139735. getClassName(): string;
  139736. /**
  139737. * Gets the position input component
  139738. */
  139739. get position(): NodeMaterialConnectionPoint;
  139740. /**
  139741. * Gets the world position input component
  139742. */
  139743. get worldPosition(): NodeMaterialConnectionPoint;
  139744. /**
  139745. * Gets the world normal input component
  139746. */
  139747. get worldNormal(): NodeMaterialConnectionPoint;
  139748. /**
  139749. * Gets the world input component
  139750. */
  139751. get world(): NodeMaterialConnectionPoint;
  139752. /**
  139753. * Gets the camera (or eye) position component
  139754. */
  139755. get cameraPosition(): NodeMaterialConnectionPoint;
  139756. /**
  139757. * Gets the view input component
  139758. */
  139759. get view(): NodeMaterialConnectionPoint;
  139760. /**
  139761. * Gets the color input component
  139762. */
  139763. get color(): NodeMaterialConnectionPoint;
  139764. /**
  139765. * Gets the reflection object output component
  139766. */
  139767. get reflection(): NodeMaterialConnectionPoint;
  139768. /**
  139769. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  139770. */
  139771. get hasTexture(): boolean;
  139772. /**
  139773. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  139774. */
  139775. get reflectionColor(): string;
  139776. protected _getTexture(): Nullable<BaseTexture>;
  139777. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139778. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  139779. /**
  139780. * Gets the code to inject in the vertex shader
  139781. * @param state current state of the node material building
  139782. * @returns the shader code
  139783. */
  139784. handleVertexSide(state: NodeMaterialBuildState): string;
  139785. /**
  139786. * Gets the main code of the block (fragment side)
  139787. * @param state current state of the node material building
  139788. * @param normalVarName name of the existing variable corresponding to the normal
  139789. * @returns the shader code
  139790. */
  139791. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  139792. protected _buildBlock(state: NodeMaterialBuildState): this;
  139793. protected _dumpPropertiesCode(): string;
  139794. serialize(): any;
  139795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139796. }
  139797. }
  139798. declare module BABYLON {
  139799. /**
  139800. * Block used to implement the sheen module of the PBR material
  139801. */
  139802. export class SheenBlock extends NodeMaterialBlock {
  139803. /**
  139804. * Create a new SheenBlock
  139805. * @param name defines the block name
  139806. */
  139807. constructor(name: string);
  139808. /**
  139809. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  139810. * It allows the strength of the sheen effect to not depend on the base color of the material,
  139811. * making it easier to setup and tweak the effect
  139812. */
  139813. albedoScaling: boolean;
  139814. /**
  139815. * Defines if the sheen is linked to the sheen color.
  139816. */
  139817. linkSheenWithAlbedo: boolean;
  139818. /**
  139819. * Initialize the block and prepare the context for build
  139820. * @param state defines the state that will be used for the build
  139821. */
  139822. initialize(state: NodeMaterialBuildState): void;
  139823. /**
  139824. * Gets the current class name
  139825. * @returns the class name
  139826. */
  139827. getClassName(): string;
  139828. /**
  139829. * Gets the intensity input component
  139830. */
  139831. get intensity(): NodeMaterialConnectionPoint;
  139832. /**
  139833. * Gets the color input component
  139834. */
  139835. get color(): NodeMaterialConnectionPoint;
  139836. /**
  139837. * Gets the roughness input component
  139838. */
  139839. get roughness(): NodeMaterialConnectionPoint;
  139840. /**
  139841. * Gets the texture input component
  139842. */
  139843. get texture(): NodeMaterialConnectionPoint;
  139844. /**
  139845. * Gets the sheen object output component
  139846. */
  139847. get sheen(): NodeMaterialConnectionPoint;
  139848. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139849. /**
  139850. * Gets the main code of the block (fragment side)
  139851. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  139852. * @returns the shader code
  139853. */
  139854. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  139855. protected _buildBlock(state: NodeMaterialBuildState): this;
  139856. protected _dumpPropertiesCode(): string;
  139857. serialize(): any;
  139858. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139859. }
  139860. }
  139861. declare module BABYLON {
  139862. /**
  139863. * Block used to implement the reflectivity module of the PBR material
  139864. */
  139865. export class ReflectivityBlock extends NodeMaterialBlock {
  139866. /**
  139867. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  139868. */
  139869. useAmbientOcclusionFromMetallicTextureRed: boolean;
  139870. /**
  139871. * Specifies if the metallic texture contains the metallness information in its blue channel.
  139872. */
  139873. useMetallnessFromMetallicTextureBlue: boolean;
  139874. /**
  139875. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  139876. */
  139877. useRoughnessFromMetallicTextureAlpha: boolean;
  139878. /**
  139879. * Specifies if the metallic texture contains the roughness information in its green channel.
  139880. */
  139881. useRoughnessFromMetallicTextureGreen: boolean;
  139882. /**
  139883. * Create a new ReflectivityBlock
  139884. * @param name defines the block name
  139885. */
  139886. constructor(name: string);
  139887. /**
  139888. * Initialize the block and prepare the context for build
  139889. * @param state defines the state that will be used for the build
  139890. */
  139891. initialize(state: NodeMaterialBuildState): void;
  139892. /**
  139893. * Gets the current class name
  139894. * @returns the class name
  139895. */
  139896. getClassName(): string;
  139897. /**
  139898. * Gets the metallic input component
  139899. */
  139900. get metallic(): NodeMaterialConnectionPoint;
  139901. /**
  139902. * Gets the roughness input component
  139903. */
  139904. get roughness(): NodeMaterialConnectionPoint;
  139905. /**
  139906. * Gets the texture input component
  139907. */
  139908. get texture(): NodeMaterialConnectionPoint;
  139909. /**
  139910. * Gets the reflectivity object output component
  139911. */
  139912. get reflectivity(): NodeMaterialConnectionPoint;
  139913. /**
  139914. * Gets the main code of the block (fragment side)
  139915. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  139916. * @returns the shader code
  139917. */
  139918. getCode(aoIntensityVarName: string): string;
  139919. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139920. protected _buildBlock(state: NodeMaterialBuildState): this;
  139921. protected _dumpPropertiesCode(): string;
  139922. serialize(): any;
  139923. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139924. }
  139925. }
  139926. declare module BABYLON {
  139927. /**
  139928. * Block used to implement the anisotropy module of the PBR material
  139929. */
  139930. export class AnisotropyBlock extends NodeMaterialBlock {
  139931. /**
  139932. * The two properties below are set by the main PBR block prior to calling methods of this class.
  139933. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  139934. * It's less burden on the user side in the editor part.
  139935. */
  139936. /** @hidden */
  139937. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  139938. /** @hidden */
  139939. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  139940. /**
  139941. * Create a new AnisotropyBlock
  139942. * @param name defines the block name
  139943. */
  139944. constructor(name: string);
  139945. /**
  139946. * Initialize the block and prepare the context for build
  139947. * @param state defines the state that will be used for the build
  139948. */
  139949. initialize(state: NodeMaterialBuildState): void;
  139950. /**
  139951. * Gets the current class name
  139952. * @returns the class name
  139953. */
  139954. getClassName(): string;
  139955. /**
  139956. * Gets the intensity input component
  139957. */
  139958. get intensity(): NodeMaterialConnectionPoint;
  139959. /**
  139960. * Gets the direction input component
  139961. */
  139962. get direction(): NodeMaterialConnectionPoint;
  139963. /**
  139964. * Gets the texture input component
  139965. */
  139966. get texture(): NodeMaterialConnectionPoint;
  139967. /**
  139968. * Gets the uv input component
  139969. */
  139970. get uv(): NodeMaterialConnectionPoint;
  139971. /**
  139972. * Gets the worldTangent input component
  139973. */
  139974. get worldTangent(): NodeMaterialConnectionPoint;
  139975. /**
  139976. * Gets the anisotropy object output component
  139977. */
  139978. get anisotropy(): NodeMaterialConnectionPoint;
  139979. private _generateTBNSpace;
  139980. /**
  139981. * Gets the main code of the block (fragment side)
  139982. * @param state current state of the node material building
  139983. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  139984. * @returns the shader code
  139985. */
  139986. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  139987. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139988. protected _buildBlock(state: NodeMaterialBuildState): this;
  139989. }
  139990. }
  139991. declare module BABYLON {
  139992. /**
  139993. * Block used to implement the clear coat module of the PBR material
  139994. */
  139995. export class ClearCoatBlock extends NodeMaterialBlock {
  139996. private _scene;
  139997. /**
  139998. * Create a new ClearCoatBlock
  139999. * @param name defines the block name
  140000. */
  140001. constructor(name: string);
  140002. /**
  140003. * Initialize the block and prepare the context for build
  140004. * @param state defines the state that will be used for the build
  140005. */
  140006. initialize(state: NodeMaterialBuildState): void;
  140007. /**
  140008. * Gets the current class name
  140009. * @returns the class name
  140010. */
  140011. getClassName(): string;
  140012. /**
  140013. * Gets the intensity input component
  140014. */
  140015. get intensity(): NodeMaterialConnectionPoint;
  140016. /**
  140017. * Gets the roughness input component
  140018. */
  140019. get roughness(): NodeMaterialConnectionPoint;
  140020. /**
  140021. * Gets the ior input component
  140022. */
  140023. get ior(): NodeMaterialConnectionPoint;
  140024. /**
  140025. * Gets the texture input component
  140026. */
  140027. get texture(): NodeMaterialConnectionPoint;
  140028. /**
  140029. * Gets the bump texture input component
  140030. */
  140031. get bumpTexture(): NodeMaterialConnectionPoint;
  140032. /**
  140033. * Gets the uv input component
  140034. */
  140035. get uv(): NodeMaterialConnectionPoint;
  140036. /**
  140037. * Gets the tint color input component
  140038. */
  140039. get tintColor(): NodeMaterialConnectionPoint;
  140040. /**
  140041. * Gets the tint "at distance" input component
  140042. */
  140043. get tintAtDistance(): NodeMaterialConnectionPoint;
  140044. /**
  140045. * Gets the tint thickness input component
  140046. */
  140047. get tintThickness(): NodeMaterialConnectionPoint;
  140048. /**
  140049. * Gets the tint texture input component
  140050. */
  140051. get tintTexture(): NodeMaterialConnectionPoint;
  140052. /**
  140053. * Gets the world tangent input component
  140054. */
  140055. get worldTangent(): NodeMaterialConnectionPoint;
  140056. /**
  140057. * Gets the clear coat object output component
  140058. */
  140059. get clearcoat(): NodeMaterialConnectionPoint;
  140060. autoConfigure(material: NodeMaterial): void;
  140061. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140062. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140063. private _generateTBNSpace;
  140064. /**
  140065. * Gets the main code of the block (fragment side)
  140066. * @param state current state of the node material building
  140067. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  140068. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140069. * @param worldPosVarName name of the variable holding the world position
  140070. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  140071. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  140072. * @param worldNormalVarName name of the variable holding the world normal
  140073. * @returns the shader code
  140074. */
  140075. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  140076. protected _buildBlock(state: NodeMaterialBuildState): this;
  140077. }
  140078. }
  140079. declare module BABYLON {
  140080. /**
  140081. * Block used to implement the sub surface module of the PBR material
  140082. */
  140083. export class SubSurfaceBlock extends NodeMaterialBlock {
  140084. /**
  140085. * Create a new SubSurfaceBlock
  140086. * @param name defines the block name
  140087. */
  140088. constructor(name: string);
  140089. /**
  140090. * Stores the intensity of the different subsurface effects in the thickness texture.
  140091. * * the green channel is the translucency intensity.
  140092. * * the blue channel is the scattering intensity.
  140093. * * the alpha channel is the refraction intensity.
  140094. */
  140095. useMaskFromThicknessTexture: boolean;
  140096. /**
  140097. * Initialize the block and prepare the context for build
  140098. * @param state defines the state that will be used for the build
  140099. */
  140100. initialize(state: NodeMaterialBuildState): void;
  140101. /**
  140102. * Gets the current class name
  140103. * @returns the class name
  140104. */
  140105. getClassName(): string;
  140106. /**
  140107. * Gets the min thickness input component
  140108. */
  140109. get minThickness(): NodeMaterialConnectionPoint;
  140110. /**
  140111. * Gets the max thickness input component
  140112. */
  140113. get maxThickness(): NodeMaterialConnectionPoint;
  140114. /**
  140115. * Gets the thickness texture component
  140116. */
  140117. get thicknessTexture(): NodeMaterialConnectionPoint;
  140118. /**
  140119. * Gets the tint color input component
  140120. */
  140121. get tintColor(): NodeMaterialConnectionPoint;
  140122. /**
  140123. * Gets the translucency intensity input component
  140124. */
  140125. get translucencyIntensity(): NodeMaterialConnectionPoint;
  140126. /**
  140127. * Gets the translucency diffusion distance input component
  140128. */
  140129. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  140130. /**
  140131. * Gets the refraction object parameters
  140132. */
  140133. get refraction(): NodeMaterialConnectionPoint;
  140134. /**
  140135. * Gets the sub surface object output component
  140136. */
  140137. get subsurface(): NodeMaterialConnectionPoint;
  140138. autoConfigure(material: NodeMaterial): void;
  140139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140140. /**
  140141. * Gets the main code of the block (fragment side)
  140142. * @param state current state of the node material building
  140143. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  140144. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140145. * @param worldPosVarName name of the variable holding the world position
  140146. * @returns the shader code
  140147. */
  140148. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  140149. protected _buildBlock(state: NodeMaterialBuildState): this;
  140150. }
  140151. }
  140152. declare module BABYLON {
  140153. /**
  140154. * Block used to implement the PBR metallic/roughness model
  140155. */
  140156. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  140157. /**
  140158. * Gets or sets the light associated with this block
  140159. */
  140160. light: Nullable<Light>;
  140161. private _lightId;
  140162. private _scene;
  140163. private _environmentBRDFTexture;
  140164. private _environmentBrdfSamplerName;
  140165. private _vNormalWName;
  140166. private _invertNormalName;
  140167. /**
  140168. * Create a new ReflectionBlock
  140169. * @param name defines the block name
  140170. */
  140171. constructor(name: string);
  140172. /**
  140173. * Intensity of the direct lights e.g. the four lights available in your scene.
  140174. * This impacts both the direct diffuse and specular highlights.
  140175. */
  140176. directIntensity: number;
  140177. /**
  140178. * Intensity of the environment e.g. how much the environment will light the object
  140179. * either through harmonics for rough material or through the refelction for shiny ones.
  140180. */
  140181. environmentIntensity: number;
  140182. /**
  140183. * This is a special control allowing the reduction of the specular highlights coming from the
  140184. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  140185. */
  140186. specularIntensity: number;
  140187. /**
  140188. * Defines the falloff type used in this material.
  140189. * It by default is Physical.
  140190. */
  140191. lightFalloff: number;
  140192. /**
  140193. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  140194. */
  140195. useAlphaFromAlbedoTexture: boolean;
  140196. /**
  140197. * Specifies that alpha test should be used
  140198. */
  140199. useAlphaTest: boolean;
  140200. /**
  140201. * Defines the alpha limits in alpha test mode.
  140202. */
  140203. alphaTestCutoff: number;
  140204. /**
  140205. * Specifies that alpha blending should be used
  140206. */
  140207. useAlphaBlending: boolean;
  140208. /**
  140209. * Defines if the alpha value should be determined via the rgb values.
  140210. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  140211. */
  140212. opacityRGB: boolean;
  140213. /**
  140214. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  140215. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  140216. */
  140217. useRadianceOverAlpha: boolean;
  140218. /**
  140219. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  140220. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  140221. */
  140222. useSpecularOverAlpha: boolean;
  140223. /**
  140224. * Enables specular anti aliasing in the PBR shader.
  140225. * It will both interacts on the Geometry for analytical and IBL lighting.
  140226. * It also prefilter the roughness map based on the bump values.
  140227. */
  140228. enableSpecularAntiAliasing: boolean;
  140229. /**
  140230. * Defines if the material uses energy conservation.
  140231. */
  140232. useEnergyConservation: boolean;
  140233. /**
  140234. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  140235. * too much the area relying on ambient texture to define their ambient occlusion.
  140236. */
  140237. useRadianceOcclusion: boolean;
  140238. /**
  140239. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  140240. * makes the reflect vector face the model (under horizon).
  140241. */
  140242. useHorizonOcclusion: boolean;
  140243. /**
  140244. * If set to true, no lighting calculations will be applied.
  140245. */
  140246. unlit: boolean;
  140247. /**
  140248. * Force normal to face away from face.
  140249. */
  140250. forceNormalForward: boolean;
  140251. /**
  140252. * Defines the material debug mode.
  140253. * It helps seeing only some components of the material while troubleshooting.
  140254. */
  140255. debugMode: number;
  140256. /**
  140257. * Specify from where on screen the debug mode should start.
  140258. * The value goes from -1 (full screen) to 1 (not visible)
  140259. * It helps with side by side comparison against the final render
  140260. * This defaults to 0
  140261. */
  140262. debugLimit: number;
  140263. /**
  140264. * As the default viewing range might not be enough (if the ambient is really small for instance)
  140265. * You can use the factor to better multiply the final value.
  140266. */
  140267. debugFactor: number;
  140268. /**
  140269. * Initialize the block and prepare the context for build
  140270. * @param state defines the state that will be used for the build
  140271. */
  140272. initialize(state: NodeMaterialBuildState): void;
  140273. /**
  140274. * Gets the current class name
  140275. * @returns the class name
  140276. */
  140277. getClassName(): string;
  140278. /**
  140279. * Gets the world position input component
  140280. */
  140281. get worldPosition(): NodeMaterialConnectionPoint;
  140282. /**
  140283. * Gets the world normal input component
  140284. */
  140285. get worldNormal(): NodeMaterialConnectionPoint;
  140286. /**
  140287. * Gets the perturbed normal input component
  140288. */
  140289. get perturbedNormal(): NodeMaterialConnectionPoint;
  140290. /**
  140291. * Gets the camera position input component
  140292. */
  140293. get cameraPosition(): NodeMaterialConnectionPoint;
  140294. /**
  140295. * Gets the base color input component
  140296. */
  140297. get baseColor(): NodeMaterialConnectionPoint;
  140298. /**
  140299. * Gets the base texture input component
  140300. */
  140301. get baseTexture(): NodeMaterialConnectionPoint;
  140302. /**
  140303. * Gets the opacity texture input component
  140304. */
  140305. get opacityTexture(): NodeMaterialConnectionPoint;
  140306. /**
  140307. * Gets the ambient color input component
  140308. */
  140309. get ambientColor(): NodeMaterialConnectionPoint;
  140310. /**
  140311. * Gets the reflectivity object parameters
  140312. */
  140313. get reflectivity(): NodeMaterialConnectionPoint;
  140314. /**
  140315. * Gets the ambient occlusion object parameters
  140316. */
  140317. get ambientOcclusion(): NodeMaterialConnectionPoint;
  140318. /**
  140319. * Gets the reflection object parameters
  140320. */
  140321. get reflection(): NodeMaterialConnectionPoint;
  140322. /**
  140323. * Gets the sheen object parameters
  140324. */
  140325. get sheen(): NodeMaterialConnectionPoint;
  140326. /**
  140327. * Gets the clear coat object parameters
  140328. */
  140329. get clearcoat(): NodeMaterialConnectionPoint;
  140330. /**
  140331. * Gets the sub surface object parameters
  140332. */
  140333. get subsurface(): NodeMaterialConnectionPoint;
  140334. /**
  140335. * Gets the anisotropy object parameters
  140336. */
  140337. get anisotropy(): NodeMaterialConnectionPoint;
  140338. /**
  140339. * Gets the ambient output component
  140340. */
  140341. get ambient(): NodeMaterialConnectionPoint;
  140342. /**
  140343. * Gets the diffuse output component
  140344. */
  140345. get diffuse(): NodeMaterialConnectionPoint;
  140346. /**
  140347. * Gets the specular output component
  140348. */
  140349. get specular(): NodeMaterialConnectionPoint;
  140350. /**
  140351. * Gets the sheen output component
  140352. */
  140353. get sheenDir(): NodeMaterialConnectionPoint;
  140354. /**
  140355. * Gets the clear coat output component
  140356. */
  140357. get clearcoatDir(): NodeMaterialConnectionPoint;
  140358. /**
  140359. * Gets the indirect diffuse output component
  140360. */
  140361. get diffuseIndirect(): NodeMaterialConnectionPoint;
  140362. /**
  140363. * Gets the indirect specular output component
  140364. */
  140365. get specularIndirect(): NodeMaterialConnectionPoint;
  140366. /**
  140367. * Gets the indirect sheen output component
  140368. */
  140369. get sheenIndirect(): NodeMaterialConnectionPoint;
  140370. /**
  140371. * Gets the indirect clear coat output component
  140372. */
  140373. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  140374. /**
  140375. * Gets the refraction output component
  140376. */
  140377. get refraction(): NodeMaterialConnectionPoint;
  140378. /**
  140379. * Gets the global lighting output component
  140380. */
  140381. get lighting(): NodeMaterialConnectionPoint;
  140382. /**
  140383. * Gets the shadow output component
  140384. */
  140385. get shadow(): NodeMaterialConnectionPoint;
  140386. /**
  140387. * Gets the alpha output component
  140388. */
  140389. get alpha(): NodeMaterialConnectionPoint;
  140390. autoConfigure(material: NodeMaterial): void;
  140391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140392. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140393. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140394. private _injectVertexCode;
  140395. /**
  140396. * Gets the code corresponding to the albedo/opacity module
  140397. * @returns the shader code
  140398. */
  140399. getAlbedoOpacityCode(): string;
  140400. protected _buildBlock(state: NodeMaterialBuildState): this;
  140401. protected _dumpPropertiesCode(): string;
  140402. serialize(): any;
  140403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140404. }
  140405. }
  140406. declare module BABYLON {
  140407. /**
  140408. * Block used to compute value of one parameter modulo another
  140409. */
  140410. export class ModBlock extends NodeMaterialBlock {
  140411. /**
  140412. * Creates a new ModBlock
  140413. * @param name defines the block name
  140414. */
  140415. constructor(name: string);
  140416. /**
  140417. * Gets the current class name
  140418. * @returns the class name
  140419. */
  140420. getClassName(): string;
  140421. /**
  140422. * Gets the left operand input component
  140423. */
  140424. get left(): NodeMaterialConnectionPoint;
  140425. /**
  140426. * Gets the right operand input component
  140427. */
  140428. get right(): NodeMaterialConnectionPoint;
  140429. /**
  140430. * Gets the output component
  140431. */
  140432. get output(): NodeMaterialConnectionPoint;
  140433. protected _buildBlock(state: NodeMaterialBuildState): this;
  140434. }
  140435. }
  140436. declare module BABYLON {
  140437. /**
  140438. * Helper class to push actions to a pool of workers.
  140439. */
  140440. export class WorkerPool implements IDisposable {
  140441. private _workerInfos;
  140442. private _pendingActions;
  140443. /**
  140444. * Constructor
  140445. * @param workers Array of workers to use for actions
  140446. */
  140447. constructor(workers: Array<Worker>);
  140448. /**
  140449. * Terminates all workers and clears any pending actions.
  140450. */
  140451. dispose(): void;
  140452. /**
  140453. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140454. * pended until a worker has completed its action.
  140455. * @param action The action to perform. Call onComplete when the action is complete.
  140456. */
  140457. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140458. private _execute;
  140459. }
  140460. }
  140461. declare module BABYLON {
  140462. /**
  140463. * Configuration for Draco compression
  140464. */
  140465. export interface IDracoCompressionConfiguration {
  140466. /**
  140467. * Configuration for the decoder.
  140468. */
  140469. decoder: {
  140470. /**
  140471. * The url to the WebAssembly module.
  140472. */
  140473. wasmUrl?: string;
  140474. /**
  140475. * The url to the WebAssembly binary.
  140476. */
  140477. wasmBinaryUrl?: string;
  140478. /**
  140479. * The url to the fallback JavaScript module.
  140480. */
  140481. fallbackUrl?: string;
  140482. };
  140483. }
  140484. /**
  140485. * Draco compression (https://google.github.io/draco/)
  140486. *
  140487. * This class wraps the Draco module.
  140488. *
  140489. * **Encoder**
  140490. *
  140491. * The encoder is not currently implemented.
  140492. *
  140493. * **Decoder**
  140494. *
  140495. * 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.
  140496. *
  140497. * To update the configuration, use the following code:
  140498. * ```javascript
  140499. * DracoCompression.Configuration = {
  140500. * decoder: {
  140501. * wasmUrl: "<url to the WebAssembly library>",
  140502. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  140503. * fallbackUrl: "<url to the fallback JavaScript library>",
  140504. * }
  140505. * };
  140506. * ```
  140507. *
  140508. * 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.
  140509. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  140510. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  140511. *
  140512. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  140513. * ```javascript
  140514. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  140515. * ```
  140516. *
  140517. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  140518. */
  140519. export class DracoCompression implements IDisposable {
  140520. private _workerPoolPromise?;
  140521. private _decoderModulePromise?;
  140522. /**
  140523. * The configuration. Defaults to the following urls:
  140524. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  140525. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  140526. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  140527. */
  140528. static Configuration: IDracoCompressionConfiguration;
  140529. /**
  140530. * Returns true if the decoder configuration is available.
  140531. */
  140532. static get DecoderAvailable(): boolean;
  140533. /**
  140534. * Default number of workers to create when creating the draco compression object.
  140535. */
  140536. static DefaultNumWorkers: number;
  140537. private static GetDefaultNumWorkers;
  140538. private static _Default;
  140539. /**
  140540. * Default instance for the draco compression object.
  140541. */
  140542. static get Default(): DracoCompression;
  140543. /**
  140544. * Constructor
  140545. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140546. */
  140547. constructor(numWorkers?: number);
  140548. /**
  140549. * Stop all async operations and release resources.
  140550. */
  140551. dispose(): void;
  140552. /**
  140553. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  140554. * @returns a promise that resolves when ready
  140555. */
  140556. whenReadyAsync(): Promise<void>;
  140557. /**
  140558. * Decode Draco compressed mesh data to vertex data.
  140559. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  140560. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  140561. * @returns A promise that resolves with the decoded vertex data
  140562. */
  140563. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  140564. [kind: string]: number;
  140565. }): Promise<VertexData>;
  140566. }
  140567. }
  140568. declare module BABYLON {
  140569. /**
  140570. * Class for building Constructive Solid Geometry
  140571. */
  140572. export class CSG {
  140573. private polygons;
  140574. /**
  140575. * The world matrix
  140576. */
  140577. matrix: Matrix;
  140578. /**
  140579. * Stores the position
  140580. */
  140581. position: Vector3;
  140582. /**
  140583. * Stores the rotation
  140584. */
  140585. rotation: Vector3;
  140586. /**
  140587. * Stores the rotation quaternion
  140588. */
  140589. rotationQuaternion: Nullable<Quaternion>;
  140590. /**
  140591. * Stores the scaling vector
  140592. */
  140593. scaling: Vector3;
  140594. /**
  140595. * Convert the Mesh to CSG
  140596. * @param mesh The Mesh to convert to CSG
  140597. * @returns A new CSG from the Mesh
  140598. */
  140599. static FromMesh(mesh: Mesh): CSG;
  140600. /**
  140601. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  140602. * @param polygons Polygons used to construct a CSG solid
  140603. */
  140604. private static FromPolygons;
  140605. /**
  140606. * Clones, or makes a deep copy, of the CSG
  140607. * @returns A new CSG
  140608. */
  140609. clone(): CSG;
  140610. /**
  140611. * Unions this CSG with another CSG
  140612. * @param csg The CSG to union against this CSG
  140613. * @returns The unioned CSG
  140614. */
  140615. union(csg: CSG): CSG;
  140616. /**
  140617. * Unions this CSG with another CSG in place
  140618. * @param csg The CSG to union against this CSG
  140619. */
  140620. unionInPlace(csg: CSG): void;
  140621. /**
  140622. * Subtracts this CSG with another CSG
  140623. * @param csg The CSG to subtract against this CSG
  140624. * @returns A new CSG
  140625. */
  140626. subtract(csg: CSG): CSG;
  140627. /**
  140628. * Subtracts this CSG with another CSG in place
  140629. * @param csg The CSG to subtact against this CSG
  140630. */
  140631. subtractInPlace(csg: CSG): void;
  140632. /**
  140633. * Intersect this CSG with another CSG
  140634. * @param csg The CSG to intersect against this CSG
  140635. * @returns A new CSG
  140636. */
  140637. intersect(csg: CSG): CSG;
  140638. /**
  140639. * Intersects this CSG with another CSG in place
  140640. * @param csg The CSG to intersect against this CSG
  140641. */
  140642. intersectInPlace(csg: CSG): void;
  140643. /**
  140644. * Return a new CSG solid with solid and empty space switched. This solid is
  140645. * not modified.
  140646. * @returns A new CSG solid with solid and empty space switched
  140647. */
  140648. inverse(): CSG;
  140649. /**
  140650. * Inverses the CSG in place
  140651. */
  140652. inverseInPlace(): void;
  140653. /**
  140654. * This is used to keep meshes transformations so they can be restored
  140655. * when we build back a Babylon Mesh
  140656. * NB : All CSG operations are performed in world coordinates
  140657. * @param csg The CSG to copy the transform attributes from
  140658. * @returns This CSG
  140659. */
  140660. copyTransformAttributes(csg: CSG): CSG;
  140661. /**
  140662. * Build Raw mesh from CSG
  140663. * Coordinates here are in world space
  140664. * @param name The name of the mesh geometry
  140665. * @param scene The Scene
  140666. * @param keepSubMeshes Specifies if the submeshes should be kept
  140667. * @returns A new Mesh
  140668. */
  140669. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140670. /**
  140671. * Build Mesh from CSG taking material and transforms into account
  140672. * @param name The name of the Mesh
  140673. * @param material The material of the Mesh
  140674. * @param scene The Scene
  140675. * @param keepSubMeshes Specifies if submeshes should be kept
  140676. * @returns The new Mesh
  140677. */
  140678. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140679. }
  140680. }
  140681. declare module BABYLON {
  140682. /**
  140683. * Class used to create a trail following a mesh
  140684. */
  140685. export class TrailMesh extends Mesh {
  140686. private _generator;
  140687. private _autoStart;
  140688. private _running;
  140689. private _diameter;
  140690. private _length;
  140691. private _sectionPolygonPointsCount;
  140692. private _sectionVectors;
  140693. private _sectionNormalVectors;
  140694. private _beforeRenderObserver;
  140695. /**
  140696. * @constructor
  140697. * @param name The value used by scene.getMeshByName() to do a lookup.
  140698. * @param generator The mesh or transform node to generate a trail.
  140699. * @param scene The scene to add this mesh to.
  140700. * @param diameter Diameter of trailing mesh. Default is 1.
  140701. * @param length Length of trailing mesh. Default is 60.
  140702. * @param autoStart Automatically start trailing mesh. Default true.
  140703. */
  140704. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  140705. /**
  140706. * "TrailMesh"
  140707. * @returns "TrailMesh"
  140708. */
  140709. getClassName(): string;
  140710. private _createMesh;
  140711. /**
  140712. * Start trailing mesh.
  140713. */
  140714. start(): void;
  140715. /**
  140716. * Stop trailing mesh.
  140717. */
  140718. stop(): void;
  140719. /**
  140720. * Update trailing mesh geometry.
  140721. */
  140722. update(): void;
  140723. /**
  140724. * Returns a new TrailMesh object.
  140725. * @param name is a string, the name given to the new mesh
  140726. * @param newGenerator use new generator object for cloned trail mesh
  140727. * @returns a new mesh
  140728. */
  140729. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  140730. /**
  140731. * Serializes this trail mesh
  140732. * @param serializationObject object to write serialization to
  140733. */
  140734. serialize(serializationObject: any): void;
  140735. /**
  140736. * Parses a serialized trail mesh
  140737. * @param parsedMesh the serialized mesh
  140738. * @param scene the scene to create the trail mesh in
  140739. * @returns the created trail mesh
  140740. */
  140741. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  140742. }
  140743. }
  140744. declare module BABYLON {
  140745. /**
  140746. * Class containing static functions to help procedurally build meshes
  140747. */
  140748. export class TiledBoxBuilder {
  140749. /**
  140750. * Creates a box mesh
  140751. * 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)
  140752. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140756. * @param name defines the name of the mesh
  140757. * @param options defines the options used to create the mesh
  140758. * @param scene defines the hosting scene
  140759. * @returns the box mesh
  140760. */
  140761. static CreateTiledBox(name: string, options: {
  140762. pattern?: number;
  140763. width?: number;
  140764. height?: number;
  140765. depth?: number;
  140766. tileSize?: number;
  140767. tileWidth?: number;
  140768. tileHeight?: number;
  140769. alignHorizontal?: number;
  140770. alignVertical?: number;
  140771. faceUV?: Vector4[];
  140772. faceColors?: Color4[];
  140773. sideOrientation?: number;
  140774. updatable?: boolean;
  140775. }, scene?: Nullable<Scene>): Mesh;
  140776. }
  140777. }
  140778. declare module BABYLON {
  140779. /**
  140780. * Class containing static functions to help procedurally build meshes
  140781. */
  140782. export class TorusKnotBuilder {
  140783. /**
  140784. * Creates a torus knot mesh
  140785. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  140786. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  140787. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  140788. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  140789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  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 torus knot mesh
  140796. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  140797. */
  140798. static CreateTorusKnot(name: string, options: {
  140799. radius?: number;
  140800. tube?: number;
  140801. radialSegments?: number;
  140802. tubularSegments?: number;
  140803. p?: number;
  140804. q?: number;
  140805. updatable?: boolean;
  140806. sideOrientation?: number;
  140807. frontUVs?: Vector4;
  140808. backUVs?: Vector4;
  140809. }, scene: any): Mesh;
  140810. }
  140811. }
  140812. declare module BABYLON {
  140813. /**
  140814. * Polygon
  140815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  140816. */
  140817. export class Polygon {
  140818. /**
  140819. * Creates a rectangle
  140820. * @param xmin bottom X coord
  140821. * @param ymin bottom Y coord
  140822. * @param xmax top X coord
  140823. * @param ymax top Y coord
  140824. * @returns points that make the resulting rectation
  140825. */
  140826. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  140827. /**
  140828. * Creates a circle
  140829. * @param radius radius of circle
  140830. * @param cx scale in x
  140831. * @param cy scale in y
  140832. * @param numberOfSides number of sides that make up the circle
  140833. * @returns points that make the resulting circle
  140834. */
  140835. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  140836. /**
  140837. * Creates a polygon from input string
  140838. * @param input Input polygon data
  140839. * @returns the parsed points
  140840. */
  140841. static Parse(input: string): Vector2[];
  140842. /**
  140843. * Starts building a polygon from x and y coordinates
  140844. * @param x x coordinate
  140845. * @param y y coordinate
  140846. * @returns the started path2
  140847. */
  140848. static StartingAt(x: number, y: number): Path2;
  140849. }
  140850. /**
  140851. * Builds a polygon
  140852. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  140853. */
  140854. export class PolygonMeshBuilder {
  140855. private _points;
  140856. private _outlinepoints;
  140857. private _holes;
  140858. private _name;
  140859. private _scene;
  140860. private _epoints;
  140861. private _eholes;
  140862. private _addToepoint;
  140863. /**
  140864. * Babylon reference to the earcut plugin.
  140865. */
  140866. bjsEarcut: any;
  140867. /**
  140868. * Creates a PolygonMeshBuilder
  140869. * @param name name of the builder
  140870. * @param contours Path of the polygon
  140871. * @param scene scene to add to when creating the mesh
  140872. * @param earcutInjection can be used to inject your own earcut reference
  140873. */
  140874. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  140875. /**
  140876. * Adds a whole within the polygon
  140877. * @param hole Array of points defining the hole
  140878. * @returns this
  140879. */
  140880. addHole(hole: Vector2[]): PolygonMeshBuilder;
  140881. /**
  140882. * Creates the polygon
  140883. * @param updatable If the mesh should be updatable
  140884. * @param depth The depth of the mesh created
  140885. * @returns the created mesh
  140886. */
  140887. build(updatable?: boolean, depth?: number): Mesh;
  140888. /**
  140889. * Creates the polygon
  140890. * @param depth The depth of the mesh created
  140891. * @returns the created VertexData
  140892. */
  140893. buildVertexData(depth?: number): VertexData;
  140894. /**
  140895. * Adds a side to the polygon
  140896. * @param positions points that make the polygon
  140897. * @param normals normals of the polygon
  140898. * @param uvs uvs of the polygon
  140899. * @param indices indices of the polygon
  140900. * @param bounds bounds of the polygon
  140901. * @param points points of the polygon
  140902. * @param depth depth of the polygon
  140903. * @param flip flip of the polygon
  140904. */
  140905. private addSide;
  140906. }
  140907. }
  140908. declare module BABYLON {
  140909. /**
  140910. * Class containing static functions to help procedurally build meshes
  140911. */
  140912. export class PolygonBuilder {
  140913. /**
  140914. * Creates a polygon mesh
  140915. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  140916. * * 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
  140917. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  140918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  140920. * * Remember you can only change the shape positions, not their number when updating a polygon
  140921. * @param name defines the name of the mesh
  140922. * @param options defines the options used to create the mesh
  140923. * @param scene defines the hosting scene
  140924. * @param earcutInjection can be used to inject your own earcut reference
  140925. * @returns the polygon mesh
  140926. */
  140927. static CreatePolygon(name: string, options: {
  140928. shape: Vector3[];
  140929. holes?: Vector3[][];
  140930. depth?: number;
  140931. faceUV?: Vector4[];
  140932. faceColors?: Color4[];
  140933. updatable?: boolean;
  140934. sideOrientation?: number;
  140935. frontUVs?: Vector4;
  140936. backUVs?: Vector4;
  140937. wrap?: boolean;
  140938. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  140939. /**
  140940. * Creates an extruded polygon mesh, with depth in the Y direction.
  140941. * * 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)
  140942. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140943. * @param name defines the name of the mesh
  140944. * @param options defines the options used to create the mesh
  140945. * @param scene defines the hosting scene
  140946. * @param earcutInjection can be used to inject your own earcut reference
  140947. * @returns the polygon mesh
  140948. */
  140949. static ExtrudePolygon(name: string, options: {
  140950. shape: Vector3[];
  140951. holes?: Vector3[][];
  140952. depth?: number;
  140953. faceUV?: Vector4[];
  140954. faceColors?: Color4[];
  140955. updatable?: boolean;
  140956. sideOrientation?: number;
  140957. frontUVs?: Vector4;
  140958. backUVs?: Vector4;
  140959. wrap?: boolean;
  140960. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  140961. }
  140962. }
  140963. declare module BABYLON {
  140964. /**
  140965. * Class containing static functions to help procedurally build meshes
  140966. */
  140967. export class LatheBuilder {
  140968. /**
  140969. * Creates lathe mesh.
  140970. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  140971. * * 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
  140972. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  140973. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  140974. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  140975. * * 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
  140976. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  140977. * * 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
  140978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  140981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140982. * @param name defines the name of the mesh
  140983. * @param options defines the options used to create the mesh
  140984. * @param scene defines the hosting scene
  140985. * @returns the lathe mesh
  140986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  140987. */
  140988. static CreateLathe(name: string, options: {
  140989. shape: Vector3[];
  140990. radius?: number;
  140991. tessellation?: number;
  140992. clip?: number;
  140993. arc?: number;
  140994. closed?: boolean;
  140995. updatable?: boolean;
  140996. sideOrientation?: number;
  140997. frontUVs?: Vector4;
  140998. backUVs?: Vector4;
  140999. cap?: number;
  141000. invertUV?: boolean;
  141001. }, scene?: Nullable<Scene>): Mesh;
  141002. }
  141003. }
  141004. declare module BABYLON {
  141005. /**
  141006. * Class containing static functions to help procedurally build meshes
  141007. */
  141008. export class TiledPlaneBuilder {
  141009. /**
  141010. * Creates a tiled plane mesh
  141011. * * The parameter `pattern` will, depending on value, do nothing or
  141012. * * * flip (reflect about central vertical) alternate tiles across and up
  141013. * * * flip every tile on alternate rows
  141014. * * * rotate (180 degs) alternate tiles across and up
  141015. * * * rotate every tile on alternate rows
  141016. * * * flip and rotate alternate tiles across and up
  141017. * * * flip and rotate every tile on alternate rows
  141018. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  141019. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  141020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141022. * * 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)
  141023. * * 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)
  141024. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141025. * @param name defines the name of the mesh
  141026. * @param options defines the options used to create the mesh
  141027. * @param scene defines the hosting scene
  141028. * @returns the box mesh
  141029. */
  141030. static CreateTiledPlane(name: string, options: {
  141031. pattern?: number;
  141032. tileSize?: number;
  141033. tileWidth?: number;
  141034. tileHeight?: number;
  141035. size?: number;
  141036. width?: number;
  141037. height?: number;
  141038. alignHorizontal?: number;
  141039. alignVertical?: number;
  141040. sideOrientation?: number;
  141041. frontUVs?: Vector4;
  141042. backUVs?: Vector4;
  141043. updatable?: boolean;
  141044. }, scene?: Nullable<Scene>): Mesh;
  141045. }
  141046. }
  141047. declare module BABYLON {
  141048. /**
  141049. * Class containing static functions to help procedurally build meshes
  141050. */
  141051. export class TubeBuilder {
  141052. /**
  141053. * Creates a tube mesh.
  141054. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141055. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  141056. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  141057. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  141058. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  141059. * * 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)
  141060. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  141061. * * 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
  141062. * * 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
  141063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141065. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141067. * @param name defines the name of the mesh
  141068. * @param options defines the options used to create the mesh
  141069. * @param scene defines the hosting scene
  141070. * @returns the tube mesh
  141071. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141072. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  141073. */
  141074. static CreateTube(name: string, options: {
  141075. path: Vector3[];
  141076. radius?: number;
  141077. tessellation?: number;
  141078. radiusFunction?: {
  141079. (i: number, distance: number): number;
  141080. };
  141081. cap?: number;
  141082. arc?: number;
  141083. updatable?: boolean;
  141084. sideOrientation?: number;
  141085. frontUVs?: Vector4;
  141086. backUVs?: Vector4;
  141087. instance?: Mesh;
  141088. invertUV?: boolean;
  141089. }, scene?: Nullable<Scene>): Mesh;
  141090. }
  141091. }
  141092. declare module BABYLON {
  141093. /**
  141094. * Class containing static functions to help procedurally build meshes
  141095. */
  141096. export class IcoSphereBuilder {
  141097. /**
  141098. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  141099. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  141100. * * 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`)
  141101. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  141102. * * 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
  141103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141106. * @param name defines the name of the mesh
  141107. * @param options defines the options used to create the mesh
  141108. * @param scene defines the hosting scene
  141109. * @returns the icosahedron mesh
  141110. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  141111. */
  141112. static CreateIcoSphere(name: string, options: {
  141113. radius?: number;
  141114. radiusX?: number;
  141115. radiusY?: number;
  141116. radiusZ?: number;
  141117. flat?: boolean;
  141118. subdivisions?: number;
  141119. sideOrientation?: number;
  141120. frontUVs?: Vector4;
  141121. backUVs?: Vector4;
  141122. updatable?: boolean;
  141123. }, scene?: Nullable<Scene>): Mesh;
  141124. }
  141125. }
  141126. declare module BABYLON {
  141127. /**
  141128. * Class containing static functions to help procedurally build meshes
  141129. */
  141130. export class DecalBuilder {
  141131. /**
  141132. * Creates a decal mesh.
  141133. * 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
  141134. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  141135. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  141136. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  141137. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  141138. * @param name defines the name of the mesh
  141139. * @param sourceMesh defines the mesh where the decal must be applied
  141140. * @param options defines the options used to create the mesh
  141141. * @param scene defines the hosting scene
  141142. * @returns the decal mesh
  141143. * @see https://doc.babylonjs.com/how_to/decals
  141144. */
  141145. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  141146. position?: Vector3;
  141147. normal?: Vector3;
  141148. size?: Vector3;
  141149. angle?: number;
  141150. }): Mesh;
  141151. }
  141152. }
  141153. declare module BABYLON {
  141154. /**
  141155. * Class containing static functions to help procedurally build meshes
  141156. */
  141157. export class MeshBuilder {
  141158. /**
  141159. * Creates a box mesh
  141160. * * The parameter `size` sets the size (float) of each box side (default 1)
  141161. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  141162. * * 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)
  141163. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141167. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141168. * @param name defines the name of the mesh
  141169. * @param options defines the options used to create the mesh
  141170. * @param scene defines the hosting scene
  141171. * @returns the box mesh
  141172. */
  141173. static CreateBox(name: string, options: {
  141174. size?: number;
  141175. width?: number;
  141176. height?: number;
  141177. depth?: number;
  141178. faceUV?: Vector4[];
  141179. faceColors?: Color4[];
  141180. sideOrientation?: number;
  141181. frontUVs?: Vector4;
  141182. backUVs?: Vector4;
  141183. wrap?: boolean;
  141184. topBaseAt?: number;
  141185. bottomBaseAt?: number;
  141186. updatable?: boolean;
  141187. }, scene?: Nullable<Scene>): Mesh;
  141188. /**
  141189. * Creates a tiled box mesh
  141190. * * faceTiles sets the pattern, tile size and number of tiles for a face
  141191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141192. * @param name defines the name of the mesh
  141193. * @param options defines the options used to create the mesh
  141194. * @param scene defines the hosting scene
  141195. * @returns the tiled box mesh
  141196. */
  141197. static CreateTiledBox(name: string, options: {
  141198. pattern?: number;
  141199. size?: number;
  141200. width?: number;
  141201. height?: number;
  141202. depth: number;
  141203. tileSize?: number;
  141204. tileWidth?: number;
  141205. tileHeight?: number;
  141206. faceUV?: Vector4[];
  141207. faceColors?: Color4[];
  141208. alignHorizontal?: number;
  141209. alignVertical?: number;
  141210. sideOrientation?: number;
  141211. updatable?: boolean;
  141212. }, scene?: Nullable<Scene>): Mesh;
  141213. /**
  141214. * Creates a sphere mesh
  141215. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  141216. * * 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`)
  141217. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  141218. * * 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
  141219. * * 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)
  141220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141223. * @param name defines the name of the mesh
  141224. * @param options defines the options used to create the mesh
  141225. * @param scene defines the hosting scene
  141226. * @returns the sphere mesh
  141227. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  141228. */
  141229. static CreateSphere(name: string, options: {
  141230. segments?: number;
  141231. diameter?: number;
  141232. diameterX?: number;
  141233. diameterY?: number;
  141234. diameterZ?: number;
  141235. arc?: number;
  141236. slice?: number;
  141237. sideOrientation?: number;
  141238. frontUVs?: Vector4;
  141239. backUVs?: Vector4;
  141240. updatable?: boolean;
  141241. }, scene?: Nullable<Scene>): Mesh;
  141242. /**
  141243. * Creates a plane polygonal mesh. By default, this is a disc
  141244. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  141245. * * 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
  141246. * * 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
  141247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141250. * @param name defines the name of the mesh
  141251. * @param options defines the options used to create the mesh
  141252. * @param scene defines the hosting scene
  141253. * @returns the plane polygonal mesh
  141254. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  141255. */
  141256. static CreateDisc(name: string, options: {
  141257. radius?: number;
  141258. tessellation?: number;
  141259. arc?: number;
  141260. updatable?: boolean;
  141261. sideOrientation?: number;
  141262. frontUVs?: Vector4;
  141263. backUVs?: Vector4;
  141264. }, scene?: Nullable<Scene>): Mesh;
  141265. /**
  141266. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  141267. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  141268. * * 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`)
  141269. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  141270. * * 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
  141271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141274. * @param name defines the name of the mesh
  141275. * @param options defines the options used to create the mesh
  141276. * @param scene defines the hosting scene
  141277. * @returns the icosahedron mesh
  141278. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  141279. */
  141280. static CreateIcoSphere(name: string, options: {
  141281. radius?: number;
  141282. radiusX?: number;
  141283. radiusY?: number;
  141284. radiusZ?: number;
  141285. flat?: boolean;
  141286. subdivisions?: number;
  141287. sideOrientation?: number;
  141288. frontUVs?: Vector4;
  141289. backUVs?: Vector4;
  141290. updatable?: boolean;
  141291. }, scene?: Nullable<Scene>): Mesh;
  141292. /**
  141293. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141294. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  141295. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  141296. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  141297. * * 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
  141298. * * 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
  141299. * * 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
  141300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141303. * * 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
  141304. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  141305. * * 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
  141306. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  141307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141308. * @param name defines the name of the mesh
  141309. * @param options defines the options used to create the mesh
  141310. * @param scene defines the hosting scene
  141311. * @returns the ribbon mesh
  141312. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  141313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141314. */
  141315. static CreateRibbon(name: string, options: {
  141316. pathArray: Vector3[][];
  141317. closeArray?: boolean;
  141318. closePath?: boolean;
  141319. offset?: number;
  141320. updatable?: boolean;
  141321. sideOrientation?: number;
  141322. frontUVs?: Vector4;
  141323. backUVs?: Vector4;
  141324. instance?: Mesh;
  141325. invertUV?: boolean;
  141326. uvs?: Vector2[];
  141327. colors?: Color4[];
  141328. }, scene?: Nullable<Scene>): Mesh;
  141329. /**
  141330. * Creates a cylinder or a cone mesh
  141331. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  141332. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  141333. * * 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.
  141334. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  141335. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  141336. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  141337. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  141338. * * 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).
  141339. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  141340. * * 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).
  141341. * * 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
  141342. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  141343. * * 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
  141344. * * 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.
  141345. * * If `enclose` is false, a ring surface is one element.
  141346. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  141347. * * 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
  141348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141351. * @param name defines the name of the mesh
  141352. * @param options defines the options used to create the mesh
  141353. * @param scene defines the hosting scene
  141354. * @returns the cylinder mesh
  141355. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  141356. */
  141357. static CreateCylinder(name: string, options: {
  141358. height?: number;
  141359. diameterTop?: number;
  141360. diameterBottom?: number;
  141361. diameter?: number;
  141362. tessellation?: number;
  141363. subdivisions?: number;
  141364. arc?: number;
  141365. faceColors?: Color4[];
  141366. faceUV?: Vector4[];
  141367. updatable?: boolean;
  141368. hasRings?: boolean;
  141369. enclose?: boolean;
  141370. cap?: number;
  141371. sideOrientation?: number;
  141372. frontUVs?: Vector4;
  141373. backUVs?: Vector4;
  141374. }, scene?: Nullable<Scene>): Mesh;
  141375. /**
  141376. * Creates a torus mesh
  141377. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  141378. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  141379. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  141380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141383. * @param name defines the name of the mesh
  141384. * @param options defines the options used to create the mesh
  141385. * @param scene defines the hosting scene
  141386. * @returns the torus mesh
  141387. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  141388. */
  141389. static CreateTorus(name: string, options: {
  141390. diameter?: number;
  141391. thickness?: number;
  141392. tessellation?: number;
  141393. updatable?: boolean;
  141394. sideOrientation?: number;
  141395. frontUVs?: Vector4;
  141396. backUVs?: Vector4;
  141397. }, scene?: Nullable<Scene>): Mesh;
  141398. /**
  141399. * Creates a torus knot mesh
  141400. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141401. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141402. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141403. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141407. * @param name defines the name of the mesh
  141408. * @param options defines the options used to create the mesh
  141409. * @param scene defines the hosting scene
  141410. * @returns the torus knot mesh
  141411. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141412. */
  141413. static CreateTorusKnot(name: string, options: {
  141414. radius?: number;
  141415. tube?: number;
  141416. radialSegments?: number;
  141417. tubularSegments?: number;
  141418. p?: number;
  141419. q?: number;
  141420. updatable?: boolean;
  141421. sideOrientation?: number;
  141422. frontUVs?: Vector4;
  141423. backUVs?: Vector4;
  141424. }, scene?: Nullable<Scene>): Mesh;
  141425. /**
  141426. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  141427. * * 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
  141428. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  141429. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  141430. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  141431. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  141432. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  141433. * * 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
  141434. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  141435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  141437. * @param name defines the name of the new line system
  141438. * @param options defines the options used to create the line system
  141439. * @param scene defines the hosting scene
  141440. * @returns a new line system mesh
  141441. */
  141442. static CreateLineSystem(name: string, options: {
  141443. lines: Vector3[][];
  141444. updatable?: boolean;
  141445. instance?: Nullable<LinesMesh>;
  141446. colors?: Nullable<Color4[][]>;
  141447. useVertexAlpha?: boolean;
  141448. }, scene: Nullable<Scene>): LinesMesh;
  141449. /**
  141450. * Creates a line mesh
  141451. * 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
  141452. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141453. * * The parameter `points` is an array successive Vector3
  141454. * * 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
  141455. * * The optional parameter `colors` is an array of successive Color4, one per line point
  141456. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  141457. * * When updating an instance, remember that only point positions can change, not the number of points
  141458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  141460. * @param name defines the name of the new line system
  141461. * @param options defines the options used to create the line system
  141462. * @param scene defines the hosting scene
  141463. * @returns a new line mesh
  141464. */
  141465. static CreateLines(name: string, options: {
  141466. points: Vector3[];
  141467. updatable?: boolean;
  141468. instance?: Nullable<LinesMesh>;
  141469. colors?: Color4[];
  141470. useVertexAlpha?: boolean;
  141471. }, scene?: Nullable<Scene>): LinesMesh;
  141472. /**
  141473. * Creates a dashed line mesh
  141474. * * 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
  141475. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141476. * * The parameter `points` is an array successive Vector3
  141477. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  141478. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  141479. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  141480. * * 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
  141481. * * When updating an instance, remember that only point positions can change, not the number of points
  141482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141483. * @param name defines the name of the mesh
  141484. * @param options defines the options used to create the mesh
  141485. * @param scene defines the hosting scene
  141486. * @returns the dashed line mesh
  141487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  141488. */
  141489. static CreateDashedLines(name: string, options: {
  141490. points: Vector3[];
  141491. dashSize?: number;
  141492. gapSize?: number;
  141493. dashNb?: number;
  141494. updatable?: boolean;
  141495. instance?: LinesMesh;
  141496. }, scene?: Nullable<Scene>): LinesMesh;
  141497. /**
  141498. * 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.
  141499. * * 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.
  141500. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141501. * * 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.
  141502. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  141503. * * 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
  141504. * * 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
  141505. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  141506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141508. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  141509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141510. * @param name defines the name of the mesh
  141511. * @param options defines the options used to create the mesh
  141512. * @param scene defines the hosting scene
  141513. * @returns the extruded shape mesh
  141514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141516. */
  141517. static ExtrudeShape(name: string, options: {
  141518. shape: Vector3[];
  141519. path: Vector3[];
  141520. scale?: number;
  141521. rotation?: number;
  141522. cap?: number;
  141523. updatable?: boolean;
  141524. sideOrientation?: number;
  141525. frontUVs?: Vector4;
  141526. backUVs?: Vector4;
  141527. instance?: Mesh;
  141528. invertUV?: boolean;
  141529. }, scene?: Nullable<Scene>): Mesh;
  141530. /**
  141531. * Creates an custom extruded shape mesh.
  141532. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  141533. * * 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.
  141534. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141535. * * 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
  141536. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  141537. * * 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
  141538. * * It must returns a float value that will be the scale value applied to the shape on each path point
  141539. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  141540. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  141541. * * 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
  141542. * * 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
  141543. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  141544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141546. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141548. * @param name defines the name of the mesh
  141549. * @param options defines the options used to create the mesh
  141550. * @param scene defines the hosting scene
  141551. * @returns the custom extruded shape mesh
  141552. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  141553. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141555. */
  141556. static ExtrudeShapeCustom(name: string, options: {
  141557. shape: Vector3[];
  141558. path: Vector3[];
  141559. scaleFunction?: any;
  141560. rotationFunction?: any;
  141561. ribbonCloseArray?: boolean;
  141562. ribbonClosePath?: boolean;
  141563. cap?: number;
  141564. updatable?: boolean;
  141565. sideOrientation?: number;
  141566. frontUVs?: Vector4;
  141567. backUVs?: Vector4;
  141568. instance?: Mesh;
  141569. invertUV?: boolean;
  141570. }, scene?: Nullable<Scene>): Mesh;
  141571. /**
  141572. * Creates lathe mesh.
  141573. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  141574. * * 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
  141575. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  141576. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  141577. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  141578. * * 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
  141579. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  141580. * * 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
  141581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141583. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141585. * @param name defines the name of the mesh
  141586. * @param options defines the options used to create the mesh
  141587. * @param scene defines the hosting scene
  141588. * @returns the lathe mesh
  141589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  141590. */
  141591. static CreateLathe(name: string, options: {
  141592. shape: Vector3[];
  141593. radius?: number;
  141594. tessellation?: number;
  141595. clip?: number;
  141596. arc?: number;
  141597. closed?: boolean;
  141598. updatable?: boolean;
  141599. sideOrientation?: number;
  141600. frontUVs?: Vector4;
  141601. backUVs?: Vector4;
  141602. cap?: number;
  141603. invertUV?: boolean;
  141604. }, scene?: Nullable<Scene>): Mesh;
  141605. /**
  141606. * Creates a tiled plane mesh
  141607. * * You can set a limited pattern arrangement with the tiles
  141608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141611. * @param name defines the name of the mesh
  141612. * @param options defines the options used to create the mesh
  141613. * @param scene defines the hosting scene
  141614. * @returns the plane mesh
  141615. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141616. */
  141617. static CreateTiledPlane(name: string, options: {
  141618. pattern?: number;
  141619. tileSize?: number;
  141620. tileWidth?: number;
  141621. tileHeight?: number;
  141622. size?: number;
  141623. width?: number;
  141624. height?: number;
  141625. alignHorizontal?: number;
  141626. alignVertical?: number;
  141627. sideOrientation?: number;
  141628. frontUVs?: Vector4;
  141629. backUVs?: Vector4;
  141630. updatable?: boolean;
  141631. }, scene?: Nullable<Scene>): Mesh;
  141632. /**
  141633. * Creates a plane mesh
  141634. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  141635. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  141636. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  141637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141640. * @param name defines the name of the mesh
  141641. * @param options defines the options used to create the mesh
  141642. * @param scene defines the hosting scene
  141643. * @returns the plane mesh
  141644. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141645. */
  141646. static CreatePlane(name: string, options: {
  141647. size?: number;
  141648. width?: number;
  141649. height?: number;
  141650. sideOrientation?: number;
  141651. frontUVs?: Vector4;
  141652. backUVs?: Vector4;
  141653. updatable?: boolean;
  141654. sourcePlane?: Plane;
  141655. }, scene?: Nullable<Scene>): Mesh;
  141656. /**
  141657. * Creates a ground mesh
  141658. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  141659. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  141660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141661. * @param name defines the name of the mesh
  141662. * @param options defines the options used to create the mesh
  141663. * @param scene defines the hosting scene
  141664. * @returns the ground mesh
  141665. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  141666. */
  141667. static CreateGround(name: string, options: {
  141668. width?: number;
  141669. height?: number;
  141670. subdivisions?: number;
  141671. subdivisionsX?: number;
  141672. subdivisionsY?: number;
  141673. updatable?: boolean;
  141674. }, scene?: Nullable<Scene>): Mesh;
  141675. /**
  141676. * Creates a tiled ground mesh
  141677. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  141678. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  141679. * * 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
  141680. * * 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
  141681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141682. * @param name defines the name of the mesh
  141683. * @param options defines the options used to create the mesh
  141684. * @param scene defines the hosting scene
  141685. * @returns the tiled ground mesh
  141686. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  141687. */
  141688. static CreateTiledGround(name: string, options: {
  141689. xmin: number;
  141690. zmin: number;
  141691. xmax: number;
  141692. zmax: number;
  141693. subdivisions?: {
  141694. w: number;
  141695. h: number;
  141696. };
  141697. precision?: {
  141698. w: number;
  141699. h: number;
  141700. };
  141701. updatable?: boolean;
  141702. }, scene?: Nullable<Scene>): Mesh;
  141703. /**
  141704. * Creates a ground mesh from a height map
  141705. * * The parameter `url` sets the URL of the height map image resource.
  141706. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  141707. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  141708. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  141709. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  141710. * * 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.
  141711. * * 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).
  141712. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  141713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141714. * @param name defines the name of the mesh
  141715. * @param url defines the url to the height map
  141716. * @param options defines the options used to create the mesh
  141717. * @param scene defines the hosting scene
  141718. * @returns the ground mesh
  141719. * @see https://doc.babylonjs.com/babylon101/height_map
  141720. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  141721. */
  141722. static CreateGroundFromHeightMap(name: string, url: string, options: {
  141723. width?: number;
  141724. height?: number;
  141725. subdivisions?: number;
  141726. minHeight?: number;
  141727. maxHeight?: number;
  141728. colorFilter?: Color3;
  141729. alphaFilter?: number;
  141730. updatable?: boolean;
  141731. onReady?: (mesh: GroundMesh) => void;
  141732. }, scene?: Nullable<Scene>): GroundMesh;
  141733. /**
  141734. * Creates a polygon mesh
  141735. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141736. * * 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
  141737. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141740. * * Remember you can only change the shape positions, not their number when updating a polygon
  141741. * @param name defines the name of the mesh
  141742. * @param options defines the options used to create the mesh
  141743. * @param scene defines the hosting scene
  141744. * @param earcutInjection can be used to inject your own earcut reference
  141745. * @returns the polygon mesh
  141746. */
  141747. static CreatePolygon(name: string, options: {
  141748. shape: Vector3[];
  141749. holes?: Vector3[][];
  141750. depth?: number;
  141751. faceUV?: Vector4[];
  141752. faceColors?: Color4[];
  141753. updatable?: boolean;
  141754. sideOrientation?: number;
  141755. frontUVs?: Vector4;
  141756. backUVs?: Vector4;
  141757. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141758. /**
  141759. * Creates an extruded polygon mesh, with depth in the Y direction.
  141760. * * 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)
  141761. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141762. * @param name defines the name of the mesh
  141763. * @param options defines the options used to create the mesh
  141764. * @param scene defines the hosting scene
  141765. * @param earcutInjection can be used to inject your own earcut reference
  141766. * @returns the polygon mesh
  141767. */
  141768. static ExtrudePolygon(name: string, options: {
  141769. shape: Vector3[];
  141770. holes?: Vector3[][];
  141771. depth?: number;
  141772. faceUV?: Vector4[];
  141773. faceColors?: Color4[];
  141774. updatable?: boolean;
  141775. sideOrientation?: number;
  141776. frontUVs?: Vector4;
  141777. backUVs?: Vector4;
  141778. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141779. /**
  141780. * Creates a tube mesh.
  141781. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141782. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  141783. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  141784. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  141785. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  141786. * * 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)
  141787. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  141788. * * 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
  141789. * * 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
  141790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141794. * @param name defines the name of the mesh
  141795. * @param options defines the options used to create the mesh
  141796. * @param scene defines the hosting scene
  141797. * @returns the tube mesh
  141798. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141799. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  141800. */
  141801. static CreateTube(name: string, options: {
  141802. path: Vector3[];
  141803. radius?: number;
  141804. tessellation?: number;
  141805. radiusFunction?: {
  141806. (i: number, distance: number): number;
  141807. };
  141808. cap?: number;
  141809. arc?: number;
  141810. updatable?: boolean;
  141811. sideOrientation?: number;
  141812. frontUVs?: Vector4;
  141813. backUVs?: Vector4;
  141814. instance?: Mesh;
  141815. invertUV?: boolean;
  141816. }, scene?: Nullable<Scene>): Mesh;
  141817. /**
  141818. * Creates a polyhedron mesh
  141819. * * 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
  141820. * * The parameter `size` (positive float, default 1) sets the polygon size
  141821. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  141822. * * 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`
  141823. * * 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
  141824. * * 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)`)
  141825. * * 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
  141826. * * 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
  141827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141830. * @param name defines the name of the mesh
  141831. * @param options defines the options used to create the mesh
  141832. * @param scene defines the hosting scene
  141833. * @returns the polyhedron mesh
  141834. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  141835. */
  141836. static CreatePolyhedron(name: string, options: {
  141837. type?: number;
  141838. size?: number;
  141839. sizeX?: number;
  141840. sizeY?: number;
  141841. sizeZ?: number;
  141842. custom?: any;
  141843. faceUV?: Vector4[];
  141844. faceColors?: Color4[];
  141845. flat?: boolean;
  141846. updatable?: boolean;
  141847. sideOrientation?: number;
  141848. frontUVs?: Vector4;
  141849. backUVs?: Vector4;
  141850. }, scene?: Nullable<Scene>): Mesh;
  141851. /**
  141852. * Creates a decal mesh.
  141853. * 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
  141854. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  141855. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  141856. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  141857. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  141858. * @param name defines the name of the mesh
  141859. * @param sourceMesh defines the mesh where the decal must be applied
  141860. * @param options defines the options used to create the mesh
  141861. * @param scene defines the hosting scene
  141862. * @returns the decal mesh
  141863. * @see https://doc.babylonjs.com/how_to/decals
  141864. */
  141865. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  141866. position?: Vector3;
  141867. normal?: Vector3;
  141868. size?: Vector3;
  141869. angle?: number;
  141870. }): Mesh;
  141871. }
  141872. }
  141873. declare module BABYLON {
  141874. /**
  141875. * A simplifier interface for future simplification implementations
  141876. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141877. */
  141878. export interface ISimplifier {
  141879. /**
  141880. * Simplification of a given mesh according to the given settings.
  141881. * Since this requires computation, it is assumed that the function runs async.
  141882. * @param settings The settings of the simplification, including quality and distance
  141883. * @param successCallback A callback that will be called after the mesh was simplified.
  141884. * @param errorCallback in case of an error, this callback will be called. optional.
  141885. */
  141886. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  141887. }
  141888. /**
  141889. * Expected simplification settings.
  141890. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  141891. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141892. */
  141893. export interface ISimplificationSettings {
  141894. /**
  141895. * Gets or sets the expected quality
  141896. */
  141897. quality: number;
  141898. /**
  141899. * Gets or sets the distance when this optimized version should be used
  141900. */
  141901. distance: number;
  141902. /**
  141903. * Gets an already optimized mesh
  141904. */
  141905. optimizeMesh?: boolean;
  141906. }
  141907. /**
  141908. * Class used to specify simplification options
  141909. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141910. */
  141911. export class SimplificationSettings implements ISimplificationSettings {
  141912. /** expected quality */
  141913. quality: number;
  141914. /** distance when this optimized version should be used */
  141915. distance: number;
  141916. /** already optimized mesh */
  141917. optimizeMesh?: boolean | undefined;
  141918. /**
  141919. * Creates a SimplificationSettings
  141920. * @param quality expected quality
  141921. * @param distance distance when this optimized version should be used
  141922. * @param optimizeMesh already optimized mesh
  141923. */
  141924. constructor(
  141925. /** expected quality */
  141926. quality: number,
  141927. /** distance when this optimized version should be used */
  141928. distance: number,
  141929. /** already optimized mesh */
  141930. optimizeMesh?: boolean | undefined);
  141931. }
  141932. /**
  141933. * Interface used to define a simplification task
  141934. */
  141935. export interface ISimplificationTask {
  141936. /**
  141937. * Array of settings
  141938. */
  141939. settings: Array<ISimplificationSettings>;
  141940. /**
  141941. * Simplification type
  141942. */
  141943. simplificationType: SimplificationType;
  141944. /**
  141945. * Mesh to simplify
  141946. */
  141947. mesh: Mesh;
  141948. /**
  141949. * Callback called on success
  141950. */
  141951. successCallback?: () => void;
  141952. /**
  141953. * Defines if parallel processing can be used
  141954. */
  141955. parallelProcessing: boolean;
  141956. }
  141957. /**
  141958. * Queue used to order the simplification tasks
  141959. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141960. */
  141961. export class SimplificationQueue {
  141962. private _simplificationArray;
  141963. /**
  141964. * Gets a boolean indicating that the process is still running
  141965. */
  141966. running: boolean;
  141967. /**
  141968. * Creates a new queue
  141969. */
  141970. constructor();
  141971. /**
  141972. * Adds a new simplification task
  141973. * @param task defines a task to add
  141974. */
  141975. addTask(task: ISimplificationTask): void;
  141976. /**
  141977. * Execute next task
  141978. */
  141979. executeNext(): void;
  141980. /**
  141981. * Execute a simplification task
  141982. * @param task defines the task to run
  141983. */
  141984. runSimplification(task: ISimplificationTask): void;
  141985. private getSimplifier;
  141986. }
  141987. /**
  141988. * The implemented types of simplification
  141989. * At the moment only Quadratic Error Decimation is implemented
  141990. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141991. */
  141992. export enum SimplificationType {
  141993. /** Quadratic error decimation */
  141994. QUADRATIC = 0
  141995. }
  141996. /**
  141997. * An implementation of the Quadratic Error simplification algorithm.
  141998. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  141999. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  142000. * @author RaananW
  142001. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142002. */
  142003. export class QuadraticErrorSimplification implements ISimplifier {
  142004. private _mesh;
  142005. private triangles;
  142006. private vertices;
  142007. private references;
  142008. private _reconstructedMesh;
  142009. /** Gets or sets the number pf sync interations */
  142010. syncIterations: number;
  142011. /** Gets or sets the aggressiveness of the simplifier */
  142012. aggressiveness: number;
  142013. /** Gets or sets the number of allowed iterations for decimation */
  142014. decimationIterations: number;
  142015. /** Gets or sets the espilon to use for bounding box computation */
  142016. boundingBoxEpsilon: number;
  142017. /**
  142018. * Creates a new QuadraticErrorSimplification
  142019. * @param _mesh defines the target mesh
  142020. */
  142021. constructor(_mesh: Mesh);
  142022. /**
  142023. * Simplification of a given mesh according to the given settings.
  142024. * Since this requires computation, it is assumed that the function runs async.
  142025. * @param settings The settings of the simplification, including quality and distance
  142026. * @param successCallback A callback that will be called after the mesh was simplified.
  142027. */
  142028. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  142029. private runDecimation;
  142030. private initWithMesh;
  142031. private init;
  142032. private reconstructMesh;
  142033. private initDecimatedMesh;
  142034. private isFlipped;
  142035. private updateTriangles;
  142036. private identifyBorder;
  142037. private updateMesh;
  142038. private vertexError;
  142039. private calculateError;
  142040. }
  142041. }
  142042. declare module BABYLON {
  142043. interface Scene {
  142044. /** @hidden (Backing field) */
  142045. _simplificationQueue: SimplificationQueue;
  142046. /**
  142047. * Gets or sets the simplification queue attached to the scene
  142048. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142049. */
  142050. simplificationQueue: SimplificationQueue;
  142051. }
  142052. interface Mesh {
  142053. /**
  142054. * Simplify the mesh according to the given array of settings.
  142055. * Function will return immediately and will simplify async
  142056. * @param settings a collection of simplification settings
  142057. * @param parallelProcessing should all levels calculate parallel or one after the other
  142058. * @param simplificationType the type of simplification to run
  142059. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  142060. * @returns the current mesh
  142061. */
  142062. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  142063. }
  142064. /**
  142065. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  142066. * created in a scene
  142067. */
  142068. export class SimplicationQueueSceneComponent implements ISceneComponent {
  142069. /**
  142070. * The component name helpfull to identify the component in the list of scene components.
  142071. */
  142072. readonly name: string;
  142073. /**
  142074. * The scene the component belongs to.
  142075. */
  142076. scene: Scene;
  142077. /**
  142078. * Creates a new instance of the component for the given scene
  142079. * @param scene Defines the scene to register the component in
  142080. */
  142081. constructor(scene: Scene);
  142082. /**
  142083. * Registers the component in a given scene
  142084. */
  142085. register(): void;
  142086. /**
  142087. * Rebuilds the elements related to this component in case of
  142088. * context lost for instance.
  142089. */
  142090. rebuild(): void;
  142091. /**
  142092. * Disposes the component and the associated ressources
  142093. */
  142094. dispose(): void;
  142095. private _beforeCameraUpdate;
  142096. }
  142097. }
  142098. declare module BABYLON {
  142099. interface Mesh {
  142100. /**
  142101. * Creates a new thin instance
  142102. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  142103. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  142104. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  142105. */
  142106. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  142107. /**
  142108. * Adds the transformation (matrix) of the current mesh as a thin instance
  142109. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  142110. * @returns the thin instance index number
  142111. */
  142112. thinInstanceAddSelf(refresh: boolean): number;
  142113. /**
  142114. * Registers a custom attribute to be used with thin instances
  142115. * @param kind name of the attribute
  142116. * @param stride size in floats of the attribute
  142117. */
  142118. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  142119. /**
  142120. * Sets the matrix of a thin instance
  142121. * @param index index of the thin instance
  142122. * @param matrix matrix to set
  142123. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  142124. */
  142125. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  142126. /**
  142127. * Sets the value of a custom attribute for a thin instance
  142128. * @param kind name of the attribute
  142129. * @param index index of the thin instance
  142130. * @param value value to set
  142131. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  142132. */
  142133. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  142134. /**
  142135. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  142136. */
  142137. thinInstanceCount: number;
  142138. /**
  142139. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  142140. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  142141. * @param buffer buffer to set
  142142. * @param stride size in floats of each value of the buffer
  142143. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  142144. */
  142145. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  142146. /**
  142147. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  142148. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  142149. */
  142150. thinInstanceBufferUpdated(kind: string): void;
  142151. /**
  142152. * Refreshes the bounding info, taking into account all the thin instances defined
  142153. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  142154. */
  142155. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  142156. /** @hidden */
  142157. _thinInstanceInitializeUserStorage(): void;
  142158. /** @hidden */
  142159. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  142160. /** @hidden */
  142161. _userThinInstanceBuffersStorage: {
  142162. data: {
  142163. [key: string]: Float32Array;
  142164. };
  142165. sizes: {
  142166. [key: string]: number;
  142167. };
  142168. vertexBuffers: {
  142169. [key: string]: Nullable<VertexBuffer>;
  142170. };
  142171. strides: {
  142172. [key: string]: number;
  142173. };
  142174. };
  142175. }
  142176. }
  142177. declare module BABYLON {
  142178. /**
  142179. * Navigation plugin interface to add navigation constrained by a navigation mesh
  142180. */
  142181. export interface INavigationEnginePlugin {
  142182. /**
  142183. * plugin name
  142184. */
  142185. name: string;
  142186. /**
  142187. * Creates a navigation mesh
  142188. * @param meshes array of all the geometry used to compute the navigatio mesh
  142189. * @param parameters bunch of parameters used to filter geometry
  142190. */
  142191. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  142192. /**
  142193. * Create a navigation mesh debug mesh
  142194. * @param scene is where the mesh will be added
  142195. * @returns debug display mesh
  142196. */
  142197. createDebugNavMesh(scene: Scene): Mesh;
  142198. /**
  142199. * Get a navigation mesh constrained position, closest to the parameter position
  142200. * @param position world position
  142201. * @returns the closest point to position constrained by the navigation mesh
  142202. */
  142203. getClosestPoint(position: Vector3): Vector3;
  142204. /**
  142205. * Get a navigation mesh constrained position, closest to the parameter position
  142206. * @param position world position
  142207. * @param result output the closest point to position constrained by the navigation mesh
  142208. */
  142209. getClosestPointToRef(position: Vector3, result: Vector3): void;
  142210. /**
  142211. * Get a navigation mesh constrained position, within a particular radius
  142212. * @param position world position
  142213. * @param maxRadius the maximum distance to the constrained world position
  142214. * @returns the closest point to position constrained by the navigation mesh
  142215. */
  142216. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  142217. /**
  142218. * Get a navigation mesh constrained position, within a particular radius
  142219. * @param position world position
  142220. * @param maxRadius the maximum distance to the constrained world position
  142221. * @param result output the closest point to position constrained by the navigation mesh
  142222. */
  142223. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  142224. /**
  142225. * Compute the final position from a segment made of destination-position
  142226. * @param position world position
  142227. * @param destination world position
  142228. * @returns the resulting point along the navmesh
  142229. */
  142230. moveAlong(position: Vector3, destination: Vector3): Vector3;
  142231. /**
  142232. * Compute the final position from a segment made of destination-position
  142233. * @param position world position
  142234. * @param destination world position
  142235. * @param result output the resulting point along the navmesh
  142236. */
  142237. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  142238. /**
  142239. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  142240. * @param start world position
  142241. * @param end world position
  142242. * @returns array containing world position composing the path
  142243. */
  142244. computePath(start: Vector3, end: Vector3): Vector3[];
  142245. /**
  142246. * If this plugin is supported
  142247. * @returns true if plugin is supported
  142248. */
  142249. isSupported(): boolean;
  142250. /**
  142251. * Create a new Crowd so you can add agents
  142252. * @param maxAgents the maximum agent count in the crowd
  142253. * @param maxAgentRadius the maximum radius an agent can have
  142254. * @param scene to attach the crowd to
  142255. * @returns the crowd you can add agents to
  142256. */
  142257. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  142258. /**
  142259. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142260. * The queries will try to find a solution within those bounds
  142261. * default is (1,1,1)
  142262. * @param extent x,y,z value that define the extent around the queries point of reference
  142263. */
  142264. setDefaultQueryExtent(extent: Vector3): void;
  142265. /**
  142266. * Get the Bounding box extent specified by setDefaultQueryExtent
  142267. * @returns the box extent values
  142268. */
  142269. getDefaultQueryExtent(): Vector3;
  142270. /**
  142271. * build the navmesh from a previously saved state using getNavmeshData
  142272. * @param data the Uint8Array returned by getNavmeshData
  142273. */
  142274. buildFromNavmeshData(data: Uint8Array): void;
  142275. /**
  142276. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  142277. * @returns data the Uint8Array that can be saved and reused
  142278. */
  142279. getNavmeshData(): Uint8Array;
  142280. /**
  142281. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142282. * @param result output the box extent values
  142283. */
  142284. getDefaultQueryExtentToRef(result: Vector3): void;
  142285. /**
  142286. * Release all resources
  142287. */
  142288. dispose(): void;
  142289. }
  142290. /**
  142291. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  142292. */
  142293. export interface ICrowd {
  142294. /**
  142295. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  142296. * You can attach anything to that node. The node position is updated in the scene update tick.
  142297. * @param pos world position that will be constrained by the navigation mesh
  142298. * @param parameters agent parameters
  142299. * @param transform hooked to the agent that will be update by the scene
  142300. * @returns agent index
  142301. */
  142302. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  142303. /**
  142304. * Returns the agent position in world space
  142305. * @param index agent index returned by addAgent
  142306. * @returns world space position
  142307. */
  142308. getAgentPosition(index: number): Vector3;
  142309. /**
  142310. * Gets the agent position result in world space
  142311. * @param index agent index returned by addAgent
  142312. * @param result output world space position
  142313. */
  142314. getAgentPositionToRef(index: number, result: Vector3): void;
  142315. /**
  142316. * Gets the agent velocity in world space
  142317. * @param index agent index returned by addAgent
  142318. * @returns world space velocity
  142319. */
  142320. getAgentVelocity(index: number): Vector3;
  142321. /**
  142322. * Gets the agent velocity result in world space
  142323. * @param index agent index returned by addAgent
  142324. * @param result output world space velocity
  142325. */
  142326. getAgentVelocityToRef(index: number, result: Vector3): void;
  142327. /**
  142328. * remove a particular agent previously created
  142329. * @param index agent index returned by addAgent
  142330. */
  142331. removeAgent(index: number): void;
  142332. /**
  142333. * get the list of all agents attached to this crowd
  142334. * @returns list of agent indices
  142335. */
  142336. getAgents(): number[];
  142337. /**
  142338. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  142339. * @param deltaTime in seconds
  142340. */
  142341. update(deltaTime: number): void;
  142342. /**
  142343. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  142344. * @param index agent index returned by addAgent
  142345. * @param destination targeted world position
  142346. */
  142347. agentGoto(index: number, destination: Vector3): void;
  142348. /**
  142349. * Teleport the agent to a new position
  142350. * @param index agent index returned by addAgent
  142351. * @param destination targeted world position
  142352. */
  142353. agentTeleport(index: number, destination: Vector3): void;
  142354. /**
  142355. * Update agent parameters
  142356. * @param index agent index returned by addAgent
  142357. * @param parameters agent parameters
  142358. */
  142359. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  142360. /**
  142361. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142362. * The queries will try to find a solution within those bounds
  142363. * default is (1,1,1)
  142364. * @param extent x,y,z value that define the extent around the queries point of reference
  142365. */
  142366. setDefaultQueryExtent(extent: Vector3): void;
  142367. /**
  142368. * Get the Bounding box extent specified by setDefaultQueryExtent
  142369. * @returns the box extent values
  142370. */
  142371. getDefaultQueryExtent(): Vector3;
  142372. /**
  142373. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142374. * @param result output the box extent values
  142375. */
  142376. getDefaultQueryExtentToRef(result: Vector3): void;
  142377. /**
  142378. * Release all resources
  142379. */
  142380. dispose(): void;
  142381. }
  142382. /**
  142383. * Configures an agent
  142384. */
  142385. export interface IAgentParameters {
  142386. /**
  142387. * Agent radius. [Limit: >= 0]
  142388. */
  142389. radius: number;
  142390. /**
  142391. * Agent height. [Limit: > 0]
  142392. */
  142393. height: number;
  142394. /**
  142395. * Maximum allowed acceleration. [Limit: >= 0]
  142396. */
  142397. maxAcceleration: number;
  142398. /**
  142399. * Maximum allowed speed. [Limit: >= 0]
  142400. */
  142401. maxSpeed: number;
  142402. /**
  142403. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  142404. */
  142405. collisionQueryRange: number;
  142406. /**
  142407. * The path visibility optimization range. [Limit: > 0]
  142408. */
  142409. pathOptimizationRange: number;
  142410. /**
  142411. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  142412. */
  142413. separationWeight: number;
  142414. }
  142415. /**
  142416. * Configures the navigation mesh creation
  142417. */
  142418. export interface INavMeshParameters {
  142419. /**
  142420. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  142421. */
  142422. cs: number;
  142423. /**
  142424. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  142425. */
  142426. ch: number;
  142427. /**
  142428. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  142429. */
  142430. walkableSlopeAngle: number;
  142431. /**
  142432. * Minimum floor to 'ceiling' height that will still allow the floor area to
  142433. * be considered walkable. [Limit: >= 3] [Units: vx]
  142434. */
  142435. walkableHeight: number;
  142436. /**
  142437. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  142438. */
  142439. walkableClimb: number;
  142440. /**
  142441. * The distance to erode/shrink the walkable area of the heightfield away from
  142442. * obstructions. [Limit: >=0] [Units: vx]
  142443. */
  142444. walkableRadius: number;
  142445. /**
  142446. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  142447. */
  142448. maxEdgeLen: number;
  142449. /**
  142450. * The maximum distance a simplfied contour's border edges should deviate
  142451. * the original raw contour. [Limit: >=0] [Units: vx]
  142452. */
  142453. maxSimplificationError: number;
  142454. /**
  142455. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  142456. */
  142457. minRegionArea: number;
  142458. /**
  142459. * Any regions with a span count smaller than this value will, if possible,
  142460. * be merged with larger regions. [Limit: >=0] [Units: vx]
  142461. */
  142462. mergeRegionArea: number;
  142463. /**
  142464. * The maximum number of vertices allowed for polygons generated during the
  142465. * contour to polygon conversion process. [Limit: >= 3]
  142466. */
  142467. maxVertsPerPoly: number;
  142468. /**
  142469. * Sets the sampling distance to use when generating the detail mesh.
  142470. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  142471. */
  142472. detailSampleDist: number;
  142473. /**
  142474. * The maximum distance the detail mesh surface should deviate from heightfield
  142475. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  142476. */
  142477. detailSampleMaxError: number;
  142478. }
  142479. }
  142480. declare module BABYLON {
  142481. /**
  142482. * RecastJS navigation plugin
  142483. */
  142484. export class RecastJSPlugin implements INavigationEnginePlugin {
  142485. /**
  142486. * Reference to the Recast library
  142487. */
  142488. bjsRECAST: any;
  142489. /**
  142490. * plugin name
  142491. */
  142492. name: string;
  142493. /**
  142494. * the first navmesh created. We might extend this to support multiple navmeshes
  142495. */
  142496. navMesh: any;
  142497. /**
  142498. * Initializes the recastJS plugin
  142499. * @param recastInjection can be used to inject your own recast reference
  142500. */
  142501. constructor(recastInjection?: any);
  142502. /**
  142503. * Creates a navigation mesh
  142504. * @param meshes array of all the geometry used to compute the navigatio mesh
  142505. * @param parameters bunch of parameters used to filter geometry
  142506. */
  142507. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  142508. /**
  142509. * Create a navigation mesh debug mesh
  142510. * @param scene is where the mesh will be added
  142511. * @returns debug display mesh
  142512. */
  142513. createDebugNavMesh(scene: Scene): Mesh;
  142514. /**
  142515. * Get a navigation mesh constrained position, closest to the parameter position
  142516. * @param position world position
  142517. * @returns the closest point to position constrained by the navigation mesh
  142518. */
  142519. getClosestPoint(position: Vector3): Vector3;
  142520. /**
  142521. * Get a navigation mesh constrained position, closest to the parameter position
  142522. * @param position world position
  142523. * @param result output the closest point to position constrained by the navigation mesh
  142524. */
  142525. getClosestPointToRef(position: Vector3, result: Vector3): void;
  142526. /**
  142527. * Get a navigation mesh constrained position, within a particular radius
  142528. * @param position world position
  142529. * @param maxRadius the maximum distance to the constrained world position
  142530. * @returns the closest point to position constrained by the navigation mesh
  142531. */
  142532. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  142533. /**
  142534. * Get a navigation mesh constrained position, within a particular radius
  142535. * @param position world position
  142536. * @param maxRadius the maximum distance to the constrained world position
  142537. * @param result output the closest point to position constrained by the navigation mesh
  142538. */
  142539. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  142540. /**
  142541. * Compute the final position from a segment made of destination-position
  142542. * @param position world position
  142543. * @param destination world position
  142544. * @returns the resulting point along the navmesh
  142545. */
  142546. moveAlong(position: Vector3, destination: Vector3): Vector3;
  142547. /**
  142548. * Compute the final position from a segment made of destination-position
  142549. * @param position world position
  142550. * @param destination world position
  142551. * @param result output the resulting point along the navmesh
  142552. */
  142553. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  142554. /**
  142555. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  142556. * @param start world position
  142557. * @param end world position
  142558. * @returns array containing world position composing the path
  142559. */
  142560. computePath(start: Vector3, end: Vector3): Vector3[];
  142561. /**
  142562. * Create a new Crowd so you can add agents
  142563. * @param maxAgents the maximum agent count in the crowd
  142564. * @param maxAgentRadius the maximum radius an agent can have
  142565. * @param scene to attach the crowd to
  142566. * @returns the crowd you can add agents to
  142567. */
  142568. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  142569. /**
  142570. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142571. * The queries will try to find a solution within those bounds
  142572. * default is (1,1,1)
  142573. * @param extent x,y,z value that define the extent around the queries point of reference
  142574. */
  142575. setDefaultQueryExtent(extent: Vector3): void;
  142576. /**
  142577. * Get the Bounding box extent specified by setDefaultQueryExtent
  142578. * @returns the box extent values
  142579. */
  142580. getDefaultQueryExtent(): Vector3;
  142581. /**
  142582. * build the navmesh from a previously saved state using getNavmeshData
  142583. * @param data the Uint8Array returned by getNavmeshData
  142584. */
  142585. buildFromNavmeshData(data: Uint8Array): void;
  142586. /**
  142587. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  142588. * @returns data the Uint8Array that can be saved and reused
  142589. */
  142590. getNavmeshData(): Uint8Array;
  142591. /**
  142592. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142593. * @param result output the box extent values
  142594. */
  142595. getDefaultQueryExtentToRef(result: Vector3): void;
  142596. /**
  142597. * Disposes
  142598. */
  142599. dispose(): void;
  142600. /**
  142601. * If this plugin is supported
  142602. * @returns true if plugin is supported
  142603. */
  142604. isSupported(): boolean;
  142605. }
  142606. /**
  142607. * Recast detour crowd implementation
  142608. */
  142609. export class RecastJSCrowd implements ICrowd {
  142610. /**
  142611. * Recast/detour plugin
  142612. */
  142613. bjsRECASTPlugin: RecastJSPlugin;
  142614. /**
  142615. * Link to the detour crowd
  142616. */
  142617. recastCrowd: any;
  142618. /**
  142619. * One transform per agent
  142620. */
  142621. transforms: TransformNode[];
  142622. /**
  142623. * All agents created
  142624. */
  142625. agents: number[];
  142626. /**
  142627. * Link to the scene is kept to unregister the crowd from the scene
  142628. */
  142629. private _scene;
  142630. /**
  142631. * Observer for crowd updates
  142632. */
  142633. private _onBeforeAnimationsObserver;
  142634. /**
  142635. * Constructor
  142636. * @param plugin recastJS plugin
  142637. * @param maxAgents the maximum agent count in the crowd
  142638. * @param maxAgentRadius the maximum radius an agent can have
  142639. * @param scene to attach the crowd to
  142640. * @returns the crowd you can add agents to
  142641. */
  142642. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  142643. /**
  142644. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  142645. * You can attach anything to that node. The node position is updated in the scene update tick.
  142646. * @param pos world position that will be constrained by the navigation mesh
  142647. * @param parameters agent parameters
  142648. * @param transform hooked to the agent that will be update by the scene
  142649. * @returns agent index
  142650. */
  142651. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  142652. /**
  142653. * Returns the agent position in world space
  142654. * @param index agent index returned by addAgent
  142655. * @returns world space position
  142656. */
  142657. getAgentPosition(index: number): Vector3;
  142658. /**
  142659. * Returns the agent position result in world space
  142660. * @param index agent index returned by addAgent
  142661. * @param result output world space position
  142662. */
  142663. getAgentPositionToRef(index: number, result: Vector3): void;
  142664. /**
  142665. * Returns the agent velocity in world space
  142666. * @param index agent index returned by addAgent
  142667. * @returns world space velocity
  142668. */
  142669. getAgentVelocity(index: number): Vector3;
  142670. /**
  142671. * Returns the agent velocity result in world space
  142672. * @param index agent index returned by addAgent
  142673. * @param result output world space velocity
  142674. */
  142675. getAgentVelocityToRef(index: number, result: Vector3): void;
  142676. /**
  142677. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  142678. * @param index agent index returned by addAgent
  142679. * @param destination targeted world position
  142680. */
  142681. agentGoto(index: number, destination: Vector3): void;
  142682. /**
  142683. * Teleport the agent to a new position
  142684. * @param index agent index returned by addAgent
  142685. * @param destination targeted world position
  142686. */
  142687. agentTeleport(index: number, destination: Vector3): void;
  142688. /**
  142689. * Update agent parameters
  142690. * @param index agent index returned by addAgent
  142691. * @param parameters agent parameters
  142692. */
  142693. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  142694. /**
  142695. * remove a particular agent previously created
  142696. * @param index agent index returned by addAgent
  142697. */
  142698. removeAgent(index: number): void;
  142699. /**
  142700. * get the list of all agents attached to this crowd
  142701. * @returns list of agent indices
  142702. */
  142703. getAgents(): number[];
  142704. /**
  142705. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  142706. * @param deltaTime in seconds
  142707. */
  142708. update(deltaTime: number): void;
  142709. /**
  142710. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142711. * The queries will try to find a solution within those bounds
  142712. * default is (1,1,1)
  142713. * @param extent x,y,z value that define the extent around the queries point of reference
  142714. */
  142715. setDefaultQueryExtent(extent: Vector3): void;
  142716. /**
  142717. * Get the Bounding box extent specified by setDefaultQueryExtent
  142718. * @returns the box extent values
  142719. */
  142720. getDefaultQueryExtent(): Vector3;
  142721. /**
  142722. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142723. * @param result output the box extent values
  142724. */
  142725. getDefaultQueryExtentToRef(result: Vector3): void;
  142726. /**
  142727. * Release all resources
  142728. */
  142729. dispose(): void;
  142730. }
  142731. }
  142732. declare module BABYLON {
  142733. /**
  142734. * Class used to enable access to IndexedDB
  142735. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  142736. */
  142737. export class Database implements IOfflineProvider {
  142738. private _callbackManifestChecked;
  142739. private _currentSceneUrl;
  142740. private _db;
  142741. private _enableSceneOffline;
  142742. private _enableTexturesOffline;
  142743. private _manifestVersionFound;
  142744. private _mustUpdateRessources;
  142745. private _hasReachedQuota;
  142746. private _isSupported;
  142747. private _idbFactory;
  142748. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  142749. private static IsUASupportingBlobStorage;
  142750. /**
  142751. * Gets a boolean indicating if Database storate is enabled (off by default)
  142752. */
  142753. static IDBStorageEnabled: boolean;
  142754. /**
  142755. * Gets a boolean indicating if scene must be saved in the database
  142756. */
  142757. get enableSceneOffline(): boolean;
  142758. /**
  142759. * Gets a boolean indicating if textures must be saved in the database
  142760. */
  142761. get enableTexturesOffline(): boolean;
  142762. /**
  142763. * Creates a new Database
  142764. * @param urlToScene defines the url to load the scene
  142765. * @param callbackManifestChecked defines the callback to use when manifest is checked
  142766. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  142767. */
  142768. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  142769. private static _ParseURL;
  142770. private static _ReturnFullUrlLocation;
  142771. private _checkManifestFile;
  142772. /**
  142773. * Open the database and make it available
  142774. * @param successCallback defines the callback to call on success
  142775. * @param errorCallback defines the callback to call on error
  142776. */
  142777. open(successCallback: () => void, errorCallback: () => void): void;
  142778. /**
  142779. * Loads an image from the database
  142780. * @param url defines the url to load from
  142781. * @param image defines the target DOM image
  142782. */
  142783. loadImage(url: string, image: HTMLImageElement): void;
  142784. private _loadImageFromDBAsync;
  142785. private _saveImageIntoDBAsync;
  142786. private _checkVersionFromDB;
  142787. private _loadVersionFromDBAsync;
  142788. private _saveVersionIntoDBAsync;
  142789. /**
  142790. * Loads a file from database
  142791. * @param url defines the URL to load from
  142792. * @param sceneLoaded defines a callback to call on success
  142793. * @param progressCallBack defines a callback to call when progress changed
  142794. * @param errorCallback defines a callback to call on error
  142795. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  142796. */
  142797. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  142798. private _loadFileAsync;
  142799. private _saveFileAsync;
  142800. /**
  142801. * Validates if xhr data is correct
  142802. * @param xhr defines the request to validate
  142803. * @param dataType defines the expected data type
  142804. * @returns true if data is correct
  142805. */
  142806. private static _ValidateXHRData;
  142807. }
  142808. }
  142809. declare module BABYLON {
  142810. /** @hidden */
  142811. export var gpuUpdateParticlesPixelShader: {
  142812. name: string;
  142813. shader: string;
  142814. };
  142815. }
  142816. declare module BABYLON {
  142817. /** @hidden */
  142818. export var gpuUpdateParticlesVertexShader: {
  142819. name: string;
  142820. shader: string;
  142821. };
  142822. }
  142823. declare module BABYLON {
  142824. /** @hidden */
  142825. export var clipPlaneFragmentDeclaration2: {
  142826. name: string;
  142827. shader: string;
  142828. };
  142829. }
  142830. declare module BABYLON {
  142831. /** @hidden */
  142832. export var gpuRenderParticlesPixelShader: {
  142833. name: string;
  142834. shader: string;
  142835. };
  142836. }
  142837. declare module BABYLON {
  142838. /** @hidden */
  142839. export var clipPlaneVertexDeclaration2: {
  142840. name: string;
  142841. shader: string;
  142842. };
  142843. }
  142844. declare module BABYLON {
  142845. /** @hidden */
  142846. export var gpuRenderParticlesVertexShader: {
  142847. name: string;
  142848. shader: string;
  142849. };
  142850. }
  142851. declare module BABYLON {
  142852. /**
  142853. * This represents a GPU particle system in Babylon
  142854. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  142855. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  142856. */
  142857. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  142858. /**
  142859. * The layer mask we are rendering the particles through.
  142860. */
  142861. layerMask: number;
  142862. private _capacity;
  142863. private _activeCount;
  142864. private _currentActiveCount;
  142865. private _accumulatedCount;
  142866. private _renderEffect;
  142867. private _updateEffect;
  142868. private _buffer0;
  142869. private _buffer1;
  142870. private _spriteBuffer;
  142871. private _updateVAO;
  142872. private _renderVAO;
  142873. private _targetIndex;
  142874. private _sourceBuffer;
  142875. private _targetBuffer;
  142876. private _engine;
  142877. private _currentRenderId;
  142878. private _started;
  142879. private _stopped;
  142880. private _timeDelta;
  142881. private _randomTexture;
  142882. private _randomTexture2;
  142883. private _attributesStrideSize;
  142884. private _updateEffectOptions;
  142885. private _randomTextureSize;
  142886. private _actualFrame;
  142887. private _customEffect;
  142888. private readonly _rawTextureWidth;
  142889. /**
  142890. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  142891. */
  142892. static get IsSupported(): boolean;
  142893. /**
  142894. * An event triggered when the system is disposed.
  142895. */
  142896. onDisposeObservable: Observable<IParticleSystem>;
  142897. /**
  142898. * Gets the maximum number of particles active at the same time.
  142899. * @returns The max number of active particles.
  142900. */
  142901. getCapacity(): number;
  142902. /**
  142903. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  142904. * to override the particles.
  142905. */
  142906. forceDepthWrite: boolean;
  142907. /**
  142908. * Gets or set the number of active particles
  142909. */
  142910. get activeParticleCount(): number;
  142911. set activeParticleCount(value: number);
  142912. private _preWarmDone;
  142913. /**
  142914. * Specifies if the particles are updated in emitter local space or world space.
  142915. */
  142916. isLocal: boolean;
  142917. /**
  142918. * Is this system ready to be used/rendered
  142919. * @return true if the system is ready
  142920. */
  142921. isReady(): boolean;
  142922. /**
  142923. * Gets if the system has been started. (Note: this will still be true after stop is called)
  142924. * @returns True if it has been started, otherwise false.
  142925. */
  142926. isStarted(): boolean;
  142927. /**
  142928. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  142929. * @returns True if it has been stopped, otherwise false.
  142930. */
  142931. isStopped(): boolean;
  142932. /**
  142933. * Gets a boolean indicating that the system is stopping
  142934. * @returns true if the system is currently stopping
  142935. */
  142936. isStopping(): boolean;
  142937. /**
  142938. * Gets the number of particles active at the same time.
  142939. * @returns The number of active particles.
  142940. */
  142941. getActiveCount(): number;
  142942. /**
  142943. * Starts the particle system and begins to emit
  142944. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  142945. */
  142946. start(delay?: number): void;
  142947. /**
  142948. * Stops the particle system.
  142949. */
  142950. stop(): void;
  142951. /**
  142952. * Remove all active particles
  142953. */
  142954. reset(): void;
  142955. /**
  142956. * Returns the string "GPUParticleSystem"
  142957. * @returns a string containing the class name
  142958. */
  142959. getClassName(): string;
  142960. /**
  142961. * Gets the custom effect used to render the particles
  142962. * @param blendMode Blend mode for which the effect should be retrieved
  142963. * @returns The effect
  142964. */
  142965. getCustomEffect(blendMode?: number): Nullable<Effect>;
  142966. /**
  142967. * Sets the custom effect used to render the particles
  142968. * @param effect The effect to set
  142969. * @param blendMode Blend mode for which the effect should be set
  142970. */
  142971. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  142972. /** @hidden */
  142973. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  142974. /**
  142975. * Observable that will be called just before the particles are drawn
  142976. */
  142977. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  142978. /**
  142979. * Gets the name of the particle vertex shader
  142980. */
  142981. get vertexShaderName(): string;
  142982. private _colorGradientsTexture;
  142983. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  142984. /**
  142985. * Adds a new color gradient
  142986. * @param gradient defines the gradient to use (between 0 and 1)
  142987. * @param color1 defines the color to affect to the specified gradient
  142988. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  142989. * @returns the current particle system
  142990. */
  142991. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  142992. private _refreshColorGradient;
  142993. /** Force the system to rebuild all gradients that need to be resync */
  142994. forceRefreshGradients(): void;
  142995. /**
  142996. * Remove a specific color gradient
  142997. * @param gradient defines the gradient to remove
  142998. * @returns the current particle system
  142999. */
  143000. removeColorGradient(gradient: number): GPUParticleSystem;
  143001. private _angularSpeedGradientsTexture;
  143002. private _sizeGradientsTexture;
  143003. private _velocityGradientsTexture;
  143004. private _limitVelocityGradientsTexture;
  143005. private _dragGradientsTexture;
  143006. private _addFactorGradient;
  143007. /**
  143008. * Adds a new size gradient
  143009. * @param gradient defines the gradient to use (between 0 and 1)
  143010. * @param factor defines the size factor to affect to the specified gradient
  143011. * @returns the current particle system
  143012. */
  143013. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  143014. /**
  143015. * Remove a specific size gradient
  143016. * @param gradient defines the gradient to remove
  143017. * @returns the current particle system
  143018. */
  143019. removeSizeGradient(gradient: number): GPUParticleSystem;
  143020. private _refreshFactorGradient;
  143021. /**
  143022. * Adds a new angular speed gradient
  143023. * @param gradient defines the gradient to use (between 0 and 1)
  143024. * @param factor defines the angular speed to affect to the specified gradient
  143025. * @returns the current particle system
  143026. */
  143027. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  143028. /**
  143029. * Remove a specific angular speed gradient
  143030. * @param gradient defines the gradient to remove
  143031. * @returns the current particle system
  143032. */
  143033. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  143034. /**
  143035. * Adds a new velocity gradient
  143036. * @param gradient defines the gradient to use (between 0 and 1)
  143037. * @param factor defines the velocity to affect to the specified gradient
  143038. * @returns the current particle system
  143039. */
  143040. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  143041. /**
  143042. * Remove a specific velocity gradient
  143043. * @param gradient defines the gradient to remove
  143044. * @returns the current particle system
  143045. */
  143046. removeVelocityGradient(gradient: number): GPUParticleSystem;
  143047. /**
  143048. * Adds a new limit velocity gradient
  143049. * @param gradient defines the gradient to use (between 0 and 1)
  143050. * @param factor defines the limit velocity value to affect to the specified gradient
  143051. * @returns the current particle system
  143052. */
  143053. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  143054. /**
  143055. * Remove a specific limit velocity gradient
  143056. * @param gradient defines the gradient to remove
  143057. * @returns the current particle system
  143058. */
  143059. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  143060. /**
  143061. * Adds a new drag gradient
  143062. * @param gradient defines the gradient to use (between 0 and 1)
  143063. * @param factor defines the drag value to affect to the specified gradient
  143064. * @returns the current particle system
  143065. */
  143066. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  143067. /**
  143068. * Remove a specific drag gradient
  143069. * @param gradient defines the gradient to remove
  143070. * @returns the current particle system
  143071. */
  143072. removeDragGradient(gradient: number): GPUParticleSystem;
  143073. /**
  143074. * Not supported by GPUParticleSystem
  143075. * @param gradient defines the gradient to use (between 0 and 1)
  143076. * @param factor defines the emit rate value to affect to the specified gradient
  143077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143078. * @returns the current particle system
  143079. */
  143080. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143081. /**
  143082. * Not supported by GPUParticleSystem
  143083. * @param gradient defines the gradient to remove
  143084. * @returns the current particle system
  143085. */
  143086. removeEmitRateGradient(gradient: number): IParticleSystem;
  143087. /**
  143088. * Not supported by GPUParticleSystem
  143089. * @param gradient defines the gradient to use (between 0 and 1)
  143090. * @param factor defines the start size value to affect to the specified gradient
  143091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143092. * @returns the current particle system
  143093. */
  143094. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143095. /**
  143096. * Not supported by GPUParticleSystem
  143097. * @param gradient defines the gradient to remove
  143098. * @returns the current particle system
  143099. */
  143100. removeStartSizeGradient(gradient: number): IParticleSystem;
  143101. /**
  143102. * Not supported by GPUParticleSystem
  143103. * @param gradient defines the gradient to use (between 0 and 1)
  143104. * @param min defines the color remap minimal range
  143105. * @param max defines the color remap maximal range
  143106. * @returns the current particle system
  143107. */
  143108. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  143109. /**
  143110. * Not supported by GPUParticleSystem
  143111. * @param gradient defines the gradient to remove
  143112. * @returns the current particle system
  143113. */
  143114. removeColorRemapGradient(): IParticleSystem;
  143115. /**
  143116. * Not supported by GPUParticleSystem
  143117. * @param gradient defines the gradient to use (between 0 and 1)
  143118. * @param min defines the alpha remap minimal range
  143119. * @param max defines the alpha remap maximal range
  143120. * @returns the current particle system
  143121. */
  143122. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  143123. /**
  143124. * Not supported by GPUParticleSystem
  143125. * @param gradient defines the gradient to remove
  143126. * @returns the current particle system
  143127. */
  143128. removeAlphaRemapGradient(): IParticleSystem;
  143129. /**
  143130. * Not supported by GPUParticleSystem
  143131. * @param gradient defines the gradient to use (between 0 and 1)
  143132. * @param color defines the color to affect to the specified gradient
  143133. * @returns the current particle system
  143134. */
  143135. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  143136. /**
  143137. * Not supported by GPUParticleSystem
  143138. * @param gradient defines the gradient to remove
  143139. * @returns the current particle system
  143140. */
  143141. removeRampGradient(): IParticleSystem;
  143142. /**
  143143. * Not supported by GPUParticleSystem
  143144. * @returns the list of ramp gradients
  143145. */
  143146. getRampGradients(): Nullable<Array<Color3Gradient>>;
  143147. /**
  143148. * Not supported by GPUParticleSystem
  143149. * Gets or sets a boolean indicating that ramp gradients must be used
  143150. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  143151. */
  143152. get useRampGradients(): boolean;
  143153. set useRampGradients(value: boolean);
  143154. /**
  143155. * Not supported by GPUParticleSystem
  143156. * @param gradient defines the gradient to use (between 0 and 1)
  143157. * @param factor defines the life time factor to affect to the specified gradient
  143158. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143159. * @returns the current particle system
  143160. */
  143161. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143162. /**
  143163. * Not supported by GPUParticleSystem
  143164. * @param gradient defines the gradient to remove
  143165. * @returns the current particle system
  143166. */
  143167. removeLifeTimeGradient(gradient: number): IParticleSystem;
  143168. /**
  143169. * Instantiates a GPU particle system.
  143170. * 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.
  143171. * @param name The name of the particle system
  143172. * @param options The options used to create the system
  143173. * @param scene The scene the particle system belongs to
  143174. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  143175. * @param customEffect a custom effect used to change the way particles are rendered by default
  143176. */
  143177. constructor(name: string, options: Partial<{
  143178. capacity: number;
  143179. randomTextureSize: number;
  143180. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  143181. protected _reset(): void;
  143182. private _createUpdateVAO;
  143183. private _createRenderVAO;
  143184. private _initialize;
  143185. /** @hidden */
  143186. _recreateUpdateEffect(): void;
  143187. private _getEffect;
  143188. /**
  143189. * Fill the defines array according to the current settings of the particle system
  143190. * @param defines Array to be updated
  143191. * @param blendMode blend mode to take into account when updating the array
  143192. */
  143193. fillDefines(defines: Array<string>, blendMode?: number): void;
  143194. /**
  143195. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  143196. * @param uniforms Uniforms array to fill
  143197. * @param attributes Attributes array to fill
  143198. * @param samplers Samplers array to fill
  143199. */
  143200. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  143201. /** @hidden */
  143202. _recreateRenderEffect(): Effect;
  143203. /**
  143204. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  143205. * @param preWarm defines if we are in the pre-warmimg phase
  143206. */
  143207. animate(preWarm?: boolean): void;
  143208. private _createFactorGradientTexture;
  143209. private _createSizeGradientTexture;
  143210. private _createAngularSpeedGradientTexture;
  143211. private _createVelocityGradientTexture;
  143212. private _createLimitVelocityGradientTexture;
  143213. private _createDragGradientTexture;
  143214. private _createColorGradientTexture;
  143215. /**
  143216. * Renders the particle system in its current state
  143217. * @param preWarm defines if the system should only update the particles but not render them
  143218. * @returns the current number of particles
  143219. */
  143220. render(preWarm?: boolean): number;
  143221. /**
  143222. * Rebuilds the particle system
  143223. */
  143224. rebuild(): void;
  143225. private _releaseBuffers;
  143226. private _releaseVAOs;
  143227. /**
  143228. * Disposes the particle system and free the associated resources
  143229. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  143230. */
  143231. dispose(disposeTexture?: boolean): void;
  143232. /**
  143233. * Clones the particle system.
  143234. * @param name The name of the cloned object
  143235. * @param newEmitter The new emitter to use
  143236. * @returns the cloned particle system
  143237. */
  143238. clone(name: string, newEmitter: any): GPUParticleSystem;
  143239. /**
  143240. * Serializes the particle system to a JSON object
  143241. * @param serializeTexture defines if the texture must be serialized as well
  143242. * @returns the JSON object
  143243. */
  143244. serialize(serializeTexture?: boolean): any;
  143245. /**
  143246. * Parses a JSON object to create a GPU particle system.
  143247. * @param parsedParticleSystem The JSON object to parse
  143248. * @param scene The scene to create the particle system in
  143249. * @param rootUrl The root url to use to load external dependencies like texture
  143250. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  143251. * @returns the parsed GPU particle system
  143252. */
  143253. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  143254. }
  143255. }
  143256. declare module BABYLON {
  143257. /**
  143258. * Represents a set of particle systems working together to create a specific effect
  143259. */
  143260. export class ParticleSystemSet implements IDisposable {
  143261. /**
  143262. * Gets or sets base Assets URL
  143263. */
  143264. static BaseAssetsUrl: string;
  143265. private _emitterCreationOptions;
  143266. private _emitterNode;
  143267. /**
  143268. * Gets the particle system list
  143269. */
  143270. systems: IParticleSystem[];
  143271. /**
  143272. * Gets the emitter node used with this set
  143273. */
  143274. get emitterNode(): Nullable<TransformNode>;
  143275. /**
  143276. * Creates a new emitter mesh as a sphere
  143277. * @param options defines the options used to create the sphere
  143278. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  143279. * @param scene defines the hosting scene
  143280. */
  143281. setEmitterAsSphere(options: {
  143282. diameter: number;
  143283. segments: number;
  143284. color: Color3;
  143285. }, renderingGroupId: number, scene: Scene): void;
  143286. /**
  143287. * Starts all particle systems of the set
  143288. * @param emitter defines an optional mesh to use as emitter for the particle systems
  143289. */
  143290. start(emitter?: AbstractMesh): void;
  143291. /**
  143292. * Release all associated resources
  143293. */
  143294. dispose(): void;
  143295. /**
  143296. * Serialize the set into a JSON compatible object
  143297. * @param serializeTexture defines if the texture must be serialized as well
  143298. * @returns a JSON compatible representation of the set
  143299. */
  143300. serialize(serializeTexture?: boolean): any;
  143301. /**
  143302. * Parse a new ParticleSystemSet from a serialized source
  143303. * @param data defines a JSON compatible representation of the set
  143304. * @param scene defines the hosting scene
  143305. * @param gpu defines if we want GPU particles or CPU particles
  143306. * @returns a new ParticleSystemSet
  143307. */
  143308. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  143309. }
  143310. }
  143311. declare module BABYLON {
  143312. /**
  143313. * This class is made for on one-liner static method to help creating particle system set.
  143314. */
  143315. export class ParticleHelper {
  143316. /**
  143317. * Gets or sets base Assets URL
  143318. */
  143319. static BaseAssetsUrl: string;
  143320. /** Define the Url to load snippets */
  143321. static SnippetUrl: string;
  143322. /**
  143323. * Create a default particle system that you can tweak
  143324. * @param emitter defines the emitter to use
  143325. * @param capacity defines the system capacity (default is 500 particles)
  143326. * @param scene defines the hosting scene
  143327. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  143328. * @returns the new Particle system
  143329. */
  143330. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  143331. /**
  143332. * This is the main static method (one-liner) of this helper to create different particle systems
  143333. * @param type This string represents the type to the particle system to create
  143334. * @param scene The scene where the particle system should live
  143335. * @param gpu If the system will use gpu
  143336. * @returns the ParticleSystemSet created
  143337. */
  143338. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  143339. /**
  143340. * Static function used to export a particle system to a ParticleSystemSet variable.
  143341. * Please note that the emitter shape is not exported
  143342. * @param systems defines the particle systems to export
  143343. * @returns the created particle system set
  143344. */
  143345. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  143346. /**
  143347. * Creates a particle system from a snippet saved in a remote file
  143348. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  143349. * @param url defines the url to load from
  143350. * @param scene defines the hosting scene
  143351. * @param gpu If the system will use gpu
  143352. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  143353. * @returns a promise that will resolve to the new particle system
  143354. */
  143355. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  143356. /**
  143357. * Creates a particle system from a snippet saved by the particle system editor
  143358. * @param snippetId defines the snippet to load
  143359. * @param scene defines the hosting scene
  143360. * @param gpu If the system will use gpu
  143361. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  143362. * @returns a promise that will resolve to the new particle system
  143363. */
  143364. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  143365. }
  143366. }
  143367. declare module BABYLON {
  143368. interface Engine {
  143369. /**
  143370. * Create an effect to use with particle systems.
  143371. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  143372. * the particle system for which you want to create a custom effect in the last parameter
  143373. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  143374. * @param uniformsNames defines a list of attribute names
  143375. * @param samplers defines an array of string used to represent textures
  143376. * @param defines defines the string containing the defines to use to compile the shaders
  143377. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  143378. * @param onCompiled defines a function to call when the effect creation is successful
  143379. * @param onError defines a function to call when the effect creation has failed
  143380. * @param particleSystem the particle system you want to create the effect for
  143381. * @returns the new Effect
  143382. */
  143383. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  143384. }
  143385. interface Mesh {
  143386. /**
  143387. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  143388. * @returns an array of IParticleSystem
  143389. */
  143390. getEmittedParticleSystems(): IParticleSystem[];
  143391. /**
  143392. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  143393. * @returns an array of IParticleSystem
  143394. */
  143395. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  143396. }
  143397. }
  143398. declare module BABYLON {
  143399. /** Defines the 4 color options */
  143400. export enum PointColor {
  143401. /** color value */
  143402. Color = 2,
  143403. /** uv value */
  143404. UV = 1,
  143405. /** random value */
  143406. Random = 0,
  143407. /** stated value */
  143408. Stated = 3
  143409. }
  143410. /**
  143411. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  143412. * 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.
  143413. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  143414. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  143415. *
  143416. * Full documentation here : TO BE ENTERED
  143417. */
  143418. export class PointsCloudSystem implements IDisposable {
  143419. /**
  143420. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  143421. * Example : var p = SPS.particles[i];
  143422. */
  143423. particles: CloudPoint[];
  143424. /**
  143425. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  143426. */
  143427. nbParticles: number;
  143428. /**
  143429. * This a counter for your own usage. It's not set by any SPS functions.
  143430. */
  143431. counter: number;
  143432. /**
  143433. * The PCS name. This name is also given to the underlying mesh.
  143434. */
  143435. name: string;
  143436. /**
  143437. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  143438. */
  143439. mesh: Mesh;
  143440. /**
  143441. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  143442. * Please read :
  143443. */
  143444. vars: any;
  143445. /**
  143446. * @hidden
  143447. */
  143448. _size: number;
  143449. private _scene;
  143450. private _promises;
  143451. private _positions;
  143452. private _indices;
  143453. private _normals;
  143454. private _colors;
  143455. private _uvs;
  143456. private _indices32;
  143457. private _positions32;
  143458. private _colors32;
  143459. private _uvs32;
  143460. private _updatable;
  143461. private _isVisibilityBoxLocked;
  143462. private _alwaysVisible;
  143463. private _groups;
  143464. private _groupCounter;
  143465. private _computeParticleColor;
  143466. private _computeParticleTexture;
  143467. private _computeParticleRotation;
  143468. private _computeBoundingBox;
  143469. private _isReady;
  143470. /**
  143471. * Creates a PCS (Points Cloud System) object
  143472. * @param name (String) is the PCS name, this will be the underlying mesh name
  143473. * @param pointSize (number) is the size for each point
  143474. * @param scene (Scene) is the scene in which the PCS is added
  143475. * @param options defines the options of the PCS e.g.
  143476. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  143477. */
  143478. constructor(name: string, pointSize: number, scene: Scene, options?: {
  143479. updatable?: boolean;
  143480. });
  143481. /**
  143482. * Builds the PCS underlying mesh. Returns a standard Mesh.
  143483. * If no points were added to the PCS, the returned mesh is just a single point.
  143484. * @returns a promise for the created mesh
  143485. */
  143486. buildMeshAsync(): Promise<Mesh>;
  143487. /**
  143488. * @hidden
  143489. */
  143490. private _buildMesh;
  143491. private _addParticle;
  143492. private _randomUnitVector;
  143493. private _getColorIndicesForCoord;
  143494. private _setPointsColorOrUV;
  143495. private _colorFromTexture;
  143496. private _calculateDensity;
  143497. /**
  143498. * Adds points to the PCS in random positions within a unit sphere
  143499. * @param nb (positive integer) the number of particles to be created from this model
  143500. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  143501. * @returns the number of groups in the system
  143502. */
  143503. addPoints(nb: number, pointFunction?: any): number;
  143504. /**
  143505. * Adds points to the PCS from the surface of the model shape
  143506. * @param mesh is any Mesh object that will be used as a surface model for the points
  143507. * @param nb (positive integer) the number of particles to be created from this model
  143508. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143509. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143510. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143511. * @returns the number of groups in the system
  143512. */
  143513. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143514. /**
  143515. * Adds points to the PCS inside the model shape
  143516. * @param mesh is any Mesh object that will be used as a surface model for the points
  143517. * @param nb (positive integer) the number of particles to be created from this model
  143518. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143519. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143520. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143521. * @returns the number of groups in the system
  143522. */
  143523. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143524. /**
  143525. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  143526. * This method calls `updateParticle()` for each particle of the SPS.
  143527. * For an animated SPS, it is usually called within the render loop.
  143528. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  143529. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  143530. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  143531. * @returns the PCS.
  143532. */
  143533. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  143534. /**
  143535. * Disposes the PCS.
  143536. */
  143537. dispose(): void;
  143538. /**
  143539. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  143540. * doc :
  143541. * @returns the PCS.
  143542. */
  143543. refreshVisibleSize(): PointsCloudSystem;
  143544. /**
  143545. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  143546. * @param size the size (float) of the visibility box
  143547. * note : this doesn't lock the PCS mesh bounding box.
  143548. * doc :
  143549. */
  143550. setVisibilityBox(size: number): void;
  143551. /**
  143552. * Gets whether the PCS is always visible or not
  143553. * doc :
  143554. */
  143555. get isAlwaysVisible(): boolean;
  143556. /**
  143557. * Sets the PCS as always visible or not
  143558. * doc :
  143559. */
  143560. set isAlwaysVisible(val: boolean);
  143561. /**
  143562. * Tells to `setParticles()` to compute the particle rotations or not
  143563. * Default value : false. The PCS is faster when it's set to false
  143564. * Note : particle rotations are only applied to parent particles
  143565. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  143566. */
  143567. set computeParticleRotation(val: boolean);
  143568. /**
  143569. * Tells to `setParticles()` to compute the particle colors or not.
  143570. * Default value : true. The PCS is faster when it's set to false.
  143571. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143572. */
  143573. set computeParticleColor(val: boolean);
  143574. set computeParticleTexture(val: boolean);
  143575. /**
  143576. * Gets if `setParticles()` computes the particle colors or not.
  143577. * Default value : false. The PCS is faster when it's set to false.
  143578. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143579. */
  143580. get computeParticleColor(): boolean;
  143581. /**
  143582. * Gets if `setParticles()` computes the particle textures or not.
  143583. * Default value : false. The PCS is faster when it's set to false.
  143584. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  143585. */
  143586. get computeParticleTexture(): boolean;
  143587. /**
  143588. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  143589. */
  143590. set computeBoundingBox(val: boolean);
  143591. /**
  143592. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  143593. */
  143594. get computeBoundingBox(): boolean;
  143595. /**
  143596. * This function does nothing. It may be overwritten to set all the particle first values.
  143597. * The PCS doesn't call this function, you may have to call it by your own.
  143598. * doc :
  143599. */
  143600. initParticles(): void;
  143601. /**
  143602. * This function does nothing. It may be overwritten to recycle a particle
  143603. * The PCS doesn't call this function, you can to call it
  143604. * doc :
  143605. * @param particle The particle to recycle
  143606. * @returns the recycled particle
  143607. */
  143608. recycleParticle(particle: CloudPoint): CloudPoint;
  143609. /**
  143610. * Updates a particle : this function should be overwritten by the user.
  143611. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  143612. * doc :
  143613. * @example : just set a particle position or velocity and recycle conditions
  143614. * @param particle The particle to update
  143615. * @returns the updated particle
  143616. */
  143617. updateParticle(particle: CloudPoint): CloudPoint;
  143618. /**
  143619. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  143620. * This does nothing and may be overwritten by the user.
  143621. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143622. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143623. * @param update the boolean update value actually passed to setParticles()
  143624. */
  143625. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143626. /**
  143627. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  143628. * This will be passed three parameters.
  143629. * This does nothing and may be overwritten by the user.
  143630. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143631. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143632. * @param update the boolean update value actually passed to setParticles()
  143633. */
  143634. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143635. }
  143636. }
  143637. declare module BABYLON {
  143638. /**
  143639. * Represents one particle of a points cloud system.
  143640. */
  143641. export class CloudPoint {
  143642. /**
  143643. * particle global index
  143644. */
  143645. idx: number;
  143646. /**
  143647. * The color of the particle
  143648. */
  143649. color: Nullable<Color4>;
  143650. /**
  143651. * The world space position of the particle.
  143652. */
  143653. position: Vector3;
  143654. /**
  143655. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  143656. */
  143657. rotation: Vector3;
  143658. /**
  143659. * The world space rotation quaternion of the particle.
  143660. */
  143661. rotationQuaternion: Nullable<Quaternion>;
  143662. /**
  143663. * The uv of the particle.
  143664. */
  143665. uv: Nullable<Vector2>;
  143666. /**
  143667. * The current speed of the particle.
  143668. */
  143669. velocity: Vector3;
  143670. /**
  143671. * The pivot point in the particle local space.
  143672. */
  143673. pivot: Vector3;
  143674. /**
  143675. * Must the particle be translated from its pivot point in its local space ?
  143676. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  143677. * Default : false
  143678. */
  143679. translateFromPivot: boolean;
  143680. /**
  143681. * Index of this particle in the global "positions" array (Internal use)
  143682. * @hidden
  143683. */
  143684. _pos: number;
  143685. /**
  143686. * @hidden Index of this particle in the global "indices" array (Internal use)
  143687. */
  143688. _ind: number;
  143689. /**
  143690. * Group this particle belongs to
  143691. */
  143692. _group: PointsGroup;
  143693. /**
  143694. * Group id of this particle
  143695. */
  143696. groupId: number;
  143697. /**
  143698. * Index of the particle in its group id (Internal use)
  143699. */
  143700. idxInGroup: number;
  143701. /**
  143702. * @hidden Particle BoundingInfo object (Internal use)
  143703. */
  143704. _boundingInfo: BoundingInfo;
  143705. /**
  143706. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  143707. */
  143708. _pcs: PointsCloudSystem;
  143709. /**
  143710. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  143711. */
  143712. _stillInvisible: boolean;
  143713. /**
  143714. * @hidden Last computed particle rotation matrix
  143715. */
  143716. _rotationMatrix: number[];
  143717. /**
  143718. * Parent particle Id, if any.
  143719. * Default null.
  143720. */
  143721. parentId: Nullable<number>;
  143722. /**
  143723. * @hidden Internal global position in the PCS.
  143724. */
  143725. _globalPosition: Vector3;
  143726. /**
  143727. * Creates a Point Cloud object.
  143728. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  143729. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  143730. * @param group (PointsGroup) is the group the particle belongs to
  143731. * @param groupId (integer) is the group identifier in the PCS.
  143732. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  143733. * @param pcs defines the PCS it is associated to
  143734. */
  143735. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  143736. /**
  143737. * get point size
  143738. */
  143739. get size(): Vector3;
  143740. /**
  143741. * Set point size
  143742. */
  143743. set size(scale: Vector3);
  143744. /**
  143745. * Legacy support, changed quaternion to rotationQuaternion
  143746. */
  143747. get quaternion(): Nullable<Quaternion>;
  143748. /**
  143749. * Legacy support, changed quaternion to rotationQuaternion
  143750. */
  143751. set quaternion(q: Nullable<Quaternion>);
  143752. /**
  143753. * Returns a boolean. True if the particle intersects a mesh, else false
  143754. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  143755. * @param target is the object (point or mesh) what the intersection is computed against
  143756. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  143757. * @returns true if it intersects
  143758. */
  143759. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  143760. /**
  143761. * get the rotation matrix of the particle
  143762. * @hidden
  143763. */
  143764. getRotationMatrix(m: Matrix): void;
  143765. }
  143766. /**
  143767. * Represents a group of points in a points cloud system
  143768. * * PCS internal tool, don't use it manually.
  143769. */
  143770. export class PointsGroup {
  143771. /**
  143772. * The group id
  143773. * @hidden
  143774. */
  143775. groupID: number;
  143776. /**
  143777. * image data for group (internal use)
  143778. * @hidden
  143779. */
  143780. _groupImageData: Nullable<ArrayBufferView>;
  143781. /**
  143782. * Image Width (internal use)
  143783. * @hidden
  143784. */
  143785. _groupImgWidth: number;
  143786. /**
  143787. * Image Height (internal use)
  143788. * @hidden
  143789. */
  143790. _groupImgHeight: number;
  143791. /**
  143792. * Custom position function (internal use)
  143793. * @hidden
  143794. */
  143795. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  143796. /**
  143797. * density per facet for surface points
  143798. * @hidden
  143799. */
  143800. _groupDensity: number[];
  143801. /**
  143802. * Only when points are colored by texture carries pointer to texture list array
  143803. * @hidden
  143804. */
  143805. _textureNb: number;
  143806. /**
  143807. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  143808. * PCS internal tool, don't use it manually.
  143809. * @hidden
  143810. */
  143811. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  143812. }
  143813. }
  143814. declare module BABYLON {
  143815. interface Scene {
  143816. /** @hidden (Backing field) */
  143817. _physicsEngine: Nullable<IPhysicsEngine>;
  143818. /** @hidden */
  143819. _physicsTimeAccumulator: number;
  143820. /**
  143821. * Gets the current physics engine
  143822. * @returns a IPhysicsEngine or null if none attached
  143823. */
  143824. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  143825. /**
  143826. * Enables physics to the current scene
  143827. * @param gravity defines the scene's gravity for the physics engine
  143828. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  143829. * @return a boolean indicating if the physics engine was initialized
  143830. */
  143831. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  143832. /**
  143833. * Disables and disposes the physics engine associated with the scene
  143834. */
  143835. disablePhysicsEngine(): void;
  143836. /**
  143837. * Gets a boolean indicating if there is an active physics engine
  143838. * @returns a boolean indicating if there is an active physics engine
  143839. */
  143840. isPhysicsEnabled(): boolean;
  143841. /**
  143842. * Deletes a physics compound impostor
  143843. * @param compound defines the compound to delete
  143844. */
  143845. deleteCompoundImpostor(compound: any): void;
  143846. /**
  143847. * An event triggered when physic simulation is about to be run
  143848. */
  143849. onBeforePhysicsObservable: Observable<Scene>;
  143850. /**
  143851. * An event triggered when physic simulation has been done
  143852. */
  143853. onAfterPhysicsObservable: Observable<Scene>;
  143854. }
  143855. interface AbstractMesh {
  143856. /** @hidden */
  143857. _physicsImpostor: Nullable<PhysicsImpostor>;
  143858. /**
  143859. * Gets or sets impostor used for physic simulation
  143860. * @see http://doc.babylonjs.com/features/physics_engine
  143861. */
  143862. physicsImpostor: Nullable<PhysicsImpostor>;
  143863. /**
  143864. * Gets the current physics impostor
  143865. * @see http://doc.babylonjs.com/features/physics_engine
  143866. * @returns a physics impostor or null
  143867. */
  143868. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  143869. /** Apply a physic impulse to the mesh
  143870. * @param force defines the force to apply
  143871. * @param contactPoint defines where to apply the force
  143872. * @returns the current mesh
  143873. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  143874. */
  143875. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  143876. /**
  143877. * Creates a physic joint between two meshes
  143878. * @param otherMesh defines the other mesh to use
  143879. * @param pivot1 defines the pivot to use on this mesh
  143880. * @param pivot2 defines the pivot to use on the other mesh
  143881. * @param options defines additional options (can be plugin dependent)
  143882. * @returns the current mesh
  143883. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  143884. */
  143885. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  143886. /** @hidden */
  143887. _disposePhysicsObserver: Nullable<Observer<Node>>;
  143888. }
  143889. /**
  143890. * Defines the physics engine scene component responsible to manage a physics engine
  143891. */
  143892. export class PhysicsEngineSceneComponent implements ISceneComponent {
  143893. /**
  143894. * The component name helpful to identify the component in the list of scene components.
  143895. */
  143896. readonly name: string;
  143897. /**
  143898. * The scene the component belongs to.
  143899. */
  143900. scene: Scene;
  143901. /**
  143902. * Creates a new instance of the component for the given scene
  143903. * @param scene Defines the scene to register the component in
  143904. */
  143905. constructor(scene: Scene);
  143906. /**
  143907. * Registers the component in a given scene
  143908. */
  143909. register(): void;
  143910. /**
  143911. * Rebuilds the elements related to this component in case of
  143912. * context lost for instance.
  143913. */
  143914. rebuild(): void;
  143915. /**
  143916. * Disposes the component and the associated ressources
  143917. */
  143918. dispose(): void;
  143919. }
  143920. }
  143921. declare module BABYLON {
  143922. /**
  143923. * A helper for physics simulations
  143924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143925. */
  143926. export class PhysicsHelper {
  143927. private _scene;
  143928. private _physicsEngine;
  143929. /**
  143930. * Initializes the Physics helper
  143931. * @param scene Babylon.js scene
  143932. */
  143933. constructor(scene: Scene);
  143934. /**
  143935. * Applies a radial explosion impulse
  143936. * @param origin the origin of the explosion
  143937. * @param radiusOrEventOptions the radius or the options of radial explosion
  143938. * @param strength the explosion strength
  143939. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143940. * @returns A physics radial explosion event, or null
  143941. */
  143942. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  143943. /**
  143944. * Applies a radial explosion force
  143945. * @param origin the origin of the explosion
  143946. * @param radiusOrEventOptions the radius or the options of radial explosion
  143947. * @param strength the explosion strength
  143948. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143949. * @returns A physics radial explosion event, or null
  143950. */
  143951. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  143952. /**
  143953. * Creates a gravitational field
  143954. * @param origin the origin of the explosion
  143955. * @param radiusOrEventOptions the radius or the options of radial explosion
  143956. * @param strength the explosion strength
  143957. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143958. * @returns A physics gravitational field event, or null
  143959. */
  143960. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  143961. /**
  143962. * Creates a physics updraft event
  143963. * @param origin the origin of the updraft
  143964. * @param radiusOrEventOptions the radius or the options of the updraft
  143965. * @param strength the strength of the updraft
  143966. * @param height the height of the updraft
  143967. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  143968. * @returns A physics updraft event, or null
  143969. */
  143970. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  143971. /**
  143972. * Creates a physics vortex event
  143973. * @param origin the of the vortex
  143974. * @param radiusOrEventOptions the radius or the options of the vortex
  143975. * @param strength the strength of the vortex
  143976. * @param height the height of the vortex
  143977. * @returns a Physics vortex event, or null
  143978. * A physics vortex event or null
  143979. */
  143980. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  143981. }
  143982. /**
  143983. * Represents a physics radial explosion event
  143984. */
  143985. class PhysicsRadialExplosionEvent {
  143986. private _scene;
  143987. private _options;
  143988. private _sphere;
  143989. private _dataFetched;
  143990. /**
  143991. * Initializes a radial explosioin event
  143992. * @param _scene BabylonJS scene
  143993. * @param _options The options for the vortex event
  143994. */
  143995. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  143996. /**
  143997. * Returns the data related to the radial explosion event (sphere).
  143998. * @returns The radial explosion event data
  143999. */
  144000. getData(): PhysicsRadialExplosionEventData;
  144001. /**
  144002. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  144003. * @param impostor A physics imposter
  144004. * @param origin the origin of the explosion
  144005. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  144006. */
  144007. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  144008. /**
  144009. * Triggers affecterd impostors callbacks
  144010. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  144011. */
  144012. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  144013. /**
  144014. * Disposes the sphere.
  144015. * @param force Specifies if the sphere should be disposed by force
  144016. */
  144017. dispose(force?: boolean): void;
  144018. /*** Helpers ***/
  144019. private _prepareSphere;
  144020. private _intersectsWithSphere;
  144021. }
  144022. /**
  144023. * Represents a gravitational field event
  144024. */
  144025. class PhysicsGravitationalFieldEvent {
  144026. private _physicsHelper;
  144027. private _scene;
  144028. private _origin;
  144029. private _options;
  144030. private _tickCallback;
  144031. private _sphere;
  144032. private _dataFetched;
  144033. /**
  144034. * Initializes the physics gravitational field event
  144035. * @param _physicsHelper A physics helper
  144036. * @param _scene BabylonJS scene
  144037. * @param _origin The origin position of the gravitational field event
  144038. * @param _options The options for the vortex event
  144039. */
  144040. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  144041. /**
  144042. * Returns the data related to the gravitational field event (sphere).
  144043. * @returns A gravitational field event
  144044. */
  144045. getData(): PhysicsGravitationalFieldEventData;
  144046. /**
  144047. * Enables the gravitational field.
  144048. */
  144049. enable(): void;
  144050. /**
  144051. * Disables the gravitational field.
  144052. */
  144053. disable(): void;
  144054. /**
  144055. * Disposes the sphere.
  144056. * @param force The force to dispose from the gravitational field event
  144057. */
  144058. dispose(force?: boolean): void;
  144059. private _tick;
  144060. }
  144061. /**
  144062. * Represents a physics updraft event
  144063. */
  144064. class PhysicsUpdraftEvent {
  144065. private _scene;
  144066. private _origin;
  144067. private _options;
  144068. private _physicsEngine;
  144069. private _originTop;
  144070. private _originDirection;
  144071. private _tickCallback;
  144072. private _cylinder;
  144073. private _cylinderPosition;
  144074. private _dataFetched;
  144075. /**
  144076. * Initializes the physics updraft event
  144077. * @param _scene BabylonJS scene
  144078. * @param _origin The origin position of the updraft
  144079. * @param _options The options for the updraft event
  144080. */
  144081. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  144082. /**
  144083. * Returns the data related to the updraft event (cylinder).
  144084. * @returns A physics updraft event
  144085. */
  144086. getData(): PhysicsUpdraftEventData;
  144087. /**
  144088. * Enables the updraft.
  144089. */
  144090. enable(): void;
  144091. /**
  144092. * Disables the updraft.
  144093. */
  144094. disable(): void;
  144095. /**
  144096. * Disposes the cylinder.
  144097. * @param force Specifies if the updraft should be disposed by force
  144098. */
  144099. dispose(force?: boolean): void;
  144100. private getImpostorHitData;
  144101. private _tick;
  144102. /*** Helpers ***/
  144103. private _prepareCylinder;
  144104. private _intersectsWithCylinder;
  144105. }
  144106. /**
  144107. * Represents a physics vortex event
  144108. */
  144109. class PhysicsVortexEvent {
  144110. private _scene;
  144111. private _origin;
  144112. private _options;
  144113. private _physicsEngine;
  144114. private _originTop;
  144115. private _tickCallback;
  144116. private _cylinder;
  144117. private _cylinderPosition;
  144118. private _dataFetched;
  144119. /**
  144120. * Initializes the physics vortex event
  144121. * @param _scene The BabylonJS scene
  144122. * @param _origin The origin position of the vortex
  144123. * @param _options The options for the vortex event
  144124. */
  144125. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  144126. /**
  144127. * Returns the data related to the vortex event (cylinder).
  144128. * @returns The physics vortex event data
  144129. */
  144130. getData(): PhysicsVortexEventData;
  144131. /**
  144132. * Enables the vortex.
  144133. */
  144134. enable(): void;
  144135. /**
  144136. * Disables the cortex.
  144137. */
  144138. disable(): void;
  144139. /**
  144140. * Disposes the sphere.
  144141. * @param force
  144142. */
  144143. dispose(force?: boolean): void;
  144144. private getImpostorHitData;
  144145. private _tick;
  144146. /*** Helpers ***/
  144147. private _prepareCylinder;
  144148. private _intersectsWithCylinder;
  144149. }
  144150. /**
  144151. * Options fot the radial explosion event
  144152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144153. */
  144154. export class PhysicsRadialExplosionEventOptions {
  144155. /**
  144156. * The radius of the sphere for the radial explosion.
  144157. */
  144158. radius: number;
  144159. /**
  144160. * The strenth of the explosion.
  144161. */
  144162. strength: number;
  144163. /**
  144164. * The strenght of the force in correspondence to the distance of the affected object
  144165. */
  144166. falloff: PhysicsRadialImpulseFalloff;
  144167. /**
  144168. * Sphere options for the radial explosion.
  144169. */
  144170. sphere: {
  144171. segments: number;
  144172. diameter: number;
  144173. };
  144174. /**
  144175. * Sphere options for the radial explosion.
  144176. */
  144177. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  144178. }
  144179. /**
  144180. * Options fot the updraft event
  144181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144182. */
  144183. export class PhysicsUpdraftEventOptions {
  144184. /**
  144185. * The radius of the cylinder for the vortex
  144186. */
  144187. radius: number;
  144188. /**
  144189. * The strenth of the updraft.
  144190. */
  144191. strength: number;
  144192. /**
  144193. * The height of the cylinder for the updraft.
  144194. */
  144195. height: number;
  144196. /**
  144197. * The mode for the the updraft.
  144198. */
  144199. updraftMode: PhysicsUpdraftMode;
  144200. }
  144201. /**
  144202. * Options fot the vortex event
  144203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144204. */
  144205. export class PhysicsVortexEventOptions {
  144206. /**
  144207. * The radius of the cylinder for the vortex
  144208. */
  144209. radius: number;
  144210. /**
  144211. * The strenth of the vortex.
  144212. */
  144213. strength: number;
  144214. /**
  144215. * The height of the cylinder for the vortex.
  144216. */
  144217. height: number;
  144218. /**
  144219. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  144220. */
  144221. centripetalForceThreshold: number;
  144222. /**
  144223. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  144224. */
  144225. centripetalForceMultiplier: number;
  144226. /**
  144227. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  144228. */
  144229. centrifugalForceMultiplier: number;
  144230. /**
  144231. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  144232. */
  144233. updraftForceMultiplier: number;
  144234. }
  144235. /**
  144236. * The strenght of the force in correspondence to the distance of the affected object
  144237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144238. */
  144239. export enum PhysicsRadialImpulseFalloff {
  144240. /** Defines that impulse is constant in strength across it's whole radius */
  144241. Constant = 0,
  144242. /** Defines that impulse gets weaker if it's further from the origin */
  144243. Linear = 1
  144244. }
  144245. /**
  144246. * The strength of the force in correspondence to the distance of the affected object
  144247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144248. */
  144249. export enum PhysicsUpdraftMode {
  144250. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  144251. Center = 0,
  144252. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  144253. Perpendicular = 1
  144254. }
  144255. /**
  144256. * Interface for a physics hit data
  144257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144258. */
  144259. export interface PhysicsHitData {
  144260. /**
  144261. * The force applied at the contact point
  144262. */
  144263. force: Vector3;
  144264. /**
  144265. * The contact point
  144266. */
  144267. contactPoint: Vector3;
  144268. /**
  144269. * The distance from the origin to the contact point
  144270. */
  144271. distanceFromOrigin: number;
  144272. }
  144273. /**
  144274. * Interface for radial explosion event data
  144275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144276. */
  144277. export interface PhysicsRadialExplosionEventData {
  144278. /**
  144279. * A sphere used for the radial explosion event
  144280. */
  144281. sphere: Mesh;
  144282. }
  144283. /**
  144284. * Interface for gravitational field event data
  144285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144286. */
  144287. export interface PhysicsGravitationalFieldEventData {
  144288. /**
  144289. * A sphere mesh used for the gravitational field event
  144290. */
  144291. sphere: Mesh;
  144292. }
  144293. /**
  144294. * Interface for updraft event data
  144295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144296. */
  144297. export interface PhysicsUpdraftEventData {
  144298. /**
  144299. * A cylinder used for the updraft event
  144300. */
  144301. cylinder: Mesh;
  144302. }
  144303. /**
  144304. * Interface for vortex event data
  144305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144306. */
  144307. export interface PhysicsVortexEventData {
  144308. /**
  144309. * A cylinder used for the vortex event
  144310. */
  144311. cylinder: Mesh;
  144312. }
  144313. /**
  144314. * Interface for an affected physics impostor
  144315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144316. */
  144317. export interface PhysicsAffectedImpostorWithData {
  144318. /**
  144319. * The impostor affected by the effect
  144320. */
  144321. impostor: PhysicsImpostor;
  144322. /**
  144323. * The data about the hit/horce from the explosion
  144324. */
  144325. hitData: PhysicsHitData;
  144326. }
  144327. }
  144328. declare module BABYLON {
  144329. /** @hidden */
  144330. export var blackAndWhitePixelShader: {
  144331. name: string;
  144332. shader: string;
  144333. };
  144334. }
  144335. declare module BABYLON {
  144336. /**
  144337. * Post process used to render in black and white
  144338. */
  144339. export class BlackAndWhitePostProcess extends PostProcess {
  144340. /**
  144341. * Linear about to convert he result to black and white (default: 1)
  144342. */
  144343. degree: number;
  144344. /**
  144345. * Creates a black and white post process
  144346. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  144347. * @param name The name of the effect.
  144348. * @param options The required width/height ratio to downsize to before computing the render pass.
  144349. * @param camera The camera to apply the render pass to.
  144350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144351. * @param engine The engine which the post process will be applied. (default: current engine)
  144352. * @param reusable If the post process can be reused on the same frame. (default: false)
  144353. */
  144354. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144355. }
  144356. }
  144357. declare module BABYLON {
  144358. /**
  144359. * This represents a set of one or more post processes in Babylon.
  144360. * A post process can be used to apply a shader to a texture after it is rendered.
  144361. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  144362. */
  144363. export class PostProcessRenderEffect {
  144364. private _postProcesses;
  144365. private _getPostProcesses;
  144366. private _singleInstance;
  144367. private _cameras;
  144368. private _indicesForCamera;
  144369. /**
  144370. * Name of the effect
  144371. * @hidden
  144372. */
  144373. _name: string;
  144374. /**
  144375. * Instantiates a post process render effect.
  144376. * A post process can be used to apply a shader to a texture after it is rendered.
  144377. * @param engine The engine the effect is tied to
  144378. * @param name The name of the effect
  144379. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  144380. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  144381. */
  144382. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  144383. /**
  144384. * Checks if all the post processes in the effect are supported.
  144385. */
  144386. get isSupported(): boolean;
  144387. /**
  144388. * Updates the current state of the effect
  144389. * @hidden
  144390. */
  144391. _update(): void;
  144392. /**
  144393. * Attaches the effect on cameras
  144394. * @param cameras The camera to attach to.
  144395. * @hidden
  144396. */
  144397. _attachCameras(cameras: Camera): void;
  144398. /**
  144399. * Attaches the effect on cameras
  144400. * @param cameras The camera to attach to.
  144401. * @hidden
  144402. */
  144403. _attachCameras(cameras: Camera[]): void;
  144404. /**
  144405. * Detaches the effect on cameras
  144406. * @param cameras The camera to detatch from.
  144407. * @hidden
  144408. */
  144409. _detachCameras(cameras: Camera): void;
  144410. /**
  144411. * Detatches the effect on cameras
  144412. * @param cameras The camera to detatch from.
  144413. * @hidden
  144414. */
  144415. _detachCameras(cameras: Camera[]): void;
  144416. /**
  144417. * Enables the effect on given cameras
  144418. * @param cameras The camera to enable.
  144419. * @hidden
  144420. */
  144421. _enable(cameras: Camera): void;
  144422. /**
  144423. * Enables the effect on given cameras
  144424. * @param cameras The camera to enable.
  144425. * @hidden
  144426. */
  144427. _enable(cameras: Nullable<Camera[]>): void;
  144428. /**
  144429. * Disables the effect on the given cameras
  144430. * @param cameras The camera to disable.
  144431. * @hidden
  144432. */
  144433. _disable(cameras: Camera): void;
  144434. /**
  144435. * Disables the effect on the given cameras
  144436. * @param cameras The camera to disable.
  144437. * @hidden
  144438. */
  144439. _disable(cameras: Nullable<Camera[]>): void;
  144440. /**
  144441. * Gets a list of the post processes contained in the effect.
  144442. * @param camera The camera to get the post processes on.
  144443. * @returns The list of the post processes in the effect.
  144444. */
  144445. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  144446. }
  144447. }
  144448. declare module BABYLON {
  144449. /** @hidden */
  144450. export var extractHighlightsPixelShader: {
  144451. name: string;
  144452. shader: string;
  144453. };
  144454. }
  144455. declare module BABYLON {
  144456. /**
  144457. * 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.
  144458. */
  144459. export class ExtractHighlightsPostProcess extends PostProcess {
  144460. /**
  144461. * The luminance threshold, pixels below this value will be set to black.
  144462. */
  144463. threshold: number;
  144464. /** @hidden */
  144465. _exposure: number;
  144466. /**
  144467. * Post process which has the input texture to be used when performing highlight extraction
  144468. * @hidden
  144469. */
  144470. _inputPostProcess: Nullable<PostProcess>;
  144471. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144472. }
  144473. }
  144474. declare module BABYLON {
  144475. /** @hidden */
  144476. export var bloomMergePixelShader: {
  144477. name: string;
  144478. shader: string;
  144479. };
  144480. }
  144481. declare module BABYLON {
  144482. /**
  144483. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  144484. */
  144485. export class BloomMergePostProcess extends PostProcess {
  144486. /** Weight of the bloom to be added to the original input. */
  144487. weight: number;
  144488. /**
  144489. * Creates a new instance of @see BloomMergePostProcess
  144490. * @param name The name of the effect.
  144491. * @param originalFromInput Post process which's input will be used for the merge.
  144492. * @param blurred Blurred highlights post process which's output will be used.
  144493. * @param weight Weight of the bloom to be added to the original input.
  144494. * @param options The required width/height ratio to downsize to before computing the render pass.
  144495. * @param camera The camera to apply the render pass to.
  144496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144497. * @param engine The engine which the post process will be applied. (default: current engine)
  144498. * @param reusable If the post process can be reused on the same frame. (default: false)
  144499. * @param textureType Type of textures used when performing the post process. (default: 0)
  144500. * @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)
  144501. */
  144502. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  144503. /** Weight of the bloom to be added to the original input. */
  144504. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144505. }
  144506. }
  144507. declare module BABYLON {
  144508. /**
  144509. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  144510. */
  144511. export class BloomEffect extends PostProcessRenderEffect {
  144512. private bloomScale;
  144513. /**
  144514. * @hidden Internal
  144515. */
  144516. _effects: Array<PostProcess>;
  144517. /**
  144518. * @hidden Internal
  144519. */
  144520. _downscale: ExtractHighlightsPostProcess;
  144521. private _blurX;
  144522. private _blurY;
  144523. private _merge;
  144524. /**
  144525. * The luminance threshold to find bright areas of the image to bloom.
  144526. */
  144527. get threshold(): number;
  144528. set threshold(value: number);
  144529. /**
  144530. * The strength of the bloom.
  144531. */
  144532. get weight(): number;
  144533. set weight(value: number);
  144534. /**
  144535. * Specifies the size of the bloom blur kernel, relative to the final output size
  144536. */
  144537. get kernel(): number;
  144538. set kernel(value: number);
  144539. /**
  144540. * Creates a new instance of @see BloomEffect
  144541. * @param scene The scene the effect belongs to.
  144542. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  144543. * @param bloomKernel The size of the kernel to be used when applying the blur.
  144544. * @param bloomWeight The the strength of bloom.
  144545. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  144546. * @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)
  144547. */
  144548. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  144549. /**
  144550. * Disposes each of the internal effects for a given camera.
  144551. * @param camera The camera to dispose the effect on.
  144552. */
  144553. disposeEffects(camera: Camera): void;
  144554. /**
  144555. * @hidden Internal
  144556. */
  144557. _updateEffects(): void;
  144558. /**
  144559. * Internal
  144560. * @returns if all the contained post processes are ready.
  144561. * @hidden
  144562. */
  144563. _isReady(): boolean;
  144564. }
  144565. }
  144566. declare module BABYLON {
  144567. /** @hidden */
  144568. export var chromaticAberrationPixelShader: {
  144569. name: string;
  144570. shader: string;
  144571. };
  144572. }
  144573. declare module BABYLON {
  144574. /**
  144575. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  144576. */
  144577. export class ChromaticAberrationPostProcess extends PostProcess {
  144578. /**
  144579. * The amount of seperation of rgb channels (default: 30)
  144580. */
  144581. aberrationAmount: number;
  144582. /**
  144583. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  144584. */
  144585. radialIntensity: number;
  144586. /**
  144587. * 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))
  144588. */
  144589. direction: Vector2;
  144590. /**
  144591. * 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))
  144592. */
  144593. centerPosition: Vector2;
  144594. /**
  144595. * Creates a new instance ChromaticAberrationPostProcess
  144596. * @param name The name of the effect.
  144597. * @param screenWidth The width of the screen to apply the effect on.
  144598. * @param screenHeight The height of the screen to apply the effect on.
  144599. * @param options The required width/height ratio to downsize to before computing the render pass.
  144600. * @param camera The camera to apply the render pass to.
  144601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144602. * @param engine The engine which the post process will be applied. (default: current engine)
  144603. * @param reusable If the post process can be reused on the same frame. (default: false)
  144604. * @param textureType Type of textures used when performing the post process. (default: 0)
  144605. * @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)
  144606. */
  144607. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144608. }
  144609. }
  144610. declare module BABYLON {
  144611. /** @hidden */
  144612. export var circleOfConfusionPixelShader: {
  144613. name: string;
  144614. shader: string;
  144615. };
  144616. }
  144617. declare module BABYLON {
  144618. /**
  144619. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  144620. */
  144621. export class CircleOfConfusionPostProcess extends PostProcess {
  144622. /**
  144623. * 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.
  144624. */
  144625. lensSize: number;
  144626. /**
  144627. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  144628. */
  144629. fStop: number;
  144630. /**
  144631. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  144632. */
  144633. focusDistance: number;
  144634. /**
  144635. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  144636. */
  144637. focalLength: number;
  144638. private _depthTexture;
  144639. /**
  144640. * Creates a new instance CircleOfConfusionPostProcess
  144641. * @param name The name of the effect.
  144642. * @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.
  144643. * @param options The required width/height ratio to downsize to before computing the render pass.
  144644. * @param camera The camera to apply the render pass to.
  144645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144646. * @param engine The engine which the post process will be applied. (default: current engine)
  144647. * @param reusable If the post process can be reused on the same frame. (default: false)
  144648. * @param textureType Type of textures used when performing the post process. (default: 0)
  144649. * @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)
  144650. */
  144651. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144652. /**
  144653. * 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.
  144654. */
  144655. set depthTexture(value: RenderTargetTexture);
  144656. }
  144657. }
  144658. declare module BABYLON {
  144659. /** @hidden */
  144660. export var colorCorrectionPixelShader: {
  144661. name: string;
  144662. shader: string;
  144663. };
  144664. }
  144665. declare module BABYLON {
  144666. /**
  144667. *
  144668. * This post-process allows the modification of rendered colors by using
  144669. * a 'look-up table' (LUT). This effect is also called Color Grading.
  144670. *
  144671. * The object needs to be provided an url to a texture containing the color
  144672. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  144673. * Use an image editing software to tweak the LUT to match your needs.
  144674. *
  144675. * For an example of a color LUT, see here:
  144676. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  144677. * For explanations on color grading, see here:
  144678. * @see http://udn.epicgames.com/Three/ColorGrading.html
  144679. *
  144680. */
  144681. export class ColorCorrectionPostProcess extends PostProcess {
  144682. private _colorTableTexture;
  144683. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144684. }
  144685. }
  144686. declare module BABYLON {
  144687. /** @hidden */
  144688. export var convolutionPixelShader: {
  144689. name: string;
  144690. shader: string;
  144691. };
  144692. }
  144693. declare module BABYLON {
  144694. /**
  144695. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  144696. * input texture to perform effects such as edge detection or sharpening
  144697. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  144698. */
  144699. export class ConvolutionPostProcess extends PostProcess {
  144700. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144701. kernel: number[];
  144702. /**
  144703. * Creates a new instance ConvolutionPostProcess
  144704. * @param name The name of the effect.
  144705. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  144706. * @param options The required width/height ratio to downsize to before computing the render pass.
  144707. * @param camera The camera to apply the render pass to.
  144708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144709. * @param engine The engine which the post process will be applied. (default: current engine)
  144710. * @param reusable If the post process can be reused on the same frame. (default: false)
  144711. * @param textureType Type of textures used when performing the post process. (default: 0)
  144712. */
  144713. constructor(name: string,
  144714. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144715. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144716. /**
  144717. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144718. */
  144719. static EdgeDetect0Kernel: number[];
  144720. /**
  144721. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144722. */
  144723. static EdgeDetect1Kernel: number[];
  144724. /**
  144725. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144726. */
  144727. static EdgeDetect2Kernel: number[];
  144728. /**
  144729. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144730. */
  144731. static SharpenKernel: number[];
  144732. /**
  144733. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144734. */
  144735. static EmbossKernel: number[];
  144736. /**
  144737. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144738. */
  144739. static GaussianKernel: number[];
  144740. }
  144741. }
  144742. declare module BABYLON {
  144743. /**
  144744. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  144745. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  144746. * based on samples that have a large difference in distance than the center pixel.
  144747. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  144748. */
  144749. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  144750. direction: Vector2;
  144751. /**
  144752. * Creates a new instance CircleOfConfusionPostProcess
  144753. * @param name The name of the effect.
  144754. * @param scene The scene the effect belongs to.
  144755. * @param direction The direction the blur should be applied.
  144756. * @param kernel The size of the kernel used to blur.
  144757. * @param options The required width/height ratio to downsize to before computing the render pass.
  144758. * @param camera The camera to apply the render pass to.
  144759. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  144760. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  144761. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144762. * @param engine The engine which the post process will be applied. (default: current engine)
  144763. * @param reusable If the post process can be reused on the same frame. (default: false)
  144764. * @param textureType Type of textures used when performing the post process. (default: 0)
  144765. * @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)
  144766. */
  144767. 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);
  144768. }
  144769. }
  144770. declare module BABYLON {
  144771. /** @hidden */
  144772. export var depthOfFieldMergePixelShader: {
  144773. name: string;
  144774. shader: string;
  144775. };
  144776. }
  144777. declare module BABYLON {
  144778. /**
  144779. * Options to be set when merging outputs from the default pipeline.
  144780. */
  144781. export class DepthOfFieldMergePostProcessOptions {
  144782. /**
  144783. * The original image to merge on top of
  144784. */
  144785. originalFromInput: PostProcess;
  144786. /**
  144787. * Parameters to perform the merge of the depth of field effect
  144788. */
  144789. depthOfField?: {
  144790. circleOfConfusion: PostProcess;
  144791. blurSteps: Array<PostProcess>;
  144792. };
  144793. /**
  144794. * Parameters to perform the merge of bloom effect
  144795. */
  144796. bloom?: {
  144797. blurred: PostProcess;
  144798. weight: number;
  144799. };
  144800. }
  144801. /**
  144802. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  144803. */
  144804. export class DepthOfFieldMergePostProcess extends PostProcess {
  144805. private blurSteps;
  144806. /**
  144807. * Creates a new instance of DepthOfFieldMergePostProcess
  144808. * @param name The name of the effect.
  144809. * @param originalFromInput Post process which's input will be used for the merge.
  144810. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  144811. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  144812. * @param options The required width/height ratio to downsize to before computing the render pass.
  144813. * @param camera The camera to apply the render pass to.
  144814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144815. * @param engine The engine which the post process will be applied. (default: current engine)
  144816. * @param reusable If the post process can be reused on the same frame. (default: false)
  144817. * @param textureType Type of textures used when performing the post process. (default: 0)
  144818. * @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)
  144819. */
  144820. 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);
  144821. /**
  144822. * Updates the effect with the current post process compile time values and recompiles the shader.
  144823. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  144824. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  144825. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  144826. * @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
  144827. * @param onCompiled Called when the shader has been compiled.
  144828. * @param onError Called if there is an error when compiling a shader.
  144829. */
  144830. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  144831. }
  144832. }
  144833. declare module BABYLON {
  144834. /**
  144835. * Specifies the level of max blur that should be applied when using the depth of field effect
  144836. */
  144837. export enum DepthOfFieldEffectBlurLevel {
  144838. /**
  144839. * Subtle blur
  144840. */
  144841. Low = 0,
  144842. /**
  144843. * Medium blur
  144844. */
  144845. Medium = 1,
  144846. /**
  144847. * Large blur
  144848. */
  144849. High = 2
  144850. }
  144851. /**
  144852. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  144853. */
  144854. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  144855. private _circleOfConfusion;
  144856. /**
  144857. * @hidden Internal, blurs from high to low
  144858. */
  144859. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  144860. private _depthOfFieldBlurY;
  144861. private _dofMerge;
  144862. /**
  144863. * @hidden Internal post processes in depth of field effect
  144864. */
  144865. _effects: Array<PostProcess>;
  144866. /**
  144867. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  144868. */
  144869. set focalLength(value: number);
  144870. get focalLength(): number;
  144871. /**
  144872. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  144873. */
  144874. set fStop(value: number);
  144875. get fStop(): number;
  144876. /**
  144877. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  144878. */
  144879. set focusDistance(value: number);
  144880. get focusDistance(): number;
  144881. /**
  144882. * 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.
  144883. */
  144884. set lensSize(value: number);
  144885. get lensSize(): number;
  144886. /**
  144887. * Creates a new instance DepthOfFieldEffect
  144888. * @param scene The scene the effect belongs to.
  144889. * @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.
  144890. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  144891. * @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)
  144892. */
  144893. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  144894. /**
  144895. * Get the current class name of the current effet
  144896. * @returns "DepthOfFieldEffect"
  144897. */
  144898. getClassName(): string;
  144899. /**
  144900. * 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.
  144901. */
  144902. set depthTexture(value: RenderTargetTexture);
  144903. /**
  144904. * Disposes each of the internal effects for a given camera.
  144905. * @param camera The camera to dispose the effect on.
  144906. */
  144907. disposeEffects(camera: Camera): void;
  144908. /**
  144909. * @hidden Internal
  144910. */
  144911. _updateEffects(): void;
  144912. /**
  144913. * Internal
  144914. * @returns if all the contained post processes are ready.
  144915. * @hidden
  144916. */
  144917. _isReady(): boolean;
  144918. }
  144919. }
  144920. declare module BABYLON {
  144921. /** @hidden */
  144922. export var displayPassPixelShader: {
  144923. name: string;
  144924. shader: string;
  144925. };
  144926. }
  144927. declare module BABYLON {
  144928. /**
  144929. * DisplayPassPostProcess which produces an output the same as it's input
  144930. */
  144931. export class DisplayPassPostProcess extends PostProcess {
  144932. /**
  144933. * Creates the DisplayPassPostProcess
  144934. * @param name The name of the effect.
  144935. * @param options The required width/height ratio to downsize to before computing the render pass.
  144936. * @param camera The camera to apply the render pass to.
  144937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144938. * @param engine The engine which the post process will be applied. (default: current engine)
  144939. * @param reusable If the post process can be reused on the same frame. (default: false)
  144940. */
  144941. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144942. }
  144943. }
  144944. declare module BABYLON {
  144945. /** @hidden */
  144946. export var filterPixelShader: {
  144947. name: string;
  144948. shader: string;
  144949. };
  144950. }
  144951. declare module BABYLON {
  144952. /**
  144953. * Applies a kernel filter to the image
  144954. */
  144955. export class FilterPostProcess extends PostProcess {
  144956. /** The matrix to be applied to the image */
  144957. kernelMatrix: Matrix;
  144958. /**
  144959. *
  144960. * @param name The name of the effect.
  144961. * @param kernelMatrix The matrix to be applied to the image
  144962. * @param options The required width/height ratio to downsize to before computing the render pass.
  144963. * @param camera The camera to apply the render pass to.
  144964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144965. * @param engine The engine which the post process will be applied. (default: current engine)
  144966. * @param reusable If the post process can be reused on the same frame. (default: false)
  144967. */
  144968. constructor(name: string,
  144969. /** The matrix to be applied to the image */
  144970. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144971. }
  144972. }
  144973. declare module BABYLON {
  144974. /** @hidden */
  144975. export var fxaaPixelShader: {
  144976. name: string;
  144977. shader: string;
  144978. };
  144979. }
  144980. declare module BABYLON {
  144981. /** @hidden */
  144982. export var fxaaVertexShader: {
  144983. name: string;
  144984. shader: string;
  144985. };
  144986. }
  144987. declare module BABYLON {
  144988. /**
  144989. * Fxaa post process
  144990. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  144991. */
  144992. export class FxaaPostProcess extends PostProcess {
  144993. /** @hidden */
  144994. texelWidth: number;
  144995. /** @hidden */
  144996. texelHeight: number;
  144997. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144998. private _getDefines;
  144999. }
  145000. }
  145001. declare module BABYLON {
  145002. /** @hidden */
  145003. export var grainPixelShader: {
  145004. name: string;
  145005. shader: string;
  145006. };
  145007. }
  145008. declare module BABYLON {
  145009. /**
  145010. * The GrainPostProcess adds noise to the image at mid luminance levels
  145011. */
  145012. export class GrainPostProcess extends PostProcess {
  145013. /**
  145014. * The intensity of the grain added (default: 30)
  145015. */
  145016. intensity: number;
  145017. /**
  145018. * If the grain should be randomized on every frame
  145019. */
  145020. animated: boolean;
  145021. /**
  145022. * Creates a new instance of @see GrainPostProcess
  145023. * @param name The name of the effect.
  145024. * @param options The required width/height ratio to downsize to before computing the render pass.
  145025. * @param camera The camera to apply the render pass to.
  145026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145027. * @param engine The engine which the post process will be applied. (default: current engine)
  145028. * @param reusable If the post process can be reused on the same frame. (default: false)
  145029. * @param textureType Type of textures used when performing the post process. (default: 0)
  145030. * @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)
  145031. */
  145032. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145033. }
  145034. }
  145035. declare module BABYLON {
  145036. /** @hidden */
  145037. export var highlightsPixelShader: {
  145038. name: string;
  145039. shader: string;
  145040. };
  145041. }
  145042. declare module BABYLON {
  145043. /**
  145044. * Extracts highlights from the image
  145045. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  145046. */
  145047. export class HighlightsPostProcess extends PostProcess {
  145048. /**
  145049. * Extracts highlights from the image
  145050. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  145051. * @param name The name of the effect.
  145052. * @param options The required width/height ratio to downsize to before computing the render pass.
  145053. * @param camera The camera to apply the render pass to.
  145054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145055. * @param engine The engine which the post process will be applied. (default: current engine)
  145056. * @param reusable If the post process can be reused on the same frame. (default: false)
  145057. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  145058. */
  145059. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145060. }
  145061. }
  145062. declare module BABYLON {
  145063. /** @hidden */
  145064. export var mrtFragmentDeclaration: {
  145065. name: string;
  145066. shader: string;
  145067. };
  145068. }
  145069. declare module BABYLON {
  145070. /** @hidden */
  145071. export var geometryPixelShader: {
  145072. name: string;
  145073. shader: string;
  145074. };
  145075. }
  145076. declare module BABYLON {
  145077. /** @hidden */
  145078. export var geometryVertexShader: {
  145079. name: string;
  145080. shader: string;
  145081. };
  145082. }
  145083. declare module BABYLON {
  145084. /** @hidden */
  145085. interface ISavedTransformationMatrix {
  145086. world: Matrix;
  145087. viewProjection: Matrix;
  145088. }
  145089. /**
  145090. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  145091. */
  145092. export class GeometryBufferRenderer {
  145093. /**
  145094. * Constant used to retrieve the position texture index in the G-Buffer textures array
  145095. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  145096. */
  145097. static readonly POSITION_TEXTURE_TYPE: number;
  145098. /**
  145099. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  145100. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  145101. */
  145102. static readonly VELOCITY_TEXTURE_TYPE: number;
  145103. /**
  145104. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  145105. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  145106. */
  145107. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  145108. /**
  145109. * Dictionary used to store the previous transformation matrices of each rendered mesh
  145110. * in order to compute objects velocities when enableVelocity is set to "true"
  145111. * @hidden
  145112. */
  145113. _previousTransformationMatrices: {
  145114. [index: number]: ISavedTransformationMatrix;
  145115. };
  145116. /**
  145117. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  145118. * in order to compute objects velocities when enableVelocity is set to "true"
  145119. * @hidden
  145120. */
  145121. _previousBonesTransformationMatrices: {
  145122. [index: number]: Float32Array;
  145123. };
  145124. /**
  145125. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  145126. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  145127. */
  145128. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  145129. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  145130. renderTransparentMeshes: boolean;
  145131. private _scene;
  145132. private _multiRenderTarget;
  145133. private _ratio;
  145134. private _enablePosition;
  145135. private _enableVelocity;
  145136. private _enableReflectivity;
  145137. private _positionIndex;
  145138. private _velocityIndex;
  145139. private _reflectivityIndex;
  145140. protected _effect: Effect;
  145141. protected _cachedDefines: string;
  145142. /**
  145143. * Set the render list (meshes to be rendered) used in the G buffer.
  145144. */
  145145. set renderList(meshes: Mesh[]);
  145146. /**
  145147. * Gets wether or not G buffer are supported by the running hardware.
  145148. * This requires draw buffer supports
  145149. */
  145150. get isSupported(): boolean;
  145151. /**
  145152. * Returns the index of the given texture type in the G-Buffer textures array
  145153. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  145154. * @returns the index of the given texture type in the G-Buffer textures array
  145155. */
  145156. getTextureIndex(textureType: number): number;
  145157. /**
  145158. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  145159. */
  145160. get enablePosition(): boolean;
  145161. /**
  145162. * Sets whether or not objects positions are enabled for the G buffer.
  145163. */
  145164. set enablePosition(enable: boolean);
  145165. /**
  145166. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  145167. */
  145168. get enableVelocity(): boolean;
  145169. /**
  145170. * Sets wether or not objects velocities are enabled for the G buffer.
  145171. */
  145172. set enableVelocity(enable: boolean);
  145173. /**
  145174. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  145175. */
  145176. get enableReflectivity(): boolean;
  145177. /**
  145178. * Sets wether or not objects roughness are enabled for the G buffer.
  145179. */
  145180. set enableReflectivity(enable: boolean);
  145181. /**
  145182. * Gets the scene associated with the buffer.
  145183. */
  145184. get scene(): Scene;
  145185. /**
  145186. * Gets the ratio used by the buffer during its creation.
  145187. * How big is the buffer related to the main canvas.
  145188. */
  145189. get ratio(): number;
  145190. /** @hidden */
  145191. static _SceneComponentInitialization: (scene: Scene) => void;
  145192. /**
  145193. * Creates a new G Buffer for the scene
  145194. * @param scene The scene the buffer belongs to
  145195. * @param ratio How big is the buffer related to the main canvas.
  145196. */
  145197. constructor(scene: Scene, ratio?: number);
  145198. /**
  145199. * Checks wether everything is ready to render a submesh to the G buffer.
  145200. * @param subMesh the submesh to check readiness for
  145201. * @param useInstances is the mesh drawn using instance or not
  145202. * @returns true if ready otherwise false
  145203. */
  145204. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  145205. /**
  145206. * Gets the current underlying G Buffer.
  145207. * @returns the buffer
  145208. */
  145209. getGBuffer(): MultiRenderTarget;
  145210. /**
  145211. * Gets the number of samples used to render the buffer (anti aliasing).
  145212. */
  145213. get samples(): number;
  145214. /**
  145215. * Sets the number of samples used to render the buffer (anti aliasing).
  145216. */
  145217. set samples(value: number);
  145218. /**
  145219. * Disposes the renderer and frees up associated resources.
  145220. */
  145221. dispose(): void;
  145222. protected _createRenderTargets(): void;
  145223. private _copyBonesTransformationMatrices;
  145224. }
  145225. }
  145226. declare module BABYLON {
  145227. interface Scene {
  145228. /** @hidden (Backing field) */
  145229. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  145230. /**
  145231. * Gets or Sets the current geometry buffer associated to the scene.
  145232. */
  145233. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  145234. /**
  145235. * Enables a GeometryBufferRender and associates it with the scene
  145236. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  145237. * @returns the GeometryBufferRenderer
  145238. */
  145239. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  145240. /**
  145241. * Disables the GeometryBufferRender associated with the scene
  145242. */
  145243. disableGeometryBufferRenderer(): void;
  145244. }
  145245. /**
  145246. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  145247. * in several rendering techniques.
  145248. */
  145249. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  145250. /**
  145251. * The component name helpful to identify the component in the list of scene components.
  145252. */
  145253. readonly name: string;
  145254. /**
  145255. * The scene the component belongs to.
  145256. */
  145257. scene: Scene;
  145258. /**
  145259. * Creates a new instance of the component for the given scene
  145260. * @param scene Defines the scene to register the component in
  145261. */
  145262. constructor(scene: Scene);
  145263. /**
  145264. * Registers the component in a given scene
  145265. */
  145266. register(): void;
  145267. /**
  145268. * Rebuilds the elements related to this component in case of
  145269. * context lost for instance.
  145270. */
  145271. rebuild(): void;
  145272. /**
  145273. * Disposes the component and the associated ressources
  145274. */
  145275. dispose(): void;
  145276. private _gatherRenderTargets;
  145277. }
  145278. }
  145279. declare module BABYLON {
  145280. /** @hidden */
  145281. export var motionBlurPixelShader: {
  145282. name: string;
  145283. shader: string;
  145284. };
  145285. }
  145286. declare module BABYLON {
  145287. /**
  145288. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  145289. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  145290. * As an example, all you have to do is to create the post-process:
  145291. * var mb = new BABYLON.MotionBlurPostProcess(
  145292. * 'mb', // The name of the effect.
  145293. * scene, // The scene containing the objects to blur according to their velocity.
  145294. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  145295. * camera // The camera to apply the render pass to.
  145296. * );
  145297. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  145298. */
  145299. export class MotionBlurPostProcess extends PostProcess {
  145300. /**
  145301. * Defines how much the image is blurred by the movement. Default value is equal to 1
  145302. */
  145303. motionStrength: number;
  145304. /**
  145305. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  145306. */
  145307. get motionBlurSamples(): number;
  145308. /**
  145309. * Sets the number of iterations to be used for motion blur quality
  145310. */
  145311. set motionBlurSamples(samples: number);
  145312. private _motionBlurSamples;
  145313. private _geometryBufferRenderer;
  145314. /**
  145315. * Creates a new instance MotionBlurPostProcess
  145316. * @param name The name of the effect.
  145317. * @param scene The scene containing the objects to blur according to their velocity.
  145318. * @param options The required width/height ratio to downsize to before computing the render pass.
  145319. * @param camera The camera to apply the render pass to.
  145320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145321. * @param engine The engine which the post process will be applied. (default: current engine)
  145322. * @param reusable If the post process can be reused on the same frame. (default: false)
  145323. * @param textureType Type of textures used when performing the post process. (default: 0)
  145324. * @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)
  145325. */
  145326. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145327. /**
  145328. * Excludes the given skinned mesh from computing bones velocities.
  145329. * 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.
  145330. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  145331. */
  145332. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  145333. /**
  145334. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  145335. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  145336. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  145337. */
  145338. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  145339. /**
  145340. * Disposes the post process.
  145341. * @param camera The camera to dispose the post process on.
  145342. */
  145343. dispose(camera?: Camera): void;
  145344. }
  145345. }
  145346. declare module BABYLON {
  145347. /** @hidden */
  145348. export var refractionPixelShader: {
  145349. name: string;
  145350. shader: string;
  145351. };
  145352. }
  145353. declare module BABYLON {
  145354. /**
  145355. * Post process which applies a refractin texture
  145356. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  145357. */
  145358. export class RefractionPostProcess extends PostProcess {
  145359. /** the base color of the refraction (used to taint the rendering) */
  145360. color: Color3;
  145361. /** simulated refraction depth */
  145362. depth: number;
  145363. /** the coefficient of the base color (0 to remove base color tainting) */
  145364. colorLevel: number;
  145365. private _refTexture;
  145366. private _ownRefractionTexture;
  145367. /**
  145368. * Gets or sets the refraction texture
  145369. * Please note that you are responsible for disposing the texture if you set it manually
  145370. */
  145371. get refractionTexture(): Texture;
  145372. set refractionTexture(value: Texture);
  145373. /**
  145374. * Initializes the RefractionPostProcess
  145375. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  145376. * @param name The name of the effect.
  145377. * @param refractionTextureUrl Url of the refraction texture to use
  145378. * @param color the base color of the refraction (used to taint the rendering)
  145379. * @param depth simulated refraction depth
  145380. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  145381. * @param camera The camera to apply the render pass to.
  145382. * @param options The required width/height ratio to downsize to before computing the render pass.
  145383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145384. * @param engine The engine which the post process will be applied. (default: current engine)
  145385. * @param reusable If the post process can be reused on the same frame. (default: false)
  145386. */
  145387. constructor(name: string, refractionTextureUrl: string,
  145388. /** the base color of the refraction (used to taint the rendering) */
  145389. color: Color3,
  145390. /** simulated refraction depth */
  145391. depth: number,
  145392. /** the coefficient of the base color (0 to remove base color tainting) */
  145393. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145394. /**
  145395. * Disposes of the post process
  145396. * @param camera Camera to dispose post process on
  145397. */
  145398. dispose(camera: Camera): void;
  145399. }
  145400. }
  145401. declare module BABYLON {
  145402. /** @hidden */
  145403. export var sharpenPixelShader: {
  145404. name: string;
  145405. shader: string;
  145406. };
  145407. }
  145408. declare module BABYLON {
  145409. /**
  145410. * The SharpenPostProcess applies a sharpen kernel to every pixel
  145411. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  145412. */
  145413. export class SharpenPostProcess extends PostProcess {
  145414. /**
  145415. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  145416. */
  145417. colorAmount: number;
  145418. /**
  145419. * How much sharpness should be applied (default: 0.3)
  145420. */
  145421. edgeAmount: number;
  145422. /**
  145423. * Creates a new instance ConvolutionPostProcess
  145424. * @param name The name of the effect.
  145425. * @param options The required width/height ratio to downsize to before computing the render pass.
  145426. * @param camera The camera to apply the render pass to.
  145427. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145428. * @param engine The engine which the post process will be applied. (default: current engine)
  145429. * @param reusable If the post process can be reused on the same frame. (default: false)
  145430. * @param textureType Type of textures used when performing the post process. (default: 0)
  145431. * @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)
  145432. */
  145433. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145434. }
  145435. }
  145436. declare module BABYLON {
  145437. /**
  145438. * PostProcessRenderPipeline
  145439. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145440. */
  145441. export class PostProcessRenderPipeline {
  145442. private engine;
  145443. private _renderEffects;
  145444. private _renderEffectsForIsolatedPass;
  145445. /**
  145446. * List of inspectable custom properties (used by the Inspector)
  145447. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  145448. */
  145449. inspectableCustomProperties: IInspectable[];
  145450. /**
  145451. * @hidden
  145452. */
  145453. protected _cameras: Camera[];
  145454. /** @hidden */
  145455. _name: string;
  145456. /**
  145457. * Gets pipeline name
  145458. */
  145459. get name(): string;
  145460. /** Gets the list of attached cameras */
  145461. get cameras(): Camera[];
  145462. /**
  145463. * Initializes a PostProcessRenderPipeline
  145464. * @param engine engine to add the pipeline to
  145465. * @param name name of the pipeline
  145466. */
  145467. constructor(engine: Engine, name: string);
  145468. /**
  145469. * Gets the class name
  145470. * @returns "PostProcessRenderPipeline"
  145471. */
  145472. getClassName(): string;
  145473. /**
  145474. * If all the render effects in the pipeline are supported
  145475. */
  145476. get isSupported(): boolean;
  145477. /**
  145478. * Adds an effect to the pipeline
  145479. * @param renderEffect the effect to add
  145480. */
  145481. addEffect(renderEffect: PostProcessRenderEffect): void;
  145482. /** @hidden */
  145483. _rebuild(): void;
  145484. /** @hidden */
  145485. _enableEffect(renderEffectName: string, cameras: Camera): void;
  145486. /** @hidden */
  145487. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  145488. /** @hidden */
  145489. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145490. /** @hidden */
  145491. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145492. /** @hidden */
  145493. _attachCameras(cameras: Camera, unique: boolean): void;
  145494. /** @hidden */
  145495. _attachCameras(cameras: Camera[], unique: boolean): void;
  145496. /** @hidden */
  145497. _detachCameras(cameras: Camera): void;
  145498. /** @hidden */
  145499. _detachCameras(cameras: Nullable<Camera[]>): void;
  145500. /** @hidden */
  145501. _update(): void;
  145502. /** @hidden */
  145503. _reset(): void;
  145504. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  145505. /**
  145506. * Disposes of the pipeline
  145507. */
  145508. dispose(): void;
  145509. }
  145510. }
  145511. declare module BABYLON {
  145512. /**
  145513. * PostProcessRenderPipelineManager class
  145514. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145515. */
  145516. export class PostProcessRenderPipelineManager {
  145517. private _renderPipelines;
  145518. /**
  145519. * Initializes a PostProcessRenderPipelineManager
  145520. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145521. */
  145522. constructor();
  145523. /**
  145524. * Gets the list of supported render pipelines
  145525. */
  145526. get supportedPipelines(): PostProcessRenderPipeline[];
  145527. /**
  145528. * Adds a pipeline to the manager
  145529. * @param renderPipeline The pipeline to add
  145530. */
  145531. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  145532. /**
  145533. * Attaches a camera to the pipeline
  145534. * @param renderPipelineName The name of the pipeline to attach to
  145535. * @param cameras the camera to attach
  145536. * @param unique if the camera can be attached multiple times to the pipeline
  145537. */
  145538. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  145539. /**
  145540. * Detaches a camera from the pipeline
  145541. * @param renderPipelineName The name of the pipeline to detach from
  145542. * @param cameras the camera to detach
  145543. */
  145544. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  145545. /**
  145546. * Enables an effect by name on a pipeline
  145547. * @param renderPipelineName the name of the pipeline to enable the effect in
  145548. * @param renderEffectName the name of the effect to enable
  145549. * @param cameras the cameras that the effect should be enabled on
  145550. */
  145551. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145552. /**
  145553. * Disables an effect by name on a pipeline
  145554. * @param renderPipelineName the name of the pipeline to disable the effect in
  145555. * @param renderEffectName the name of the effect to disable
  145556. * @param cameras the cameras that the effect should be disabled on
  145557. */
  145558. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145559. /**
  145560. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  145561. */
  145562. update(): void;
  145563. /** @hidden */
  145564. _rebuild(): void;
  145565. /**
  145566. * Disposes of the manager and pipelines
  145567. */
  145568. dispose(): void;
  145569. }
  145570. }
  145571. declare module BABYLON {
  145572. interface Scene {
  145573. /** @hidden (Backing field) */
  145574. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145575. /**
  145576. * Gets the postprocess render pipeline manager
  145577. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145578. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145579. */
  145580. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145581. }
  145582. /**
  145583. * Defines the Render Pipeline scene component responsible to rendering pipelines
  145584. */
  145585. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  145586. /**
  145587. * The component name helpfull to identify the component in the list of scene components.
  145588. */
  145589. readonly name: string;
  145590. /**
  145591. * The scene the component belongs to.
  145592. */
  145593. scene: Scene;
  145594. /**
  145595. * Creates a new instance of the component for the given scene
  145596. * @param scene Defines the scene to register the component in
  145597. */
  145598. constructor(scene: Scene);
  145599. /**
  145600. * Registers the component in a given scene
  145601. */
  145602. register(): void;
  145603. /**
  145604. * Rebuilds the elements related to this component in case of
  145605. * context lost for instance.
  145606. */
  145607. rebuild(): void;
  145608. /**
  145609. * Disposes the component and the associated ressources
  145610. */
  145611. dispose(): void;
  145612. private _gatherRenderTargets;
  145613. }
  145614. }
  145615. declare module BABYLON {
  145616. /**
  145617. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  145618. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145619. */
  145620. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  145621. private _scene;
  145622. private _camerasToBeAttached;
  145623. /**
  145624. * ID of the sharpen post process,
  145625. */
  145626. private readonly SharpenPostProcessId;
  145627. /**
  145628. * @ignore
  145629. * ID of the image processing post process;
  145630. */
  145631. readonly ImageProcessingPostProcessId: string;
  145632. /**
  145633. * @ignore
  145634. * ID of the Fast Approximate Anti-Aliasing post process;
  145635. */
  145636. readonly FxaaPostProcessId: string;
  145637. /**
  145638. * ID of the chromatic aberration post process,
  145639. */
  145640. private readonly ChromaticAberrationPostProcessId;
  145641. /**
  145642. * ID of the grain post process
  145643. */
  145644. private readonly GrainPostProcessId;
  145645. /**
  145646. * Sharpen post process which will apply a sharpen convolution to enhance edges
  145647. */
  145648. sharpen: SharpenPostProcess;
  145649. private _sharpenEffect;
  145650. private bloom;
  145651. /**
  145652. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  145653. */
  145654. depthOfField: DepthOfFieldEffect;
  145655. /**
  145656. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  145657. */
  145658. fxaa: FxaaPostProcess;
  145659. /**
  145660. * Image post processing pass used to perform operations such as tone mapping or color grading.
  145661. */
  145662. imageProcessing: ImageProcessingPostProcess;
  145663. /**
  145664. * Chromatic aberration post process which will shift rgb colors in the image
  145665. */
  145666. chromaticAberration: ChromaticAberrationPostProcess;
  145667. private _chromaticAberrationEffect;
  145668. /**
  145669. * Grain post process which add noise to the image
  145670. */
  145671. grain: GrainPostProcess;
  145672. private _grainEffect;
  145673. /**
  145674. * Glow post process which adds a glow to emissive areas of the image
  145675. */
  145676. private _glowLayer;
  145677. /**
  145678. * Animations which can be used to tweak settings over a period of time
  145679. */
  145680. animations: Animation[];
  145681. private _imageProcessingConfigurationObserver;
  145682. private _sharpenEnabled;
  145683. private _bloomEnabled;
  145684. private _depthOfFieldEnabled;
  145685. private _depthOfFieldBlurLevel;
  145686. private _fxaaEnabled;
  145687. private _imageProcessingEnabled;
  145688. private _defaultPipelineTextureType;
  145689. private _bloomScale;
  145690. private _chromaticAberrationEnabled;
  145691. private _grainEnabled;
  145692. private _buildAllowed;
  145693. /**
  145694. * Gets active scene
  145695. */
  145696. get scene(): Scene;
  145697. /**
  145698. * Enable or disable the sharpen process from the pipeline
  145699. */
  145700. set sharpenEnabled(enabled: boolean);
  145701. get sharpenEnabled(): boolean;
  145702. private _resizeObserver;
  145703. private _hardwareScaleLevel;
  145704. private _bloomKernel;
  145705. /**
  145706. * Specifies the size of the bloom blur kernel, relative to the final output size
  145707. */
  145708. get bloomKernel(): number;
  145709. set bloomKernel(value: number);
  145710. /**
  145711. * Specifies the weight of the bloom in the final rendering
  145712. */
  145713. private _bloomWeight;
  145714. /**
  145715. * Specifies the luma threshold for the area that will be blurred by the bloom
  145716. */
  145717. private _bloomThreshold;
  145718. private _hdr;
  145719. /**
  145720. * The strength of the bloom.
  145721. */
  145722. set bloomWeight(value: number);
  145723. get bloomWeight(): number;
  145724. /**
  145725. * The strength of the bloom.
  145726. */
  145727. set bloomThreshold(value: number);
  145728. get bloomThreshold(): number;
  145729. /**
  145730. * The scale of the bloom, lower value will provide better performance.
  145731. */
  145732. set bloomScale(value: number);
  145733. get bloomScale(): number;
  145734. /**
  145735. * Enable or disable the bloom from the pipeline
  145736. */
  145737. set bloomEnabled(enabled: boolean);
  145738. get bloomEnabled(): boolean;
  145739. private _rebuildBloom;
  145740. /**
  145741. * If the depth of field is enabled.
  145742. */
  145743. get depthOfFieldEnabled(): boolean;
  145744. set depthOfFieldEnabled(enabled: boolean);
  145745. /**
  145746. * Blur level of the depth of field effect. (Higher blur will effect performance)
  145747. */
  145748. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  145749. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  145750. /**
  145751. * If the anti aliasing is enabled.
  145752. */
  145753. set fxaaEnabled(enabled: boolean);
  145754. get fxaaEnabled(): boolean;
  145755. private _samples;
  145756. /**
  145757. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  145758. */
  145759. set samples(sampleCount: number);
  145760. get samples(): number;
  145761. /**
  145762. * If image processing is enabled.
  145763. */
  145764. set imageProcessingEnabled(enabled: boolean);
  145765. get imageProcessingEnabled(): boolean;
  145766. /**
  145767. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  145768. */
  145769. set glowLayerEnabled(enabled: boolean);
  145770. get glowLayerEnabled(): boolean;
  145771. /**
  145772. * Gets the glow layer (or null if not defined)
  145773. */
  145774. get glowLayer(): Nullable<GlowLayer>;
  145775. /**
  145776. * Enable or disable the chromaticAberration process from the pipeline
  145777. */
  145778. set chromaticAberrationEnabled(enabled: boolean);
  145779. get chromaticAberrationEnabled(): boolean;
  145780. /**
  145781. * Enable or disable the grain process from the pipeline
  145782. */
  145783. set grainEnabled(enabled: boolean);
  145784. get grainEnabled(): boolean;
  145785. /**
  145786. * @constructor
  145787. * @param name - The rendering pipeline name (default: "")
  145788. * @param hdr - If high dynamic range textures should be used (default: true)
  145789. * @param scene - The scene linked to this pipeline (default: the last created scene)
  145790. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  145791. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  145792. */
  145793. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  145794. /**
  145795. * Get the class name
  145796. * @returns "DefaultRenderingPipeline"
  145797. */
  145798. getClassName(): string;
  145799. /**
  145800. * Force the compilation of the entire pipeline.
  145801. */
  145802. prepare(): void;
  145803. private _hasCleared;
  145804. private _prevPostProcess;
  145805. private _prevPrevPostProcess;
  145806. private _setAutoClearAndTextureSharing;
  145807. private _depthOfFieldSceneObserver;
  145808. private _buildPipeline;
  145809. private _disposePostProcesses;
  145810. /**
  145811. * Adds a camera to the pipeline
  145812. * @param camera the camera to be added
  145813. */
  145814. addCamera(camera: Camera): void;
  145815. /**
  145816. * Removes a camera from the pipeline
  145817. * @param camera the camera to remove
  145818. */
  145819. removeCamera(camera: Camera): void;
  145820. /**
  145821. * Dispose of the pipeline and stop all post processes
  145822. */
  145823. dispose(): void;
  145824. /**
  145825. * Serialize the rendering pipeline (Used when exporting)
  145826. * @returns the serialized object
  145827. */
  145828. serialize(): any;
  145829. /**
  145830. * Parse the serialized pipeline
  145831. * @param source Source pipeline.
  145832. * @param scene The scene to load the pipeline to.
  145833. * @param rootUrl The URL of the serialized pipeline.
  145834. * @returns An instantiated pipeline from the serialized object.
  145835. */
  145836. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  145837. }
  145838. }
  145839. declare module BABYLON {
  145840. /** @hidden */
  145841. export var lensHighlightsPixelShader: {
  145842. name: string;
  145843. shader: string;
  145844. };
  145845. }
  145846. declare module BABYLON {
  145847. /** @hidden */
  145848. export var depthOfFieldPixelShader: {
  145849. name: string;
  145850. shader: string;
  145851. };
  145852. }
  145853. declare module BABYLON {
  145854. /**
  145855. * BABYLON.JS Chromatic Aberration GLSL Shader
  145856. * Author: Olivier Guyot
  145857. * Separates very slightly R, G and B colors on the edges of the screen
  145858. * Inspired by Francois Tarlier & Martins Upitis
  145859. */
  145860. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  145861. /**
  145862. * @ignore
  145863. * The chromatic aberration PostProcess id in the pipeline
  145864. */
  145865. LensChromaticAberrationEffect: string;
  145866. /**
  145867. * @ignore
  145868. * The highlights enhancing PostProcess id in the pipeline
  145869. */
  145870. HighlightsEnhancingEffect: string;
  145871. /**
  145872. * @ignore
  145873. * The depth-of-field PostProcess id in the pipeline
  145874. */
  145875. LensDepthOfFieldEffect: string;
  145876. private _scene;
  145877. private _depthTexture;
  145878. private _grainTexture;
  145879. private _chromaticAberrationPostProcess;
  145880. private _highlightsPostProcess;
  145881. private _depthOfFieldPostProcess;
  145882. private _edgeBlur;
  145883. private _grainAmount;
  145884. private _chromaticAberration;
  145885. private _distortion;
  145886. private _highlightsGain;
  145887. private _highlightsThreshold;
  145888. private _dofDistance;
  145889. private _dofAperture;
  145890. private _dofDarken;
  145891. private _dofPentagon;
  145892. private _blurNoise;
  145893. /**
  145894. * @constructor
  145895. *
  145896. * Effect parameters are as follow:
  145897. * {
  145898. * chromatic_aberration: number; // from 0 to x (1 for realism)
  145899. * edge_blur: number; // from 0 to x (1 for realism)
  145900. * distortion: number; // from 0 to x (1 for realism)
  145901. * grain_amount: number; // from 0 to 1
  145902. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  145903. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  145904. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  145905. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  145906. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  145907. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  145908. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  145909. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  145910. * }
  145911. * Note: if an effect parameter is unset, effect is disabled
  145912. *
  145913. * @param name The rendering pipeline name
  145914. * @param parameters - An object containing all parameters (see above)
  145915. * @param scene The scene linked to this pipeline
  145916. * @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)
  145917. * @param cameras The array of cameras that the rendering pipeline will be attached to
  145918. */
  145919. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  145920. /**
  145921. * Get the class name
  145922. * @returns "LensRenderingPipeline"
  145923. */
  145924. getClassName(): string;
  145925. /**
  145926. * Gets associated scene
  145927. */
  145928. get scene(): Scene;
  145929. /**
  145930. * Gets or sets the edge blur
  145931. */
  145932. get edgeBlur(): number;
  145933. set edgeBlur(value: number);
  145934. /**
  145935. * Gets or sets the grain amount
  145936. */
  145937. get grainAmount(): number;
  145938. set grainAmount(value: number);
  145939. /**
  145940. * Gets or sets the chromatic aberration amount
  145941. */
  145942. get chromaticAberration(): number;
  145943. set chromaticAberration(value: number);
  145944. /**
  145945. * Gets or sets the depth of field aperture
  145946. */
  145947. get dofAperture(): number;
  145948. set dofAperture(value: number);
  145949. /**
  145950. * Gets or sets the edge distortion
  145951. */
  145952. get edgeDistortion(): number;
  145953. set edgeDistortion(value: number);
  145954. /**
  145955. * Gets or sets the depth of field distortion
  145956. */
  145957. get dofDistortion(): number;
  145958. set dofDistortion(value: number);
  145959. /**
  145960. * Gets or sets the darken out of focus amount
  145961. */
  145962. get darkenOutOfFocus(): number;
  145963. set darkenOutOfFocus(value: number);
  145964. /**
  145965. * Gets or sets a boolean indicating if blur noise is enabled
  145966. */
  145967. get blurNoise(): boolean;
  145968. set blurNoise(value: boolean);
  145969. /**
  145970. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  145971. */
  145972. get pentagonBokeh(): boolean;
  145973. set pentagonBokeh(value: boolean);
  145974. /**
  145975. * Gets or sets the highlight grain amount
  145976. */
  145977. get highlightsGain(): number;
  145978. set highlightsGain(value: number);
  145979. /**
  145980. * Gets or sets the highlight threshold
  145981. */
  145982. get highlightsThreshold(): number;
  145983. set highlightsThreshold(value: number);
  145984. /**
  145985. * Sets the amount of blur at the edges
  145986. * @param amount blur amount
  145987. */
  145988. setEdgeBlur(amount: number): void;
  145989. /**
  145990. * Sets edge blur to 0
  145991. */
  145992. disableEdgeBlur(): void;
  145993. /**
  145994. * Sets the amout of grain
  145995. * @param amount Amount of grain
  145996. */
  145997. setGrainAmount(amount: number): void;
  145998. /**
  145999. * Set grain amount to 0
  146000. */
  146001. disableGrain(): void;
  146002. /**
  146003. * Sets the chromatic aberration amount
  146004. * @param amount amount of chromatic aberration
  146005. */
  146006. setChromaticAberration(amount: number): void;
  146007. /**
  146008. * Sets chromatic aberration amount to 0
  146009. */
  146010. disableChromaticAberration(): void;
  146011. /**
  146012. * Sets the EdgeDistortion amount
  146013. * @param amount amount of EdgeDistortion
  146014. */
  146015. setEdgeDistortion(amount: number): void;
  146016. /**
  146017. * Sets edge distortion to 0
  146018. */
  146019. disableEdgeDistortion(): void;
  146020. /**
  146021. * Sets the FocusDistance amount
  146022. * @param amount amount of FocusDistance
  146023. */
  146024. setFocusDistance(amount: number): void;
  146025. /**
  146026. * Disables depth of field
  146027. */
  146028. disableDepthOfField(): void;
  146029. /**
  146030. * Sets the Aperture amount
  146031. * @param amount amount of Aperture
  146032. */
  146033. setAperture(amount: number): void;
  146034. /**
  146035. * Sets the DarkenOutOfFocus amount
  146036. * @param amount amount of DarkenOutOfFocus
  146037. */
  146038. setDarkenOutOfFocus(amount: number): void;
  146039. private _pentagonBokehIsEnabled;
  146040. /**
  146041. * Creates a pentagon bokeh effect
  146042. */
  146043. enablePentagonBokeh(): void;
  146044. /**
  146045. * Disables the pentagon bokeh effect
  146046. */
  146047. disablePentagonBokeh(): void;
  146048. /**
  146049. * Enables noise blur
  146050. */
  146051. enableNoiseBlur(): void;
  146052. /**
  146053. * Disables noise blur
  146054. */
  146055. disableNoiseBlur(): void;
  146056. /**
  146057. * Sets the HighlightsGain amount
  146058. * @param amount amount of HighlightsGain
  146059. */
  146060. setHighlightsGain(amount: number): void;
  146061. /**
  146062. * Sets the HighlightsThreshold amount
  146063. * @param amount amount of HighlightsThreshold
  146064. */
  146065. setHighlightsThreshold(amount: number): void;
  146066. /**
  146067. * Disables highlights
  146068. */
  146069. disableHighlights(): void;
  146070. /**
  146071. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  146072. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  146073. */
  146074. dispose(disableDepthRender?: boolean): void;
  146075. private _createChromaticAberrationPostProcess;
  146076. private _createHighlightsPostProcess;
  146077. private _createDepthOfFieldPostProcess;
  146078. private _createGrainTexture;
  146079. }
  146080. }
  146081. declare module BABYLON {
  146082. /** @hidden */
  146083. export var ssao2PixelShader: {
  146084. name: string;
  146085. shader: string;
  146086. };
  146087. }
  146088. declare module BABYLON {
  146089. /** @hidden */
  146090. export var ssaoCombinePixelShader: {
  146091. name: string;
  146092. shader: string;
  146093. };
  146094. }
  146095. declare module BABYLON {
  146096. /**
  146097. * Render pipeline to produce ssao effect
  146098. */
  146099. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  146100. /**
  146101. * @ignore
  146102. * The PassPostProcess id in the pipeline that contains the original scene color
  146103. */
  146104. SSAOOriginalSceneColorEffect: string;
  146105. /**
  146106. * @ignore
  146107. * The SSAO PostProcess id in the pipeline
  146108. */
  146109. SSAORenderEffect: string;
  146110. /**
  146111. * @ignore
  146112. * The horizontal blur PostProcess id in the pipeline
  146113. */
  146114. SSAOBlurHRenderEffect: string;
  146115. /**
  146116. * @ignore
  146117. * The vertical blur PostProcess id in the pipeline
  146118. */
  146119. SSAOBlurVRenderEffect: string;
  146120. /**
  146121. * @ignore
  146122. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  146123. */
  146124. SSAOCombineRenderEffect: string;
  146125. /**
  146126. * The output strength of the SSAO post-process. Default value is 1.0.
  146127. */
  146128. totalStrength: number;
  146129. /**
  146130. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  146131. */
  146132. maxZ: number;
  146133. /**
  146134. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  146135. */
  146136. minZAspect: number;
  146137. private _samples;
  146138. /**
  146139. * Number of samples used for the SSAO calculations. Default value is 8
  146140. */
  146141. set samples(n: number);
  146142. get samples(): number;
  146143. private _textureSamples;
  146144. /**
  146145. * Number of samples to use for antialiasing
  146146. */
  146147. set textureSamples(n: number);
  146148. get textureSamples(): number;
  146149. /**
  146150. * Ratio object used for SSAO ratio and blur ratio
  146151. */
  146152. private _ratio;
  146153. /**
  146154. * Dynamically generated sphere sampler.
  146155. */
  146156. private _sampleSphere;
  146157. /**
  146158. * Blur filter offsets
  146159. */
  146160. private _samplerOffsets;
  146161. private _expensiveBlur;
  146162. /**
  146163. * If bilateral blur should be used
  146164. */
  146165. set expensiveBlur(b: boolean);
  146166. get expensiveBlur(): boolean;
  146167. /**
  146168. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  146169. */
  146170. radius: number;
  146171. /**
  146172. * The base color of the SSAO post-process
  146173. * The final result is "base + ssao" between [0, 1]
  146174. */
  146175. base: number;
  146176. /**
  146177. * Support test.
  146178. */
  146179. static get IsSupported(): boolean;
  146180. private _scene;
  146181. private _depthTexture;
  146182. private _normalTexture;
  146183. private _randomTexture;
  146184. private _originalColorPostProcess;
  146185. private _ssaoPostProcess;
  146186. private _blurHPostProcess;
  146187. private _blurVPostProcess;
  146188. private _ssaoCombinePostProcess;
  146189. /**
  146190. * Gets active scene
  146191. */
  146192. get scene(): Scene;
  146193. /**
  146194. * @constructor
  146195. * @param name The rendering pipeline name
  146196. * @param scene The scene linked to this pipeline
  146197. * @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 }
  146198. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146199. */
  146200. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  146201. /**
  146202. * Get the class name
  146203. * @returns "SSAO2RenderingPipeline"
  146204. */
  146205. getClassName(): string;
  146206. /**
  146207. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  146208. */
  146209. dispose(disableGeometryBufferRenderer?: boolean): void;
  146210. private _createBlurPostProcess;
  146211. /** @hidden */
  146212. _rebuild(): void;
  146213. private _bits;
  146214. private _radicalInverse_VdC;
  146215. private _hammersley;
  146216. private _hemisphereSample_uniform;
  146217. private _generateHemisphere;
  146218. private _createSSAOPostProcess;
  146219. private _createSSAOCombinePostProcess;
  146220. private _createRandomTexture;
  146221. /**
  146222. * Serialize the rendering pipeline (Used when exporting)
  146223. * @returns the serialized object
  146224. */
  146225. serialize(): any;
  146226. /**
  146227. * Parse the serialized pipeline
  146228. * @param source Source pipeline.
  146229. * @param scene The scene to load the pipeline to.
  146230. * @param rootUrl The URL of the serialized pipeline.
  146231. * @returns An instantiated pipeline from the serialized object.
  146232. */
  146233. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  146234. }
  146235. }
  146236. declare module BABYLON {
  146237. /** @hidden */
  146238. export var ssaoPixelShader: {
  146239. name: string;
  146240. shader: string;
  146241. };
  146242. }
  146243. declare module BABYLON {
  146244. /**
  146245. * Render pipeline to produce ssao effect
  146246. */
  146247. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  146248. /**
  146249. * @ignore
  146250. * The PassPostProcess id in the pipeline that contains the original scene color
  146251. */
  146252. SSAOOriginalSceneColorEffect: string;
  146253. /**
  146254. * @ignore
  146255. * The SSAO PostProcess id in the pipeline
  146256. */
  146257. SSAORenderEffect: string;
  146258. /**
  146259. * @ignore
  146260. * The horizontal blur PostProcess id in the pipeline
  146261. */
  146262. SSAOBlurHRenderEffect: string;
  146263. /**
  146264. * @ignore
  146265. * The vertical blur PostProcess id in the pipeline
  146266. */
  146267. SSAOBlurVRenderEffect: string;
  146268. /**
  146269. * @ignore
  146270. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  146271. */
  146272. SSAOCombineRenderEffect: string;
  146273. /**
  146274. * The output strength of the SSAO post-process. Default value is 1.0.
  146275. */
  146276. totalStrength: number;
  146277. /**
  146278. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  146279. */
  146280. radius: number;
  146281. /**
  146282. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  146283. * Must not be equal to fallOff and superior to fallOff.
  146284. * Default value is 0.0075
  146285. */
  146286. area: number;
  146287. /**
  146288. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  146289. * Must not be equal to area and inferior to area.
  146290. * Default value is 0.000001
  146291. */
  146292. fallOff: number;
  146293. /**
  146294. * The base color of the SSAO post-process
  146295. * The final result is "base + ssao" between [0, 1]
  146296. */
  146297. base: number;
  146298. private _scene;
  146299. private _depthTexture;
  146300. private _randomTexture;
  146301. private _originalColorPostProcess;
  146302. private _ssaoPostProcess;
  146303. private _blurHPostProcess;
  146304. private _blurVPostProcess;
  146305. private _ssaoCombinePostProcess;
  146306. private _firstUpdate;
  146307. /**
  146308. * Gets active scene
  146309. */
  146310. get scene(): Scene;
  146311. /**
  146312. * @constructor
  146313. * @param name - The rendering pipeline name
  146314. * @param scene - The scene linked to this pipeline
  146315. * @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 }
  146316. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  146317. */
  146318. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  146319. /**
  146320. * Get the class name
  146321. * @returns "SSAORenderingPipeline"
  146322. */
  146323. getClassName(): string;
  146324. /**
  146325. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  146326. */
  146327. dispose(disableDepthRender?: boolean): void;
  146328. private _createBlurPostProcess;
  146329. /** @hidden */
  146330. _rebuild(): void;
  146331. private _createSSAOPostProcess;
  146332. private _createSSAOCombinePostProcess;
  146333. private _createRandomTexture;
  146334. }
  146335. }
  146336. declare module BABYLON {
  146337. /** @hidden */
  146338. export var screenSpaceReflectionPixelShader: {
  146339. name: string;
  146340. shader: string;
  146341. };
  146342. }
  146343. declare module BABYLON {
  146344. /**
  146345. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  146346. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  146347. */
  146348. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  146349. /**
  146350. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  146351. */
  146352. threshold: number;
  146353. /**
  146354. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  146355. */
  146356. strength: number;
  146357. /**
  146358. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  146359. */
  146360. reflectionSpecularFalloffExponent: number;
  146361. /**
  146362. * 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]
  146363. */
  146364. step: number;
  146365. /**
  146366. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  146367. */
  146368. roughnessFactor: number;
  146369. private _geometryBufferRenderer;
  146370. private _enableSmoothReflections;
  146371. private _reflectionSamples;
  146372. private _smoothSteps;
  146373. /**
  146374. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  146375. * @param name The name of the effect.
  146376. * @param scene The scene containing the objects to calculate reflections.
  146377. * @param options The required width/height ratio to downsize to before computing the render pass.
  146378. * @param camera The camera to apply the render pass to.
  146379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146380. * @param engine The engine which the post process will be applied. (default: current engine)
  146381. * @param reusable If the post process can be reused on the same frame. (default: false)
  146382. * @param textureType Type of textures used when performing the post process. (default: 0)
  146383. * @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)
  146384. */
  146385. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146386. /**
  146387. * Gets wether or not smoothing reflections is enabled.
  146388. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  146389. */
  146390. get enableSmoothReflections(): boolean;
  146391. /**
  146392. * Sets wether or not smoothing reflections is enabled.
  146393. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  146394. */
  146395. set enableSmoothReflections(enabled: boolean);
  146396. /**
  146397. * Gets the number of samples taken while computing reflections. More samples count is high,
  146398. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  146399. */
  146400. get reflectionSamples(): number;
  146401. /**
  146402. * Sets the number of samples taken while computing reflections. More samples count is high,
  146403. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  146404. */
  146405. set reflectionSamples(samples: number);
  146406. /**
  146407. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  146408. * more the post-process will require GPU power and can generate a drop in FPS.
  146409. * Default value (5.0) work pretty well in all cases but can be adjusted.
  146410. */
  146411. get smoothSteps(): number;
  146412. set smoothSteps(steps: number);
  146413. private _updateEffectDefines;
  146414. }
  146415. }
  146416. declare module BABYLON {
  146417. /** @hidden */
  146418. export var standardPixelShader: {
  146419. name: string;
  146420. shader: string;
  146421. };
  146422. }
  146423. declare module BABYLON {
  146424. /**
  146425. * Standard rendering pipeline
  146426. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  146427. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  146428. */
  146429. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  146430. /**
  146431. * Public members
  146432. */
  146433. /**
  146434. * Post-process which contains the original scene color before the pipeline applies all the effects
  146435. */
  146436. originalPostProcess: Nullable<PostProcess>;
  146437. /**
  146438. * Post-process used to down scale an image x4
  146439. */
  146440. downSampleX4PostProcess: Nullable<PostProcess>;
  146441. /**
  146442. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  146443. */
  146444. brightPassPostProcess: Nullable<PostProcess>;
  146445. /**
  146446. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  146447. */
  146448. blurHPostProcesses: PostProcess[];
  146449. /**
  146450. * Post-process array storing all the vertical blur post-processes used by the pipeline
  146451. */
  146452. blurVPostProcesses: PostProcess[];
  146453. /**
  146454. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  146455. */
  146456. textureAdderPostProcess: Nullable<PostProcess>;
  146457. /**
  146458. * Post-process used to create volumetric lighting effect
  146459. */
  146460. volumetricLightPostProcess: Nullable<PostProcess>;
  146461. /**
  146462. * Post-process used to smooth the previous volumetric light post-process on the X axis
  146463. */
  146464. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  146465. /**
  146466. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  146467. */
  146468. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  146469. /**
  146470. * Post-process used to merge the volumetric light effect and the real scene color
  146471. */
  146472. volumetricLightMergePostProces: Nullable<PostProcess>;
  146473. /**
  146474. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  146475. */
  146476. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  146477. /**
  146478. * Base post-process used to calculate the average luminance of the final image for HDR
  146479. */
  146480. luminancePostProcess: Nullable<PostProcess>;
  146481. /**
  146482. * Post-processes used to create down sample post-processes in order to get
  146483. * the average luminance of the final image for HDR
  146484. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  146485. */
  146486. luminanceDownSamplePostProcesses: PostProcess[];
  146487. /**
  146488. * Post-process used to create a HDR effect (light adaptation)
  146489. */
  146490. hdrPostProcess: Nullable<PostProcess>;
  146491. /**
  146492. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  146493. */
  146494. textureAdderFinalPostProcess: Nullable<PostProcess>;
  146495. /**
  146496. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  146497. */
  146498. lensFlareFinalPostProcess: Nullable<PostProcess>;
  146499. /**
  146500. * Post-process used to merge the final HDR post-process and the real scene color
  146501. */
  146502. hdrFinalPostProcess: Nullable<PostProcess>;
  146503. /**
  146504. * Post-process used to create a lens flare effect
  146505. */
  146506. lensFlarePostProcess: Nullable<PostProcess>;
  146507. /**
  146508. * Post-process that merges the result of the lens flare post-process and the real scene color
  146509. */
  146510. lensFlareComposePostProcess: Nullable<PostProcess>;
  146511. /**
  146512. * Post-process used to create a motion blur effect
  146513. */
  146514. motionBlurPostProcess: Nullable<PostProcess>;
  146515. /**
  146516. * Post-process used to create a depth of field effect
  146517. */
  146518. depthOfFieldPostProcess: Nullable<PostProcess>;
  146519. /**
  146520. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146521. */
  146522. fxaaPostProcess: Nullable<FxaaPostProcess>;
  146523. /**
  146524. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  146525. */
  146526. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  146527. /**
  146528. * Represents the brightness threshold in order to configure the illuminated surfaces
  146529. */
  146530. brightThreshold: number;
  146531. /**
  146532. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  146533. */
  146534. blurWidth: number;
  146535. /**
  146536. * Sets if the blur for highlighted surfaces must be only horizontal
  146537. */
  146538. horizontalBlur: boolean;
  146539. /**
  146540. * Gets the overall exposure used by the pipeline
  146541. */
  146542. get exposure(): number;
  146543. /**
  146544. * Sets the overall exposure used by the pipeline
  146545. */
  146546. set exposure(value: number);
  146547. /**
  146548. * Texture used typically to simulate "dirty" on camera lens
  146549. */
  146550. lensTexture: Nullable<Texture>;
  146551. /**
  146552. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  146553. */
  146554. volumetricLightCoefficient: number;
  146555. /**
  146556. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  146557. */
  146558. volumetricLightPower: number;
  146559. /**
  146560. * Used the set the blur intensity to smooth the volumetric lights
  146561. */
  146562. volumetricLightBlurScale: number;
  146563. /**
  146564. * Light (spot or directional) used to generate the volumetric lights rays
  146565. * The source light must have a shadow generate so the pipeline can get its
  146566. * depth map
  146567. */
  146568. sourceLight: Nullable<SpotLight | DirectionalLight>;
  146569. /**
  146570. * For eye adaptation, represents the minimum luminance the eye can see
  146571. */
  146572. hdrMinimumLuminance: number;
  146573. /**
  146574. * For eye adaptation, represents the decrease luminance speed
  146575. */
  146576. hdrDecreaseRate: number;
  146577. /**
  146578. * For eye adaptation, represents the increase luminance speed
  146579. */
  146580. hdrIncreaseRate: number;
  146581. /**
  146582. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146583. */
  146584. get hdrAutoExposure(): boolean;
  146585. /**
  146586. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146587. */
  146588. set hdrAutoExposure(value: boolean);
  146589. /**
  146590. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  146591. */
  146592. lensColorTexture: Nullable<Texture>;
  146593. /**
  146594. * The overall strengh for the lens flare effect
  146595. */
  146596. lensFlareStrength: number;
  146597. /**
  146598. * Dispersion coefficient for lens flare ghosts
  146599. */
  146600. lensFlareGhostDispersal: number;
  146601. /**
  146602. * Main lens flare halo width
  146603. */
  146604. lensFlareHaloWidth: number;
  146605. /**
  146606. * Based on the lens distortion effect, defines how much the lens flare result
  146607. * is distorted
  146608. */
  146609. lensFlareDistortionStrength: number;
  146610. /**
  146611. * Configures the blur intensity used for for lens flare (halo)
  146612. */
  146613. lensFlareBlurWidth: number;
  146614. /**
  146615. * Lens star texture must be used to simulate rays on the flares and is available
  146616. * in the documentation
  146617. */
  146618. lensStarTexture: Nullable<Texture>;
  146619. /**
  146620. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  146621. * flare effect by taking account of the dirt texture
  146622. */
  146623. lensFlareDirtTexture: Nullable<Texture>;
  146624. /**
  146625. * Represents the focal length for the depth of field effect
  146626. */
  146627. depthOfFieldDistance: number;
  146628. /**
  146629. * Represents the blur intensity for the blurred part of the depth of field effect
  146630. */
  146631. depthOfFieldBlurWidth: number;
  146632. /**
  146633. * Gets how much the image is blurred by the movement while using the motion blur post-process
  146634. */
  146635. get motionStrength(): number;
  146636. /**
  146637. * Sets how much the image is blurred by the movement while using the motion blur post-process
  146638. */
  146639. set motionStrength(strength: number);
  146640. /**
  146641. * Gets wether or not the motion blur post-process is object based or screen based.
  146642. */
  146643. get objectBasedMotionBlur(): boolean;
  146644. /**
  146645. * Sets wether or not the motion blur post-process should be object based or screen based
  146646. */
  146647. set objectBasedMotionBlur(value: boolean);
  146648. /**
  146649. * List of animations for the pipeline (IAnimatable implementation)
  146650. */
  146651. animations: Animation[];
  146652. /**
  146653. * Private members
  146654. */
  146655. private _scene;
  146656. private _currentDepthOfFieldSource;
  146657. private _basePostProcess;
  146658. private _fixedExposure;
  146659. private _currentExposure;
  146660. private _hdrAutoExposure;
  146661. private _hdrCurrentLuminance;
  146662. private _motionStrength;
  146663. private _isObjectBasedMotionBlur;
  146664. private _floatTextureType;
  146665. private _camerasToBeAttached;
  146666. private _ratio;
  146667. private _bloomEnabled;
  146668. private _depthOfFieldEnabled;
  146669. private _vlsEnabled;
  146670. private _lensFlareEnabled;
  146671. private _hdrEnabled;
  146672. private _motionBlurEnabled;
  146673. private _fxaaEnabled;
  146674. private _screenSpaceReflectionsEnabled;
  146675. private _motionBlurSamples;
  146676. private _volumetricLightStepsCount;
  146677. private _samples;
  146678. /**
  146679. * @ignore
  146680. * Specifies if the bloom pipeline is enabled
  146681. */
  146682. get BloomEnabled(): boolean;
  146683. set BloomEnabled(enabled: boolean);
  146684. /**
  146685. * @ignore
  146686. * Specifies if the depth of field pipeline is enabed
  146687. */
  146688. get DepthOfFieldEnabled(): boolean;
  146689. set DepthOfFieldEnabled(enabled: boolean);
  146690. /**
  146691. * @ignore
  146692. * Specifies if the lens flare pipeline is enabed
  146693. */
  146694. get LensFlareEnabled(): boolean;
  146695. set LensFlareEnabled(enabled: boolean);
  146696. /**
  146697. * @ignore
  146698. * Specifies if the HDR pipeline is enabled
  146699. */
  146700. get HDREnabled(): boolean;
  146701. set HDREnabled(enabled: boolean);
  146702. /**
  146703. * @ignore
  146704. * Specifies if the volumetric lights scattering effect is enabled
  146705. */
  146706. get VLSEnabled(): boolean;
  146707. set VLSEnabled(enabled: boolean);
  146708. /**
  146709. * @ignore
  146710. * Specifies if the motion blur effect is enabled
  146711. */
  146712. get MotionBlurEnabled(): boolean;
  146713. set MotionBlurEnabled(enabled: boolean);
  146714. /**
  146715. * Specifies if anti-aliasing is enabled
  146716. */
  146717. get fxaaEnabled(): boolean;
  146718. set fxaaEnabled(enabled: boolean);
  146719. /**
  146720. * Specifies if screen space reflections are enabled.
  146721. */
  146722. get screenSpaceReflectionsEnabled(): boolean;
  146723. set screenSpaceReflectionsEnabled(enabled: boolean);
  146724. /**
  146725. * Specifies the number of steps used to calculate the volumetric lights
  146726. * Typically in interval [50, 200]
  146727. */
  146728. get volumetricLightStepsCount(): number;
  146729. set volumetricLightStepsCount(count: number);
  146730. /**
  146731. * Specifies the number of samples used for the motion blur effect
  146732. * Typically in interval [16, 64]
  146733. */
  146734. get motionBlurSamples(): number;
  146735. set motionBlurSamples(samples: number);
  146736. /**
  146737. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  146738. */
  146739. get samples(): number;
  146740. set samples(sampleCount: number);
  146741. /**
  146742. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  146743. * @constructor
  146744. * @param name The rendering pipeline name
  146745. * @param scene The scene linked to this pipeline
  146746. * @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)
  146747. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  146748. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146749. */
  146750. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  146751. private _buildPipeline;
  146752. private _createDownSampleX4PostProcess;
  146753. private _createBrightPassPostProcess;
  146754. private _createBlurPostProcesses;
  146755. private _createTextureAdderPostProcess;
  146756. private _createVolumetricLightPostProcess;
  146757. private _createLuminancePostProcesses;
  146758. private _createHdrPostProcess;
  146759. private _createLensFlarePostProcess;
  146760. private _createDepthOfFieldPostProcess;
  146761. private _createMotionBlurPostProcess;
  146762. private _getDepthTexture;
  146763. private _disposePostProcesses;
  146764. /**
  146765. * Dispose of the pipeline and stop all post processes
  146766. */
  146767. dispose(): void;
  146768. /**
  146769. * Serialize the rendering pipeline (Used when exporting)
  146770. * @returns the serialized object
  146771. */
  146772. serialize(): any;
  146773. /**
  146774. * Parse the serialized pipeline
  146775. * @param source Source pipeline.
  146776. * @param scene The scene to load the pipeline to.
  146777. * @param rootUrl The URL of the serialized pipeline.
  146778. * @returns An instantiated pipeline from the serialized object.
  146779. */
  146780. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  146781. /**
  146782. * Luminance steps
  146783. */
  146784. static LuminanceSteps: number;
  146785. }
  146786. }
  146787. declare module BABYLON {
  146788. /** @hidden */
  146789. export var stereoscopicInterlacePixelShader: {
  146790. name: string;
  146791. shader: string;
  146792. };
  146793. }
  146794. declare module BABYLON {
  146795. /**
  146796. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  146797. */
  146798. export class StereoscopicInterlacePostProcessI extends PostProcess {
  146799. private _stepSize;
  146800. private _passedProcess;
  146801. /**
  146802. * Initializes a StereoscopicInterlacePostProcessI
  146803. * @param name The name of the effect.
  146804. * @param rigCameras The rig cameras to be appled to the post process
  146805. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  146806. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  146807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146808. * @param engine The engine which the post process will be applied. (default: current engine)
  146809. * @param reusable If the post process can be reused on the same frame. (default: false)
  146810. */
  146811. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146812. }
  146813. /**
  146814. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  146815. */
  146816. export class StereoscopicInterlacePostProcess extends PostProcess {
  146817. private _stepSize;
  146818. private _passedProcess;
  146819. /**
  146820. * Initializes a StereoscopicInterlacePostProcess
  146821. * @param name The name of the effect.
  146822. * @param rigCameras The rig cameras to be appled to the post process
  146823. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  146824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146825. * @param engine The engine which the post process will be applied. (default: current engine)
  146826. * @param reusable If the post process can be reused on the same frame. (default: false)
  146827. */
  146828. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146829. }
  146830. }
  146831. declare module BABYLON {
  146832. /** @hidden */
  146833. export var tonemapPixelShader: {
  146834. name: string;
  146835. shader: string;
  146836. };
  146837. }
  146838. declare module BABYLON {
  146839. /** Defines operator used for tonemapping */
  146840. export enum TonemappingOperator {
  146841. /** Hable */
  146842. Hable = 0,
  146843. /** Reinhard */
  146844. Reinhard = 1,
  146845. /** HejiDawson */
  146846. HejiDawson = 2,
  146847. /** Photographic */
  146848. Photographic = 3
  146849. }
  146850. /**
  146851. * Defines a post process to apply tone mapping
  146852. */
  146853. export class TonemapPostProcess extends PostProcess {
  146854. private _operator;
  146855. /** Defines the required exposure adjustement */
  146856. exposureAdjustment: number;
  146857. /**
  146858. * Creates a new TonemapPostProcess
  146859. * @param name defines the name of the postprocess
  146860. * @param _operator defines the operator to use
  146861. * @param exposureAdjustment defines the required exposure adjustement
  146862. * @param camera defines the camera to use (can be null)
  146863. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  146864. * @param engine defines the hosting engine (can be ignore if camera is set)
  146865. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  146866. */
  146867. constructor(name: string, _operator: TonemappingOperator,
  146868. /** Defines the required exposure adjustement */
  146869. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  146870. }
  146871. }
  146872. declare module BABYLON {
  146873. /** @hidden */
  146874. export var volumetricLightScatteringPixelShader: {
  146875. name: string;
  146876. shader: string;
  146877. };
  146878. }
  146879. declare module BABYLON {
  146880. /** @hidden */
  146881. export var volumetricLightScatteringPassVertexShader: {
  146882. name: string;
  146883. shader: string;
  146884. };
  146885. }
  146886. declare module BABYLON {
  146887. /** @hidden */
  146888. export var volumetricLightScatteringPassPixelShader: {
  146889. name: string;
  146890. shader: string;
  146891. };
  146892. }
  146893. declare module BABYLON {
  146894. /**
  146895. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  146896. */
  146897. export class VolumetricLightScatteringPostProcess extends PostProcess {
  146898. private _volumetricLightScatteringPass;
  146899. private _volumetricLightScatteringRTT;
  146900. private _viewPort;
  146901. private _screenCoordinates;
  146902. private _cachedDefines;
  146903. /**
  146904. * If not undefined, the mesh position is computed from the attached node position
  146905. */
  146906. attachedNode: {
  146907. position: Vector3;
  146908. };
  146909. /**
  146910. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  146911. */
  146912. customMeshPosition: Vector3;
  146913. /**
  146914. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  146915. */
  146916. useCustomMeshPosition: boolean;
  146917. /**
  146918. * If the post-process should inverse the light scattering direction
  146919. */
  146920. invert: boolean;
  146921. /**
  146922. * The internal mesh used by the post-process
  146923. */
  146924. mesh: Mesh;
  146925. /**
  146926. * @hidden
  146927. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  146928. */
  146929. get useDiffuseColor(): boolean;
  146930. set useDiffuseColor(useDiffuseColor: boolean);
  146931. /**
  146932. * Array containing the excluded meshes not rendered in the internal pass
  146933. */
  146934. excludedMeshes: AbstractMesh[];
  146935. /**
  146936. * Controls the overall intensity of the post-process
  146937. */
  146938. exposure: number;
  146939. /**
  146940. * Dissipates each sample's contribution in range [0, 1]
  146941. */
  146942. decay: number;
  146943. /**
  146944. * Controls the overall intensity of each sample
  146945. */
  146946. weight: number;
  146947. /**
  146948. * Controls the density of each sample
  146949. */
  146950. density: number;
  146951. /**
  146952. * @constructor
  146953. * @param name The post-process name
  146954. * @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)
  146955. * @param camera The camera that the post-process will be attached to
  146956. * @param mesh The mesh used to create the light scattering
  146957. * @param samples The post-process quality, default 100
  146958. * @param samplingModeThe post-process filtering mode
  146959. * @param engine The babylon engine
  146960. * @param reusable If the post-process is reusable
  146961. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  146962. */
  146963. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  146964. /**
  146965. * Returns the string "VolumetricLightScatteringPostProcess"
  146966. * @returns "VolumetricLightScatteringPostProcess"
  146967. */
  146968. getClassName(): string;
  146969. private _isReady;
  146970. /**
  146971. * Sets the new light position for light scattering effect
  146972. * @param position The new custom light position
  146973. */
  146974. setCustomMeshPosition(position: Vector3): void;
  146975. /**
  146976. * Returns the light position for light scattering effect
  146977. * @return Vector3 The custom light position
  146978. */
  146979. getCustomMeshPosition(): Vector3;
  146980. /**
  146981. * Disposes the internal assets and detaches the post-process from the camera
  146982. */
  146983. dispose(camera: Camera): void;
  146984. /**
  146985. * Returns the render target texture used by the post-process
  146986. * @return the render target texture used by the post-process
  146987. */
  146988. getPass(): RenderTargetTexture;
  146989. private _meshExcluded;
  146990. private _createPass;
  146991. private _updateMeshScreenCoordinates;
  146992. /**
  146993. * Creates a default mesh for the Volumeric Light Scattering post-process
  146994. * @param name The mesh name
  146995. * @param scene The scene where to create the mesh
  146996. * @return the default mesh
  146997. */
  146998. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  146999. }
  147000. }
  147001. declare module BABYLON {
  147002. interface Scene {
  147003. /** @hidden (Backing field) */
  147004. _boundingBoxRenderer: BoundingBoxRenderer;
  147005. /** @hidden (Backing field) */
  147006. _forceShowBoundingBoxes: boolean;
  147007. /**
  147008. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  147009. */
  147010. forceShowBoundingBoxes: boolean;
  147011. /**
  147012. * Gets the bounding box renderer associated with the scene
  147013. * @returns a BoundingBoxRenderer
  147014. */
  147015. getBoundingBoxRenderer(): BoundingBoxRenderer;
  147016. }
  147017. interface AbstractMesh {
  147018. /** @hidden (Backing field) */
  147019. _showBoundingBox: boolean;
  147020. /**
  147021. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  147022. */
  147023. showBoundingBox: boolean;
  147024. }
  147025. /**
  147026. * Component responsible of rendering the bounding box of the meshes in a scene.
  147027. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  147028. */
  147029. export class BoundingBoxRenderer implements ISceneComponent {
  147030. /**
  147031. * The component name helpfull to identify the component in the list of scene components.
  147032. */
  147033. readonly name: string;
  147034. /**
  147035. * The scene the component belongs to.
  147036. */
  147037. scene: Scene;
  147038. /**
  147039. * Color of the bounding box lines placed in front of an object
  147040. */
  147041. frontColor: Color3;
  147042. /**
  147043. * Color of the bounding box lines placed behind an object
  147044. */
  147045. backColor: Color3;
  147046. /**
  147047. * Defines if the renderer should show the back lines or not
  147048. */
  147049. showBackLines: boolean;
  147050. /**
  147051. * Observable raised before rendering a bounding box
  147052. */
  147053. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  147054. /**
  147055. * Observable raised after rendering a bounding box
  147056. */
  147057. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  147058. /**
  147059. * @hidden
  147060. */
  147061. renderList: SmartArray<BoundingBox>;
  147062. private _colorShader;
  147063. private _vertexBuffers;
  147064. private _indexBuffer;
  147065. private _fillIndexBuffer;
  147066. private _fillIndexData;
  147067. /**
  147068. * Instantiates a new bounding box renderer in a scene.
  147069. * @param scene the scene the renderer renders in
  147070. */
  147071. constructor(scene: Scene);
  147072. /**
  147073. * Registers the component in a given scene
  147074. */
  147075. register(): void;
  147076. private _evaluateSubMesh;
  147077. private _activeMesh;
  147078. private _prepareRessources;
  147079. private _createIndexBuffer;
  147080. /**
  147081. * Rebuilds the elements related to this component in case of
  147082. * context lost for instance.
  147083. */
  147084. rebuild(): void;
  147085. /**
  147086. * @hidden
  147087. */
  147088. reset(): void;
  147089. /**
  147090. * Render the bounding boxes of a specific rendering group
  147091. * @param renderingGroupId defines the rendering group to render
  147092. */
  147093. render(renderingGroupId: number): void;
  147094. /**
  147095. * In case of occlusion queries, we can render the occlusion bounding box through this method
  147096. * @param mesh Define the mesh to render the occlusion bounding box for
  147097. */
  147098. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  147099. /**
  147100. * Dispose and release the resources attached to this renderer.
  147101. */
  147102. dispose(): void;
  147103. }
  147104. }
  147105. declare module BABYLON {
  147106. interface Scene {
  147107. /** @hidden (Backing field) */
  147108. _depthRenderer: {
  147109. [id: string]: DepthRenderer;
  147110. };
  147111. /**
  147112. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  147113. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  147114. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  147115. * @returns the created depth renderer
  147116. */
  147117. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  147118. /**
  147119. * Disables a depth renderer for a given camera
  147120. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  147121. */
  147122. disableDepthRenderer(camera?: Nullable<Camera>): void;
  147123. }
  147124. /**
  147125. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  147126. * in several rendering techniques.
  147127. */
  147128. export class DepthRendererSceneComponent implements ISceneComponent {
  147129. /**
  147130. * The component name helpfull to identify the component in the list of scene components.
  147131. */
  147132. readonly name: string;
  147133. /**
  147134. * The scene the component belongs to.
  147135. */
  147136. scene: Scene;
  147137. /**
  147138. * Creates a new instance of the component for the given scene
  147139. * @param scene Defines the scene to register the component in
  147140. */
  147141. constructor(scene: Scene);
  147142. /**
  147143. * Registers the component in a given scene
  147144. */
  147145. register(): void;
  147146. /**
  147147. * Rebuilds the elements related to this component in case of
  147148. * context lost for instance.
  147149. */
  147150. rebuild(): void;
  147151. /**
  147152. * Disposes the component and the associated ressources
  147153. */
  147154. dispose(): void;
  147155. private _gatherRenderTargets;
  147156. private _gatherActiveCameraRenderTargets;
  147157. }
  147158. }
  147159. declare module BABYLON {
  147160. /** @hidden */
  147161. export var outlinePixelShader: {
  147162. name: string;
  147163. shader: string;
  147164. };
  147165. }
  147166. declare module BABYLON {
  147167. /** @hidden */
  147168. export var outlineVertexShader: {
  147169. name: string;
  147170. shader: string;
  147171. };
  147172. }
  147173. declare module BABYLON {
  147174. interface Scene {
  147175. /** @hidden */
  147176. _outlineRenderer: OutlineRenderer;
  147177. /**
  147178. * Gets the outline renderer associated with the scene
  147179. * @returns a OutlineRenderer
  147180. */
  147181. getOutlineRenderer(): OutlineRenderer;
  147182. }
  147183. interface AbstractMesh {
  147184. /** @hidden (Backing field) */
  147185. _renderOutline: boolean;
  147186. /**
  147187. * Gets or sets a boolean indicating if the outline must be rendered as well
  147188. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  147189. */
  147190. renderOutline: boolean;
  147191. /** @hidden (Backing field) */
  147192. _renderOverlay: boolean;
  147193. /**
  147194. * Gets or sets a boolean indicating if the overlay must be rendered as well
  147195. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  147196. */
  147197. renderOverlay: boolean;
  147198. }
  147199. /**
  147200. * This class is responsible to draw bothe outline/overlay of meshes.
  147201. * It should not be used directly but through the available method on mesh.
  147202. */
  147203. export class OutlineRenderer implements ISceneComponent {
  147204. /**
  147205. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  147206. */
  147207. private static _StencilReference;
  147208. /**
  147209. * The name of the component. Each component must have a unique name.
  147210. */
  147211. name: string;
  147212. /**
  147213. * The scene the component belongs to.
  147214. */
  147215. scene: Scene;
  147216. /**
  147217. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  147218. */
  147219. zOffset: number;
  147220. private _engine;
  147221. private _effect;
  147222. private _cachedDefines;
  147223. private _savedDepthWrite;
  147224. /**
  147225. * Instantiates a new outline renderer. (There could be only one per scene).
  147226. * @param scene Defines the scene it belongs to
  147227. */
  147228. constructor(scene: Scene);
  147229. /**
  147230. * Register the component to one instance of a scene.
  147231. */
  147232. register(): void;
  147233. /**
  147234. * Rebuilds the elements related to this component in case of
  147235. * context lost for instance.
  147236. */
  147237. rebuild(): void;
  147238. /**
  147239. * Disposes the component and the associated ressources.
  147240. */
  147241. dispose(): void;
  147242. /**
  147243. * Renders the outline in the canvas.
  147244. * @param subMesh Defines the sumesh to render
  147245. * @param batch Defines the batch of meshes in case of instances
  147246. * @param useOverlay Defines if the rendering is for the overlay or the outline
  147247. */
  147248. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  147249. /**
  147250. * Returns whether or not the outline renderer is ready for a given submesh.
  147251. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  147252. * @param subMesh Defines the submesh to check readyness for
  147253. * @param useInstances Defines wheter wee are trying to render instances or not
  147254. * @returns true if ready otherwise false
  147255. */
  147256. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147257. private _beforeRenderingMesh;
  147258. private _afterRenderingMesh;
  147259. }
  147260. }
  147261. declare module BABYLON {
  147262. /**
  147263. * Defines the basic options interface of a Sprite Frame Source Size.
  147264. */
  147265. export interface ISpriteJSONSpriteSourceSize {
  147266. /**
  147267. * number of the original width of the Frame
  147268. */
  147269. w: number;
  147270. /**
  147271. * number of the original height of the Frame
  147272. */
  147273. h: number;
  147274. }
  147275. /**
  147276. * Defines the basic options interface of a Sprite Frame Data.
  147277. */
  147278. export interface ISpriteJSONSpriteFrameData {
  147279. /**
  147280. * number of the x offset of the Frame
  147281. */
  147282. x: number;
  147283. /**
  147284. * number of the y offset of the Frame
  147285. */
  147286. y: number;
  147287. /**
  147288. * number of the width of the Frame
  147289. */
  147290. w: number;
  147291. /**
  147292. * number of the height of the Frame
  147293. */
  147294. h: number;
  147295. }
  147296. /**
  147297. * Defines the basic options interface of a JSON Sprite.
  147298. */
  147299. export interface ISpriteJSONSprite {
  147300. /**
  147301. * string name of the Frame
  147302. */
  147303. filename: string;
  147304. /**
  147305. * ISpriteJSONSpriteFrame basic object of the frame data
  147306. */
  147307. frame: ISpriteJSONSpriteFrameData;
  147308. /**
  147309. * boolean to flag is the frame was rotated.
  147310. */
  147311. rotated: boolean;
  147312. /**
  147313. * boolean to flag is the frame was trimmed.
  147314. */
  147315. trimmed: boolean;
  147316. /**
  147317. * ISpriteJSONSpriteFrame basic object of the source data
  147318. */
  147319. spriteSourceSize: ISpriteJSONSpriteFrameData;
  147320. /**
  147321. * ISpriteJSONSpriteFrame basic object of the source data
  147322. */
  147323. sourceSize: ISpriteJSONSpriteSourceSize;
  147324. }
  147325. /**
  147326. * Defines the basic options interface of a JSON atlas.
  147327. */
  147328. export interface ISpriteJSONAtlas {
  147329. /**
  147330. * Array of objects that contain the frame data.
  147331. */
  147332. frames: Array<ISpriteJSONSprite>;
  147333. /**
  147334. * object basic object containing the sprite meta data.
  147335. */
  147336. meta?: object;
  147337. }
  147338. }
  147339. declare module BABYLON {
  147340. /** @hidden */
  147341. export var spriteMapPixelShader: {
  147342. name: string;
  147343. shader: string;
  147344. };
  147345. }
  147346. declare module BABYLON {
  147347. /** @hidden */
  147348. export var spriteMapVertexShader: {
  147349. name: string;
  147350. shader: string;
  147351. };
  147352. }
  147353. declare module BABYLON {
  147354. /**
  147355. * Defines the basic options interface of a SpriteMap
  147356. */
  147357. export interface ISpriteMapOptions {
  147358. /**
  147359. * Vector2 of the number of cells in the grid.
  147360. */
  147361. stageSize?: Vector2;
  147362. /**
  147363. * Vector2 of the size of the output plane in World Units.
  147364. */
  147365. outputSize?: Vector2;
  147366. /**
  147367. * Vector3 of the position of the output plane in World Units.
  147368. */
  147369. outputPosition?: Vector3;
  147370. /**
  147371. * Vector3 of the rotation of the output plane.
  147372. */
  147373. outputRotation?: Vector3;
  147374. /**
  147375. * number of layers that the system will reserve in resources.
  147376. */
  147377. layerCount?: number;
  147378. /**
  147379. * number of max animation frames a single cell will reserve in resources.
  147380. */
  147381. maxAnimationFrames?: number;
  147382. /**
  147383. * number cell index of the base tile when the system compiles.
  147384. */
  147385. baseTile?: number;
  147386. /**
  147387. * boolean flip the sprite after its been repositioned by the framing data.
  147388. */
  147389. flipU?: boolean;
  147390. /**
  147391. * Vector3 scalar of the global RGB values of the SpriteMap.
  147392. */
  147393. colorMultiply?: Vector3;
  147394. }
  147395. /**
  147396. * Defines the IDisposable interface in order to be cleanable from resources.
  147397. */
  147398. export interface ISpriteMap extends IDisposable {
  147399. /**
  147400. * String name of the SpriteMap.
  147401. */
  147402. name: string;
  147403. /**
  147404. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  147405. */
  147406. atlasJSON: ISpriteJSONAtlas;
  147407. /**
  147408. * Texture of the SpriteMap.
  147409. */
  147410. spriteSheet: Texture;
  147411. /**
  147412. * The parameters to initialize the SpriteMap with.
  147413. */
  147414. options: ISpriteMapOptions;
  147415. }
  147416. /**
  147417. * Class used to manage a grid restricted sprite deployment on an Output plane.
  147418. */
  147419. export class SpriteMap implements ISpriteMap {
  147420. /** The Name of the spriteMap */
  147421. name: string;
  147422. /** The JSON file with the frame and meta data */
  147423. atlasJSON: ISpriteJSONAtlas;
  147424. /** The systems Sprite Sheet Texture */
  147425. spriteSheet: Texture;
  147426. /** Arguments passed with the Constructor */
  147427. options: ISpriteMapOptions;
  147428. /** Public Sprite Storage array, parsed from atlasJSON */
  147429. sprites: Array<ISpriteJSONSprite>;
  147430. /** Returns the Number of Sprites in the System */
  147431. get spriteCount(): number;
  147432. /** Returns the Position of Output Plane*/
  147433. get position(): Vector3;
  147434. /** Returns the Position of Output Plane*/
  147435. set position(v: Vector3);
  147436. /** Returns the Rotation of Output Plane*/
  147437. get rotation(): Vector3;
  147438. /** Returns the Rotation of Output Plane*/
  147439. set rotation(v: Vector3);
  147440. /** Sets the AnimationMap*/
  147441. get animationMap(): RawTexture;
  147442. /** Sets the AnimationMap*/
  147443. set animationMap(v: RawTexture);
  147444. /** Scene that the SpriteMap was created in */
  147445. private _scene;
  147446. /** Texture Buffer of Float32 that holds tile frame data*/
  147447. private _frameMap;
  147448. /** Texture Buffers of Float32 that holds tileMap data*/
  147449. private _tileMaps;
  147450. /** Texture Buffer of Float32 that holds Animation Data*/
  147451. private _animationMap;
  147452. /** Custom ShaderMaterial Central to the System*/
  147453. private _material;
  147454. /** Custom ShaderMaterial Central to the System*/
  147455. private _output;
  147456. /** Systems Time Ticker*/
  147457. private _time;
  147458. /**
  147459. * Creates a new SpriteMap
  147460. * @param name defines the SpriteMaps Name
  147461. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  147462. * @param spriteSheet is the Texture that the Sprites are on.
  147463. * @param options a basic deployment configuration
  147464. * @param scene The Scene that the map is deployed on
  147465. */
  147466. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  147467. /**
  147468. * Returns tileID location
  147469. * @returns Vector2 the cell position ID
  147470. */
  147471. getTileID(): Vector2;
  147472. /**
  147473. * Gets the UV location of the mouse over the SpriteMap.
  147474. * @returns Vector2 the UV position of the mouse interaction
  147475. */
  147476. getMousePosition(): Vector2;
  147477. /**
  147478. * Creates the "frame" texture Buffer
  147479. * -------------------------------------
  147480. * Structure of frames
  147481. * "filename": "Falling-Water-2.png",
  147482. * "frame": {"x":69,"y":103,"w":24,"h":32},
  147483. * "rotated": true,
  147484. * "trimmed": true,
  147485. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  147486. * "sourceSize": {"w":32,"h":32}
  147487. * @returns RawTexture of the frameMap
  147488. */
  147489. private _createFrameBuffer;
  147490. /**
  147491. * Creates the tileMap texture Buffer
  147492. * @param buffer normally and array of numbers, or a false to generate from scratch
  147493. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  147494. * @returns RawTexture of the tileMap
  147495. */
  147496. private _createTileBuffer;
  147497. /**
  147498. * Modifies the data of the tileMaps
  147499. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  147500. * @param pos is the iVector2 Coordinates of the Tile
  147501. * @param tile The SpriteIndex of the new Tile
  147502. */
  147503. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  147504. /**
  147505. * Creates the animationMap texture Buffer
  147506. * @param buffer normally and array of numbers, or a false to generate from scratch
  147507. * @returns RawTexture of the animationMap
  147508. */
  147509. private _createTileAnimationBuffer;
  147510. /**
  147511. * Modifies the data of the animationMap
  147512. * @param cellID is the Index of the Sprite
  147513. * @param _frame is the target Animation frame
  147514. * @param toCell is the Target Index of the next frame of the animation
  147515. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  147516. * @param speed is a global scalar of the time variable on the map.
  147517. */
  147518. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  147519. /**
  147520. * Exports the .tilemaps file
  147521. */
  147522. saveTileMaps(): void;
  147523. /**
  147524. * Imports the .tilemaps file
  147525. * @param url of the .tilemaps file
  147526. */
  147527. loadTileMaps(url: string): void;
  147528. /**
  147529. * Release associated resources
  147530. */
  147531. dispose(): void;
  147532. }
  147533. }
  147534. declare module BABYLON {
  147535. /**
  147536. * Class used to manage multiple sprites of different sizes on the same spritesheet
  147537. * @see http://doc.babylonjs.com/babylon101/sprites
  147538. */
  147539. export class SpritePackedManager extends SpriteManager {
  147540. /** defines the packed manager's name */
  147541. name: string;
  147542. /**
  147543. * Creates a new sprite manager from a packed sprite sheet
  147544. * @param name defines the manager's name
  147545. * @param imgUrl defines the sprite sheet url
  147546. * @param capacity defines the maximum allowed number of sprites
  147547. * @param scene defines the hosting scene
  147548. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  147549. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  147550. * @param samplingMode defines the smapling mode to use with spritesheet
  147551. * @param fromPacked set to true; do not alter
  147552. */
  147553. constructor(
  147554. /** defines the packed manager's name */
  147555. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  147556. }
  147557. }
  147558. declare module BABYLON {
  147559. /**
  147560. * Defines the list of states available for a task inside a AssetsManager
  147561. */
  147562. export enum AssetTaskState {
  147563. /**
  147564. * Initialization
  147565. */
  147566. INIT = 0,
  147567. /**
  147568. * Running
  147569. */
  147570. RUNNING = 1,
  147571. /**
  147572. * Done
  147573. */
  147574. DONE = 2,
  147575. /**
  147576. * Error
  147577. */
  147578. ERROR = 3
  147579. }
  147580. /**
  147581. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  147582. */
  147583. export abstract class AbstractAssetTask {
  147584. /**
  147585. * Task name
  147586. */ name: string;
  147587. /**
  147588. * Callback called when the task is successful
  147589. */
  147590. onSuccess: (task: any) => void;
  147591. /**
  147592. * Callback called when the task is not successful
  147593. */
  147594. onError: (task: any, message?: string, exception?: any) => void;
  147595. /**
  147596. * Creates a new AssetsManager
  147597. * @param name defines the name of the task
  147598. */
  147599. constructor(
  147600. /**
  147601. * Task name
  147602. */ name: string);
  147603. private _isCompleted;
  147604. private _taskState;
  147605. private _errorObject;
  147606. /**
  147607. * Get if the task is completed
  147608. */
  147609. get isCompleted(): boolean;
  147610. /**
  147611. * Gets the current state of the task
  147612. */
  147613. get taskState(): AssetTaskState;
  147614. /**
  147615. * Gets the current error object (if task is in error)
  147616. */
  147617. get errorObject(): {
  147618. message?: string;
  147619. exception?: any;
  147620. };
  147621. /**
  147622. * Internal only
  147623. * @hidden
  147624. */
  147625. _setErrorObject(message?: string, exception?: any): void;
  147626. /**
  147627. * Execute the current task
  147628. * @param scene defines the scene where you want your assets to be loaded
  147629. * @param onSuccess is a callback called when the task is successfully executed
  147630. * @param onError is a callback called if an error occurs
  147631. */
  147632. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147633. /**
  147634. * Execute the current task
  147635. * @param scene defines the scene where you want your assets to be loaded
  147636. * @param onSuccess is a callback called when the task is successfully executed
  147637. * @param onError is a callback called if an error occurs
  147638. */
  147639. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147640. /**
  147641. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  147642. * This can be used with failed tasks that have the reason for failure fixed.
  147643. */
  147644. reset(): void;
  147645. private onErrorCallback;
  147646. private onDoneCallback;
  147647. }
  147648. /**
  147649. * Define the interface used by progress events raised during assets loading
  147650. */
  147651. export interface IAssetsProgressEvent {
  147652. /**
  147653. * Defines the number of remaining tasks to process
  147654. */
  147655. remainingCount: number;
  147656. /**
  147657. * Defines the total number of tasks
  147658. */
  147659. totalCount: number;
  147660. /**
  147661. * Defines the task that was just processed
  147662. */
  147663. task: AbstractAssetTask;
  147664. }
  147665. /**
  147666. * Class used to share progress information about assets loading
  147667. */
  147668. export class AssetsProgressEvent implements IAssetsProgressEvent {
  147669. /**
  147670. * Defines the number of remaining tasks to process
  147671. */
  147672. remainingCount: number;
  147673. /**
  147674. * Defines the total number of tasks
  147675. */
  147676. totalCount: number;
  147677. /**
  147678. * Defines the task that was just processed
  147679. */
  147680. task: AbstractAssetTask;
  147681. /**
  147682. * Creates a AssetsProgressEvent
  147683. * @param remainingCount defines the number of remaining tasks to process
  147684. * @param totalCount defines the total number of tasks
  147685. * @param task defines the task that was just processed
  147686. */
  147687. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  147688. }
  147689. /**
  147690. * Define a task used by AssetsManager to load meshes
  147691. */
  147692. export class MeshAssetTask extends AbstractAssetTask {
  147693. /**
  147694. * Defines the name of the task
  147695. */
  147696. name: string;
  147697. /**
  147698. * Defines the list of mesh's names you want to load
  147699. */
  147700. meshesNames: any;
  147701. /**
  147702. * Defines the root url to use as a base to load your meshes and associated resources
  147703. */
  147704. rootUrl: string;
  147705. /**
  147706. * Defines the filename or File of the scene to load from
  147707. */
  147708. sceneFilename: string | File;
  147709. /**
  147710. * Gets the list of loaded meshes
  147711. */
  147712. loadedMeshes: Array<AbstractMesh>;
  147713. /**
  147714. * Gets the list of loaded particle systems
  147715. */
  147716. loadedParticleSystems: Array<IParticleSystem>;
  147717. /**
  147718. * Gets the list of loaded skeletons
  147719. */
  147720. loadedSkeletons: Array<Skeleton>;
  147721. /**
  147722. * Gets the list of loaded animation groups
  147723. */
  147724. loadedAnimationGroups: Array<AnimationGroup>;
  147725. /**
  147726. * Callback called when the task is successful
  147727. */
  147728. onSuccess: (task: MeshAssetTask) => void;
  147729. /**
  147730. * Callback called when the task is successful
  147731. */
  147732. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  147733. /**
  147734. * Creates a new MeshAssetTask
  147735. * @param name defines the name of the task
  147736. * @param meshesNames defines the list of mesh's names you want to load
  147737. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  147738. * @param sceneFilename defines the filename or File of the scene to load from
  147739. */
  147740. constructor(
  147741. /**
  147742. * Defines the name of the task
  147743. */
  147744. name: string,
  147745. /**
  147746. * Defines the list of mesh's names you want to load
  147747. */
  147748. meshesNames: any,
  147749. /**
  147750. * Defines the root url to use as a base to load your meshes and associated resources
  147751. */
  147752. rootUrl: string,
  147753. /**
  147754. * Defines the filename or File of the scene to load from
  147755. */
  147756. sceneFilename: string | File);
  147757. /**
  147758. * Execute the current task
  147759. * @param scene defines the scene where you want your assets to be loaded
  147760. * @param onSuccess is a callback called when the task is successfully executed
  147761. * @param onError is a callback called if an error occurs
  147762. */
  147763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147764. }
  147765. /**
  147766. * Define a task used by AssetsManager to load text content
  147767. */
  147768. export class TextFileAssetTask extends AbstractAssetTask {
  147769. /**
  147770. * Defines the name of the task
  147771. */
  147772. name: string;
  147773. /**
  147774. * Defines the location of the file to load
  147775. */
  147776. url: string;
  147777. /**
  147778. * Gets the loaded text string
  147779. */
  147780. text: string;
  147781. /**
  147782. * Callback called when the task is successful
  147783. */
  147784. onSuccess: (task: TextFileAssetTask) => void;
  147785. /**
  147786. * Callback called when the task is successful
  147787. */
  147788. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  147789. /**
  147790. * Creates a new TextFileAssetTask object
  147791. * @param name defines the name of the task
  147792. * @param url defines the location of the file to load
  147793. */
  147794. constructor(
  147795. /**
  147796. * Defines the name of the task
  147797. */
  147798. name: string,
  147799. /**
  147800. * Defines the location of the file to load
  147801. */
  147802. url: string);
  147803. /**
  147804. * Execute the current task
  147805. * @param scene defines the scene where you want your assets to be loaded
  147806. * @param onSuccess is a callback called when the task is successfully executed
  147807. * @param onError is a callback called if an error occurs
  147808. */
  147809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147810. }
  147811. /**
  147812. * Define a task used by AssetsManager to load binary data
  147813. */
  147814. export class BinaryFileAssetTask extends AbstractAssetTask {
  147815. /**
  147816. * Defines the name of the task
  147817. */
  147818. name: string;
  147819. /**
  147820. * Defines the location of the file to load
  147821. */
  147822. url: string;
  147823. /**
  147824. * Gets the lodaded data (as an array buffer)
  147825. */
  147826. data: ArrayBuffer;
  147827. /**
  147828. * Callback called when the task is successful
  147829. */
  147830. onSuccess: (task: BinaryFileAssetTask) => void;
  147831. /**
  147832. * Callback called when the task is successful
  147833. */
  147834. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  147835. /**
  147836. * Creates a new BinaryFileAssetTask object
  147837. * @param name defines the name of the new task
  147838. * @param url defines the location of the file to load
  147839. */
  147840. constructor(
  147841. /**
  147842. * Defines the name of the task
  147843. */
  147844. name: string,
  147845. /**
  147846. * Defines the location of the file to load
  147847. */
  147848. url: string);
  147849. /**
  147850. * Execute the current task
  147851. * @param scene defines the scene where you want your assets to be loaded
  147852. * @param onSuccess is a callback called when the task is successfully executed
  147853. * @param onError is a callback called if an error occurs
  147854. */
  147855. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147856. }
  147857. /**
  147858. * Define a task used by AssetsManager to load images
  147859. */
  147860. export class ImageAssetTask extends AbstractAssetTask {
  147861. /**
  147862. * Defines the name of the task
  147863. */
  147864. name: string;
  147865. /**
  147866. * Defines the location of the image to load
  147867. */
  147868. url: string;
  147869. /**
  147870. * Gets the loaded images
  147871. */
  147872. image: HTMLImageElement;
  147873. /**
  147874. * Callback called when the task is successful
  147875. */
  147876. onSuccess: (task: ImageAssetTask) => void;
  147877. /**
  147878. * Callback called when the task is successful
  147879. */
  147880. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  147881. /**
  147882. * Creates a new ImageAssetTask
  147883. * @param name defines the name of the task
  147884. * @param url defines the location of the image to load
  147885. */
  147886. constructor(
  147887. /**
  147888. * Defines the name of the task
  147889. */
  147890. name: string,
  147891. /**
  147892. * Defines the location of the image to load
  147893. */
  147894. url: string);
  147895. /**
  147896. * Execute the current task
  147897. * @param scene defines the scene where you want your assets to be loaded
  147898. * @param onSuccess is a callback called when the task is successfully executed
  147899. * @param onError is a callback called if an error occurs
  147900. */
  147901. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147902. }
  147903. /**
  147904. * Defines the interface used by texture loading tasks
  147905. */
  147906. export interface ITextureAssetTask<TEX extends BaseTexture> {
  147907. /**
  147908. * Gets the loaded texture
  147909. */
  147910. texture: TEX;
  147911. }
  147912. /**
  147913. * Define a task used by AssetsManager to load 2D textures
  147914. */
  147915. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  147916. /**
  147917. * Defines the name of the task
  147918. */
  147919. name: string;
  147920. /**
  147921. * Defines the location of the file to load
  147922. */
  147923. url: string;
  147924. /**
  147925. * Defines if mipmap should not be generated (default is false)
  147926. */
  147927. noMipmap?: boolean | undefined;
  147928. /**
  147929. * Defines if texture must be inverted on Y axis (default is true)
  147930. */
  147931. invertY: boolean;
  147932. /**
  147933. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147934. */
  147935. samplingMode: number;
  147936. /**
  147937. * Gets the loaded texture
  147938. */
  147939. texture: Texture;
  147940. /**
  147941. * Callback called when the task is successful
  147942. */
  147943. onSuccess: (task: TextureAssetTask) => void;
  147944. /**
  147945. * Callback called when the task is successful
  147946. */
  147947. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  147948. /**
  147949. * Creates a new TextureAssetTask object
  147950. * @param name defines the name of the task
  147951. * @param url defines the location of the file to load
  147952. * @param noMipmap defines if mipmap should not be generated (default is false)
  147953. * @param invertY defines if texture must be inverted on Y axis (default is true)
  147954. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147955. */
  147956. constructor(
  147957. /**
  147958. * Defines the name of the task
  147959. */
  147960. name: string,
  147961. /**
  147962. * Defines the location of the file to load
  147963. */
  147964. url: string,
  147965. /**
  147966. * Defines if mipmap should not be generated (default is false)
  147967. */
  147968. noMipmap?: boolean | undefined,
  147969. /**
  147970. * Defines if texture must be inverted on Y axis (default is true)
  147971. */
  147972. invertY?: boolean,
  147973. /**
  147974. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147975. */
  147976. samplingMode?: number);
  147977. /**
  147978. * Execute the current task
  147979. * @param scene defines the scene where you want your assets to be loaded
  147980. * @param onSuccess is a callback called when the task is successfully executed
  147981. * @param onError is a callback called if an error occurs
  147982. */
  147983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147984. }
  147985. /**
  147986. * Define a task used by AssetsManager to load cube textures
  147987. */
  147988. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  147989. /**
  147990. * Defines the name of the task
  147991. */
  147992. name: string;
  147993. /**
  147994. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  147995. */
  147996. url: string;
  147997. /**
  147998. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  147999. */
  148000. extensions?: string[] | undefined;
  148001. /**
  148002. * Defines if mipmaps should not be generated (default is false)
  148003. */
  148004. noMipmap?: boolean | undefined;
  148005. /**
  148006. * Defines the explicit list of files (undefined by default)
  148007. */
  148008. files?: string[] | undefined;
  148009. /**
  148010. * Gets the loaded texture
  148011. */
  148012. texture: CubeTexture;
  148013. /**
  148014. * Callback called when the task is successful
  148015. */
  148016. onSuccess: (task: CubeTextureAssetTask) => void;
  148017. /**
  148018. * Callback called when the task is successful
  148019. */
  148020. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  148021. /**
  148022. * Creates a new CubeTextureAssetTask
  148023. * @param name defines the name of the task
  148024. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148025. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148026. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148027. * @param files defines the explicit list of files (undefined by default)
  148028. */
  148029. constructor(
  148030. /**
  148031. * Defines the name of the task
  148032. */
  148033. name: string,
  148034. /**
  148035. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148036. */
  148037. url: string,
  148038. /**
  148039. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148040. */
  148041. extensions?: string[] | undefined,
  148042. /**
  148043. * Defines if mipmaps should not be generated (default is false)
  148044. */
  148045. noMipmap?: boolean | undefined,
  148046. /**
  148047. * Defines the explicit list of files (undefined by default)
  148048. */
  148049. files?: string[] | undefined);
  148050. /**
  148051. * Execute the current task
  148052. * @param scene defines the scene where you want your assets to be loaded
  148053. * @param onSuccess is a callback called when the task is successfully executed
  148054. * @param onError is a callback called if an error occurs
  148055. */
  148056. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148057. }
  148058. /**
  148059. * Define a task used by AssetsManager to load HDR cube textures
  148060. */
  148061. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  148062. /**
  148063. * Defines the name of the task
  148064. */
  148065. name: string;
  148066. /**
  148067. * Defines the location of the file to load
  148068. */
  148069. url: string;
  148070. /**
  148071. * Defines the desired size (the more it increases the longer the generation will be)
  148072. */
  148073. size: number;
  148074. /**
  148075. * Defines if mipmaps should not be generated (default is false)
  148076. */
  148077. noMipmap: boolean;
  148078. /**
  148079. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148080. */
  148081. generateHarmonics: boolean;
  148082. /**
  148083. * 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)
  148084. */
  148085. gammaSpace: boolean;
  148086. /**
  148087. * Internal Use Only
  148088. */
  148089. reserved: boolean;
  148090. /**
  148091. * Gets the loaded texture
  148092. */
  148093. texture: HDRCubeTexture;
  148094. /**
  148095. * Callback called when the task is successful
  148096. */
  148097. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  148098. /**
  148099. * Callback called when the task is successful
  148100. */
  148101. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  148102. /**
  148103. * Creates a new HDRCubeTextureAssetTask object
  148104. * @param name defines the name of the task
  148105. * @param url defines the location of the file to load
  148106. * @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.
  148107. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148108. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148109. * @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)
  148110. * @param reserved Internal use only
  148111. */
  148112. constructor(
  148113. /**
  148114. * Defines the name of the task
  148115. */
  148116. name: string,
  148117. /**
  148118. * Defines the location of the file to load
  148119. */
  148120. url: string,
  148121. /**
  148122. * Defines the desired size (the more it increases the longer the generation will be)
  148123. */
  148124. size: number,
  148125. /**
  148126. * Defines if mipmaps should not be generated (default is false)
  148127. */
  148128. noMipmap?: boolean,
  148129. /**
  148130. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148131. */
  148132. generateHarmonics?: boolean,
  148133. /**
  148134. * 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)
  148135. */
  148136. gammaSpace?: boolean,
  148137. /**
  148138. * Internal Use Only
  148139. */
  148140. reserved?: boolean);
  148141. /**
  148142. * Execute the current task
  148143. * @param scene defines the scene where you want your assets to be loaded
  148144. * @param onSuccess is a callback called when the task is successfully executed
  148145. * @param onError is a callback called if an error occurs
  148146. */
  148147. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148148. }
  148149. /**
  148150. * Define a task used by AssetsManager to load Equirectangular cube textures
  148151. */
  148152. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  148153. /**
  148154. * Defines the name of the task
  148155. */
  148156. name: string;
  148157. /**
  148158. * Defines the location of the file to load
  148159. */
  148160. url: string;
  148161. /**
  148162. * Defines the desired size (the more it increases the longer the generation will be)
  148163. */
  148164. size: number;
  148165. /**
  148166. * Defines if mipmaps should not be generated (default is false)
  148167. */
  148168. noMipmap: boolean;
  148169. /**
  148170. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  148171. * but the standard material would require them in Gamma space) (default is true)
  148172. */
  148173. gammaSpace: boolean;
  148174. /**
  148175. * Gets the loaded texture
  148176. */
  148177. texture: EquiRectangularCubeTexture;
  148178. /**
  148179. * Callback called when the task is successful
  148180. */
  148181. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  148182. /**
  148183. * Callback called when the task is successful
  148184. */
  148185. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  148186. /**
  148187. * Creates a new EquiRectangularCubeTextureAssetTask object
  148188. * @param name defines the name of the task
  148189. * @param url defines the location of the file to load
  148190. * @param size defines the desired size (the more it increases the longer the generation will be)
  148191. * If the size is omitted this implies you are using a preprocessed cubemap.
  148192. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148193. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  148194. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  148195. * (default is true)
  148196. */
  148197. constructor(
  148198. /**
  148199. * Defines the name of the task
  148200. */
  148201. name: string,
  148202. /**
  148203. * Defines the location of the file to load
  148204. */
  148205. url: string,
  148206. /**
  148207. * Defines the desired size (the more it increases the longer the generation will be)
  148208. */
  148209. size: number,
  148210. /**
  148211. * Defines if mipmaps should not be generated (default is false)
  148212. */
  148213. noMipmap?: boolean,
  148214. /**
  148215. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  148216. * but the standard material would require them in Gamma space) (default is true)
  148217. */
  148218. gammaSpace?: boolean);
  148219. /**
  148220. * Execute the current task
  148221. * @param scene defines the scene where you want your assets to be loaded
  148222. * @param onSuccess is a callback called when the task is successfully executed
  148223. * @param onError is a callback called if an error occurs
  148224. */
  148225. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148226. }
  148227. /**
  148228. * This class can be used to easily import assets into a scene
  148229. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  148230. */
  148231. export class AssetsManager {
  148232. private _scene;
  148233. private _isLoading;
  148234. protected _tasks: AbstractAssetTask[];
  148235. protected _waitingTasksCount: number;
  148236. protected _totalTasksCount: number;
  148237. /**
  148238. * Callback called when all tasks are processed
  148239. */
  148240. onFinish: (tasks: AbstractAssetTask[]) => void;
  148241. /**
  148242. * Callback called when a task is successful
  148243. */
  148244. onTaskSuccess: (task: AbstractAssetTask) => void;
  148245. /**
  148246. * Callback called when a task had an error
  148247. */
  148248. onTaskError: (task: AbstractAssetTask) => void;
  148249. /**
  148250. * Callback called when a task is done (whatever the result is)
  148251. */
  148252. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  148253. /**
  148254. * Observable called when all tasks are processed
  148255. */
  148256. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  148257. /**
  148258. * Observable called when a task had an error
  148259. */
  148260. onTaskErrorObservable: Observable<AbstractAssetTask>;
  148261. /**
  148262. * Observable called when all tasks were executed
  148263. */
  148264. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  148265. /**
  148266. * Observable called when a task is done (whatever the result is)
  148267. */
  148268. onProgressObservable: Observable<IAssetsProgressEvent>;
  148269. /**
  148270. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  148271. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  148272. */
  148273. useDefaultLoadingScreen: boolean;
  148274. /**
  148275. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  148276. * when all assets have been downloaded.
  148277. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  148278. */
  148279. autoHideLoadingUI: boolean;
  148280. /**
  148281. * Creates a new AssetsManager
  148282. * @param scene defines the scene to work on
  148283. */
  148284. constructor(scene: Scene);
  148285. /**
  148286. * Add a MeshAssetTask to the list of active tasks
  148287. * @param taskName defines the name of the new task
  148288. * @param meshesNames defines the name of meshes to load
  148289. * @param rootUrl defines the root url to use to locate files
  148290. * @param sceneFilename defines the filename of the scene file
  148291. * @returns a new MeshAssetTask object
  148292. */
  148293. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  148294. /**
  148295. * Add a TextFileAssetTask to the list of active tasks
  148296. * @param taskName defines the name of the new task
  148297. * @param url defines the url of the file to load
  148298. * @returns a new TextFileAssetTask object
  148299. */
  148300. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  148301. /**
  148302. * Add a BinaryFileAssetTask to the list of active tasks
  148303. * @param taskName defines the name of the new task
  148304. * @param url defines the url of the file to load
  148305. * @returns a new BinaryFileAssetTask object
  148306. */
  148307. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  148308. /**
  148309. * Add a ImageAssetTask to the list of active tasks
  148310. * @param taskName defines the name of the new task
  148311. * @param url defines the url of the file to load
  148312. * @returns a new ImageAssetTask object
  148313. */
  148314. addImageTask(taskName: string, url: string): ImageAssetTask;
  148315. /**
  148316. * Add a TextureAssetTask to the list of active tasks
  148317. * @param taskName defines the name of the new task
  148318. * @param url defines the url of the file to load
  148319. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148320. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  148321. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  148322. * @returns a new TextureAssetTask object
  148323. */
  148324. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  148325. /**
  148326. * Add a CubeTextureAssetTask to the list of active tasks
  148327. * @param taskName defines the name of the new task
  148328. * @param url defines the url of the file to load
  148329. * @param extensions defines the extension to use to load the cube map (can be null)
  148330. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148331. * @param files defines the list of files to load (can be null)
  148332. * @returns a new CubeTextureAssetTask object
  148333. */
  148334. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  148335. /**
  148336. *
  148337. * Add a HDRCubeTextureAssetTask to the list of active tasks
  148338. * @param taskName defines the name of the new task
  148339. * @param url defines the url of the file to load
  148340. * @param size defines the size you want for the cubemap (can be null)
  148341. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148342. * @param generateHarmonics defines if you want to automatically generate (true by default)
  148343. * @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)
  148344. * @param reserved Internal use only
  148345. * @returns a new HDRCubeTextureAssetTask object
  148346. */
  148347. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  148348. /**
  148349. *
  148350. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  148351. * @param taskName defines the name of the new task
  148352. * @param url defines the url of the file to load
  148353. * @param size defines the size you want for the cubemap (can be null)
  148354. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148355. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  148356. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  148357. * @returns a new EquiRectangularCubeTextureAssetTask object
  148358. */
  148359. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  148360. /**
  148361. * Remove a task from the assets manager.
  148362. * @param task the task to remove
  148363. */
  148364. removeTask(task: AbstractAssetTask): void;
  148365. private _decreaseWaitingTasksCount;
  148366. private _runTask;
  148367. /**
  148368. * Reset the AssetsManager and remove all tasks
  148369. * @return the current instance of the AssetsManager
  148370. */
  148371. reset(): AssetsManager;
  148372. /**
  148373. * Start the loading process
  148374. * @return the current instance of the AssetsManager
  148375. */
  148376. load(): AssetsManager;
  148377. /**
  148378. * Start the loading process as an async operation
  148379. * @return a promise returning the list of failed tasks
  148380. */
  148381. loadAsync(): Promise<void>;
  148382. }
  148383. }
  148384. declare module BABYLON {
  148385. /**
  148386. * Wrapper class for promise with external resolve and reject.
  148387. */
  148388. export class Deferred<T> {
  148389. /**
  148390. * The promise associated with this deferred object.
  148391. */
  148392. readonly promise: Promise<T>;
  148393. private _resolve;
  148394. private _reject;
  148395. /**
  148396. * The resolve method of the promise associated with this deferred object.
  148397. */
  148398. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  148399. /**
  148400. * The reject method of the promise associated with this deferred object.
  148401. */
  148402. get reject(): (reason?: any) => void;
  148403. /**
  148404. * Constructor for this deferred object.
  148405. */
  148406. constructor();
  148407. }
  148408. }
  148409. declare module BABYLON {
  148410. /**
  148411. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  148412. */
  148413. export class MeshExploder {
  148414. private _centerMesh;
  148415. private _meshes;
  148416. private _meshesOrigins;
  148417. private _toCenterVectors;
  148418. private _scaledDirection;
  148419. private _newPosition;
  148420. private _centerPosition;
  148421. /**
  148422. * Explodes meshes from a center mesh.
  148423. * @param meshes The meshes to explode.
  148424. * @param centerMesh The mesh to be center of explosion.
  148425. */
  148426. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  148427. private _setCenterMesh;
  148428. /**
  148429. * Get class name
  148430. * @returns "MeshExploder"
  148431. */
  148432. getClassName(): string;
  148433. /**
  148434. * "Exploded meshes"
  148435. * @returns Array of meshes with the centerMesh at index 0.
  148436. */
  148437. getMeshes(): Array<Mesh>;
  148438. /**
  148439. * Explodes meshes giving a specific direction
  148440. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  148441. */
  148442. explode(direction?: number): void;
  148443. }
  148444. }
  148445. declare module BABYLON {
  148446. /**
  148447. * Class used to help managing file picking and drag'n'drop
  148448. */
  148449. export class FilesInput {
  148450. /**
  148451. * List of files ready to be loaded
  148452. */
  148453. static get FilesToLoad(): {
  148454. [key: string]: File;
  148455. };
  148456. /**
  148457. * Callback called when a file is processed
  148458. */
  148459. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  148460. private _engine;
  148461. private _currentScene;
  148462. private _sceneLoadedCallback;
  148463. private _progressCallback;
  148464. private _additionalRenderLoopLogicCallback;
  148465. private _textureLoadingCallback;
  148466. private _startingProcessingFilesCallback;
  148467. private _onReloadCallback;
  148468. private _errorCallback;
  148469. private _elementToMonitor;
  148470. private _sceneFileToLoad;
  148471. private _filesToLoad;
  148472. /**
  148473. * Creates a new FilesInput
  148474. * @param engine defines the rendering engine
  148475. * @param scene defines the hosting scene
  148476. * @param sceneLoadedCallback callback called when scene is loaded
  148477. * @param progressCallback callback called to track progress
  148478. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  148479. * @param textureLoadingCallback callback called when a texture is loading
  148480. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  148481. * @param onReloadCallback callback called when a reload is requested
  148482. * @param errorCallback callback call if an error occurs
  148483. */
  148484. 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);
  148485. private _dragEnterHandler;
  148486. private _dragOverHandler;
  148487. private _dropHandler;
  148488. /**
  148489. * Calls this function to listen to drag'n'drop events on a specific DOM element
  148490. * @param elementToMonitor defines the DOM element to track
  148491. */
  148492. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  148493. /**
  148494. * Release all associated resources
  148495. */
  148496. dispose(): void;
  148497. private renderFunction;
  148498. private drag;
  148499. private drop;
  148500. private _traverseFolder;
  148501. private _processFiles;
  148502. /**
  148503. * Load files from a drop event
  148504. * @param event defines the drop event to use as source
  148505. */
  148506. loadFiles(event: any): void;
  148507. private _processReload;
  148508. /**
  148509. * Reload the current scene from the loaded files
  148510. */
  148511. reload(): void;
  148512. }
  148513. }
  148514. declare module BABYLON {
  148515. /**
  148516. * Defines the root class used to create scene optimization to use with SceneOptimizer
  148517. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148518. */
  148519. export class SceneOptimization {
  148520. /**
  148521. * Defines the priority of this optimization (0 by default which means first in the list)
  148522. */
  148523. priority: number;
  148524. /**
  148525. * Gets a string describing the action executed by the current optimization
  148526. * @returns description string
  148527. */
  148528. getDescription(): string;
  148529. /**
  148530. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148531. * @param scene defines the current scene where to apply this optimization
  148532. * @param optimizer defines the current optimizer
  148533. * @returns true if everything that can be done was applied
  148534. */
  148535. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148536. /**
  148537. * Creates the SceneOptimization object
  148538. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148539. * @param desc defines the description associated with the optimization
  148540. */
  148541. constructor(
  148542. /**
  148543. * Defines the priority of this optimization (0 by default which means first in the list)
  148544. */
  148545. priority?: number);
  148546. }
  148547. /**
  148548. * Defines an optimization used to reduce the size of render target textures
  148549. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148550. */
  148551. export class TextureOptimization extends SceneOptimization {
  148552. /**
  148553. * Defines the priority of this optimization (0 by default which means first in the list)
  148554. */
  148555. priority: number;
  148556. /**
  148557. * 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
  148558. */
  148559. maximumSize: number;
  148560. /**
  148561. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148562. */
  148563. step: number;
  148564. /**
  148565. * Gets a string describing the action executed by the current optimization
  148566. * @returns description string
  148567. */
  148568. getDescription(): string;
  148569. /**
  148570. * Creates the TextureOptimization object
  148571. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148572. * @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
  148573. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148574. */
  148575. constructor(
  148576. /**
  148577. * Defines the priority of this optimization (0 by default which means first in the list)
  148578. */
  148579. priority?: number,
  148580. /**
  148581. * 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
  148582. */
  148583. maximumSize?: number,
  148584. /**
  148585. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148586. */
  148587. step?: number);
  148588. /**
  148589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148590. * @param scene defines the current scene where to apply this optimization
  148591. * @param optimizer defines the current optimizer
  148592. * @returns true if everything that can be done was applied
  148593. */
  148594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148595. }
  148596. /**
  148597. * Defines an optimization used to increase or decrease the rendering resolution
  148598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148599. */
  148600. export class HardwareScalingOptimization extends SceneOptimization {
  148601. /**
  148602. * Defines the priority of this optimization (0 by default which means first in the list)
  148603. */
  148604. priority: number;
  148605. /**
  148606. * Defines the maximum scale to use (2 by default)
  148607. */
  148608. maximumScale: number;
  148609. /**
  148610. * Defines the step to use between two passes (0.5 by default)
  148611. */
  148612. step: number;
  148613. private _currentScale;
  148614. private _directionOffset;
  148615. /**
  148616. * Gets a string describing the action executed by the current optimization
  148617. * @return description string
  148618. */
  148619. getDescription(): string;
  148620. /**
  148621. * Creates the HardwareScalingOptimization object
  148622. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148623. * @param maximumScale defines the maximum scale to use (2 by default)
  148624. * @param step defines the step to use between two passes (0.5 by default)
  148625. */
  148626. constructor(
  148627. /**
  148628. * Defines the priority of this optimization (0 by default which means first in the list)
  148629. */
  148630. priority?: number,
  148631. /**
  148632. * Defines the maximum scale to use (2 by default)
  148633. */
  148634. maximumScale?: number,
  148635. /**
  148636. * Defines the step to use between two passes (0.5 by default)
  148637. */
  148638. step?: number);
  148639. /**
  148640. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148641. * @param scene defines the current scene where to apply this optimization
  148642. * @param optimizer defines the current optimizer
  148643. * @returns true if everything that can be done was applied
  148644. */
  148645. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148646. }
  148647. /**
  148648. * Defines an optimization used to remove shadows
  148649. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148650. */
  148651. export class ShadowsOptimization extends SceneOptimization {
  148652. /**
  148653. * Gets a string describing the action executed by the current optimization
  148654. * @return description string
  148655. */
  148656. getDescription(): string;
  148657. /**
  148658. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148659. * @param scene defines the current scene where to apply this optimization
  148660. * @param optimizer defines the current optimizer
  148661. * @returns true if everything that can be done was applied
  148662. */
  148663. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148664. }
  148665. /**
  148666. * Defines an optimization used to turn post-processes off
  148667. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148668. */
  148669. export class PostProcessesOptimization extends SceneOptimization {
  148670. /**
  148671. * Gets a string describing the action executed by the current optimization
  148672. * @return description string
  148673. */
  148674. getDescription(): string;
  148675. /**
  148676. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148677. * @param scene defines the current scene where to apply this optimization
  148678. * @param optimizer defines the current optimizer
  148679. * @returns true if everything that can be done was applied
  148680. */
  148681. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148682. }
  148683. /**
  148684. * Defines an optimization used to turn lens flares off
  148685. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148686. */
  148687. export class LensFlaresOptimization extends SceneOptimization {
  148688. /**
  148689. * Gets a string describing the action executed by the current optimization
  148690. * @return description string
  148691. */
  148692. getDescription(): string;
  148693. /**
  148694. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148695. * @param scene defines the current scene where to apply this optimization
  148696. * @param optimizer defines the current optimizer
  148697. * @returns true if everything that can be done was applied
  148698. */
  148699. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148700. }
  148701. /**
  148702. * Defines an optimization based on user defined callback.
  148703. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148704. */
  148705. export class CustomOptimization extends SceneOptimization {
  148706. /**
  148707. * Callback called to apply the custom optimization.
  148708. */
  148709. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  148710. /**
  148711. * Callback called to get custom description
  148712. */
  148713. onGetDescription: () => string;
  148714. /**
  148715. * Gets a string describing the action executed by the current optimization
  148716. * @returns description string
  148717. */
  148718. getDescription(): string;
  148719. /**
  148720. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148721. * @param scene defines the current scene where to apply this optimization
  148722. * @param optimizer defines the current optimizer
  148723. * @returns true if everything that can be done was applied
  148724. */
  148725. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148726. }
  148727. /**
  148728. * Defines an optimization used to turn particles off
  148729. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148730. */
  148731. export class ParticlesOptimization extends SceneOptimization {
  148732. /**
  148733. * Gets a string describing the action executed by the current optimization
  148734. * @return description string
  148735. */
  148736. getDescription(): string;
  148737. /**
  148738. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148739. * @param scene defines the current scene where to apply this optimization
  148740. * @param optimizer defines the current optimizer
  148741. * @returns true if everything that can be done was applied
  148742. */
  148743. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148744. }
  148745. /**
  148746. * Defines an optimization used to turn render targets off
  148747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148748. */
  148749. export class RenderTargetsOptimization extends SceneOptimization {
  148750. /**
  148751. * Gets a string describing the action executed by the current optimization
  148752. * @return description string
  148753. */
  148754. getDescription(): string;
  148755. /**
  148756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148757. * @param scene defines the current scene where to apply this optimization
  148758. * @param optimizer defines the current optimizer
  148759. * @returns true if everything that can be done was applied
  148760. */
  148761. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148762. }
  148763. /**
  148764. * Defines an optimization used to merge meshes with compatible materials
  148765. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148766. */
  148767. export class MergeMeshesOptimization extends SceneOptimization {
  148768. private static _UpdateSelectionTree;
  148769. /**
  148770. * Gets or sets a boolean which defines if optimization octree has to be updated
  148771. */
  148772. static get UpdateSelectionTree(): boolean;
  148773. /**
  148774. * Gets or sets a boolean which defines if optimization octree has to be updated
  148775. */
  148776. static set UpdateSelectionTree(value: boolean);
  148777. /**
  148778. * Gets a string describing the action executed by the current optimization
  148779. * @return description string
  148780. */
  148781. getDescription(): string;
  148782. private _canBeMerged;
  148783. /**
  148784. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148785. * @param scene defines the current scene where to apply this optimization
  148786. * @param optimizer defines the current optimizer
  148787. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  148788. * @returns true if everything that can be done was applied
  148789. */
  148790. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  148791. }
  148792. /**
  148793. * Defines a list of options used by SceneOptimizer
  148794. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148795. */
  148796. export class SceneOptimizerOptions {
  148797. /**
  148798. * Defines the target frame rate to reach (60 by default)
  148799. */
  148800. targetFrameRate: number;
  148801. /**
  148802. * Defines the interval between two checkes (2000ms by default)
  148803. */
  148804. trackerDuration: number;
  148805. /**
  148806. * Gets the list of optimizations to apply
  148807. */
  148808. optimizations: SceneOptimization[];
  148809. /**
  148810. * Creates a new list of options used by SceneOptimizer
  148811. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  148812. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  148813. */
  148814. constructor(
  148815. /**
  148816. * Defines the target frame rate to reach (60 by default)
  148817. */
  148818. targetFrameRate?: number,
  148819. /**
  148820. * Defines the interval between two checkes (2000ms by default)
  148821. */
  148822. trackerDuration?: number);
  148823. /**
  148824. * Add a new optimization
  148825. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  148826. * @returns the current SceneOptimizerOptions
  148827. */
  148828. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  148829. /**
  148830. * Add a new custom optimization
  148831. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  148832. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  148833. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148834. * @returns the current SceneOptimizerOptions
  148835. */
  148836. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  148837. /**
  148838. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  148839. * @param targetFrameRate defines the target frame rate (60 by default)
  148840. * @returns a SceneOptimizerOptions object
  148841. */
  148842. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148843. /**
  148844. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  148845. * @param targetFrameRate defines the target frame rate (60 by default)
  148846. * @returns a SceneOptimizerOptions object
  148847. */
  148848. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148849. /**
  148850. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  148851. * @param targetFrameRate defines the target frame rate (60 by default)
  148852. * @returns a SceneOptimizerOptions object
  148853. */
  148854. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148855. }
  148856. /**
  148857. * Class used to run optimizations in order to reach a target frame rate
  148858. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148859. */
  148860. export class SceneOptimizer implements IDisposable {
  148861. private _isRunning;
  148862. private _options;
  148863. private _scene;
  148864. private _currentPriorityLevel;
  148865. private _targetFrameRate;
  148866. private _trackerDuration;
  148867. private _currentFrameRate;
  148868. private _sceneDisposeObserver;
  148869. private _improvementMode;
  148870. /**
  148871. * Defines an observable called when the optimizer reaches the target frame rate
  148872. */
  148873. onSuccessObservable: Observable<SceneOptimizer>;
  148874. /**
  148875. * Defines an observable called when the optimizer enables an optimization
  148876. */
  148877. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  148878. /**
  148879. * Defines an observable called when the optimizer is not able to reach the target frame rate
  148880. */
  148881. onFailureObservable: Observable<SceneOptimizer>;
  148882. /**
  148883. * Gets a boolean indicating if the optimizer is in improvement mode
  148884. */
  148885. get isInImprovementMode(): boolean;
  148886. /**
  148887. * Gets the current priority level (0 at start)
  148888. */
  148889. get currentPriorityLevel(): number;
  148890. /**
  148891. * Gets the current frame rate checked by the SceneOptimizer
  148892. */
  148893. get currentFrameRate(): number;
  148894. /**
  148895. * Gets or sets the current target frame rate (60 by default)
  148896. */
  148897. get targetFrameRate(): number;
  148898. /**
  148899. * Gets or sets the current target frame rate (60 by default)
  148900. */
  148901. set targetFrameRate(value: number);
  148902. /**
  148903. * Gets or sets the current interval between two checks (every 2000ms by default)
  148904. */
  148905. get trackerDuration(): number;
  148906. /**
  148907. * Gets or sets the current interval between two checks (every 2000ms by default)
  148908. */
  148909. set trackerDuration(value: number);
  148910. /**
  148911. * Gets the list of active optimizations
  148912. */
  148913. get optimizations(): SceneOptimization[];
  148914. /**
  148915. * Creates a new SceneOptimizer
  148916. * @param scene defines the scene to work on
  148917. * @param options defines the options to use with the SceneOptimizer
  148918. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  148919. * @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)
  148920. */
  148921. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  148922. /**
  148923. * Stops the current optimizer
  148924. */
  148925. stop(): void;
  148926. /**
  148927. * Reset the optimizer to initial step (current priority level = 0)
  148928. */
  148929. reset(): void;
  148930. /**
  148931. * Start the optimizer. By default it will try to reach a specific framerate
  148932. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  148933. */
  148934. start(): void;
  148935. private _checkCurrentState;
  148936. /**
  148937. * Release all resources
  148938. */
  148939. dispose(): void;
  148940. /**
  148941. * Helper function to create a SceneOptimizer with one single line of code
  148942. * @param scene defines the scene to work on
  148943. * @param options defines the options to use with the SceneOptimizer
  148944. * @param onSuccess defines a callback to call on success
  148945. * @param onFailure defines a callback to call on failure
  148946. * @returns the new SceneOptimizer object
  148947. */
  148948. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  148949. }
  148950. }
  148951. declare module BABYLON {
  148952. /**
  148953. * Class used to serialize a scene into a string
  148954. */
  148955. export class SceneSerializer {
  148956. /**
  148957. * Clear cache used by a previous serialization
  148958. */
  148959. static ClearCache(): void;
  148960. /**
  148961. * Serialize a scene into a JSON compatible object
  148962. * @param scene defines the scene to serialize
  148963. * @returns a JSON compatible object
  148964. */
  148965. static Serialize(scene: Scene): any;
  148966. /**
  148967. * Serialize a mesh into a JSON compatible object
  148968. * @param toSerialize defines the mesh to serialize
  148969. * @param withParents defines if parents must be serialized as well
  148970. * @param withChildren defines if children must be serialized as well
  148971. * @returns a JSON compatible object
  148972. */
  148973. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  148974. }
  148975. }
  148976. declare module BABYLON {
  148977. /**
  148978. * Class used to host texture specific utilities
  148979. */
  148980. export class TextureTools {
  148981. /**
  148982. * Uses the GPU to create a copy texture rescaled at a given size
  148983. * @param texture Texture to copy from
  148984. * @param width defines the desired width
  148985. * @param height defines the desired height
  148986. * @param useBilinearMode defines if bilinear mode has to be used
  148987. * @return the generated texture
  148988. */
  148989. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  148990. }
  148991. }
  148992. declare module BABYLON {
  148993. /**
  148994. * This represents the different options available for the video capture.
  148995. */
  148996. export interface VideoRecorderOptions {
  148997. /** Defines the mime type of the video. */
  148998. mimeType: string;
  148999. /** Defines the FPS the video should be recorded at. */
  149000. fps: number;
  149001. /** Defines the chunk size for the recording data. */
  149002. recordChunckSize: number;
  149003. /** The audio tracks to attach to the recording. */
  149004. audioTracks?: MediaStreamTrack[];
  149005. }
  149006. /**
  149007. * This can help with recording videos from BabylonJS.
  149008. * This is based on the available WebRTC functionalities of the browser.
  149009. *
  149010. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  149011. */
  149012. export class VideoRecorder {
  149013. private static readonly _defaultOptions;
  149014. /**
  149015. * Returns whether or not the VideoRecorder is available in your browser.
  149016. * @param engine Defines the Babylon Engine.
  149017. * @returns true if supported otherwise false.
  149018. */
  149019. static IsSupported(engine: Engine): boolean;
  149020. private readonly _options;
  149021. private _canvas;
  149022. private _mediaRecorder;
  149023. private _recordedChunks;
  149024. private _fileName;
  149025. private _resolve;
  149026. private _reject;
  149027. /**
  149028. * True when a recording is already in progress.
  149029. */
  149030. get isRecording(): boolean;
  149031. /**
  149032. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  149033. * @param engine Defines the BabylonJS Engine you wish to record.
  149034. * @param options Defines options that can be used to customize the capture.
  149035. */
  149036. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  149037. /**
  149038. * Stops the current recording before the default capture timeout passed in the startRecording function.
  149039. */
  149040. stopRecording(): void;
  149041. /**
  149042. * Starts recording the canvas for a max duration specified in parameters.
  149043. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  149044. * If null no automatic download will start and you can rely on the promise to get the data back.
  149045. * @param maxDuration Defines the maximum recording time in seconds.
  149046. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  149047. * @return A promise callback at the end of the recording with the video data in Blob.
  149048. */
  149049. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  149050. /**
  149051. * Releases internal resources used during the recording.
  149052. */
  149053. dispose(): void;
  149054. private _handleDataAvailable;
  149055. private _handleError;
  149056. private _handleStop;
  149057. }
  149058. }
  149059. declare module BABYLON {
  149060. /**
  149061. * Class containing a set of static utilities functions for screenshots
  149062. */
  149063. export class ScreenshotTools {
  149064. /**
  149065. * Captures a screenshot of the current rendering
  149066. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149067. * @param engine defines the rendering engine
  149068. * @param camera defines the source camera
  149069. * @param size This parameter can be set to a single number or to an object with the
  149070. * following (optional) properties: precision, width, height. If a single number is passed,
  149071. * it will be used for both width and height. If an object is passed, the screenshot size
  149072. * will be derived from the parameters. The precision property is a multiplier allowing
  149073. * rendering at a higher or lower resolution
  149074. * @param successCallback defines the callback receives a single parameter which contains the
  149075. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  149076. * src parameter of an <img> to display it
  149077. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  149078. * Check your browser for supported MIME types
  149079. */
  149080. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  149081. /**
  149082. * Captures a screenshot of the current rendering
  149083. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149084. * @param engine defines the rendering engine
  149085. * @param camera defines the source camera
  149086. * @param size This parameter can be set to a single number or to an object with the
  149087. * following (optional) properties: precision, width, height. If a single number is passed,
  149088. * it will be used for both width and height. If an object is passed, the screenshot size
  149089. * will be derived from the parameters. The precision property is a multiplier allowing
  149090. * rendering at a higher or lower resolution
  149091. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  149092. * Check your browser for supported MIME types
  149093. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  149094. * to the src parameter of an <img> to display it
  149095. */
  149096. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  149097. /**
  149098. * Generates an image screenshot from the specified camera.
  149099. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149100. * @param engine The engine to use for rendering
  149101. * @param camera The camera to use for rendering
  149102. * @param size This parameter can be set to a single number or to an object with the
  149103. * following (optional) properties: precision, width, height. If a single number is passed,
  149104. * it will be used for both width and height. If an object is passed, the screenshot size
  149105. * will be derived from the parameters. The precision property is a multiplier allowing
  149106. * rendering at a higher or lower resolution
  149107. * @param successCallback The callback receives a single parameter which contains the
  149108. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  149109. * src parameter of an <img> to display it
  149110. * @param mimeType The MIME type of the screenshot image (default: image/png).
  149111. * Check your browser for supported MIME types
  149112. * @param samples Texture samples (default: 1)
  149113. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  149114. * @param fileName A name for for the downloaded file.
  149115. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  149116. */
  149117. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  149118. /**
  149119. * Generates an image screenshot from the specified camera.
  149120. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149121. * @param engine The engine to use for rendering
  149122. * @param camera The camera to use for rendering
  149123. * @param size This parameter can be set to a single number or to an object with the
  149124. * following (optional) properties: precision, width, height. If a single number is passed,
  149125. * it will be used for both width and height. If an object is passed, the screenshot size
  149126. * will be derived from the parameters. The precision property is a multiplier allowing
  149127. * rendering at a higher or lower resolution
  149128. * @param mimeType The MIME type of the screenshot image (default: image/png).
  149129. * Check your browser for supported MIME types
  149130. * @param samples Texture samples (default: 1)
  149131. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  149132. * @param fileName A name for for the downloaded file.
  149133. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  149134. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  149135. * to the src parameter of an <img> to display it
  149136. */
  149137. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  149138. /**
  149139. * Gets height and width for screenshot size
  149140. * @private
  149141. */
  149142. private static _getScreenshotSize;
  149143. }
  149144. }
  149145. declare module BABYLON {
  149146. /**
  149147. * Interface for a data buffer
  149148. */
  149149. export interface IDataBuffer {
  149150. /**
  149151. * Reads bytes from the data buffer.
  149152. * @param byteOffset The byte offset to read
  149153. * @param byteLength The byte length to read
  149154. * @returns A promise that resolves when the bytes are read
  149155. */
  149156. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  149157. /**
  149158. * The byte length of the buffer.
  149159. */
  149160. readonly byteLength: number;
  149161. }
  149162. /**
  149163. * Utility class for reading from a data buffer
  149164. */
  149165. export class DataReader {
  149166. /**
  149167. * The data buffer associated with this data reader.
  149168. */
  149169. readonly buffer: IDataBuffer;
  149170. /**
  149171. * The current byte offset from the beginning of the data buffer.
  149172. */
  149173. byteOffset: number;
  149174. private _dataView;
  149175. private _dataByteOffset;
  149176. /**
  149177. * Constructor
  149178. * @param buffer The buffer to read
  149179. */
  149180. constructor(buffer: IDataBuffer);
  149181. /**
  149182. * Loads the given byte length.
  149183. * @param byteLength The byte length to load
  149184. * @returns A promise that resolves when the load is complete
  149185. */
  149186. loadAsync(byteLength: number): Promise<void>;
  149187. /**
  149188. * Read a unsigned 32-bit integer from the currently loaded data range.
  149189. * @returns The 32-bit integer read
  149190. */
  149191. readUint32(): number;
  149192. /**
  149193. * Read a byte array from the currently loaded data range.
  149194. * @param byteLength The byte length to read
  149195. * @returns The byte array read
  149196. */
  149197. readUint8Array(byteLength: number): Uint8Array;
  149198. /**
  149199. * Read a string from the currently loaded data range.
  149200. * @param byteLength The byte length to read
  149201. * @returns The string read
  149202. */
  149203. readString(byteLength: number): string;
  149204. /**
  149205. * Skips the given byte length the currently loaded data range.
  149206. * @param byteLength The byte length to skip
  149207. */
  149208. skipBytes(byteLength: number): void;
  149209. }
  149210. }
  149211. declare module BABYLON {
  149212. /**
  149213. * Class for storing data to local storage if available or in-memory storage otherwise
  149214. */
  149215. export class DataStorage {
  149216. private static _Storage;
  149217. private static _GetStorage;
  149218. /**
  149219. * Reads a string from the data storage
  149220. * @param key The key to read
  149221. * @param defaultValue The value if the key doesn't exist
  149222. * @returns The string value
  149223. */
  149224. static ReadString(key: string, defaultValue: string): string;
  149225. /**
  149226. * Writes a string to the data storage
  149227. * @param key The key to write
  149228. * @param value The value to write
  149229. */
  149230. static WriteString(key: string, value: string): void;
  149231. /**
  149232. * Reads a boolean from the data storage
  149233. * @param key The key to read
  149234. * @param defaultValue The value if the key doesn't exist
  149235. * @returns The boolean value
  149236. */
  149237. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  149238. /**
  149239. * Writes a boolean to the data storage
  149240. * @param key The key to write
  149241. * @param value The value to write
  149242. */
  149243. static WriteBoolean(key: string, value: boolean): void;
  149244. /**
  149245. * Reads a number from the data storage
  149246. * @param key The key to read
  149247. * @param defaultValue The value if the key doesn't exist
  149248. * @returns The number value
  149249. */
  149250. static ReadNumber(key: string, defaultValue: number): number;
  149251. /**
  149252. * Writes a number to the data storage
  149253. * @param key The key to write
  149254. * @param value The value to write
  149255. */
  149256. static WriteNumber(key: string, value: number): void;
  149257. }
  149258. }
  149259. declare module BABYLON {
  149260. /**
  149261. * An interface for all Hit test features
  149262. */
  149263. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  149264. /**
  149265. * Triggered when new babylon (transformed) hit test results are available
  149266. */
  149267. onHitTestResultObservable: Observable<T[]>;
  149268. }
  149269. /**
  149270. * Options used for hit testing
  149271. */
  149272. export interface IWebXRLegacyHitTestOptions {
  149273. /**
  149274. * Only test when user interacted with the scene. Default - hit test every frame
  149275. */
  149276. testOnPointerDownOnly?: boolean;
  149277. /**
  149278. * The node to use to transform the local results to world coordinates
  149279. */
  149280. worldParentNode?: TransformNode;
  149281. }
  149282. /**
  149283. * Interface defining the babylon result of raycasting/hit-test
  149284. */
  149285. export interface IWebXRLegacyHitResult {
  149286. /**
  149287. * Transformation matrix that can be applied to a node that will put it in the hit point location
  149288. */
  149289. transformationMatrix: Matrix;
  149290. /**
  149291. * The native hit test result
  149292. */
  149293. xrHitResult: XRHitResult | XRHitTestResult;
  149294. }
  149295. /**
  149296. * The currently-working hit-test module.
  149297. * Hit test (or Ray-casting) is used to interact with the real world.
  149298. * For further information read here - https://github.com/immersive-web/hit-test
  149299. */
  149300. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  149301. /**
  149302. * options to use when constructing this feature
  149303. */
  149304. readonly options: IWebXRLegacyHitTestOptions;
  149305. private _direction;
  149306. private _mat;
  149307. private _onSelectEnabled;
  149308. private _origin;
  149309. /**
  149310. * The module's name
  149311. */
  149312. static readonly Name: string;
  149313. /**
  149314. * The (Babylon) version of this module.
  149315. * This is an integer representing the implementation version.
  149316. * This number does not correspond to the WebXR specs version
  149317. */
  149318. static readonly Version: number;
  149319. /**
  149320. * Populated with the last native XR Hit Results
  149321. */
  149322. lastNativeXRHitResults: XRHitResult[];
  149323. /**
  149324. * Triggered when new babylon (transformed) hit test results are available
  149325. */
  149326. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  149327. /**
  149328. * Creates a new instance of the (legacy version) hit test feature
  149329. * @param _xrSessionManager an instance of WebXRSessionManager
  149330. * @param options options to use when constructing this feature
  149331. */
  149332. constructor(_xrSessionManager: WebXRSessionManager,
  149333. /**
  149334. * options to use when constructing this feature
  149335. */
  149336. options?: IWebXRLegacyHitTestOptions);
  149337. /**
  149338. * execute a hit test with an XR Ray
  149339. *
  149340. * @param xrSession a native xrSession that will execute this hit test
  149341. * @param xrRay the ray (position and direction) to use for ray-casting
  149342. * @param referenceSpace native XR reference space to use for the hit-test
  149343. * @param filter filter function that will filter the results
  149344. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  149345. */
  149346. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  149347. /**
  149348. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  149349. * @param event the (select) event to use to select with
  149350. * @param referenceSpace the reference space to use for this hit test
  149351. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  149352. */
  149353. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  149354. /**
  149355. * attach this feature
  149356. * Will usually be called by the features manager
  149357. *
  149358. * @returns true if successful.
  149359. */
  149360. attach(): boolean;
  149361. /**
  149362. * detach this feature.
  149363. * Will usually be called by the features manager
  149364. *
  149365. * @returns true if successful.
  149366. */
  149367. detach(): boolean;
  149368. /**
  149369. * Dispose this feature and all of the resources attached
  149370. */
  149371. dispose(): void;
  149372. protected _onXRFrame(frame: XRFrame): void;
  149373. private _onHitTestResults;
  149374. private _onSelect;
  149375. }
  149376. }
  149377. declare module BABYLON {
  149378. /**
  149379. * Options used for hit testing (version 2)
  149380. */
  149381. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  149382. /**
  149383. * Do not create a permanent hit test. Will usually be used when only
  149384. * transient inputs are needed.
  149385. */
  149386. disablePermanentHitTest?: boolean;
  149387. /**
  149388. * Enable transient (for example touch-based) hit test inspections
  149389. */
  149390. enableTransientHitTest?: boolean;
  149391. /**
  149392. * Offset ray for the permanent hit test
  149393. */
  149394. offsetRay?: Vector3;
  149395. /**
  149396. * Offset ray for the transient hit test
  149397. */
  149398. transientOffsetRay?: Vector3;
  149399. /**
  149400. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  149401. */
  149402. useReferenceSpace?: boolean;
  149403. }
  149404. /**
  149405. * Interface defining the babylon result of hit-test
  149406. */
  149407. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  149408. /**
  149409. * The input source that generated this hit test (if transient)
  149410. */
  149411. inputSource?: XRInputSource;
  149412. /**
  149413. * Is this a transient hit test
  149414. */
  149415. isTransient?: boolean;
  149416. /**
  149417. * Position of the hit test result
  149418. */
  149419. position: Vector3;
  149420. /**
  149421. * Rotation of the hit test result
  149422. */
  149423. rotationQuaternion: Quaternion;
  149424. /**
  149425. * The native hit test result
  149426. */
  149427. xrHitResult: XRHitTestResult;
  149428. }
  149429. /**
  149430. * The currently-working hit-test module.
  149431. * Hit test (or Ray-casting) is used to interact with the real world.
  149432. * For further information read here - https://github.com/immersive-web/hit-test
  149433. *
  149434. * Tested on chrome (mobile) 80.
  149435. */
  149436. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  149437. /**
  149438. * options to use when constructing this feature
  149439. */
  149440. readonly options: IWebXRHitTestOptions;
  149441. private _tmpMat;
  149442. private _tmpPos;
  149443. private _tmpQuat;
  149444. private _transientXrHitTestSource;
  149445. private _xrHitTestSource;
  149446. private initHitTestSource;
  149447. /**
  149448. * The module's name
  149449. */
  149450. static readonly Name: string;
  149451. /**
  149452. * The (Babylon) version of this module.
  149453. * This is an integer representing the implementation version.
  149454. * This number does not correspond to the WebXR specs version
  149455. */
  149456. static readonly Version: number;
  149457. /**
  149458. * When set to true, each hit test will have its own position/rotation objects
  149459. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  149460. * the developers will clone them or copy them as they see fit.
  149461. */
  149462. autoCloneTransformation: boolean;
  149463. /**
  149464. * Triggered when new babylon (transformed) hit test results are available
  149465. */
  149466. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  149467. /**
  149468. * Use this to temporarily pause hit test checks.
  149469. */
  149470. paused: boolean;
  149471. /**
  149472. * Creates a new instance of the hit test feature
  149473. * @param _xrSessionManager an instance of WebXRSessionManager
  149474. * @param options options to use when constructing this feature
  149475. */
  149476. constructor(_xrSessionManager: WebXRSessionManager,
  149477. /**
  149478. * options to use when constructing this feature
  149479. */
  149480. options?: IWebXRHitTestOptions);
  149481. /**
  149482. * attach this feature
  149483. * Will usually be called by the features manager
  149484. *
  149485. * @returns true if successful.
  149486. */
  149487. attach(): boolean;
  149488. /**
  149489. * detach this feature.
  149490. * Will usually be called by the features manager
  149491. *
  149492. * @returns true if successful.
  149493. */
  149494. detach(): boolean;
  149495. /**
  149496. * Dispose this feature and all of the resources attached
  149497. */
  149498. dispose(): void;
  149499. protected _onXRFrame(frame: XRFrame): void;
  149500. private _processWebXRHitTestResult;
  149501. }
  149502. }
  149503. declare module BABYLON {
  149504. /**
  149505. * Configuration options of the anchor system
  149506. */
  149507. export interface IWebXRAnchorSystemOptions {
  149508. /**
  149509. * a node that will be used to convert local to world coordinates
  149510. */
  149511. worldParentNode?: TransformNode;
  149512. /**
  149513. * If set to true a reference of the created anchors will be kept until the next session starts
  149514. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  149515. */
  149516. doNotRemoveAnchorsOnSessionEnded?: boolean;
  149517. }
  149518. /**
  149519. * A babylon container for an XR Anchor
  149520. */
  149521. export interface IWebXRAnchor {
  149522. /**
  149523. * A babylon-assigned ID for this anchor
  149524. */
  149525. id: number;
  149526. /**
  149527. * Transformation matrix to apply to an object attached to this anchor
  149528. */
  149529. transformationMatrix: Matrix;
  149530. /**
  149531. * The native anchor object
  149532. */
  149533. xrAnchor: XRAnchor;
  149534. /**
  149535. * if defined, this object will be constantly updated by the anchor's position and rotation
  149536. */
  149537. attachedNode?: TransformNode;
  149538. }
  149539. /**
  149540. * An implementation of the anchor system for WebXR.
  149541. * For further information see https://github.com/immersive-web/anchors/
  149542. */
  149543. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  149544. private _options;
  149545. private _lastFrameDetected;
  149546. private _trackedAnchors;
  149547. private _referenceSpaceForFrameAnchors;
  149548. private _futureAnchors;
  149549. /**
  149550. * The module's name
  149551. */
  149552. static readonly Name: string;
  149553. /**
  149554. * The (Babylon) version of this module.
  149555. * This is an integer representing the implementation version.
  149556. * This number does not correspond to the WebXR specs version
  149557. */
  149558. static readonly Version: number;
  149559. /**
  149560. * Observers registered here will be executed when a new anchor was added to the session
  149561. */
  149562. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  149563. /**
  149564. * Observers registered here will be executed when an anchor was removed from the session
  149565. */
  149566. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  149567. /**
  149568. * Observers registered here will be executed when an existing anchor updates
  149569. * This can execute N times every frame
  149570. */
  149571. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  149572. /**
  149573. * Set the reference space to use for anchor creation, when not using a hit test.
  149574. * Will default to the session's reference space if not defined
  149575. */
  149576. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  149577. /**
  149578. * constructs a new anchor system
  149579. * @param _xrSessionManager an instance of WebXRSessionManager
  149580. * @param _options configuration object for this feature
  149581. */
  149582. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  149583. private _tmpVector;
  149584. private _tmpQuaternion;
  149585. private _populateTmpTransformation;
  149586. /**
  149587. * Create a new anchor point using a hit test result at a specific point in the scene
  149588. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  149589. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  149590. *
  149591. * @param hitTestResult The hit test result to use for this anchor creation
  149592. * @param position an optional position offset for this anchor
  149593. * @param rotationQuaternion an optional rotation offset for this anchor
  149594. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  149595. */
  149596. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  149597. /**
  149598. * Add a new anchor at a specific position and rotation
  149599. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  149600. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  149601. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  149602. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  149603. *
  149604. * @param position the position in which to add an anchor
  149605. * @param rotationQuaternion an optional rotation for the anchor transformation
  149606. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  149607. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  149608. */
  149609. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  149610. /**
  149611. * detach this feature.
  149612. * Will usually be called by the features manager
  149613. *
  149614. * @returns true if successful.
  149615. */
  149616. detach(): boolean;
  149617. /**
  149618. * Dispose this feature and all of the resources attached
  149619. */
  149620. dispose(): void;
  149621. protected _onXRFrame(frame: XRFrame): void;
  149622. /**
  149623. * avoiding using Array.find for global support.
  149624. * @param xrAnchor the plane to find in the array
  149625. */
  149626. private _findIndexInAnchorArray;
  149627. private _updateAnchorWithXRFrame;
  149628. private _createAnchorAtTransformation;
  149629. }
  149630. }
  149631. declare module BABYLON {
  149632. /**
  149633. * Options used in the plane detector module
  149634. */
  149635. export interface IWebXRPlaneDetectorOptions {
  149636. /**
  149637. * The node to use to transform the local results to world coordinates
  149638. */
  149639. worldParentNode?: TransformNode;
  149640. /**
  149641. * If set to true a reference of the created planes will be kept until the next session starts
  149642. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  149643. */
  149644. doNotRemovePlanesOnSessionEnded?: boolean;
  149645. }
  149646. /**
  149647. * A babylon interface for a WebXR plane.
  149648. * A Plane is actually a polygon, built from N points in space
  149649. *
  149650. * Supported in chrome 79, not supported in canary 81 ATM
  149651. */
  149652. export interface IWebXRPlane {
  149653. /**
  149654. * a babylon-assigned ID for this polygon
  149655. */
  149656. id: number;
  149657. /**
  149658. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  149659. */
  149660. polygonDefinition: Array<Vector3>;
  149661. /**
  149662. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  149663. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  149664. */
  149665. transformationMatrix: Matrix;
  149666. /**
  149667. * the native xr-plane object
  149668. */
  149669. xrPlane: XRPlane;
  149670. }
  149671. /**
  149672. * The plane detector is used to detect planes in the real world when in AR
  149673. * For more information see https://github.com/immersive-web/real-world-geometry/
  149674. */
  149675. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  149676. private _options;
  149677. private _detectedPlanes;
  149678. private _enabled;
  149679. private _lastFrameDetected;
  149680. /**
  149681. * The module's name
  149682. */
  149683. static readonly Name: string;
  149684. /**
  149685. * The (Babylon) version of this module.
  149686. * This is an integer representing the implementation version.
  149687. * This number does not correspond to the WebXR specs version
  149688. */
  149689. static readonly Version: number;
  149690. /**
  149691. * Observers registered here will be executed when a new plane was added to the session
  149692. */
  149693. onPlaneAddedObservable: Observable<IWebXRPlane>;
  149694. /**
  149695. * Observers registered here will be executed when a plane is no longer detected in the session
  149696. */
  149697. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  149698. /**
  149699. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  149700. * This can execute N times every frame
  149701. */
  149702. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  149703. /**
  149704. * construct a new Plane Detector
  149705. * @param _xrSessionManager an instance of xr Session manager
  149706. * @param _options configuration to use when constructing this feature
  149707. */
  149708. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  149709. /**
  149710. * detach this feature.
  149711. * Will usually be called by the features manager
  149712. *
  149713. * @returns true if successful.
  149714. */
  149715. detach(): boolean;
  149716. /**
  149717. * Dispose this feature and all of the resources attached
  149718. */
  149719. dispose(): void;
  149720. protected _onXRFrame(frame: XRFrame): void;
  149721. private _init;
  149722. private _updatePlaneWithXRPlane;
  149723. /**
  149724. * avoiding using Array.find for global support.
  149725. * @param xrPlane the plane to find in the array
  149726. */
  149727. private findIndexInPlaneArray;
  149728. }
  149729. }
  149730. declare module BABYLON {
  149731. /**
  149732. * Options interface for the background remover plugin
  149733. */
  149734. export interface IWebXRBackgroundRemoverOptions {
  149735. /**
  149736. * Further background meshes to disable when entering AR
  149737. */
  149738. backgroundMeshes?: AbstractMesh[];
  149739. /**
  149740. * flags to configure the removal of the environment helper.
  149741. * If not set, the entire background will be removed. If set, flags should be set as well.
  149742. */
  149743. environmentHelperRemovalFlags?: {
  149744. /**
  149745. * Should the skybox be removed (default false)
  149746. */
  149747. skyBox?: boolean;
  149748. /**
  149749. * Should the ground be removed (default false)
  149750. */
  149751. ground?: boolean;
  149752. };
  149753. /**
  149754. * don't disable the environment helper
  149755. */
  149756. ignoreEnvironmentHelper?: boolean;
  149757. }
  149758. /**
  149759. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  149760. */
  149761. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  149762. /**
  149763. * read-only options to be used in this module
  149764. */
  149765. readonly options: IWebXRBackgroundRemoverOptions;
  149766. /**
  149767. * The module's name
  149768. */
  149769. static readonly Name: string;
  149770. /**
  149771. * The (Babylon) version of this module.
  149772. * This is an integer representing the implementation version.
  149773. * This number does not correspond to the WebXR specs version
  149774. */
  149775. static readonly Version: number;
  149776. /**
  149777. * registered observers will be triggered when the background state changes
  149778. */
  149779. onBackgroundStateChangedObservable: Observable<boolean>;
  149780. /**
  149781. * constructs a new background remover module
  149782. * @param _xrSessionManager the session manager for this module
  149783. * @param options read-only options to be used in this module
  149784. */
  149785. constructor(_xrSessionManager: WebXRSessionManager,
  149786. /**
  149787. * read-only options to be used in this module
  149788. */
  149789. options?: IWebXRBackgroundRemoverOptions);
  149790. /**
  149791. * attach this feature
  149792. * Will usually be called by the features manager
  149793. *
  149794. * @returns true if successful.
  149795. */
  149796. attach(): boolean;
  149797. /**
  149798. * detach this feature.
  149799. * Will usually be called by the features manager
  149800. *
  149801. * @returns true if successful.
  149802. */
  149803. detach(): boolean;
  149804. /**
  149805. * Dispose this feature and all of the resources attached
  149806. */
  149807. dispose(): void;
  149808. protected _onXRFrame(_xrFrame: XRFrame): void;
  149809. private _setBackgroundState;
  149810. }
  149811. }
  149812. declare module BABYLON {
  149813. /**
  149814. * Options for the controller physics feature
  149815. */
  149816. export class IWebXRControllerPhysicsOptions {
  149817. /**
  149818. * Should the headset get its own impostor
  149819. */
  149820. enableHeadsetImpostor?: boolean;
  149821. /**
  149822. * Optional parameters for the headset impostor
  149823. */
  149824. headsetImpostorParams?: {
  149825. /**
  149826. * The type of impostor to create. Default is sphere
  149827. */
  149828. impostorType: number;
  149829. /**
  149830. * the size of the impostor. Defaults to 10cm
  149831. */
  149832. impostorSize?: number | {
  149833. width: number;
  149834. height: number;
  149835. depth: number;
  149836. };
  149837. /**
  149838. * Friction definitions
  149839. */
  149840. friction?: number;
  149841. /**
  149842. * Restitution
  149843. */
  149844. restitution?: number;
  149845. };
  149846. /**
  149847. * The physics properties of the future impostors
  149848. */
  149849. physicsProperties?: {
  149850. /**
  149851. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  149852. * Note that this requires a physics engine that supports mesh impostors!
  149853. */
  149854. useControllerMesh?: boolean;
  149855. /**
  149856. * The type of impostor to create. Default is sphere
  149857. */
  149858. impostorType?: number;
  149859. /**
  149860. * the size of the impostor. Defaults to 10cm
  149861. */
  149862. impostorSize?: number | {
  149863. width: number;
  149864. height: number;
  149865. depth: number;
  149866. };
  149867. /**
  149868. * Friction definitions
  149869. */
  149870. friction?: number;
  149871. /**
  149872. * Restitution
  149873. */
  149874. restitution?: number;
  149875. };
  149876. /**
  149877. * the xr input to use with this pointer selection
  149878. */
  149879. xrInput: WebXRInput;
  149880. }
  149881. /**
  149882. * Add physics impostor to your webxr controllers,
  149883. * including naive calculation of their linear and angular velocity
  149884. */
  149885. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  149886. private readonly _options;
  149887. private _attachController;
  149888. private _controllers;
  149889. private _debugMode;
  149890. private _delta;
  149891. private _headsetImpostor?;
  149892. private _headsetMesh?;
  149893. private _lastTimestamp;
  149894. private _tmpQuaternion;
  149895. private _tmpVector;
  149896. /**
  149897. * The module's name
  149898. */
  149899. static readonly Name: string;
  149900. /**
  149901. * The (Babylon) version of this module.
  149902. * This is an integer representing the implementation version.
  149903. * This number does not correspond to the webxr specs version
  149904. */
  149905. static readonly Version: number;
  149906. /**
  149907. * Construct a new Controller Physics Feature
  149908. * @param _xrSessionManager the corresponding xr session manager
  149909. * @param _options options to create this feature with
  149910. */
  149911. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  149912. /**
  149913. * @hidden
  149914. * enable debugging - will show console outputs and the impostor mesh
  149915. */
  149916. _enablePhysicsDebug(): void;
  149917. /**
  149918. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  149919. * @param xrController the controller to add
  149920. */
  149921. addController(xrController: WebXRInputSource): void;
  149922. /**
  149923. * attach this feature
  149924. * Will usually be called by the features manager
  149925. *
  149926. * @returns true if successful.
  149927. */
  149928. attach(): boolean;
  149929. /**
  149930. * detach this feature.
  149931. * Will usually be called by the features manager
  149932. *
  149933. * @returns true if successful.
  149934. */
  149935. detach(): boolean;
  149936. /**
  149937. * Get the headset impostor, if enabled
  149938. * @returns the impostor
  149939. */
  149940. getHeadsetImpostor(): PhysicsImpostor | undefined;
  149941. /**
  149942. * Get the physics impostor of a specific controller.
  149943. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  149944. * @param controller the controller or the controller id of which to get the impostor
  149945. * @returns the impostor or null
  149946. */
  149947. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  149948. /**
  149949. * Update the physics properties provided in the constructor
  149950. * @param newProperties the new properties object
  149951. */
  149952. setPhysicsProperties(newProperties: {
  149953. impostorType?: number;
  149954. impostorSize?: number | {
  149955. width: number;
  149956. height: number;
  149957. depth: number;
  149958. };
  149959. friction?: number;
  149960. restitution?: number;
  149961. }): void;
  149962. protected _onXRFrame(_xrFrame: any): void;
  149963. private _detachController;
  149964. }
  149965. }
  149966. declare module BABYLON {
  149967. /**
  149968. * The motion controller class for all microsoft mixed reality controllers
  149969. */
  149970. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  149971. protected readonly _mapping: {
  149972. defaultButton: {
  149973. valueNodeName: string;
  149974. unpressedNodeName: string;
  149975. pressedNodeName: string;
  149976. };
  149977. defaultAxis: {
  149978. valueNodeName: string;
  149979. minNodeName: string;
  149980. maxNodeName: string;
  149981. };
  149982. buttons: {
  149983. "xr-standard-trigger": {
  149984. rootNodeName: string;
  149985. componentProperty: string;
  149986. states: string[];
  149987. };
  149988. "xr-standard-squeeze": {
  149989. rootNodeName: string;
  149990. componentProperty: string;
  149991. states: string[];
  149992. };
  149993. "xr-standard-touchpad": {
  149994. rootNodeName: string;
  149995. labelAnchorNodeName: string;
  149996. touchPointNodeName: string;
  149997. };
  149998. "xr-standard-thumbstick": {
  149999. rootNodeName: string;
  150000. componentProperty: string;
  150001. states: string[];
  150002. };
  150003. };
  150004. axes: {
  150005. "xr-standard-touchpad": {
  150006. "x-axis": {
  150007. rootNodeName: string;
  150008. };
  150009. "y-axis": {
  150010. rootNodeName: string;
  150011. };
  150012. };
  150013. "xr-standard-thumbstick": {
  150014. "x-axis": {
  150015. rootNodeName: string;
  150016. };
  150017. "y-axis": {
  150018. rootNodeName: string;
  150019. };
  150020. };
  150021. };
  150022. };
  150023. /**
  150024. * The base url used to load the left and right controller models
  150025. */
  150026. static MODEL_BASE_URL: string;
  150027. /**
  150028. * The name of the left controller model file
  150029. */
  150030. static MODEL_LEFT_FILENAME: string;
  150031. /**
  150032. * The name of the right controller model file
  150033. */
  150034. static MODEL_RIGHT_FILENAME: string;
  150035. profileId: string;
  150036. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  150037. protected _getFilenameAndPath(): {
  150038. filename: string;
  150039. path: string;
  150040. };
  150041. protected _getModelLoadingConstraints(): boolean;
  150042. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150043. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150044. protected _updateModel(): void;
  150045. }
  150046. }
  150047. declare module BABYLON {
  150048. /**
  150049. * The motion controller class for oculus touch (quest, rift).
  150050. * This class supports legacy mapping as well the standard xr mapping
  150051. */
  150052. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  150053. private _forceLegacyControllers;
  150054. private _modelRootNode;
  150055. /**
  150056. * The base url used to load the left and right controller models
  150057. */
  150058. static MODEL_BASE_URL: string;
  150059. /**
  150060. * The name of the left controller model file
  150061. */
  150062. static MODEL_LEFT_FILENAME: string;
  150063. /**
  150064. * The name of the right controller model file
  150065. */
  150066. static MODEL_RIGHT_FILENAME: string;
  150067. /**
  150068. * Base Url for the Quest controller model.
  150069. */
  150070. static QUEST_MODEL_BASE_URL: string;
  150071. profileId: string;
  150072. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  150073. protected _getFilenameAndPath(): {
  150074. filename: string;
  150075. path: string;
  150076. };
  150077. protected _getModelLoadingConstraints(): boolean;
  150078. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150079. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150080. protected _updateModel(): void;
  150081. /**
  150082. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  150083. * between the touch and touch 2.
  150084. */
  150085. private _isQuest;
  150086. }
  150087. }
  150088. declare module BABYLON {
  150089. /**
  150090. * The motion controller class for the standard HTC-Vive controllers
  150091. */
  150092. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  150093. private _modelRootNode;
  150094. /**
  150095. * The base url used to load the left and right controller models
  150096. */
  150097. static MODEL_BASE_URL: string;
  150098. /**
  150099. * File name for the controller model.
  150100. */
  150101. static MODEL_FILENAME: string;
  150102. profileId: string;
  150103. /**
  150104. * Create a new Vive motion controller object
  150105. * @param scene the scene to use to create this controller
  150106. * @param gamepadObject the corresponding gamepad object
  150107. * @param handedness the handedness of the controller
  150108. */
  150109. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  150110. protected _getFilenameAndPath(): {
  150111. filename: string;
  150112. path: string;
  150113. };
  150114. protected _getModelLoadingConstraints(): boolean;
  150115. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150116. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150117. protected _updateModel(): void;
  150118. }
  150119. }
  150120. declare module BABYLON {
  150121. /**
  150122. * A cursor which tracks a point on a path
  150123. */
  150124. export class PathCursor {
  150125. private path;
  150126. /**
  150127. * Stores path cursor callbacks for when an onchange event is triggered
  150128. */
  150129. private _onchange;
  150130. /**
  150131. * The value of the path cursor
  150132. */
  150133. value: number;
  150134. /**
  150135. * The animation array of the path cursor
  150136. */
  150137. animations: Animation[];
  150138. /**
  150139. * Initializes the path cursor
  150140. * @param path The path to track
  150141. */
  150142. constructor(path: Path2);
  150143. /**
  150144. * Gets the cursor point on the path
  150145. * @returns A point on the path cursor at the cursor location
  150146. */
  150147. getPoint(): Vector3;
  150148. /**
  150149. * Moves the cursor ahead by the step amount
  150150. * @param step The amount to move the cursor forward
  150151. * @returns This path cursor
  150152. */
  150153. moveAhead(step?: number): PathCursor;
  150154. /**
  150155. * Moves the cursor behind by the step amount
  150156. * @param step The amount to move the cursor back
  150157. * @returns This path cursor
  150158. */
  150159. moveBack(step?: number): PathCursor;
  150160. /**
  150161. * Moves the cursor by the step amount
  150162. * If the step amount is greater than one, an exception is thrown
  150163. * @param step The amount to move the cursor
  150164. * @returns This path cursor
  150165. */
  150166. move(step: number): PathCursor;
  150167. /**
  150168. * Ensures that the value is limited between zero and one
  150169. * @returns This path cursor
  150170. */
  150171. private ensureLimits;
  150172. /**
  150173. * Runs onchange callbacks on change (used by the animation engine)
  150174. * @returns This path cursor
  150175. */
  150176. private raiseOnChange;
  150177. /**
  150178. * Executes a function on change
  150179. * @param f A path cursor onchange callback
  150180. * @returns This path cursor
  150181. */
  150182. onchange(f: (cursor: PathCursor) => void): PathCursor;
  150183. }
  150184. }
  150185. declare module BABYLON {
  150186. /** @hidden */
  150187. export var blurPixelShader: {
  150188. name: string;
  150189. shader: string;
  150190. };
  150191. }
  150192. declare module BABYLON {
  150193. /** @hidden */
  150194. export var pointCloudVertexDeclaration: {
  150195. name: string;
  150196. shader: string;
  150197. };
  150198. }
  150199. // Mixins
  150200. interface Window {
  150201. mozIndexedDB: IDBFactory;
  150202. webkitIndexedDB: IDBFactory;
  150203. msIndexedDB: IDBFactory;
  150204. webkitURL: typeof URL;
  150205. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  150206. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  150207. WebGLRenderingContext: WebGLRenderingContext;
  150208. MSGesture: MSGesture;
  150209. CANNON: any;
  150210. AudioContext: AudioContext;
  150211. webkitAudioContext: AudioContext;
  150212. PointerEvent: any;
  150213. Math: Math;
  150214. Uint8Array: Uint8ArrayConstructor;
  150215. Float32Array: Float32ArrayConstructor;
  150216. mozURL: typeof URL;
  150217. msURL: typeof URL;
  150218. VRFrameData: any; // WebVR, from specs 1.1
  150219. DracoDecoderModule: any;
  150220. setImmediate(handler: (...args: any[]) => void): number;
  150221. }
  150222. interface HTMLCanvasElement {
  150223. requestPointerLock(): void;
  150224. msRequestPointerLock?(): void;
  150225. mozRequestPointerLock?(): void;
  150226. webkitRequestPointerLock?(): void;
  150227. /** Track wether a record is in progress */
  150228. isRecording: boolean;
  150229. /** Capture Stream method defined by some browsers */
  150230. captureStream(fps?: number): MediaStream;
  150231. }
  150232. interface CanvasRenderingContext2D {
  150233. msImageSmoothingEnabled: boolean;
  150234. }
  150235. interface MouseEvent {
  150236. mozMovementX: number;
  150237. mozMovementY: number;
  150238. webkitMovementX: number;
  150239. webkitMovementY: number;
  150240. msMovementX: number;
  150241. msMovementY: number;
  150242. }
  150243. interface Navigator {
  150244. mozGetVRDevices: (any: any) => any;
  150245. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150246. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150247. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150248. webkitGetGamepads(): Gamepad[];
  150249. msGetGamepads(): Gamepad[];
  150250. webkitGamepads(): Gamepad[];
  150251. }
  150252. interface HTMLVideoElement {
  150253. mozSrcObject: any;
  150254. }
  150255. interface Math {
  150256. fround(x: number): number;
  150257. imul(a: number, b: number): number;
  150258. }
  150259. interface WebGLRenderingContext {
  150260. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  150261. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  150262. vertexAttribDivisor(index: number, divisor: number): void;
  150263. createVertexArray(): any;
  150264. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  150265. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  150266. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  150267. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  150268. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  150269. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  150270. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  150271. // Queries
  150272. createQuery(): WebGLQuery;
  150273. deleteQuery(query: WebGLQuery): void;
  150274. beginQuery(target: number, query: WebGLQuery): void;
  150275. endQuery(target: number): void;
  150276. getQueryParameter(query: WebGLQuery, pname: number): any;
  150277. getQuery(target: number, pname: number): any;
  150278. MAX_SAMPLES: number;
  150279. RGBA8: number;
  150280. READ_FRAMEBUFFER: number;
  150281. DRAW_FRAMEBUFFER: number;
  150282. UNIFORM_BUFFER: number;
  150283. HALF_FLOAT_OES: number;
  150284. RGBA16F: number;
  150285. RGBA32F: number;
  150286. R32F: number;
  150287. RG32F: number;
  150288. RGB32F: number;
  150289. R16F: number;
  150290. RG16F: number;
  150291. RGB16F: number;
  150292. RED: number;
  150293. RG: number;
  150294. R8: number;
  150295. RG8: number;
  150296. UNSIGNED_INT_24_8: number;
  150297. DEPTH24_STENCIL8: number;
  150298. MIN: number;
  150299. MAX: number;
  150300. /* Multiple Render Targets */
  150301. drawBuffers(buffers: number[]): void;
  150302. readBuffer(src: number): void;
  150303. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  150304. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  150305. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  150306. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  150307. // Occlusion Query
  150308. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  150309. ANY_SAMPLES_PASSED: number;
  150310. QUERY_RESULT_AVAILABLE: number;
  150311. QUERY_RESULT: number;
  150312. }
  150313. interface WebGLProgram {
  150314. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  150315. }
  150316. interface EXT_disjoint_timer_query {
  150317. QUERY_COUNTER_BITS_EXT: number;
  150318. TIME_ELAPSED_EXT: number;
  150319. TIMESTAMP_EXT: number;
  150320. GPU_DISJOINT_EXT: number;
  150321. QUERY_RESULT_EXT: number;
  150322. QUERY_RESULT_AVAILABLE_EXT: number;
  150323. queryCounterEXT(query: WebGLQuery, target: number): void;
  150324. createQueryEXT(): WebGLQuery;
  150325. beginQueryEXT(target: number, query: WebGLQuery): void;
  150326. endQueryEXT(target: number): void;
  150327. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  150328. deleteQueryEXT(query: WebGLQuery): void;
  150329. }
  150330. interface WebGLUniformLocation {
  150331. _currentState: any;
  150332. }
  150333. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  150334. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  150335. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  150336. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  150337. interface WebGLRenderingContext {
  150338. readonly RASTERIZER_DISCARD: number;
  150339. readonly DEPTH_COMPONENT24: number;
  150340. readonly TEXTURE_3D: number;
  150341. readonly TEXTURE_2D_ARRAY: number;
  150342. readonly TEXTURE_COMPARE_FUNC: number;
  150343. readonly TEXTURE_COMPARE_MODE: number;
  150344. readonly COMPARE_REF_TO_TEXTURE: number;
  150345. readonly TEXTURE_WRAP_R: number;
  150346. readonly HALF_FLOAT: number;
  150347. readonly RGB8: number;
  150348. readonly RED_INTEGER: number;
  150349. readonly RG_INTEGER: number;
  150350. readonly RGB_INTEGER: number;
  150351. readonly RGBA_INTEGER: number;
  150352. readonly R8_SNORM: number;
  150353. readonly RG8_SNORM: number;
  150354. readonly RGB8_SNORM: number;
  150355. readonly RGBA8_SNORM: number;
  150356. readonly R8I: number;
  150357. readonly RG8I: number;
  150358. readonly RGB8I: number;
  150359. readonly RGBA8I: number;
  150360. readonly R8UI: number;
  150361. readonly RG8UI: number;
  150362. readonly RGB8UI: number;
  150363. readonly RGBA8UI: number;
  150364. readonly R16I: number;
  150365. readonly RG16I: number;
  150366. readonly RGB16I: number;
  150367. readonly RGBA16I: number;
  150368. readonly R16UI: number;
  150369. readonly RG16UI: number;
  150370. readonly RGB16UI: number;
  150371. readonly RGBA16UI: number;
  150372. readonly R32I: number;
  150373. readonly RG32I: number;
  150374. readonly RGB32I: number;
  150375. readonly RGBA32I: number;
  150376. readonly R32UI: number;
  150377. readonly RG32UI: number;
  150378. readonly RGB32UI: number;
  150379. readonly RGBA32UI: number;
  150380. readonly RGB10_A2UI: number;
  150381. readonly R11F_G11F_B10F: number;
  150382. readonly RGB9_E5: number;
  150383. readonly RGB10_A2: number;
  150384. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  150385. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  150386. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  150387. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  150388. readonly DEPTH_COMPONENT32F: number;
  150389. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  150390. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  150391. 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;
  150392. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  150393. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  150394. readonly TRANSFORM_FEEDBACK: number;
  150395. readonly INTERLEAVED_ATTRIBS: number;
  150396. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  150397. createTransformFeedback(): WebGLTransformFeedback;
  150398. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  150399. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  150400. beginTransformFeedback(primitiveMode: number): void;
  150401. endTransformFeedback(): void;
  150402. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  150403. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150404. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150405. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150406. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  150407. }
  150408. interface ImageBitmap {
  150409. readonly width: number;
  150410. readonly height: number;
  150411. close(): void;
  150412. }
  150413. interface WebGLQuery extends WebGLObject {
  150414. }
  150415. declare var WebGLQuery: {
  150416. prototype: WebGLQuery;
  150417. new(): WebGLQuery;
  150418. };
  150419. interface WebGLSampler extends WebGLObject {
  150420. }
  150421. declare var WebGLSampler: {
  150422. prototype: WebGLSampler;
  150423. new(): WebGLSampler;
  150424. };
  150425. interface WebGLSync extends WebGLObject {
  150426. }
  150427. declare var WebGLSync: {
  150428. prototype: WebGLSync;
  150429. new(): WebGLSync;
  150430. };
  150431. interface WebGLTransformFeedback extends WebGLObject {
  150432. }
  150433. declare var WebGLTransformFeedback: {
  150434. prototype: WebGLTransformFeedback;
  150435. new(): WebGLTransformFeedback;
  150436. };
  150437. interface WebGLVertexArrayObject extends WebGLObject {
  150438. }
  150439. declare var WebGLVertexArrayObject: {
  150440. prototype: WebGLVertexArrayObject;
  150441. new(): WebGLVertexArrayObject;
  150442. };
  150443. // Type definitions for WebVR API
  150444. // Project: https://w3c.github.io/webvr/
  150445. // Definitions by: six a <https://github.com/lostfictions>
  150446. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  150447. interface VRDisplay extends EventTarget {
  150448. /**
  150449. * Dictionary of capabilities describing the VRDisplay.
  150450. */
  150451. readonly capabilities: VRDisplayCapabilities;
  150452. /**
  150453. * z-depth defining the far plane of the eye view frustum
  150454. * enables mapping of values in the render target depth
  150455. * attachment to scene coordinates. Initially set to 10000.0.
  150456. */
  150457. depthFar: number;
  150458. /**
  150459. * z-depth defining the near plane of the eye view frustum
  150460. * enables mapping of values in the render target depth
  150461. * attachment to scene coordinates. Initially set to 0.01.
  150462. */
  150463. depthNear: number;
  150464. /**
  150465. * An identifier for this distinct VRDisplay. Used as an
  150466. * association point in the Gamepad API.
  150467. */
  150468. readonly displayId: number;
  150469. /**
  150470. * A display name, a user-readable name identifying it.
  150471. */
  150472. readonly displayName: string;
  150473. readonly isConnected: boolean;
  150474. readonly isPresenting: boolean;
  150475. /**
  150476. * If this VRDisplay supports room-scale experiences, the optional
  150477. * stage attribute contains details on the room-scale parameters.
  150478. */
  150479. readonly stageParameters: VRStageParameters | null;
  150480. /**
  150481. * Passing the value returned by `requestAnimationFrame` to
  150482. * `cancelAnimationFrame` will unregister the callback.
  150483. * @param handle Define the hanle of the request to cancel
  150484. */
  150485. cancelAnimationFrame(handle: number): void;
  150486. /**
  150487. * Stops presenting to the VRDisplay.
  150488. * @returns a promise to know when it stopped
  150489. */
  150490. exitPresent(): Promise<void>;
  150491. /**
  150492. * Return the current VREyeParameters for the given eye.
  150493. * @param whichEye Define the eye we want the parameter for
  150494. * @returns the eye parameters
  150495. */
  150496. getEyeParameters(whichEye: string): VREyeParameters;
  150497. /**
  150498. * Populates the passed VRFrameData with the information required to render
  150499. * the current frame.
  150500. * @param frameData Define the data structure to populate
  150501. * @returns true if ok otherwise false
  150502. */
  150503. getFrameData(frameData: VRFrameData): boolean;
  150504. /**
  150505. * Get the layers currently being presented.
  150506. * @returns the list of VR layers
  150507. */
  150508. getLayers(): VRLayer[];
  150509. /**
  150510. * Return a VRPose containing the future predicted pose of the VRDisplay
  150511. * when the current frame will be presented. The value returned will not
  150512. * change until JavaScript has returned control to the browser.
  150513. *
  150514. * The VRPose will contain the position, orientation, velocity,
  150515. * and acceleration of each of these properties.
  150516. * @returns the pose object
  150517. */
  150518. getPose(): VRPose;
  150519. /**
  150520. * Return the current instantaneous pose of the VRDisplay, with no
  150521. * prediction applied.
  150522. * @returns the current instantaneous pose
  150523. */
  150524. getImmediatePose(): VRPose;
  150525. /**
  150526. * The callback passed to `requestAnimationFrame` will be called
  150527. * any time a new frame should be rendered. When the VRDisplay is
  150528. * presenting the callback will be called at the native refresh
  150529. * rate of the HMD. When not presenting this function acts
  150530. * identically to how window.requestAnimationFrame acts. Content should
  150531. * make no assumptions of frame rate or vsync behavior as the HMD runs
  150532. * asynchronously from other displays and at differing refresh rates.
  150533. * @param callback Define the eaction to run next frame
  150534. * @returns the request handle it
  150535. */
  150536. requestAnimationFrame(callback: FrameRequestCallback): number;
  150537. /**
  150538. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  150539. * Repeat calls while already presenting will update the VRLayers being displayed.
  150540. * @param layers Define the list of layer to present
  150541. * @returns a promise to know when the request has been fulfilled
  150542. */
  150543. requestPresent(layers: VRLayer[]): Promise<void>;
  150544. /**
  150545. * Reset the pose for this display, treating its current position and
  150546. * orientation as the "origin/zero" values. VRPose.position,
  150547. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  150548. * updated when calling resetPose(). This should be called in only
  150549. * sitting-space experiences.
  150550. */
  150551. resetPose(): void;
  150552. /**
  150553. * The VRLayer provided to the VRDisplay will be captured and presented
  150554. * in the HMD. Calling this function has the same effect on the source
  150555. * canvas as any other operation that uses its source image, and canvases
  150556. * created without preserveDrawingBuffer set to true will be cleared.
  150557. * @param pose Define the pose to submit
  150558. */
  150559. submitFrame(pose?: VRPose): void;
  150560. }
  150561. declare var VRDisplay: {
  150562. prototype: VRDisplay;
  150563. new(): VRDisplay;
  150564. };
  150565. interface VRLayer {
  150566. leftBounds?: number[] | Float32Array | null;
  150567. rightBounds?: number[] | Float32Array | null;
  150568. source?: HTMLCanvasElement | null;
  150569. }
  150570. interface VRDisplayCapabilities {
  150571. readonly canPresent: boolean;
  150572. readonly hasExternalDisplay: boolean;
  150573. readonly hasOrientation: boolean;
  150574. readonly hasPosition: boolean;
  150575. readonly maxLayers: number;
  150576. }
  150577. interface VREyeParameters {
  150578. /** @deprecated */
  150579. readonly fieldOfView: VRFieldOfView;
  150580. readonly offset: Float32Array;
  150581. readonly renderHeight: number;
  150582. readonly renderWidth: number;
  150583. }
  150584. interface VRFieldOfView {
  150585. readonly downDegrees: number;
  150586. readonly leftDegrees: number;
  150587. readonly rightDegrees: number;
  150588. readonly upDegrees: number;
  150589. }
  150590. interface VRFrameData {
  150591. readonly leftProjectionMatrix: Float32Array;
  150592. readonly leftViewMatrix: Float32Array;
  150593. readonly pose: VRPose;
  150594. readonly rightProjectionMatrix: Float32Array;
  150595. readonly rightViewMatrix: Float32Array;
  150596. readonly timestamp: number;
  150597. }
  150598. interface VRPose {
  150599. readonly angularAcceleration: Float32Array | null;
  150600. readonly angularVelocity: Float32Array | null;
  150601. readonly linearAcceleration: Float32Array | null;
  150602. readonly linearVelocity: Float32Array | null;
  150603. readonly orientation: Float32Array | null;
  150604. readonly position: Float32Array | null;
  150605. readonly timestamp: number;
  150606. }
  150607. interface VRStageParameters {
  150608. sittingToStandingTransform?: Float32Array;
  150609. sizeX?: number;
  150610. sizeY?: number;
  150611. }
  150612. interface Navigator {
  150613. getVRDisplays(): Promise<VRDisplay[]>;
  150614. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  150615. }
  150616. interface Window {
  150617. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  150618. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  150619. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  150620. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150621. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150622. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  150623. }
  150624. interface Gamepad {
  150625. readonly displayId: number;
  150626. }
  150627. type XRSessionMode =
  150628. | "inline"
  150629. | "immersive-vr"
  150630. | "immersive-ar";
  150631. type XRReferenceSpaceType =
  150632. | "viewer"
  150633. | "local"
  150634. | "local-floor"
  150635. | "bounded-floor"
  150636. | "unbounded";
  150637. type XREnvironmentBlendMode =
  150638. | "opaque"
  150639. | "additive"
  150640. | "alpha-blend";
  150641. type XRVisibilityState =
  150642. | "visible"
  150643. | "visible-blurred"
  150644. | "hidden";
  150645. type XRHandedness =
  150646. | "none"
  150647. | "left"
  150648. | "right";
  150649. type XRTargetRayMode =
  150650. | "gaze"
  150651. | "tracked-pointer"
  150652. | "screen";
  150653. type XREye =
  150654. | "none"
  150655. | "left"
  150656. | "right";
  150657. type XREventType =
  150658. | "devicechange"
  150659. | "visibilitychange"
  150660. | "end"
  150661. | "inputsourceschange"
  150662. | "select"
  150663. | "selectstart"
  150664. | "selectend"
  150665. | "squeeze"
  150666. | "squeezestart"
  150667. | "squeezeend"
  150668. | "reset";
  150669. interface XRSpace extends EventTarget {
  150670. }
  150671. interface XRRenderState {
  150672. depthNear?: number;
  150673. depthFar?: number;
  150674. inlineVerticalFieldOfView?: number;
  150675. baseLayer?: XRWebGLLayer;
  150676. }
  150677. interface XRInputSource {
  150678. handedness: XRHandedness;
  150679. targetRayMode: XRTargetRayMode;
  150680. targetRaySpace: XRSpace;
  150681. gripSpace: XRSpace | undefined;
  150682. gamepad: Gamepad | undefined;
  150683. profiles: Array<string>;
  150684. }
  150685. interface XRSessionInit {
  150686. optionalFeatures?: string[];
  150687. requiredFeatures?: string[];
  150688. }
  150689. interface XRSession {
  150690. addEventListener: Function;
  150691. removeEventListener: Function;
  150692. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  150693. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  150694. requestAnimationFrame: Function;
  150695. end(): Promise<void>;
  150696. renderState: XRRenderState;
  150697. inputSources: Array<XRInputSource>;
  150698. // hit test
  150699. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  150700. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  150701. // legacy AR hit test
  150702. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150703. // legacy plane detection
  150704. updateWorldTrackingState(options: {
  150705. planeDetectionState?: { enabled: boolean; }
  150706. }): void;
  150707. }
  150708. interface XRReferenceSpace extends XRSpace {
  150709. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  150710. onreset: any;
  150711. }
  150712. type XRPlaneSet = Set<XRPlane>;
  150713. type XRAnchorSet = Set<XRAnchor>;
  150714. interface XRFrame {
  150715. session: XRSession;
  150716. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  150717. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  150718. // AR
  150719. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  150720. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  150721. // Anchors
  150722. trackedAnchors?: XRAnchorSet;
  150723. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  150724. // Planes
  150725. worldInformation: {
  150726. detectedPlanes?: XRPlaneSet;
  150727. };
  150728. }
  150729. interface XRViewerPose extends XRPose {
  150730. views: Array<XRView>;
  150731. }
  150732. interface XRPose {
  150733. transform: XRRigidTransform;
  150734. emulatedPosition: boolean;
  150735. }
  150736. interface XRWebGLLayerOptions {
  150737. antialias?: boolean;
  150738. depth?: boolean;
  150739. stencil?: boolean;
  150740. alpha?: boolean;
  150741. multiview?: boolean;
  150742. framebufferScaleFactor?: number;
  150743. }
  150744. declare var XRWebGLLayer: {
  150745. prototype: XRWebGLLayer;
  150746. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  150747. };
  150748. interface XRWebGLLayer {
  150749. framebuffer: WebGLFramebuffer;
  150750. framebufferWidth: number;
  150751. framebufferHeight: number;
  150752. getViewport: Function;
  150753. }
  150754. declare class XRRigidTransform {
  150755. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  150756. position: DOMPointReadOnly;
  150757. orientation: DOMPointReadOnly;
  150758. matrix: Float32Array;
  150759. inverse: XRRigidTransform;
  150760. }
  150761. interface XRView {
  150762. eye: XREye;
  150763. projectionMatrix: Float32Array;
  150764. transform: XRRigidTransform;
  150765. }
  150766. interface XRInputSourceChangeEvent {
  150767. session: XRSession;
  150768. removed: Array<XRInputSource>;
  150769. added: Array<XRInputSource>;
  150770. }
  150771. interface XRInputSourceEvent extends Event {
  150772. readonly frame: XRFrame;
  150773. readonly inputSource: XRInputSource;
  150774. }
  150775. // Experimental(er) features
  150776. declare class XRRay {
  150777. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  150778. origin: DOMPointReadOnly;
  150779. direction: DOMPointReadOnly;
  150780. matrix: Float32Array;
  150781. }
  150782. declare enum XRHitTestTrackableType {
  150783. "point",
  150784. "plane"
  150785. }
  150786. interface XRHitResult {
  150787. hitMatrix: Float32Array;
  150788. }
  150789. interface XRTransientInputHitTestResult {
  150790. readonly inputSource: XRInputSource;
  150791. readonly results: Array<XRHitTestResult>;
  150792. }
  150793. interface XRHitTestResult {
  150794. getPose(baseSpace: XRSpace): XRPose | undefined;
  150795. // When anchor system is enabled
  150796. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  150797. }
  150798. interface XRHitTestSource {
  150799. cancel(): void;
  150800. }
  150801. interface XRTransientInputHitTestSource {
  150802. cancel(): void;
  150803. }
  150804. interface XRHitTestOptionsInit {
  150805. space: XRSpace;
  150806. entityTypes?: Array<XRHitTestTrackableType>;
  150807. offsetRay?: XRRay;
  150808. }
  150809. interface XRTransientInputHitTestOptionsInit {
  150810. profile: string;
  150811. entityTypes?: Array<XRHitTestTrackableType>;
  150812. offsetRay?: XRRay;
  150813. }
  150814. interface XRAnchor {
  150815. anchorSpace: XRSpace;
  150816. delete(): void;
  150817. }
  150818. interface XRPlane {
  150819. orientation: "Horizontal" | "Vertical";
  150820. planeSpace: XRSpace;
  150821. polygon: Array<DOMPointReadOnly>;
  150822. lastChangedTime: number;
  150823. }